:root {
  color-scheme: light dark;
  --bg: light-dark(#f3f4f2, #111413);
  --surface: light-dark(#ffffff, #1a1e1d);
  --muted-bg: light-dark(#f0f2f1, #232827);
  --line: light-dark(#e2e5e3, #2c3230);
  --ink: light-dark(#141817, #eef1f0);
  --muted: light-dark(#5f6966, #9aa4a1);
  --accent: light-dark(#0f766e, #5eead4);
  --accent-bg: light-dark(#ccf3ec, #12322e);
  --ok: light-dark(#15803d, #4ade80); --ok-bg: light-dark(#dcfce7, #13301f);
  --warn: light-dark(#a16207, #facc15); --warn-bg: light-dark(#fef3c7, #33290d);
  --bad: light-dark(#b91c1c, #f87171); --bad-bg: light-dark(#fee2e2, #3a1616);
  --info: light-dark(#1d4ed8, #93c5fd); --info-bg: light-dark(#dbeafe, #172442);
  --radius: 14px; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .04);
  font: 15px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2 { margin: 0; letter-spacing: -.02em; text-wrap: balance; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.05rem; }
p { margin: 0; }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; }
pre { overflow-x: auto; background: var(--muted-bg); padding: 12px; border-radius: 10px; margin: 10px 0 0; }
.muted { color: var(--muted); } .error { color: var(--bad); } .block { display: block; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--muted-bg); border-radius: 10px; padding: 8px 14px; font-weight: 600;
  transition: transform .12s, background-color .15s; }
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--surface); border-color: transparent; }
button.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: .85rem; }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-height: 40px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.off, .pill.muted { background: var(--muted-bg); color: var(--muted); }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(100%, 380px); display: grid; gap: 14px; }
.logo, .brand b { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--surface); font-weight: 750; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100dvh; }
.rail { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 22px; padding: 20px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 750; font-size: 1.1rem; padding: 0 8px; }
.brand small { color: var(--muted); font-weight: 550; }
nav { display: grid; gap: 4px; }
nav a { padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; }
nav a:hover { background: var(--muted-bg); color: var(--ink); }
nav a[aria-current] { background: var(--accent-bg); color: var(--accent); }
.rail-status { margin-top: auto; display: flex; gap: 8px; align-items: center; padding: 12px; background: var(--muted-bg); border-radius: 10px; font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; }
.rail-status i, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.rail-status i.ok, .dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-bg); }

.workspace { padding: 32px 40px; min-width: 0; }
.workspace > section { max-width: 1200px; display: grid; gap: 16px; }
.page-head { display: grid; gap: 4px; margin-bottom: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.pet { display: grid; gap: 12px; }
.pet.offline { opacity: .7; }
.pet > header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.pet > header > span:first-child { display: grid; min-width: 0; }
.phones { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.phone { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--muted-bg); border-radius: 10px; }
.phone-name { display: grid; min-width: 0; }
.phone-name small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { color: var(--muted); font-variant-numeric: tabular-nums; }
.pet footer { font-size: .85rem; }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .wide { grid-column: 1 / -1; }
.form.inline { grid-template-columns: 2fr 1fr auto; align-items: end; }
.modes { display: flex; gap: 18px; border: 0; padding: 0; margin: 0; }
.modes label { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.modes input { width: auto; min-height: 0; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.secret { display: grid; gap: 8px; border-color: var(--warn); }
.secret code { word-break: break-all; font-size: .95rem; }
.docs { display: grid; gap: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  nav { display: flex; overflow-x: auto; flex: 1 1 100%; order: 3; }
  .rail-status { margin: 0 0 0 auto; padding: 6px 10px; }
  .workspace { padding: 18px 16px; }
  .form, .form.inline { grid-template-columns: 1fr; }
  .table { display: block; overflow-x: auto; }
}
