/* GridSense console. Tokens first; light and dark are both defined, the OS
   preference applies until the toggle stores a choice (html[data-theme]). */
:root {
  color-scheme: light;
  --bg: #f3f6fb; --bg-2: #e9eef6;
  --surface: rgba(255,255,255,.78); --surface-solid: #fff; --surface-2: #f6f9fd;
  --ink: #0a1830; --ink-2: #33465f; --muted: #5b6d86; --faint: #8796ab;
  --line: #d9e2ee; --line-2: #c7d3e3;
  --navy: #0b1d3a;
  --accent: #0ea58c; --accent-ink: #067565; --accent-soft: rgba(14,165,140,.12); --accent-strong: #0b8f7a;
  --on-accent: #fff;
  --neg: #7c4dff; --neg-soft: rgba(124,77,255,.13);
  --cheap: #0ea58c; --normal: #9aa8bb; --peak: #e8890c; --peak-ink: #a15c00; --peak-soft: rgba(232,137,12,.14);
  --bad: #d63a4a; --bad-soft: rgba(214,58,74,.11); --ok: #0f9d6b; --ok-soft: rgba(15,157,107,.12);
  --warn: #c77700; --warn-soft: rgba(232,137,12,.14); --info: #2f6fed; --info-soft: rgba(47,111,237,.12);
  --baseline: #6f7f96;
  --shadow: 0 1px 2px rgba(10,24,48,.05), 0 8px 24px -12px rgba(10,24,48,.14);
  --shadow-lg: 0 24px 60px -20px rgba(10,24,48,.35);
  --ring: 0 0 0 3px rgba(14,165,140,.38);
  --radius: 16px; --radius-sm: 10px; --radius-xs: 7px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --glow-a: rgba(14,165,140,.16); --glow-b: rgba(124,77,255,.12);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060e1c; --bg-2: #0a1628;
  --surface: rgba(18,32,56,.62); --surface-solid: #0f1d34; --surface-2: #0c1830;
  --ink: #e9f0fb; --ink-2: #c3d0e4; --muted: #94a5bf; --faint: #6d7f9a;
  --line: #1c2d49; --line-2: #2a3f62;
  --accent: #2dd4b0; --accent-ink: #4be3c1; --accent-soft: rgba(45,212,176,.14); --accent-strong: #5eead4;
  --on-accent: #052b24;
  --neg: #a78bfa; --neg-soft: rgba(167,139,250,.17);
  --cheap: #2dd4b0; --normal: #5f718c; --peak: #fbab2f; --peak-ink: #ffc266; --peak-soft: rgba(251,171,47,.15);
  --bad: #ff6b7a; --bad-soft: rgba(255,107,122,.14); --ok: #3ddc97; --ok-soft: rgba(61,220,151,.14);
  --warn: #ffb347; --warn-soft: rgba(251,171,47,.15); --info: #7aa7ff; --info-soft: rgba(122,167,255,.15);
  --baseline: #8a9bb5;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
  --shadow-lg: 0 28px 70px -20px rgba(0,0,0,.8);
  --ring: 0 0 0 3px rgba(45,212,176,.45);
  --glow-a: rgba(45,212,176,.13); --glow-b: rgba(167,139,250,.12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #060e1c; --bg-2: #0a1628;
    --surface: rgba(18,32,56,.62); --surface-solid: #0f1d34; --surface-2: #0c1830;
    --ink: #e9f0fb; --ink-2: #c3d0e4; --muted: #94a5bf; --faint: #6d7f9a;
    --line: #1c2d49; --line-2: #2a3f62;
    --accent: #2dd4b0; --accent-ink: #4be3c1; --accent-soft: rgba(45,212,176,.14); --accent-strong: #5eead4;
    --on-accent: #052b24;
    --neg: #a78bfa; --neg-soft: rgba(167,139,250,.17);
    --cheap: #2dd4b0; --normal: #5f718c; --peak: #fbab2f; --peak-ink: #ffc266; --peak-soft: rgba(251,171,47,.15);
    --bad: #ff6b7a; --bad-soft: rgba(255,107,122,.14); --ok: #3ddc97; --ok-soft: rgba(61,220,151,.14);
    --warn: #ffb347; --warn-soft: rgba(251,171,47,.15); --info: #7aa7ff; --info-soft: rgba(122,167,255,.15);
    --baseline: #8a9bb5;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    --shadow-lg: 0 28px 70px -20px rgba(0,0,0,.8);
    --ring: 0 0 0 3px rgba(45,212,176,.45);
    --glow-a: rgba(45,212,176,.13); --glow-b: rgba(167,139,250,.12);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 15px/1.55 var(--font); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(900px 500px at 8% -10%, var(--glow-a), transparent 60%), radial-gradient(800px 500px at 100% 0%, var(--glow-b), transparent 60%);
  background-attachment: fixed; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.015em; font-weight: 650; }
h1 { font-size: 1.65rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent-ink); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: var(--mono); font-size: .86em; }
[hidden] { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 18px 14px; display: flex; flex-direction: column; gap: 18px;
  background: linear-gradient(180deg, #0b1d3a, #081428); color: #cfe0f7; border-right: 1px solid rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: #fff; font-weight: 700; font-size: 1.12rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; overflow: hidden; box-shadow: 0 6px 18px -8px rgba(45,212,176,.6); }
.brand-mark img { width: 100%; height: 100%; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-group { margin: 14px 10px 4px; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: #6f87aa; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: #b8cbe6; font-weight: 500; transition: background .15s, color .15s; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link[aria-current="page"] { background: linear-gradient(90deg, rgba(45,212,176,.22), rgba(45,212,176,.06)); color: #fff; box-shadow: inset 2px 0 0 #2dd4b0; }
.nav-link svg { width: 19px; height: 19px; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: .76rem; color: #6f87aa; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 28px; min-height: 60px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 650; font-size: 1.02rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn.menu-btn { display: none; }
.main { padding: 26px 28px 60px; max-width: 1440px; width: 100%; margin: 0 auto; outline: none; }
.live-badge { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--muted); padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-badge[data-state="live"] .live-dot { background: var(--ok); box-shadow: 0 0 0 0 rgba(15,157,107,.5); animation: pulse 2.2s infinite; }
.live-badge[data-state="retry"] .live-dot { background: var(--warn); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(15,157,107,0); } 100% { box-shadow: 0 0 0 0 rgba(15,157,107,0); } }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: transform .15s, background .15s; }
.icon-btn:hover { background: var(--surface-solid); transform: translateY(-1px); }
.wallet-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: .86rem; }
.wallet-chip:hover { text-decoration: none; border-color: var(--accent); }
.wallet-chip.low { border-color: var(--warn); color: var(--warn); }
.user-menu { position: relative; }
.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--neg)); color: #fff; font-weight: 700; border: 0; cursor: pointer; }
.pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 8px; border-radius: 14px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow-lg); z-index: 40; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.pop .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.pop .who b { display: block; } .pop .who span { color: var(--muted); font-size: .84rem; }
.pop a, .pop button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; color: var(--ink); cursor: pointer; text-align: left; }
.pop a:hover, .pop button:hover { background: var(--accent-soft); text-decoration: none; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; border: 1px solid var(--line); background: var(--surface); }
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.banner .grow { flex: 1; }

