/* Synapse Options web theme. Synapse identity (near-black canvas, lime accent, IBM Plex),
   laid out as a web app. See docs/DESIGN.md. Class names used by views are stable. */
:root {
  --bg: #07090C;
  --bg-raise: #0A0D12;
  --panel: #0E131A;
  --panel-2: #121821;
  --chrome: #0A0D12;
  --field: #0F141B;
  --panel-line: #1A222D;
  --row-line: #141B24;
  --field-line: #26303E;
  --text-hi: #F4EEE2;
  --text: #DCE3EE;
  --text-dim: #8F9AAE;
  --text-low: #5B6576;
  --header: #8F9AAE;
  --accent: #C9F158;
  --accent-hover: #D7F57E;
  --accent-ink: #0A0D12;
  --accent-soft: rgba(201, 241, 88, 0.12);
  --up: #2FC98C;
  --down: #F05B4F;
  --neutral: #8F9AAE;
  --amber: #E8B54A;
  --sel: rgba(201, 241, 88, 0.10);
  --hover: rgba(255, 255, 255, 0.035);
  --mono: "IBM Plex Mono", "Cascadia Mono", Consolas, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --side: 232px;
  --side-collapsed: 64px;
  --top: 56px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dim { color: var(--text-dim); }
.low { color: var(--text-low); }
.hi { color: var(--text-hi); }
.mono { font-family: var(--mono); }
.up { color: var(--up); }
.down { color: var(--down); }
.amber { color: var(--amber); }
.accent { color: var(--accent); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.boot { font: 600 13px var(--mono); letter-spacing: .12em; color: var(--accent); padding: 40px; }

/* ── shell ─────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--side) 1fr; grid-template-rows: var(--top) 1fr; height: 100vh; height: 100dvh; }
.shell.collapsed { grid-template-columns: var(--side-collapsed) 1fr; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: rgba(10, 13, 18, 0.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--panel-line); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font: 600 15px var(--sans); color: var(--text-hi); letter-spacing: .01em; min-width: calc(var(--side) - 32px); }
.shell.collapsed .brand { min-width: auto; }
.brand:hover { color: var(--text-hi); }
.brand i { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; box-shadow: 0 0 0 3px var(--accent-soft); }
.brand.lg { font-size: 20px; }
.topbar .spacer { flex: 1; }

.search-btn {
  display: flex; align-items: center; gap: 10px; width: min(440px, 40vw); padding: 8px 12px;
  background: var(--field); border: 1px solid var(--field-line); border-radius: 8px; color: var(--text-low);
  font: 400 13.5px var(--sans); text-transform: none; letter-spacing: 0; cursor: pointer;
}
.search-btn:hover { border-color: var(--text-low); color: var(--text-dim); }
.search-btn .search-text { flex: 1; text-align: left; }
kbd { font: 500 11px var(--mono); color: var(--text-low); border: 1px solid var(--field-line); border-radius: 4px; padding: 1px 5px; background: var(--bg); }

.status { display: flex; align-items: center; gap: 10px; }
.credits { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.credits-label { font-size: 12px; }
.meter { width: 70px; height: 6px; background: var(--field-line); border-radius: 3px; overflow: hidden; display: inline-block; }
.meter i { display: block; height: 100%; border-radius: 3px; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--field-line); font: 600 13px var(--sans); color: var(--text-hi); }
.user-pop { position: absolute; right: 0; top: 42px; min-width: 220px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); z-index: 30; font-size: 13px; }

.sidebar { background: var(--bg-raise); border-right: 1px solid var(--panel-line); overflow-y: auto; padding: 12px 10px 20px; display: flex; flex-direction: column; gap: 6px; }
.nav-group { display: flex; flex-direction: column; gap: 1px; padding-bottom: 6px; }
.nav-title { margin: 10px 10px 4px; font: 600 11px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--text-low); }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--text-dim); font: 500 13.5px var(--sans); }
.nav-link:hover { color: var(--text); background: var(--hover); }
.nav-link.active { color: var(--text-hi); background: var(--accent-soft); }
.nav-link.active .nav-icon { color: var(--accent); }
.nav-icon { width: 20px; text-align: center; font-size: 14px; color: var(--text-low); flex: none; }
.nav-foot { margin-top: auto; padding: 8px 10px 0; }
.shell.collapsed .nav-title, .shell.collapsed .nav-label, .shell.collapsed .brand-text { display: none; }
.shell.collapsed .nav-link { justify-content: center; padding: 9px 0; }
.shell.collapsed .nav-group { border-top: 1px solid var(--row-line); padding-top: 6px; }
.nav-scrim { display: none; }
.dock { display: none; }

.main { overflow: auto; min-width: 0; scroll-behavior: smooth; }
.view { padding: 22px 28px 60px; display: flex; flex-direction: column; gap: 16px; min-height: 100%; max-width: 1600px; }
.view-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.view-head h1 { margin: 0; font: 600 22px/1.25 var(--sans); letter-spacing: -.01em; color: var(--text-hi); text-transform: none; }
.view-head p { margin: 0; color: var(--text-dim); font-size: 13.5px; flex-basis: 100%; }
h2 { font: 600 16px var(--sans); color: var(--text-hi); margin: 0; }
h3 { font: 600 14px var(--sans); color: var(--text-hi); margin: 0; }

/* ── panels, cards ─────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); min-width: 0; }
.panel > header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--panel-line); font: 600 13px var(--sans); letter-spacing: .01em; color: var(--text-hi); text-transform: none; }
.panel > header .spacer { flex: 1; }
.panel > .body { padding: 14px 16px; }
.panel > .body.flush { padding: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.cards, .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card, .stat {
  display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: var(--radius); padding: 14px 16px; color: inherit; font: inherit; letter-spacing: 0; text-transform: none;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { border-color: var(--field-line); background: var(--panel-2); color: inherit; }
.card-label, .stat span { font: 500 12px var(--sans); color: var(--text-dim); letter-spacing: 0; text-transform: none; }
.card-value, .stat b { font: 600 22px/1.2 var(--mono); color: var(--text-hi); font-variant-numeric: tabular-nums; margin-top: 2px; }
.card-sub, .stat small { color: var(--text-dim); font: 12px var(--sans); }

.howto { background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); font-size: 13.5px; }
.howto summary { cursor: pointer; padding: 10px 14px; color: var(--text-dim); list-style: none; display: flex; align-items: center; gap: 8px; }
.howto summary::before { content: '?'; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--field-line); font: 600 11px var(--mono); color: var(--accent); }
.howto summary::-webkit-details-marker { display: none; }
.howto[open] summary { border-bottom: 1px solid var(--panel-line); color: var(--text); }
.howto-body { padding: 12px 16px; color: var(--text-dim); line-height: 1.6; }
.howto-body b, .howto-body strong { color: var(--text); }

/* ── toolbars and forms ────────────────────────────────── */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font: 500 12px var(--sans); color: var(--text-dim); letter-spacing: 0; text-transform: none; }
input, select, textarea {
  background: var(--field); color: var(--text); border: 1px solid var(--field-line); border-radius: var(--radius-sm);
  font: 13.5px var(--sans); padding: 8px 10px; outline: none; min-width: 0; transition: border-color .12s;
}
input[type=number], input.mono { font-family: var(--mono); }
input:hover, select:hover, textarea:hover { border-color: #33404f; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=number] { width: 104px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 15px; height: 15px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font: 13.5px var(--sans); color: var(--text-dim); padding-bottom: 8px; cursor: pointer; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }

button, .btn {
  font: 500 13.5px var(--sans); letter-spacing: 0; text-transform: none; cursor: pointer; white-space: nowrap;
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--field-line); background: var(--panel-2); color: var(--text);
  transition: background .12s, border-color .12s, color .12s;
}
button:hover { border-color: #3a4757; color: var(--text-hi); background: #18202b; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
button.danger:hover { border-color: var(--down); color: var(--down); }
button:disabled { opacity: .45; cursor: default; }
button.link, button.icon { border: 0; background: transparent; padding: 4px 6px; color: var(--accent); font-weight: 500; }
button.link:hover, button.icon:hover { background: var(--hover); color: var(--accent-hover); }
button.icon { color: var(--text-dim); font-size: 15px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--panel-line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--text-dim); padding: 10px 14px; font-weight: 500; }
.tabs button:hover { color: var(--text); background: transparent; }
.tabs button.active { color: var(--text-hi); border-bottom-color: var(--accent); }

/* ── tables ────────────────────────────────────────────── */
.table-wrap { overflow: auto; max-height: 70vh; border-radius: inherit; }
table.grid { width: 100%; border-collapse: collapse; font: 13px var(--sans); }
table.grid th {
  position: sticky; top: 0; z-index: 1; background: var(--panel-2); color: var(--text-dim); text-align: left;
  font: 500 12px var(--sans); letter-spacing: 0; text-transform: none; padding: 9px 12px; border-bottom: 1px solid var(--panel-line); white-space: nowrap; user-select: none;
}
table.grid th.sortable { cursor: pointer; }
table.grid th.sortable:hover { color: var(--text); }
table.grid th.sorted { color: var(--accent); }
table.grid th.num { text-align: right; }
table.grid td { padding: 8px 12px; border-bottom: 1px solid var(--row-line); white-space: nowrap; }
table.grid td.num { font-family: var(--mono); font-size: 12.5px; }
table.grid tbody tr:hover { background: var(--hover); }
table.grid tbody tr.selected { background: var(--sel); box-shadow: inset 2px 0 0 var(--accent); }
table.grid tbody tr.clickable { cursor: pointer; }
table.grid tbody tr:last-child td { border-bottom: 0; }

/* ── states ────────────────────────────────────────────── */
.state { padding: 36px 16px; text-align: center; color: var(--text-dim); font: 13.5px var(--sans); }
.state.error { color: var(--down); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--field-line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font: 500 11.5px var(--sans); letter-spacing: 0; border: 1px solid var(--field-line); color: var(--text-dim); white-space: nowrap; }
.badge.up { color: var(--up); border-color: rgba(47,201,140,.35); background: rgba(47,201,140,.08); }
.badge.down { color: var(--down); border-color: rgba(240,91,79,.35); background: rgba(240,91,79,.08); }
.badge.accent { color: var(--accent); border-color: rgba(201,241,88,.35); background: var(--accent-soft); }
.badge.amber { color: var(--amber); border-color: rgba(232,181,74,.35); background: rgba(232,181,74,.08); }
.note { font-size: 13px; color: var(--text-dim); }
.notice { padding: 10px 14px; border: 1px solid rgba(232,181,74,.3); background: rgba(232,181,74,.06); color: var(--amber); border-radius: var(--radius-sm); font: 13.5px var(--sans); }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--panel-2); border: 1px solid var(--panel-line); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; font: 13.5px var(--sans); max-width: 400px; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--down); }

