/* ==========================================================================
   Northbay Systems — Workstation Portal
   Design system: borderless surfaces, layered soft shadows, calm neutrals.
   Radii are conventional (no squircle corner-shape).
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
  color-scheme: light;

  --bg: #fbfbfa;
  --bg-sunken: #f4f4f2;
  --surface: #ffffff;
  --surface-alt: #f7f7f6;

  --ink: #1a1a1a;
  --ink-soft: #6b6b6b;
  --ink-faint: #9a9a9a;
  --line: rgba(17, 17, 17, 0.09);
  --line-soft: rgba(17, 17, 17, 0.06);

  --accent: #37469f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(55, 70, 159, 0.09);

  --ok: #2f7d54;
  --ok-soft: rgba(47, 125, 84, 0.10);
  --warn: #a5731d;
  --warn-soft: rgba(165, 115, 29, 0.12);
  --down: #b3352f;
  --down-soft: rgba(179, 53, 47, 0.10);

  --shadow-rest:
    0 1px 2px rgba(17, 17, 17, 0.04),
    0 8px 24px rgba(17, 17, 17, 0.055),
    0 16px 48px rgba(17, 17, 17, 0.045);
  --shadow-raised:
    0 2px 4px rgba(59, 79, 196, 0.07),
    0 12px 32px rgba(59, 79, 196, 0.13),
    0 28px 72px rgba(59, 79, 196, 0.14);
  --shadow-flat: 0 1px 2px rgba(17, 17, 17, 0.05);

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;

  --topbar-h: 60px;
  --sidebar-w: 232px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131316;
  --bg-sunken: #0f0f11;
  --surface: #1e1e22;
  --surface-alt: #26262b;

  --ink: #f2f2f3;
  --ink-soft: #a0a0a8;
  --ink-faint: #6a6a72;
  --line: rgba(255, 255, 255, 0.09);
  --line-soft: rgba(255, 255, 255, 0.06);

  --accent: #8c9cff;
  --accent-ink: #14141a;
  --accent-soft: rgba(140, 156, 255, 0.14);

  --ok: #64c88c;
  --ok-soft: rgba(100, 200, 140, 0.13);
  --warn: #d9b25a;
  --warn-soft: rgba(217, 178, 90, 0.14);
  --down: #e2756c;
  --down-soft: rgba(226, 117, 108, 0.13);

  --shadow-rest:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  --shadow-raised:
    0 2px 4px rgba(0, 0, 0, 0.42),
    0 14px 38px rgba(140, 156, 255, 0.16),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  --shadow-flat: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131316;
    --bg-sunken: #0f0f11;
    --surface: #1e1e22;
    --surface-alt: #26262b;
    --ink: #f2f2f3;
    --ink-soft: #a0a0a8;
    --ink-faint: #6a6a72;
    --line: rgba(255, 255, 255, 0.09);
    --line-soft: rgba(255, 255, 255, 0.06);
    --accent: #8c9cff;
    --accent-ink: #14141a;
    --accent-soft: rgba(140, 156, 255, 0.14);
    --ok: #64c88c;
    --ok-soft: rgba(100, 200, 140, 0.13);
    --warn: #d9b25a;
    --warn-soft: rgba(217, 178, 90, 0.14);
    --down: #e2756c;
    --down-soft: rgba(226, 117, 108, 0.13);
    --shadow-rest:
      0 1px 2px rgba(0, 0, 0, 0.4),
      0 8px 24px rgba(0, 0, 0, 0.34),
      inset 0 0 0 1px rgba(255, 255, 255, 0.035);
    --shadow-raised:
      0 2px 4px rgba(0, 0, 0, 0.42),
      0 14px 38px rgba(140, 156, 255, 0.16),
      inset 0 0 0 1px rgba(255, 255, 255, 0.07);
    --shadow-flat: 0 1px 2px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  }
}

/* --- Base ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s, color 0.4s;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
::selection { background: var(--accent-soft); }

h1, h2, h3, h4 { letter-spacing: -0.02em; font-weight: 600; line-height: 1.25; }
h1 { font-size: clamp(24px, 3.4vw, 31px); }
h2 { font-size: 19px; }
h3 { font-size: 15.5px; }
p { color: var(--ink-soft); }

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
  border-radius: var(--r-sm);
}

/* --- Layout --------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 clamp(16px, 3vw, 28px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  transition: background-color 0.4s, border-color 0.4s;
}

.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand .mark {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center; flex: none;
  transition: background-color 0.4s, color 0.4s;
}
.brand .mark svg { width: 16px; height: 16px; }
.brand .name { font-weight: 600; letter-spacing: -0.015em; font-size: 14.5px; white-space: nowrap; }
.brand .name span { color: var(--ink-faint); font-weight: 500; }

.mainnav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.mainnav a {
  padding: 7px 11px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  transition: color 0.2s, background-color 0.2s;
}
.mainnav a:hover { color: var(--ink); background: var(--surface-alt); }
.mainnav a[aria-current="page"] { color: var(--ink); background: var(--surface-alt); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-soft);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

.theme-toggle .icon-wrap { position: relative; width: 17px; height: 17px; }
.theme-toggle svg { position: absolute; inset: 0; width: 17px; height: 17px; transition: opacity 0.4s, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.theme-toggle .sun { opacity: 1; transform: rotate(0) scale(1); }
.theme-toggle .moon { opacity: 0; transform: rotate(-90deg) scale(0.4); }
:root[data-theme="dark"] .theme-toggle .moon { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="dark"] .theme-toggle .sun { opacity: 0; transform: rotate(90deg) scale(0.4); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { opacity: 1; transform: rotate(0) scale(1); }
  :root:not([data-theme="light"]) .theme-toggle .sun { opacity: 0; transform: rotate(90deg) scale(0.4); }
}

/* Account menu */
.account { position: relative; }
.account-trigger {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px 0 4px;
  border: none; border-radius: var(--r-sm);
  background: transparent; cursor: pointer;
  transition: background-color 0.2s;
}
.account-trigger:hover { background: var(--surface-alt); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  flex: none;
}
.account-trigger .who { font-size: 13px; font-weight: 500; }
.account-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 232px; padding: 6px;
  background: var(--surface); border-radius: var(--r-md);
  box-shadow: var(--shadow-rest);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.2s, transform 0.2s var(--ease), visibility 0.2s;
}
.account.open .account-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.account-menu .head { padding: 9px 10px 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.account-menu .head strong { display: block; font-size: 13.5px; font-weight: 600; }
.account-menu .head span { font-size: 12px; color: var(--ink-faint); }
.account-menu a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-soft);
  transition: background-color 0.15s, color 0.15s;
}
.account-menu a:hover { background: var(--surface-alt); color: var(--ink); }
.account-menu a kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--ink-faint);
}