/* ---- page header & layout helpers ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; justify-content: space-between; margin-bottom: 22px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.stack { display: grid; gap: 18px; } .stack.sm { gap: 10px; }
.grid { display: grid; gap: 18px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.auto { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .84rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.pos { color: var(--ok); } .neg-text { color: var(--bad); }
.grow { flex: 1; min-width: 0; }

/* ---- cards ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  backdrop-filter: blur(12px) saturate(1.3); -webkit-backdrop-filter: blur(12px) saturate(1.3);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
}
.card.hover:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: var(--shadow-lg); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 8px; }
.card-head .sub { color: var(--muted); font-size: .86rem; font-weight: 400; }
.card.flush { padding: 0; overflow: hidden; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 16px; }
.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: .82rem; font-weight: 550; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; line-height: 1.1; }
.kpi .value small { font-size: .95rem; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .foot { margin-top: 6px; font-size: .82rem; color: var(--muted); }
.kpi.accent { background: linear-gradient(140deg, color-mix(in srgb, var(--accent) 22%, var(--surface-solid)), var(--surface)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.kpi .spark { position: absolute; right: 12px; bottom: 10px; width: 90px; height: 34px; opacity: .9; }
.callout { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--neg-soft); border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent); }
.callout .ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--neg); color: #fff; flex: none; }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--surface-solid); color: var(--ink); font-weight: 600; cursor: pointer; transition: transform .12s, box-shadow .15s, background .15s, border-color .15s; white-space: nowrap; line-height: 1.2;
}
.btn:hover { transform: translateY(-1px); border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent-strong)); color: var(--on-accent); border-color: transparent; box-shadow: 0 8px 20px -10px var(--accent); }
.btn.primary:hover { box-shadow: 0 12px 26px -10px var(--accent); }
.btn.danger { color: var(--bad); } .btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; } .btn.ghost:hover { background: var(--accent-soft); }
.btn.sm { padding: 5px 11px; font-size: .86rem; border-radius: 9px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; pointer-events: none; }
.btn[aria-busy="true"]::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > label, .field > .lbl { font-size: .84rem; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: .78rem; color: var(--muted); } .field .err { font-size: .8rem; color: var(--bad); min-height: 0; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-solid); color: var(--ink); min-height: 40px; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 90px; resize: vertical; font-family: inherit; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.field.invalid .input { border-color: var(--bad); }
.input[type="color"] { padding: 2px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.switch { appearance: none; width: 40px; height: 23px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch:checked { background: var(--accent); } .switch:checked::after { transform: translateX(17px); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: .88rem; }
.seg button[aria-pressed="true"] { background: var(--surface-solid); color: var(--ink); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); }

/* ---- badges ---- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 650; background: var(--bg-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.neg { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.badge.peak { background: var(--peak-soft); color: var(--peak-ink); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px; background: var(--bg-2); font-size: .8rem; font-weight: 600; color: var(--ink-2); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: transparent; }
table.t th.sortable { cursor: pointer; user-select: none; } table.t th.sortable:hover { color: var(--ink); }
table.t th[aria-sort="ascending"]::after { content: " ↑"; } table.t th[aria-sort="descending"]::after { content: " ↓"; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.clickable { cursor: pointer; } table.t tbody tr:hover { background: var(--accent-soft); }
table.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { width: 54px; height: 54px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent-ink); }
.empty .big svg { width: 26px; height: 26px; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

/* ---- skeleton ---- */
.skel { position: relative; overflow: hidden; border-radius: 8px; background: var(--bg-2); min-height: 14px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface-solid) 70%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel.chart { height: 260px; border-radius: 12px; } .skel.line { height: 14px; margin: 8px 0; } .skel.kpi-s { height: 104px; border-radius: var(--radius); }