/* ── drawer ────────────────────────────────────────────── */
.drawer-host { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: fade .15s; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--panel-line); box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .18s ease-out; }
.drawer > header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--panel-line); }
.drawer-body { padding: 16px 18px 30px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
@keyframes slide { from { transform: translateX(24px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ── command palette ───────────────────────────────────── */
.palette-host { position: fixed; inset: 0; z-index: 70; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); animation: fade .12s; }
.palette { position: relative; margin: 12vh auto 0; width: min(620px, calc(100vw - 24px)); background: var(--panel); border: 1px solid var(--field-line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.palette-input { width: 100%; border: 0; border-bottom: 1px solid var(--panel-line); border-radius: 0; padding: 16px 18px; font-size: 16px; background: transparent; }
.palette-input:focus { box-shadow: none; }
.palette-list { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; }
.palette-item.active, .palette-item:hover { background: var(--accent-soft); }
.palette-icon { width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 6px; background: var(--panel-2); color: var(--accent); flex: none; font-family: var(--mono); }
.palette-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.palette-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-kind { font-size: 11.5px; color: var(--text-low); }
.palette-foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--panel-line); font-size: 12px; color: var(--text-low); }

/* ── charts ────────────────────────────────────────────── */
svg.chart { display: block; width: 100%; height: auto; font: 10.5px var(--mono); }
svg.chart .axis text { fill: var(--text-low); }
svg.chart .axis line, svg.chart .gridline { stroke: var(--row-line); }
svg.chart .zero { stroke: var(--field-line); }

/* ── login ─────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, rgba(201,241,88,.06), transparent 60%), var(--bg); }
.login form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 14px; padding: 30px 28px; box-shadow: var(--shadow); }
.login p { margin: -6px 0 6px; }
.login input { width: 100%; padding: 10px 12px; }
.login .err { color: var(--down); font-size: 13px; min-height: 18px; }
.login button.primary { padding: 10px 14px; }

/* ── tablet / phone ────────────────────────────────────── */
@media (max-width: 1100px) {
  .search-btn { width: 260px; }
  .credits-label { display: none; }
}
@media (max-width: 820px) {
  :root { --top: 52px; }
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top) minmax(0, 1fr) auto; }
  .topbar { min-width: 0; gap: 10px; padding: 0 12px; }
  .search-btn { min-width: 0; }
  .search-btn .search-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand { min-width: 0; }
  .search-btn { flex: 1; width: auto; }
  .search-btn kbd, .status .badge.amber { display: none; }
  .sidebar { position: fixed; top: var(--top); bottom: 0; left: 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform .18s; }
  .shell.collapsed .nav-title, .shell.collapsed .nav-label { display: initial; }
  .shell.collapsed .nav-link { justify-content: flex-start; padding: 7px 10px; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .shell.nav-open .nav-scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(0,0,0,.5); z-index: 35; }
  .nav-foot { display: none; }
  .main { grid-row: 2; }
  .dock { display: flex; grid-row: 3; border-top: 1px solid var(--panel-line); background: var(--bg-raise); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .dock-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 0; border: 0; background: transparent; color: var(--text-dim); font-size: 17px; border-radius: 8px; }
  .dock-link small { font-size: 11px; }
  .dock-link.active { color: var(--accent); }
  .view { padding: 16px 14px 40px; gap: 14px; }
  .view-head h1 { font-size: 19px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .cards, .stats { grid-template-columns: repeat(2, 1fr); }
  .card-value, .stat b { font-size: 18px; }
  .toolbar { padding: 12px; }
}