/* Page shells */
.shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--topbar-h);
  width: var(--sidebar-w); flex: none;
  height: calc(100dvh - var(--topbar-h));
  padding: 20px 14px;
  border-right: 1px solid var(--line-soft);
  overflow-y: auto;
}
.sidebar .group { margin-bottom: 22px; }
.sidebar .group-label {
  padding: 0 10px 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-faint);
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  transition: background-color 0.2s, color 0.2s;
}
.sidebar a svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.sidebar a:hover { background: var(--surface-alt); color: var(--ink); }
.sidebar a[aria-current="page"] { background: var(--surface-alt); color: var(--ink); }
.sidebar a .tag { margin-left: auto; font-size: 11px; color: var(--ink-faint); }

.content {
  flex: 1 1 auto; min-width: 0;
  padding: clamp(22px, 3.2vw, 36px) clamp(16px, 3vw, 40px) 64px;
}
.content.narrow { max-width: 900px; margin-inline: auto; }

.page { max-width: 1120px; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head .eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 7px;
}
.page-head p { margin-top: 7px; max-width: 68ch; font-size: 14px; }
.page-head .row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head .row .spacer { margin-left: auto; }

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-rest);
  padding: 20px;
  transition: box-shadow 0.4s var(--ease), background-color 0.4s, transform 0.4s var(--ease);
}
a.card { display: block; color: inherit; }
a.card:hover, .card.interactive:hover { box-shadow: var(--shadow-raised); }
.card > header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.card > header h2, .card > header h3 { font-size: 14.5px; }
.card > header .spacer { margin-left: auto; }
.card .card-note { font-size: 12.5px; color: var(--ink-faint); }
.card-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500; color: var(--accent);
}
.card-link svg { width: 13px; height: 13px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.span-2 { grid-column: span 2; }

.stack { display: flex; flex-direction: column; gap: 16px; }

/* Metric tile */
.metric .label { font-size: 12.5px; color: var(--ink-faint); font-weight: 500; }
.metric .value {
  font-size: 27px; font-weight: 600; letter-spacing: -0.03em;
  margin-top: 6px; font-variant-numeric: tabular-nums;
}
.metric .delta { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* --- Badges, pills, dots -------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
  background: var(--surface-alt); color: var(--ink-soft);
  white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.kv { display: flex; align-items: baseline; gap: 8px; font-size: 13.5px; }
.kv dt { color: var(--ink-faint); min-width: 116px; flex: none; }
.kv dd { color: var(--ink); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: none; border-radius: var(--r-md);
  background: var(--surface-alt); color: var(--ink);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-flat);
  transition: background-color 0.2s, box-shadow 0.35s var(--ease), color 0.2s, opacity 0.2s;
}
.btn:hover { box-shadow: var(--shadow-rest); }
.btn svg { width: 15px; height: 15px; }
/* Primary actions stay monochrome — colour is reserved for state, not emphasis. */
.btn.primary { background: var(--ink); color: var(--bg); box-shadow: var(--shadow-flat); }
.btn.primary:hover { box-shadow: var(--shadow-raised); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-alt); color: var(--ink); box-shadow: none; }
.btn.block { width: 100%; }
.btn.lg { height: 42px; padding: 0 20px; font-size: 14px; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn.danger { color: var(--down); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* --- Forms ---------------------------------------------------------------- */

.field { margin-bottom: 15px; }
.field > label,
.field-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500; color: var(--ink);
}
.hint, .field .hint { display: block; margin-top: 6px; font-size: 12.5px; color: var(--ink-faint); }
.field .label-row { display: flex; align-items: baseline; margin-bottom: 6px; }
.field .label-row a { margin-left: auto; font-size: 12.5px; color: var(--accent); font-weight: 500; }

.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 14px; color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.25s, background-color 0.4s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 92px; line-height: 1.5; }
.input::placeholder { color: var(--ink-faint); }
.input:hover { border-color: color-mix(in srgb, var(--ink) 22%, transparent); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-group { display: flex; gap: 8px; }
.input.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.42em; text-align: center; font-size: 17px;
}