/* ---- toasts & dialogs ---- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 90; max-width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--line); box-shadow: var(--shadow-lg); animation: toast-in .22s ease-out; border-left: 4px solid var(--info); }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.toast .body { flex: 1; min-width: 0; overflow-wrap: anywhere; } .toast .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1.1rem; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.scrim { position: fixed; inset: 0; z-index: 80; background: rgba(4,10,22,.55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 22px; animation: pop .18s ease-out; }
.dialog.wide { width: min(760px, 100%); }
.dialog h2 { margin-bottom: 6px; } .dialog .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---- code ---- */
pre.code { margin: 0; padding: 14px 16px; border-radius: 12px; background: #0a1629; color: #d7e4f8; overflow-x: auto; line-height: 1.55; border: 1px solid var(--line); }
.codebox { position: relative; } .codebox .copy { position: absolute; top: 8px; right: 8px; }
.secret { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px dashed var(--line-2); font-family: var(--mono); overflow-wrap: anywhere; }

/* ---- price band legend, charts ---- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); align-items: center; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.line { height: 3px; border-radius: 2px; vertical-align: 3px; width: 16px; } .legend i.dash { height: 0; border-top: 2px dashed var(--baseline); background: none; width: 16px; vertical-align: 3px; }
.chart { position: relative; width: 100%; min-height: 120px; }
.chart svg { display: block; overflow: visible; max-width: 100%; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--line-2); shape-rendering: crispEdges; }
.chart .zero-line { stroke: var(--faint); stroke-dasharray: 3 3; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; pointer-events: none; }
.chart .bar { transition: opacity .15s; } .chart .bar.dim { opacity: .45; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; min-width: 130px; max-width: 260px; padding: 8px 10px; border-radius: 10px; font-size: .8rem; background: var(--surface-solid); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .1s; transform: translateY(-6px); }
.chart-tip.on { opacity: 1; } .chart-tip b { display: block; margin-bottom: 3px; }
.chart-tip .tr { display: flex; justify-content: space-between; gap: 14px; } .chart-tip .tr i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.chart-msg { display: grid; place-items: center; text-align: center; color: var(--muted); min-height: 140px; padding: 20px; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }
.heat-legend .ramp { width: 160px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--neg), var(--cheap), var(--normal), var(--peak)); }

/* ---- plan specifics ---- */
.fin-wrap { container-type: inline-size; }
/* A fixed column count per width, so the last tile can take the rest of its
   row instead of leaving a gap. */
.fin { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fin .it:last-child:nth-child(odd) { grid-column: 1 / -1; }
@container (min-width: 500px) {
  .fin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fin .it:last-child:nth-child(odd) { grid-column: auto; }
  .fin .it:last-child:nth-child(3n+1) { grid-column: 1 / -1; }
  .fin .it:last-child:nth-child(3n+2) { grid-column: span 2; }
}
@container (min-width: 760px) {
  .fin { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fin .it:last-child:nth-child(3n+1), .fin .it:last-child:nth-child(3n+2) { grid-column: auto; }
  .fin .it:last-child:nth-child(4n+1) { grid-column: 1 / -1; }
  .fin .it:last-child:nth-child(4n+2) { grid-column: span 3; }
  .fin .it:last-child:nth-child(4n+3) { grid-column: span 2; }
}
.fin .it { min-width: 0; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 3px; }
.fin .it .l { font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.fin .it .v { font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--ink); }
.fin .it .v.pos { color: var(--ok); }
.fin .it .s { font-size: .78rem; color: var(--faint); }
.action { display: grid; gap: 6px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); border-left: 4px solid var(--normal); }
.action.high { border-left-color: var(--peak); } .action.medium { border-left-color: var(--accent); } .action.low { border-left-color: var(--line-2); }
.action h4 { font-size: .98rem; } .action .meta { display: flex; gap: 6px; flex-wrap: wrap; }
.checks { display: grid; gap: 6px; }
.check-row { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 8px 10px; border-radius: 10px; align-items: start; }
.check-row:hover { background: var(--accent-soft); } .check-row .mk { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; background: var(--ok); }
.check-row.fail .mk { background: var(--bad); } .check-row.fail { background: var(--bad-soft); }
.check-row .d { color: var(--muted); font-size: .84rem; }
/* Facility card: identity, facts, saving, status, headline, footer. */
.fac-card { display: flex; flex-direction: column; gap: 14px; color: inherit; }
.fac-card:hover { text-decoration: none; }
.fc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.fc-id { min-width: 0; display: grid; gap: 2px; }
.fac-card .name { font-weight: 650; font-size: 1.06rem; color: var(--ink); }
.fc-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fc-fact { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: var(--bg-2); color: var(--ink-2); font-size: .78rem; font-weight: 550; white-space: nowrap; }
.fc-fact svg { width: 13px; height: 13px; color: var(--muted); }
.fc-plan { display: grid; gap: 8px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: inherit; transition: border-color .15s; }
.fc-plan:hover { text-decoration: none; border-color: var(--accent); }
.fc-saving { display: flex; align-items: baseline; gap: 8px; min-width: 0; white-space: nowrap; }
.fc-plan { min-width: 0; overflow: hidden; }
.fc-plan-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.fc-saving b { font-size: 1.5rem; letter-spacing: -.03em; line-height: 1.1; }
.fc-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fc-checks { display: inline-flex; align-items: center; gap: 5px; font-size: .82rem; font-weight: 600; color: var(--ok); white-space: nowrap; }
.fc-checks.bad { color: var(--bad); } .fc-checks svg { width: 15px; height: 15px; }
.fc-headline { font-size: .84rem; color: var(--ink-2); }
.fc-empty { justify-items: start; }
.fc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.fc-foot > span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.fc-foot .btn { flex: none; } .fac-card { min-width: 0; }
.fc-foot > span svg { width: 14px; height: 14px; flex: none; }
.eq-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) 1.4fr auto; gap: 10px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.eq-block { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface-2); display: grid; gap: 12px; }
.eq-block.invalid { border-color: var(--bad); }
.sec-title { font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 650; margin: 4px 0 -4px; }
.meter { height: 8px; border-radius: 4px; background: var(--bg-2); overflow: hidden; } .meter > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: 4px; transition: width .5s; }
.timeline { display: grid; gap: 10px; } .tl { display: grid; grid-template-columns: 12px 1fr; gap: 12px; } .tl .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.tl.warning .dot { background: var(--warn); } .tl.critical .dot { background: var(--bad); }
.pagebar { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.sev-info { color: var(--info); } .sev-warning { color: var(--warn); } .sev-critical { color: var(--bad); }

/* ---- motion & responsive ---- */
.fade-in { animation: fade-up .35s ease-out both; }
.settled .fade-in { animation: none; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } }
@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 (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.c3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 270px; transform: translateX(-102%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 8px 14px; } .main { padding: 18px 14px 50px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: minmax(0, 1fr); }
  .eq-row { grid-template-columns: 1fr; }
  .live-label, .wallet-chip .wl { display: none; }
  h1 { font-size: 1.4rem; }
}
@media (max-width: 480px) { .kpis { grid-template-columns: 1fr 1fr; } .kpis > :first-child:nth-last-child(odd) { grid-column: 1 / -1; } .card { padding: 15px; } .topbar-actions { gap: 5px; } }

