/* Zyreca portal design system: tokens, layout, components. System fonts only (no webfont requests). */

:root {
  color-scheme: dark;
  --bg: #0b1020;
  --surface: #121a2e;
  --surface-2: #182238;
  --surface-3: #1f2b45;
  --border: #243150;
  --border-strong: #33446b;
  --text: #f1f5f9;
  --muted: #9fb0c9;
  --primary: #3b82f6;
  --primary-solid: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(59, 130, 246, .16);
  --accent: #8b5cf6;
  --grad: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --success: #10b981;
  --success-solid: #047857;
  --danger: #ef4444;
  --danger-solid: #dc2626;
  --warning: #f59e0b;
  --ring: rgba(96, 165, 250, .55);
  --code-bg: #0a0f1d;
  --code-fg: #d6e2f5;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --badge-green-bg: rgba(16, 185, 129, .16);  --badge-green-fg: #4ade80;
  --badge-red-bg: rgba(239, 68, 68, .16);     --badge-red-fg: #fca5a5;
  --badge-blue-bg: rgba(59, 130, 246, .18);   --badge-blue-fg: #93c5fd;
  --badge-purple-bg: rgba(139, 92, 246, .2);  --badge-purple-fg: #c4b5fd;
  --badge-amber-bg: rgba(245, 158, 11, .18);  --badge-amber-fg: #fcd34d;
  --badge-gray-bg: rgba(148, 163, 184, .16);  --badge-gray-fg: #cbd5e1;
  --r: 12px;
  --r-sm: 8px;
  --sidebar-w: 256px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f3f5fa;
  --surface-3: #e8ecf5;
  --border: #dfe4ef;
  --border-strong: #c5cde0;
  --text: #0f172a;
  --muted: #566078;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, .1);
  --ring: rgba(37, 99, 235, .45);
  --code-bg: #f3f5fa;
  --code-fg: #1e293b;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
  --badge-green-bg: #dcfce7;  --badge-green-fg: #166534;
  --badge-red-bg: #fee2e2;    --badge-red-fg: #991b1b;
  --badge-blue-bg: #dbeafe;   --badge-blue-fg: #1e40af;
  --badge-purple-bg: #ede9fe; --badge-purple-fg: #5b21b6;
  --badge-amber-bg: #fef3c7;  --badge-amber-fg: #92400e;
  --badge-gray-bg: #e5e7eb;   --badge-gray-fg: #374151;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f3f5fa;
    --surface-3: #e8ecf5;
    --border: #dfe4ef;
    --border-strong: #c5cde0;
    --text: #0f172a;
    --muted: #566078;
    --primary: #2563eb;
    --primary-soft: rgba(37, 99, 235, .1);
    --ring: rgba(37, 99, 235, .45);
    --code-bg: #f3f5fa;
    --code-fg: #1e293b;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08);
    --badge-green-bg: #dcfce7;  --badge-green-fg: #166534;
    --badge-red-bg: #fee2e2;    --badge-red-fg: #991b1b;
    --badge-blue-bg: #dbeafe;   --badge-blue-fg: #1e40af;
    --badge-purple-bg: #ede9fe; --badge-purple-fg: #5b21b6;
    --badge-amber-bg: #fef3c7;  --badge-amber-fg: #92400e;
    --badge-gray-bg: #e5e7eb;   --badge-gray-fg: #374151;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--text);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd { font-family: var(--mono); }
code { font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: .08em .4em; border-radius: 6px; word-break: break-word; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: .75rem; top: -4rem; z-index: 300; background: var(--primary-solid); color: #fff; padding: .6rem 1rem; border-radius: var(--r-sm); font-weight: 600; }
.skip-link:focus { top: .75rem; text-decoration: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.icon-lg { width: 22px; height: 22px; }
.stack-v { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.05rem; color: var(--text); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 4px 14px rgba(99, 102, 241, .4); }
.brand-mark .icon { width: 18px; height: 18px; }
.brand small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; line-height: 1.1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 38px; padding: .5rem .95rem; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: .875rem; line-height: 1.2; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { background: var(--success-solid); border-color: var(--success-solid); color: #fff; }
.btn-success:hover { filter: brightness(1.12); background: var(--success-solid); }
.btn-danger { background: transparent; border-color: rgba(239, 68, 68, .55); color: var(--badge-red-fg); }
.btn-danger:hover { background: var(--badge-red-bg); }
.btn-danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.1); background: var(--danger-solid); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 32px; padding: .3rem .65rem; font-size: .8rem; }
.btn-icon { min-width: 38px; padding: .5rem; }
.btn-block { width: 100%; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field .hint { font-size: .76rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: .55rem .8rem; border-radius: var(--r-sm);
  background: var(--code-bg); border: 1px solid var(--border-strong); color: var(--text);
  font-size: .92rem; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; font-family: var(--mono); font-size: .85rem; }
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: .75; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.input:user-invalid { border-color: var(--danger); }
.select { appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239fb0c9' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; }
.input-sm { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.input-group { display: flex; gap: .5rem; }
.input-group .input { flex: 1; }
.search { position: relative; flex: 1 1 220px; min-width: 0; max-width: 360px; }
.search .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 2.25rem; }
.alert { padding: .7rem .9rem; border-radius: var(--r-sm); font-size: .88rem; border: 1px solid; }
.alert-error { background: var(--badge-red-bg); color: var(--badge-red-fg); border-color: rgba(239, 68, 68, .4); }
.alert-success { background: var(--badge-green-bg); color: var(--badge-green-fg); border-color: rgba(16, 185, 129, .4); }
.alert-info { background: var(--badge-blue-bg); color: var(--badge-blue-fg); border-color: rgba(59, 130, 246, .4); }

/* ---------- Cards, stats ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.card-pad { padding: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.card-head p { font-size: .84rem; color: var(--muted); margin-top: .15rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; gap: .9rem; align-items: center; padding: 1.1rem 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); min-width: 0; }
.stat-ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.stat-ico.purple { background: var(--badge-purple-bg); color: var(--badge-purple-fg); }
.stat-ico.green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.stat-ico.amber { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }
.stat-label { font-size: .74rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat-val { font-size: 1.5rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { font-size: .76rem; color: var(--muted); }
.section-gap > * + * { margin-top: 1.5rem; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.kv { display: grid; grid-template-columns: minmax(120px, 210px) 1fr auto; gap: .75rem 1rem; padding: .85rem 1.25rem; border-bottom: 1px solid var(--border); align-items: center; font-size: .9rem; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-weight: 600; }

/* ---------- Badges, meters ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700; line-height: 1.4; white-space: nowrap; background: var(--badge-gray-bg); color: var(--badge-gray-fg); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge-green { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.badge-red { background: var(--badge-red-bg); color: var(--badge-red-fg); }
.badge-blue { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }
.badge-purple { background: var(--badge-purple-bg); color: var(--badge-purple-fg); }
.badge-amber { background: var(--badge-amber-bg); color: var(--badge-amber-fg); }
.meter { display: flex; align-items: center; gap: .45rem; min-width: 78px; }
.meter-track { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 4px; background: var(--success); transition: width .4s; }
.meter-fill.mid { background: var(--warning); }
.meter-fill.low { background: var(--danger); }
.meter-val { font-size: .78rem; font-weight: 700; width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; text-align: left; }
table.data th, table.data td { padding: .75rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; z-index: 1; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-actions { white-space: nowrap; }
.cell-actions .btn + .btn { margin-left: .3rem; }
.cell-title { font-weight: 700; }
.cell-sub { font-size: .76rem; color: var(--muted); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; padding: .75rem 1.1rem; border-top: 1px solid var(--border); font-size: .84rem; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.toolbar .field { min-width: 130px; flex: 1 1 130px; }
.toolbar .field.wide { flex: 2 1 200px; }
.toolbar .field.narrow { flex: 0 1 110px; min-width: 96px; }
.toolbar .actions { display: flex; gap: .5rem; }
.empty { text-align: center; padding: 2.75rem 1rem; color: var(--muted); }
.empty .icon { width: 34px; height: 34px; opacity: .6; margin-bottom: .6rem; }
.empty h3 { color: var(--text); margin-bottom: .25rem; font-size: 1rem; }
.skeleton { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- App shell (dashboards) ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; gap: .25rem; padding: 1.1rem .9rem; background: var(--surface); border-right: 1px solid var(--border); overflow-y: auto; }
.sidebar .brand { padding: .25rem .5rem 1.1rem; }
.nav-label { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: .8rem .75rem .3rem; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: var(--r-sm); color: var(--muted); font-weight: 600; font-size: .9rem; text-decoration: none; transition: background-color .15s, color .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--primary-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--primary); }
.nav-link[aria-current="page"] .icon { color: var(--primary); }
.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .25rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .75rem; padding: .75rem clamp(1rem, 3vw, 2rem); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 1.15rem; }
.topbar .who { font-size: .78rem; color: var(--muted); }
.topbar .actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.menu-btn { display: none; }
.content { padding: clamp(1rem, 3vw, 2rem); max-width: 1400px; width: 100%; margin: 0 auto; }
.content:focus { outline: none; }
.view-head { margin-bottom: 1.25rem; }
.view-head p { color: var(--muted); margin-top: .2rem; font-size: .9rem; }
.scrim { position: fixed; inset: 0; background: rgba(2, 6, 23, .6); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s; }

/* Top-header shell (reseller) */
.topnav { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border); }
.topnav-in { display: flex; align-items: center; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 2rem); max-width: 1400px; margin: 0 auto; }
.topnav .links { display: flex; gap: .25rem; margin-left: 1rem; }
.topnav .links .nav-link { padding: .5rem .8rem; }
.topnav .actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; min-width: 0; }
.topnav .who { font-size: .8rem; color: var(--muted); max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Dialogs ---------- */
dialog.modal { padding: 0; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 2rem)); max-height: min(90vh, 90dvh); box-shadow: var(--shadow); overflow: hidden; }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
dialog.modal.wide { width: min(880px, calc(100vw - 2rem)); }
dialog.modal::backdrop { background: rgba(2, 6, 23, .68); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-head p { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.code-block { position: relative; }
pre.code { margin: 0; padding: 1rem 1.1rem; background: var(--code-bg); color: var(--code-fg); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: auto; font-size: .82rem; line-height: 1.6; tab-size: 2; max-height: 340px; }
pre.code.tall { max-height: none; }
pre.code code { background: none; border: 0; padding: 0; font-size: inherit; word-break: normal; }
pre.wrap { white-space: pre-wrap; word-break: break-word; }
.copy-btn { position: absolute; top: .5rem; right: .5rem; }
.reveal-key { font-family: var(--mono); font-size: 1rem; padding: .9rem 1rem; background: var(--code-bg); border: 1px dashed var(--primary); border-radius: var(--r-sm); word-break: break-all; user-select: all; color: var(--badge-blue-fg); }
.meta-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 500; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; width: min(380px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: .65rem; align-items: flex-start; padding: .8rem .95rem; border-radius: var(--r-sm); background: var(--surface-3); border: 1px solid var(--border-strong); box-shadow: var(--shadow); font-size: .88rem; animation: pop .18s ease-out; }
.toast .icon { margin-top: 2px; }
.toast.success { border-color: rgba(16, 185, 129, .55); } .toast.success .icon { color: var(--success); }
.toast.error { border-color: rgba(239, 68, 68, .6); } .toast.error .icon { color: var(--danger); }
.toast.info .icon { color: var(--primary); }
.toast button { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 .2rem; font-size: 1.1rem; line-height: 1; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; background:
  radial-gradient(60rem 30rem at 10% -10%, rgba(59, 130, 246, .18), transparent 60%),
  radial-gradient(50rem 26rem at 110% 110%, rgba(139, 92, 246, .16), transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: clamp(1.4rem, 5vw, 2.2rem); box-shadow: var(--shadow); }
.auth-card .brand { justify-content: center; width: 100%; margin-bottom: .4rem; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }
.auth-card form { display: flex; flex-direction: column; gap: 1rem; }
.auth-foot { text-align: center; margin-top: 1.25rem; font-size: .82rem; color: var(--muted); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 2.75rem; }
.pw-toggle { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); }

/* ---------- Docs ---------- */
.site-header { position: sticky; top: 0; z-index: 60; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); }
.site-header-in { max-width: 1240px; margin: 0 auto; padding: .7rem clamp(1rem, 3vw, 2rem); display: flex; align-items: center; gap: 1rem; }
.site-header .actions { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
.docs-shell { max-width: 1240px; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2.5rem; }
.toc { position: sticky; top: 4.5rem; align-self: start; max-height: calc(100vh - 5.5rem); overflow-y: auto; padding: 2rem 0; }
.toc a { display: block; padding: .38rem .75rem; border-left: 2px solid var(--border); color: var(--muted); font-size: .86rem; font-weight: 600; }
.toc a:hover { color: var(--text); text-decoration: none; border-color: var(--border-strong); }
.toc a.active { color: var(--primary); border-color: var(--primary); }
.docs-main { min-width: 0; padding: 2rem 0 4rem; }
.hero { padding: 1rem 0 2.25rem; }
.hero .eyebrow { display: inline-flex; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(1.9rem, 1.2rem + 3vw, 3rem); line-height: 1.12; font-weight: 800; letter-spacing: -.02em; max-width: 22ch; }
.hero h1 span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { margin-top: 1rem; color: var(--muted); font-size: 1.08rem; max-width: 62ch; }
.hero .cta { margin-top: 1.4rem; display: flex; gap: .6rem; flex-wrap: wrap; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem; margin: 0 0 2.5rem; }
.feature { padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.feature .icon { color: var(--primary); margin-bottom: .5rem; }
.feature h3 { font-size: .95rem; margin-bottom: .2rem; }
.feature p { font-size: .84rem; color: var(--muted); }
.doc-section { margin-top: 3rem; }
.doc-section > h2 { font-size: 1.5rem; margin-bottom: .6rem; letter-spacing: -.015em; }
.doc-section h3 { margin: 1.5rem 0 .4rem; }
.doc-section p, .doc-section li { color: var(--muted); margin-bottom: .6rem; }
.doc-section ul { padding-left: 1.2rem; margin: .4rem 0 1rem; }
.doc-section li b { color: var(--text); }
.doc-section code { color: var(--badge-blue-fg); }
.tabs { display: flex; gap: .25rem; overflow-x: auto; padding: .35rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm) var(--r-sm) 0 0; border-bottom: 0; scrollbar-width: thin; }
.tab { flex: none; padding: .45rem .85rem; border-radius: 6px; border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: .84rem; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--border-strong); }
.tabpanel { border: 1px solid var(--border); border-radius: 0 0 var(--r) var(--r); background: var(--surface); padding: 1rem 1.1rem 1.1rem; }
.tabpanel > p { font-size: .88rem; margin-bottom: .7rem; color: var(--muted); }
.method { display: inline-block; font: 700 .7rem var(--mono); padding: .15rem .45rem; border-radius: 5px; margin-right: .45rem; vertical-align: 1px; }
.m-get { background: var(--badge-green-bg); color: var(--badge-green-fg); }
.m-post { background: var(--badge-blue-bg); color: var(--badge-blue-fg); }
.docs-table td, .docs-table th { vertical-align: top; }
.docs-table td:first-child { white-space: nowrap; }
.tester { padding: 1.4rem; border-radius: var(--r); border: 1px solid var(--border-strong); background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.site-foot { border-top: 1px solid var(--border); padding: 1.5rem 0; text-align: center; color: var(--muted); font-size: .84rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 100; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .menu-btn { display: inline-flex; }
  .topnav .links { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  .stat { flex-direction: column; align-items: flex-start; gap: .55rem; padding: .9rem; }
  .stat-val { font-size: 1.25rem; }
  .topbar .who { display: none; }
  .topbar .actions .btn .btn-label { display: none; }
  .topnav .who { display: none; }
  .kv { grid-template-columns: 1fr; gap: .25rem; }
  .card-head, .toolbar { padding: .85rem 1rem; }
  /* Tables become stacked cards */
  .table-wrap:has(> table.stack) { overflow: visible; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tbody tr { margin: 0; padding: .55rem 1rem; border-bottom: 1px solid var(--border); }
  table.stack tbody tr:hover { background: transparent; }
  table.stack td { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .35rem 0; border: 0; text-align: right; }
  table.stack td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; text-align: left; }
  table.stack td.cell-main { display: block; text-align: left; padding-top: .2rem; }
  table.stack td.cell-main::before { display: none; }
  table.stack td.cell-actions { justify-content: flex-end; padding-top: .55rem; flex-wrap: wrap; }
  table.stack td.cell-actions::before { display: none; }
  table.stack td.empty-cell { display: block; text-align: center; }
  table.stack td.empty-cell::before { display: none; }
  .meter { min-width: 120px; flex: 0 1 60%; }
  .toasts { left: 1rem; right: 1rem; width: auto; bottom: .75rem; }
  dialog.modal { width: calc(100vw - 1rem); max-height: 94dvh; border-radius: 14px; }
  .modal-foot .btn { flex: 1; }
  .docs-table td:first-child { white-space: normal; }
}
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .input, .select { min-height: 44px; font-size: 16px; }
  .nav-link { padding: .75rem .8rem; }
}
@media (max-width: 340px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar, .topbar, .topnav, .site-header, .toc, .toasts, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ---------- Additions ---------- */
:root[data-theme="dark"] .ico-moon, :root[data-theme="light"] .ico-sun { display: none; }
button.nav-link { background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font: inherit; font-weight: 600; font-size: .9rem; }
.auth-tools { position: fixed; top: .75rem; right: .75rem; z-index: 5; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 38px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary-solid); }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 72px; padding: .4rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); }
.spark i { flex: 1; min-height: 4px; border-radius: 2px; background: var(--primary); opacity: .9; }
.spark i.err { background: var(--danger); }
.spark i.warn { background: var(--warning); }
.spark:empty::after { content: "No data yet"; margin: auto; color: var(--muted); font-size: .82rem; }
.subnav { display: flex; gap: .25rem; max-width: 1400px; margin: 0 auto; padding: 0 clamp(.5rem, 2.6vw, 1.85rem); overflow-x: auto; scrollbar-width: none; }
.subnav::-webkit-scrollbar { display: none; }
.subnav .nav-link { flex: none; border-radius: 0; padding: .7rem .85rem; border-bottom: 2px solid transparent; }
.subnav .nav-link:hover { background: transparent; color: var(--text); }
.subnav .nav-link[aria-current="page"] { background: transparent; box-shadow: none; border-bottom-color: var(--primary); color: var(--text); }
.toc-mobile { display: none; margin-bottom: 1.5rem; padding: .25rem 1rem; }
.toc-mobile summary { cursor: pointer; font-weight: 700; padding: .65rem 0; }
.toc-mobile div { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .1rem .75rem; padding-bottom: .75rem; }
.toc-mobile a { padding: .35rem 0; font-weight: 600; font-size: .9rem; }
@media (max-width: 1100px) { .toc-mobile { display: block; } }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.6rem; }
.step { display: flex; gap: 1rem; }
.step-num { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; background: var(--primary-soft); color: var(--primary); border: 1px solid var(--border-strong); }
.step-body { flex: 1; min-width: 0; }
.step-body h2 { font-size: 1.05rem; margin-bottom: .25rem; }
.btn-google { margin-top: .8rem; background: #fff; color: #1f2937; border-color: #d1d5db; }
.btn-google:hover { background: #f3f4f6; }
.hero code.input { min-height: 38px; }
.badge.eyebrow { font-size: .8rem; padding: .3rem .8rem; }
@media (max-width: 720px) {
  .topnav-in { padding-top: .55rem; padding-bottom: .4rem; }
  .brand small { display: none; }
  .hero .cta { flex-direction: column; align-items: stretch; }
  .hero .cta .input-group { max-width: none !important; }
  .tabpanel { padding: .8rem; }
  .doc-section > h2 { font-size: 1.3rem; }
}
table.data td code { white-space: nowrap; }
table.data td.cell-main { max-width: 260px; overflow-wrap: anywhere; }
table.data td.cell-main.nowrap { max-width: none; }
.brand > span { white-space: nowrap; }
@media (max-width: 360px) {
  .topbar { gap: .4rem; padding-left: .6rem; padding-right: .6rem; }
  .topbar .actions { gap: .25rem; }
  .topbar .actions a.btn { display: none; }
  .content { padding: .75rem; }
  .stat-val { font-size: 1.15rem; }
}
@media (max-width: 720px) {
  .topnav .actions .btn .btn-label, .site-header .actions .btn .btn-label { display: none; }
  .topnav-in { gap: .5rem; }
}