.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--ink-soft); }
.check input { margin-top: 3px; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }

.form-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0; font-size: 12px; color: var(--ink-faint);
}
.form-divider::before, .form-divider::after {
  content: ""; height: 1px; background: var(--line); flex: 1;
}

/* --- Banner / notice ------------------------------------------------------ */

.banner {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: 13.5px; color: var(--ink);
}
.banner svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--accent); }
.banner.warn { background: var(--warn-soft); }
.banner.warn svg { color: var(--warn); }
.banner.down { background: var(--down-soft); }
.banner.down svg { color: var(--down); }
.banner strong { font-weight: 600; }
.banner p { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.banner .close { margin-left: auto; }

/* --- Lists ---------------------------------------------------------------- */

.list { display: flex; flex-direction: column; }
.list > * { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.list > *:first-child { padding-top: 0; }
.list > *:last-child { border-bottom: none; padding-bottom: 0; }

.item { display: flex; align-items: flex-start; gap: 12px; }
.item .item-icon {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  background: var(--surface-alt); color: var(--ink-soft);
  display: grid; place-items: center; flex: none;
}
.item .item-icon svg { width: 15px; height: 15px; }
.item .item-body { min-width: 0; flex: 1; }
.item .item-title { font-size: 13.5px; font-weight: 500; }
.item .item-meta { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.item .item-side { margin-left: auto; text-align: right; flex: none; font-size: 12.5px; color: var(--ink-faint); white-space: nowrap; }

/* Service status rows */
.svc { display: flex; align-items: center; gap: 12px; }
.svc .svc-name { font-size: 13.5px; font-weight: 500; }
.svc .svc-desc { font-size: 12.5px; color: var(--ink-faint); margin-top: 1px; }
.svc .svc-state { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.uptime { display: flex; gap: 2px; align-items: flex-end; }
.uptime i {
  display: block; width: 3px; height: 19px; border-radius: 2px;
  background: var(--ok); opacity: 0.7;
}
.uptime i.warn { background: var(--warn); opacity: 1; }
.uptime i.down { background: var(--down); opacity: 1; }
@media (max-width: 1240px) { .uptime i:nth-child(n+41) { display: none; } }
@media (max-width: 900px) { .uptime { display: none; } }
@media (max-width: 480px) { .svc { flex-wrap: wrap; } .svc .svc-state { margin-left: 0; } }

/* --- Tables --------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-weight: 600; font-size: 11.5px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-faint);
  padding: 0 14px 10px 0; white-space: nowrap;
}
table.data td {
  padding: 11px 14px 11px 0;
  border-top: 1px solid var(--line-soft);
  vertical-align: middle; white-space: nowrap;
}
table.data td.wrap { white-space: normal; min-width: 220px; }
table.data tbody tr { transition: background-color 0.15s; }
table.data tbody tr:hover { background: var(--surface-alt); }
table.data td.num { font-variant-numeric: tabular-nums; color: var(--ink-soft); }
table.data td .sub { display: block; font-size: 12px; color: var(--ink-faint); }
table.data th:last-child, table.data td:last-child { padding-right: 0; }
table.data th.actions, table.data td.actions { text-align: right; }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .input { height: 34px; width: auto; min-width: 200px; font-size: 13px; }
.toolbar select.input { min-width: 150px; }
.toolbar .spacer { margin-left: auto; }

.pager {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--ink-faint);
}
.pager .spacer { margin-left: auto; }

/* --- Timeline (incidents) ------------------------------------------------- */

.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line);
}
.timeline .entry { position: relative; padding-bottom: 20px; }
.timeline .entry:last-child { padding-bottom: 0; }
.timeline .entry::before {
  content: ""; position: absolute; left: -22px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 4px var(--surface);
}
.timeline .entry.ok::before { background: var(--ok); }
.timeline .entry.warn::before { background: var(--warn); }
.timeline .entry.down::before { background: var(--down); }
.timeline .when { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.timeline .what { font-size: 13.5px; font-weight: 500; margin-top: 2px; }
.timeline .detail { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }

/* --- Accordion ------------------------------------------------------------ */

.accordion details { border-bottom: 1px solid var(--line-soft); }
.accordion details:last-child { border-bottom: none; }
.accordion summary {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 0; cursor: pointer; list-style: none;
  font-size: 14px; font-weight: 500;
  transition: color 0.2s;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { color: var(--accent); }
.accordion summary .chev {
  margin-left: auto; width: 15px; height: 15px; flex: none;
  color: var(--ink-faint); transition: transform 0.3s var(--ease);
}
.accordion details[open] summary .chev { transform: rotate(180deg); }
.accordion .answer { padding: 0 0 16px; font-size: 13.5px; color: var(--ink-soft); max-width: 76ch; }
.accordion .answer p + p, .accordion .answer p + ul, .accordion .answer ul + p { margin-top: 9px; }
.accordion .answer ul { padding-left: 18px; }
.accordion .answer li { margin-bottom: 4px; }
.accordion .answer code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; background: var(--surface-alt);
  padding: 1px 5px; border-radius: 5px; color: var(--ink);
}

/* --- Docs ----------------------------------------------------------------- */

.doc-layout { display: grid; grid-template-columns: 214px minmax(0, 1fr); gap: 30px; align-items: start; }
.doc-toc { position: sticky; top: calc(var(--topbar-h) + 24px); }
.doc-toc .group-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-faint); padding: 0 10px 8px;
}
.doc-toc a {
  display: block; padding: 6px 10px; border-radius: var(--r-sm);
  font-size: 13.5px; color: var(--ink-soft);
  transition: background-color 0.2s, color 0.2s;
}
.doc-toc a:hover { background: var(--surface-alt); color: var(--ink); }

.prose { font-size: 14.5px; color: var(--ink-soft); }
.prose h2 { color: var(--ink); margin-bottom: 10px; scroll-margin-top: calc(var(--topbar-h) + 20px); }
.prose h3 { color: var(--ink); margin: 20px 0 8px; }
.prose p + p { margin-top: 10px; }
.prose ul, .prose ol { padding-left: 20px; margin: 10px 0; }
.prose li { margin-bottom: 5px; }
.prose li strong { color: var(--ink); font-weight: 600; }
.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; background: var(--surface-alt);
  padding: 1.5px 5px; border-radius: 5px; color: var(--ink);
}
.prose pre {
  background: var(--surface-alt); border-radius: var(--r-md);
  padding: 14px 16px; overflow-x: auto; margin: 12px 0;
}
.prose pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.65; }
.prose .card + .card, .prose section + section { margin-top: 16px; }
.prose section { scroll-margin-top: calc(var(--topbar-h) + 20px); }
.prose table.data { margin-top: 12px; }
.prose table.data td { white-space: normal; color: var(--ink-soft); }
.prose table.data td:first-child { color: var(--ink); font-weight: 500; white-space: nowrap; }