/* ==================================================================== */
/* Responsive: desktop > 1180px, tablet 861-1180 (icon rail),           */
/* phone <= 860 (drawer + bottom tab bar), small phone <= 480.          */
/* ==================================================================== */
.tabbar, .nav-scrim { display: none; }

@media (min-width: 861px) and (max-width: 1180px) {
  :root { --sidebar-w: 78px; }
  .sidebar { padding: 16px 10px; align-items: stretch; }
  .brand { justify-content: center; padding: 4px 0; }
  .brand > span:last-child, .nav-link span, .sidebar-foot { display: none; }
  .nav-link { justify-content: center; padding: 11px 0; }
  .nav-link svg { width: 21px; height: 21px; }
  .nav-group { font-size: 0; height: 1px; margin: 10px 12px; background: rgba(255,255,255,.08); }
  .topbar { padding: 10px 22px; }
  .main { padding: 22px 22px 56px; }
  .grid.split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(4,10,22,.5); backdrop-filter: blur(3px); animation: fade .15s; }
  .nav-scrim[hidden] { display: none; }
  body.nav-open { overflow: hidden; }
  .sidebar { width: min(300px, 86vw); padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 88%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border: 0; background: none; border-radius: 12px;
    color: var(--muted); font: inherit; font-size: .68rem; font-weight: 600; cursor: pointer; min-height: 48px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"], .tabbar button.current { color: var(--accent-ink); background: var(--accent-soft); }
  .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(78px + env(safe-area-inset-bottom)); left: 12px; right: 12px; max-width: none; }
  /* 16px stops iOS zooming into a field on focus. */
  input.input, select.input, textarea.input, .input { font-size: 16px; }
  .btn, .icon-btn { min-height: 40px; }
  .card-head { align-items: flex-start; }
  .page-head { align-items: stretch; }
  .tabs { margin-left: -14px; margin-right: -14px; padding: 0 14px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
}

