/* Design tokens, reset, app shell (sidebar + content) and utilities. */
:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --surface-3: #eef0f3;
  --border: #e3e6eb; --border-strong: #cfd4dc;
  --text: #101828; --text-2: #3d4757; --muted: #667085;
  --brand: #f59e0b; --brand-hover: #e69009; --brand-ink: #1c1203; --brand-soft: #fff4dc; --brand-text: #b45309;
  --ring: 0 0 0 3px rgba(245, 158, 11, .35);
  --ok: #067647; --ok-bg: #ecfdf3; --ok-dot: #12b76a;
  --warn: #b54708; --warn-bg: #fffaeb; --warn-dot: #f79009;
  --err: #b42318; --err-bg: #fef3f2; --err-dot: #f04438;
  --sidebar: #111827; --sidebar-hover: #1d2738; --sidebar-text: #cfd5df; --sidebar-muted: #8490a3; --sidebar-active: #fbbf24;
  --series: #2a78d6; --grid: #eaecf0;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 40px -8px rgba(16, 24, 40, .22);
  --radius: 12px; --radius-sm: 8px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b0f17; --surface: #121826; --surface-2: #161d2c; --surface-3: #1d2638;
    --border: #243045; --border-strong: #33415a;
    --text: #f2f4f7; --text-2: #c5ccd8; --muted: #8b95a7;
    --brand-soft: rgba(245, 158, 11, .14); --brand-text: #fbbf24;
    --ok: #47cd89; --ok-bg: rgba(23, 178, 106, .14); --warn: #fdb022; --warn-bg: rgba(247, 144, 9, .14);
    --err: #f97066; --err-bg: rgba(240, 68, 56, .14);
    --sidebar: #0a0e15; --sidebar-hover: #161d2b;
    --series: #3987e5; --grid: #1f293b;
    --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0f17; --surface: #121826; --surface-2: #161d2c; --surface-3: #1d2638;
  --border: #243045; --border-strong: #33415a;
  --text: #f2f4f7; --text-2: #c5ccd8; --muted: #8b95a7;
  --brand-soft: rgba(245, 158, 11, .14); --brand-text: #fbbf24;
  --ok: #47cd89; --ok-bg: rgba(23, 178, 106, .14); --warn: #fdb022; --warn-bg: rgba(247, 144, 9, .14);
  --err: #f97066; --err-bg: rgba(240, 68, 56, .14);
  --sidebar: #0a0e15; --sidebar-hover: #161d2b;
  --series: #3987e5; --grid: #1f293b;
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 24px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; line-height: 1.25; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 600; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
img { max-width: 100%; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
[hidden] { display: none !important; }
.icon { flex-shrink: 0; }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; width: 252px; display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text); padding: 16px 12px; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 20px; }
.sidebar-brand a { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.sidebar-brand strong { display: block; font-size: 16px; letter-spacing: -.01em; }
.sidebar-brand small { display: block; color: var(--sidebar-muted); font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--brand-ink);
  background: linear-gradient(135deg, #fcd34d, #f59e0b 60%, #d97706); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); }
.brand-mark.sm { width: 28px; height: 28px; border-radius: 8px; }
.brand-mark.lg { width: 48px; height: 48px; border-radius: 14px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-label { margin: 18px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sidebar-muted); }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--sidebar-text); font: inherit; font-weight: 500; text-align: left; cursor: pointer; text-decoration: none; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item[aria-current="page"] { background: rgba(245, 158, 11, .14); color: var(--sidebar-active); }
.nav-text { flex: 1; }
.nav-count { padding: 0 7px; border-radius: 10px; background: rgba(240, 68, 56, .2); color: #fda29b; font-size: 11px; font-weight: 600; }
.sidebar-footer { display: grid; gap: 2px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: inline; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}
.sidebar .sidebar-close { display: none; color: var(--sidebar-text); }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(10, 14, 21, .5); backdrop-filter: blur(2px); }
.skip-link { position: absolute; left: 12px; top: -40px; z-index: 100; padding: 8px 12px; background: var(--surface); border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* Content */
.main { margin-left: 252px; min-width: 0; }
.mobile-bar { display: none; position: sticky; top: 0; z-index: 30; align-items: center; gap: 8px; padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.mobile-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; text-decoration: none; }
.content { max-width: 1240px; margin: 0 auto; padding: 28px 32px 72px; display: grid; gap: 20px; align-content: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-sub { margin-top: 4px; color: var(--muted); max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: -8px; width: fit-content; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }

@media (max-width: 1080px) { .grid-2, .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  .sidebar .sidebar-close { display: inline-grid; }
  .main { margin-left: 0; }
  .mobile-bar { display: flex; }
  .content { padding: 20px 16px 56px; gap: 16px; }
  h1 { font-size: 21px; }
}

/* Utilities */
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.truncate { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.stack { display: grid; gap: 14px; }
.grow { flex: 1; min-width: 0; }
.span-2 { grid-column: 1 / -1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.danger-text { color: var(--err) !important; }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--err); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.ok { background: var(--ok-dot); } .dot.warn { background: var(--warn-dot); } .dot.err { background: var(--err-dot); }