/* --- Home hero ------------------------------------------------------------ */

.hero { padding: clamp(30px, 5vw, 54px) 0 clamp(22px, 3vw, 30px); }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--ink-soft); margin-bottom: 14px;
}
.hero h1 { max-width: 20ch; }
.hero p { margin-top: 12px; max-width: 60ch; font-size: 15px; }
.hero .actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }

/* Tool card */
.tool { display: flex; flex-direction: column; height: 100%; }
.tool .top { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 12px; }
.tool .tool-icon {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  background: var(--surface-alt); color: var(--ink);
  display: grid; place-items: center; flex: none;
}
.tool .tool-icon svg { width: 16px; height: 16px; }
.tool h3 { font-size: 14px; }
.tool .owner { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.tool p { font-size: 13px; margin-bottom: 14px; }
.tool .foot {
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-faint);
}
.tool .foot .spacer { margin-left: auto; }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--line-soft);
  padding: 34px clamp(16px, 3vw, 40px) 40px;
  margin-top: 40px;
}
.site-footer .inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; gap: 40px; flex-wrap: wrap;
}
.site-footer .col { min-width: 132px; }
.site-footer .col-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 10px;
}
.site-footer a { display: block; font-size: 13px; color: var(--ink-soft); padding: 3px 0; transition: color 0.2s; }
.site-footer a:hover { color: var(--ink); }
.site-footer .end {
  max-width: 1120px; margin: 26px auto 0;
  padding-top: 18px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: 12px; color: var(--ink-faint);
}
.site-footer .end .spacer { margin-left: auto; }