@media (max-width: 640px) {
  .page-head > :not(:first-child) { width: 100%; }
  .page-head > .btn, .page-head > :not(:first-child) > .btn { flex: 1; justify-content: center; }
  .page-head .row { width: 100%; }
  .seg { width: 100%; } .seg button { flex: 1; }
  /* Dialogs become bottom sheets, with the actions always in reach. */
  .scrim { place-items: end center; padding: 0; }
  .dialog, .dialog.wide { width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; padding: 20px 18px calc(16px + env(safe-area-inset-bottom)); animation: sheet .22s ease-out; }
  .dialog .actions { position: sticky; bottom: -16px; margin: 18px -18px -16px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface-solid); border-top: 1px solid var(--line); }
  .dialog .actions .btn { flex: 1; justify-content: center; }
  /* Wide tables become one card per row: label on the left, value on the right. */
  table.t.stackable thead { display: none; }
  table.t.stackable, table.t.stackable tbody, table.t.stackable tr, table.t.stackable td { display: block; width: 100%; }
  table.t.stackable tr { padding: 10px 2px; border-bottom: 1px solid var(--line); }
  table.t.stackable tr:last-child { border-bottom: 0; }
  table.t.stackable tbody tr:hover { background: none; }
  table.t.stackable td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 5px 8px; border: 0; text-align: right; }
  table.t.stackable td::before { content: attr(data-label); flex: none; text-align: left; color: var(--muted); font-size: .72rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
  table.t.stackable td:first-child { display: block; text-align: left; font-size: .98rem; padding-bottom: 8px; }
  table.t.stackable td:first-child::before { display: none; }
  table.t.stackable td.td-actions { justify-content: flex-end; padding-top: 8px; }
  table.t.stackable td.td-actions::before { content: none; }
  table.t.stackable td > div { text-align: right; }
  table.t.stackable td:first-child > div { text-align: left; }
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }

@media (max-width: 480px) {
  .topbar-actions #theme-toggle { display: none; }
  .wallet-chip { padding: 6px 10px; }
  .main { padding-left: 12px; padding-right: 12px; }
  h1 { font-size: 1.3rem; }
}

@media print { .sidebar, .topbar, .toasts { display: none !important; } .shell { display: block; } body { background: #fff; } }
.pop .theme-item { display: none; } @media (max-width: 480px) { .pop .theme-item { display: flex; } }
/* Five KPIs: never a lone card on the last row. Desktop fits five across;
   tablets use three columns with the headline spanning two (2 + 1, then 3). */
@media (min-width: 481px) and (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis > :first-child:nth-last-child(5) { grid-column: span 2; }
}
/* Page rhythm: every top-level block on a page is spaced the same, so cards,
   KPI rows and section headings never sit flush against each other. */
#app { display: grid; gap: 22px; align-content: start; }
#app > * { min-width: 0; }
#app > .page-head { margin-bottom: 0; }
@media (max-width: 860px) { #app { gap: 16px; } }
/* KPI figures scale with their card, not the window, and never wrap. */
.kpi { container-type: inline-size; }
.kpi .value { font-size: clamp(1.25rem, 12.5cqi, 1.85rem); white-space: nowrap; }
@container (max-width: 220px) { .kpi .spark { display: none; } }

/* ==================================================================== */
/* One line per label. Labels, captions, titles in lists, badges and    */
/* controls never wrap; when space runs out they end in an ellipsis and */
/* the full text is in the element's title.                             */
/* ==================================================================== */
.one-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.btn, .badge, .chip, .seg button, .tabs button, table.t th, .wallet-chip, .live-badge, .nav-link span, .crumbs a { white-space: nowrap; }
.kpi .label { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .label svg { vertical-align: -2px; margin-right: 6px; }
.kpi .foot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl > div { min-width: 0; }
.tl b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.callout > div { min-width: 0; }
.callout > div > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-head > div:first-child { min-width: 0; }
.page-head .sub { overflow-wrap: anywhere; }
@media (min-width: 641px) { .page-head > .row { flex-wrap: nowrap; } .page-head > .row .input { width: 240px; } }

/* KPI rows sized by how many figures they hold. */
@media (min-width: 861px) {
  .kpis:has(> :nth-child(4):last-child) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1181px) {
  .kpis:has(> :nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 481px) and (max-width: 860px) {
  .kpis:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Stat strip: many small figures in one card, divided by thin rules. */
.kpis.strip { gap: 0; padding: 0; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: hidden; }
.kpis.strip > .kpi { padding: 16px 18px; border-left: 1px solid var(--line); }
.kpis.strip > .kpi:first-child { border-left: 0; }
.kpis.strip > .kpi .value { font-size: clamp(1.05rem, 13cqi, 1.45rem); }
@media (max-width: 1180px) {
  .kpis.strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis.strip > .kpi:nth-child(3n + 1) { border-left: 0; }
  .kpis.strip > .kpi:nth-child(n + 4) { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .kpis.strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.strip > .kpi { border-left: 1px solid var(--line); border-top: 0; }
  .kpis.strip > .kpi:nth-child(odd) { border-left: 0; }
  .kpis.strip > .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpis.strip > :first-child:nth-last-child(odd) { grid-column: auto; }
}

/* Dashboard: the market card and the right-hand column are one height; the
   alert list fills whatever the callout leaves. */
.side-stack { display: flex; flex-direction: column; gap: 18px; }
.side-stack > .card:last-child { flex: 1; }

/* Channel type picker: one chip per type, icon and label. */
.type-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2);
  color: var(--ink-2); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.type-chip:hover:not(:disabled) { border-color: var(--accent); }
.type-chip[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.type-chip:disabled { opacity: .45; cursor: not-allowed; }
.type-chip svg { width: 17px; height: 17px; }

/* Plan page: waterfall + checks side by side, the same height; the checks
   list scrolls inside its card instead of stretching the row. */
.plan-pair > .card { display: flex; flex-direction: column; }
.checks.scroll { max-height: 372px; overflow-y: auto; padding-right: 4px; overscroll-behavior: contain; scrollbar-width: thin; gap: 2px; }
.checks.scroll .check-row { padding: 7px 10px; }
.checks-wrap { position: relative; }
.checks-wrap::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px; pointer-events: none; background: linear-gradient(transparent, var(--surface)); }
.wf-list { display: grid; gap: 7px; padding-top: 10px; border-top: 1px solid var(--line); }
.wf-row { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) auto; gap: 12px; align-items: center; font-size: .86rem; }
.wf-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wf-bar { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.wf-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.neg-v { color: var(--bad); }

/* Webhook signing secret: two radio cards. */
.secret-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 8px; }
.secret-opt { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.secret-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.secret-opt input { margin-top: 3px; accent-color: var(--accent); }
.secret-opt > span { display: grid; gap: 2px; }

/* ---- API reference ---- */
.api-layout { display: grid; grid-template-columns: 282px minmax(0, 1fr); gap: 22px; align-items: start; }
.api-index { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; display: grid; gap: 2px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; }
.api-search { display: flex; align-items: center; gap: 8px; padding: 0 10px; margin-bottom: 8px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface-2); }
.api-search svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
.api-search .input { border: 0; background: none; padding: 8px 0; box-shadow: none; min-width: 0; width: 100%; }
.api-ix-top { padding: 7px 10px; border-radius: 8px; font-weight: 600; font-size: .88rem; color: var(--ink); }
.api-ix-tag { padding: 12px 10px 4px; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.api-ix { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 8px; font-size: .76rem; color: var(--ink-2); font-family: var(--mono); min-width: 0; }
.api-ix .api-m { min-width: 44px; font-size: .62rem; padding: 2px 0; }
.api-ix:hover, .api-ix-top:hover { background: var(--accent-soft); text-decoration: none; }
.api-ix.on { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 2px 0 0 var(--accent); }
.api-main { min-width: 0; }
.api-base { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.api-base code { font-size: .92rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.api-base .btn { margin-left: auto; }
.api-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.api-step { display: flex; gap: 12px; align-items: flex-start; }
.api-step p { margin: 2px 0 0; }
.api-n { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 800; font-size: .82rem; }
.api-group { display: grid; gap: 14px; scroll-margin-top: 80px; }
.api-group-head { padding: 14px 2px 0; }
.api-group-head h2 { font-size: 1.25rem; letter-spacing: -.01em; }
.api-group-head p { margin: 4px 0 0; max-width: 72ch; }
.api-op { display: grid; gap: 14px; scroll-margin-top: 80px; }
.api-op-head { display: grid; gap: 6px; }
.api-op-head h3 { font-size: 1.02rem; font-weight: 650; }
.api-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.api-path { font-family: var(--mono); font-size: .95rem; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.api-path em { font-style: normal; color: var(--accent-ink); }
.api-anchor { margin-left: auto; opacity: .5; } .api-op:hover .api-anchor { opacity: 1; }
.api-m { display: inline-block; min-width: 58px; text-align: center; padding: 3px 8px; border-radius: 7px; font: 800 .7rem/1.3 var(--mono); letter-spacing: .04em; color: #fff; flex: none; }
.m-get { background: #0f9f7a; } .m-post { background: #2f6fe4; } .m-put { background: #c98410; } .m-patch { background: #8a5cf6; } .m-delete { background: #d6455d; }
.api-desc { margin: 0; color: var(--ink-2); max-width: 80ch; }
.api-desc code, .api-group-head code, .card-head .sub code { padding: 1px 5px; border-radius: 5px; background: var(--bg-2); }
.api-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 18px; align-items: start; }
.api-sample .tabs { margin-bottom: 8px; }
.api-sample pre.code, .api-start pre.code, #signatures pre.code, #errors pre.code { max-height: 340px; font-size: .8rem; padding-top: 42px; }
.api-fields { display: grid; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.api-field { display: grid; grid-template-columns: minmax(120px, .8fr) minmax(0, 1.4fr); gap: 12px; padding: 9px 12px; border-top: 1px solid var(--line); }
.api-field:first-child { border-top: 0; }
.api-fname { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.api-fname code { font-weight: 650; color: var(--ink); overflow-wrap: anywhere; }
.api-fmeta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; min-width: 0; }
.api-type { font: 600 .76rem var(--mono); color: var(--info, #2f6fe4); white-space: nowrap; }
.api-enum { display: inline-flex; flex-wrap: wrap; gap: 4px; } .api-enum code { font-size: .72rem; padding: 0 5px; border-radius: 5px; background: var(--bg-2); }
.api-req { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--bad); }
.api-in { font-size: .7rem; color: var(--faint); font-family: var(--mono); }
.api-resps { display: grid; gap: 6px; }
.api-resp { display: flex; align-items: center; gap: 10px; font-size: .86rem; min-width: 0; }
.api-code { flex: none; min-width: 44px; text-align: center; padding: 2px 6px; border-radius: 6px; font: 700 .76rem var(--mono); }
.api-code.c2 { background: var(--ok-soft, #dff5ec); color: var(--ok); } .api-code.c4 { background: var(--warn-soft, #fdf0d9); color: var(--warn, #b26b00); } .api-code.c5 { background: var(--bad-soft); color: var(--bad); }
.api-etitle { flex: none; min-width: 150px; font-size: .86rem; }
#events, #errors, #signatures { scroll-margin-top: 80px; }
@media (max-width: 1280px) { .api-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 980px) {
  .api-layout { grid-template-columns: minmax(0, 1fr); }
  .api-index { position: static; max-height: none; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .api-index .api-search, .api-index .api-ix-top { grid-column: 1 / -1; }
  .api-ix-group { display: none; }
}
@media (max-width: 640px) {
  .api-field { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .api-etitle { min-width: 0; }
  .api-resp { flex-wrap: wrap; }
}
.sec-title .api-type { text-transform: none; letter-spacing: 0; }
/* Nothing in a page may widen the layout viewport: on a phone that zooms the
   whole page out and pushes the top bar off the screen. */
.main-col, #app, .api-main, .api-main > *, .api-step > div { min-width: 0; }
.api-step code, .api-desc code, .card-head .sub code { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 640px) { .api-base .btn { margin-left: 0; } .api-base code { flex-basis: 100%; } }
/* Grid and flex children default to min-width:auto, so one long code line or
   URL stretches the card and, on a phone, the whole layout viewport. Cards and
   layout children shrink; code scrolls inside its own box. */
.card, .grid > *, .stack > *, .row > .grow, .codebox, .tabs { min-width: 0; }
.codebox, pre.code { max-width: 100%; }
.tabs { max-width: 100%; }
.action { min-width: 0; grid-template-columns: minmax(0, 1fr); } .action .small { overflow-wrap: anywhere; }
.chip-cut .one-line { min-width: 0; }
.action .meta { min-width: 0; } .chip-cut { max-width: 100%; min-width: 0; } .chip-cut svg { flex: none; }

/* Webhook form: event cards and the secret field with its actions. */
.webhook-form { gap: 18px; }
.ev-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.ev-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); cursor: pointer; min-width: 0; transition: border-color .15s, background .15s; }
.ev-opt:hover { border-color: var(--accent); }
.ev-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ev-opt input { margin-top: 3px; accent-color: var(--accent); flex: none; }
.ev-opt > span { display: grid; gap: 1px; min-width: 0; }
.ev-opt b { font-size: .9rem; }
.secret-input { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 0; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); }
.secret-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.secret-input .input, .secret-input input { flex: 1; min-width: 0; border: 0 !important; box-shadow: none !important; background: none; font-family: var(--mono); font-size: .86rem; }
.secret-actions { display: flex; gap: 4px; flex: none; }
@media (max-width: 520px) { .secret-input { flex-wrap: wrap; padding: 4px; } .secret-actions { width: 100%; justify-content: flex-end; } }

/* Plan progress: shown in a facility card's plan box or on the facility page
   while a plan runs. */
.plan-progress { display: grid; gap: 12px; min-width: 0; }
.pp-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pp-text { display: grid; gap: 1px; min-width: 0; flex: 1; }
.pp-text b { font-size: .95rem; }
.pp-pct { font: 700 .82rem var(--mono); color: var(--accent-ink); flex: none; }
.pp-spin { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2.5px solid var(--accent-soft); border-top-color: var(--accent); animation: pp-spin .8s linear infinite; }
@keyframes pp-spin { to { transform: rotate(360deg); } }
.pp-bar { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.pp-bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--info)); transition: width .4s ease; position: relative; overflow: hidden; }
.pp-bar i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); animation: pp-shine 1.4s linear infinite; }
@keyframes pp-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.pp-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.pp-steps li { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: .76rem; font-weight: 600; color: var(--faint); }
.pp-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.pp-steps li[data-state="now"] { color: var(--accent-ink); } .pp-steps li[data-state="now"] .pp-dot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pp-steps li[data-state="done"] { color: var(--ink-2); } .pp-steps li[data-state="done"] .pp-dot { background: var(--accent); border-color: var(--accent); }
.plan-progress.ok .pp-spin { animation: none; border-color: var(--ok); background: var(--ok); }
.plan-progress.ok .pp-bar i::after, .plan-progress.bad .pp-bar i::after { display: none; }
.plan-progress.bad .pp-spin { animation: none; border-color: var(--bad); background: var(--bad); }
.plan-progress.bad .pp-bar i { background: var(--bad); } .plan-progress.bad .pp-text b { color: var(--bad); }
.plan-progress.compact .pp-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fc-running { padding: 14px; }
@media (prefers-reduced-motion: reduce) { .pp-spin, .pp-bar i::after { animation: none; } }
@media (max-width: 640px) { .pp-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