/* --- Auth pages ----------------------------------------------------------- */

.auth-wrap {
  min-height: calc(100dvh - var(--topbar-h));
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px 64px;
}
.auth-card { width: 100%; max-width: 396px; }
.auth-card .card { padding: 26px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .mark {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center; margin: 0 auto 14px;
  transition: background-color 0.4s, color 0.4s;
}
.auth-head .mark svg { width: 21px; height: 21px; }
.auth-head h1 { font-size: 21px; }
.auth-head p { font-size: 13.5px; margin-top: 5px; }
.auth-foot {
  margin-top: 18px; text-align: center;
  font-size: 12.5px; color: var(--ink-faint);
}
.auth-foot a { color: var(--ink-soft); }
.auth-foot a:hover { color: var(--ink); }
.sso-btn { justify-content: center; }
.step { display: none; }
.step.active { display: block; }

/* --- Utilities ------------------------------------------------------------ */

.muted { color: var(--ink-faint); }
.soft { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; color: var(--ink); }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row .spacer { margin-left: auto; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.hide { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split { grid-template-columns: minmax(0, 1fr); }
  .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .doc-toc { position: static; }
  .doc-toc nav { display: flex; flex-wrap: wrap; gap: 4px; }
}

@media (max-width: 860px) {
  .mainnav { display: none; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 35;
    height: calc(100dvh - var(--topbar-h));
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    box-shadow: var(--shadow-rest);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim {
    position: fixed; inset: var(--topbar-h) 0 0; z-index: 30;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
  }
  body.nav-open .nav-scrim { opacity: 1; visibility: visible; }
  .menu-btn { display: grid !important; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: span 1; }
  .account-trigger .who { display: none; }
}

@media (min-width: 861px) {
  .menu-btn { display: none !important; }
  .nav-scrim { display: none; }
}

@media (max-width: 560px) {
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .brand .name span { display: none; }
  .site-footer .inner { gap: 24px; }
  .card { padding: 17px; }
  .toolbar .input { min-width: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto; }
}

/* ==========================================================================
   Content plane — library, preview, downloads, delivery status
   ========================================================================== */

/* Asset thumbnails. Placeholder surfaces only: no bytes are fetched from an
   external host, which is also how the real pages behave until a signed URL
   is issued. */
.thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: var(--r-md);
  background:
    radial-gradient(120% 120% at 20% 15%, var(--surface-alt) 0%, transparent 60%),
    linear-gradient(140deg, color-mix(in srgb, var(--accent) 12%, var(--surface-alt)) 0%, var(--surface-alt) 70%);
  display: grid; place-items: center;
  overflow: hidden;
  color: var(--ink-soft);
}
.thumb svg { width: 26px; height: 26px; opacity: 0.7; }
.thumb .thumb-tag {
  position: absolute; left: 8px; top: 8px;
  height: 20px; padding: 0 7px;
  display: inline-flex; align-items: center;
  border-radius: 5px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(6px);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--ink-soft);
}
.thumb .thumb-dur {
  position: absolute; right: 8px; bottom: 8px;
  padding: 2px 6px; border-radius: 5px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ink-soft);
}
.card.asset { display: flex; flex-direction: column; gap: 12px; height: 100%; }
.card.asset > span { display: block; }
.card.asset > .thumb { display: grid; place-items: center; }
.card.asset .asset-title { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; }
.card.asset .asset-meta { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.card.asset .asset-foot {
  margin-top: auto; padding-top: 11px;
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-faint);
}
.card.asset .asset-foot .spacer { margin-left: auto; }

/* Preview player shell */
.player {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  background:
    radial-gradient(90% 120% at 30% 10%, color-mix(in srgb, var(--accent) 18%, #0d0d10) 0%, #0d0d10 65%);
  display: grid; place-items: center;
}
.player .play {
  width: 62px; height: 62px; border-radius: 50%;
  border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.92); color: #14141a;
  display: grid; place-items: center;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.player .play:hover { transform: scale(1.05); box-shadow: 0 10px 38px rgba(0, 0, 0, 0.45); }
.player .play svg { width: 24px; height: 24px; margin-left: 3px; }
.player .player-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), transparent);
  color: rgba(255, 255, 255, 0.92);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.player .scrub {
  flex: 1; height: 3px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.28);
  position: relative;
}
.player .scrub i {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 34%; border-radius: 2px; background: rgba(255, 255, 255, 0.9);
}
.player .player-note {
  position: absolute; left: 14px; top: 12px;
  font-size: 11.5px; color: rgba(255, 255, 255, 0.7);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Meters for hit ratio / quota */
.meter { height: 6px; border-radius: 3px; background: var(--surface-alt); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.meter i.warn { background: var(--warn); }
.meter i.down { background: var(--down); }
.meter i.neutral { background: var(--ink-faint); }
.meter-row { display: flex; align-items: center; gap: 12px; }
.meter-row .meter { flex: 1; }
.meter-row .val { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-soft); min-width: 52px; text-align: right; }

/* Endpoint / host rows */
.endpoint { display: flex; align-items: flex-start; gap: 12px; }
.endpoint .host {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; font-weight: 500; color: var(--ink);
}
.endpoint .purpose { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }
.endpoint .endpoint-side { margin-left: auto; text-align: right; flex: none; }

/* Copyable value rows */
.copy-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: var(--r-sm);
}
.copy-row code {
  flex: 1; min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--ink-soft);
  overflow-x: auto; white-space: nowrap;
}

/* Plane labels used in the architecture explainers */
.plane {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 8px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
}
.plane.control { background: var(--accent-soft); color: var(--accent); }
.plane.content { background: var(--ok-soft); color: var(--ok); }

@media (max-width: 560px) {
  .player .play { width: 50px; height: 50px; }
}
