/* OmniScan Cloud: Data Terminal Theme (dark, 1px accent selection line, icon rail) */
:root {
  --ground: #171719;
  --surface: #131217;
  --raised: #212023;
  --active: #212023;
  --border: #222224;
  --rule: #1b1a1f;
  --control: #3a3a3e;
  --text: #ffffff;
  --muted: #8a8c92;
  --faint: #8a8c92;
  --accent: #4a8ad6;
  --primary: #ffffff;
  --primary-ink: #131217;
  --positive: #44a282;
  --negative: #e5566f;
  --warning: #d9a441;
  --pill-positive-bg: #1b2828;
  --pill-positive-ink: #5fc39c;
  --pill-negative-bg: #2c1a20;
  --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2a2416;
  --pill-warning-ink: #d9a441;
  --pill-neutral-bg: #212023;
  --pill-neutral-ink: #bdbdc0;

  --chart-1: #f2f2f3;
  --chart-2: #e5566f;
  --chart-3: #4a8ad6;
  --chart-muted: #5a5c63;
  --chart-mark: #ffffff;
  --chart-span: 0.12;
  --chart-track: #1b1a1f;
  --grid: #222224;
  --axis-ink: #8a8c92;
  --ink: #ffffff;

  --shadow: 0 12px 28px rgba(0, 0, 0, .2);
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-title: 26px;
  --fs-section: 20px;
  --fs-card: 16px;
  --fs-kpi: 20px;
  --fs-body: 13px;
  --fs-small: 12px;

  --sidebar-width: 50px;
  --pad: 32px;
  --gap: 24px;
  --card-pad: 20px;
  --radius-card: 6px;
  --radius-control: 999px;
  --control-height: 34px;
  --row-height: 42px;
  --nav-row: 40px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --t-press: 120ms;
  --t-hover: 150ms;
  --t-ui: 200ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--text);
  font: var(--fs-body)/20px var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.num, table, .kpi-value { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- Shell: 50px Icon Rail ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100svh;
  background: var(--ground);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  gap: 6px;
  z-index: 20;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--text);
  margin-bottom: 4px;
}

.rail-sep {
  width: 20px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
  flex: none;
}

.nav-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.nav-item {
  position: relative;
  width: 100%;
  height: var(--nav-row);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: color var(--t-hover) ease, background-color var(--t-hover) ease;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex: none;
  stroke-width: 1.5;
}

.nav-item .nav-label {
  display: none;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.nav-item[aria-current="page"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
}

.nav-item[aria-current="page"]::after {
  content: "";
  position: absolute;
  right: 0;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--accent);
}

.rail-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.rail-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--t-hover) ease, background-color var(--t-hover) ease;
}
.rail-btn:hover { color: var(--text); background: var(--raised); }
.rail-btn svg { width: 17px; height: 17px; stroke-width: 1.5; }

/* ---------- Main Canvas & Header ---------- */
.canvas {
  min-width: 0;
  padding: var(--pad);
  max-width: 1440px;
}

.view-panel { display: grid; gap: var(--gap); }

.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.title-block h1 {
  font-size: var(--fs-title);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.title-block .sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-body);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-heading {
  font-size: var(--fs-section);
  line-height: 1.3;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Divided KPI Strip ---------- */
.kpis {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.kpi { padding: 14px var(--card-pad); min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--border); }
.kpi-label { font-size: var(--fs-small); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { margin-top: 6px; font-size: var(--fs-kpi); line-height: 1.15; font-weight: 500; letter-spacing: -0.01em; }
.kpi-sub { margin-top: 4px; font-size: var(--fs-small); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Panels & Grids ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
}
.grid.top { align-items: start; }

.span-12 { grid-column: span 12; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h2,
.panel-head h3 {
  font-size: var(--fs-card);
  line-height: 1.3;
  font-weight: 600;
  color: var(--text);
}

.panel .meta {
  color: var(--muted);
  font-size: var(--fs-small);
}

/* ---------- Controls & Data-Terminal 1px Selection Line ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--control);
  background: transparent;
  color: var(--text);
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--t-hover) ease, border-color var(--t-hover) ease, transform var(--t-press) var(--ease-out);
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: #e8e8ea; }
.btn.sm { height: 28px; padding: 0 10px; font-size: var(--fs-small); }
.btn.danger { color: var(--negative); border-color: #442730; }
.btn.danger:hover:not(:disabled) { background: #2c1a20; }

.control-deck {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
}

.ctrl-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ctrl-label {
  font-size: var(--fs-small);
  color: var(--muted);
  white-space: nowrap;
}

/* Underline switch (1px --accent selection line, never filled) */
.line-switch {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.line-switch button {
  position: relative;
  height: 30px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-hover) ease;
}

.line-switch button:hover { color: var(--text); }
.line-switch button[aria-pressed="true"] { color: var(--text); }
.line-switch button[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
}

.stepper {
  display: inline-flex;
  align-items: center;
  height: var(--control-height);
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  overflow: hidden;
}
.stepper button {
  width: 28px;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.stepper button:hover { background: var(--raised); color: var(--text); }
.stepper .step-val {
  padding: 0 8px;
  font-size: var(--fs-small);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.input, select.input {
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-body);
  min-width: 0;
}
.input::placeholder { color: var(--muted); }
select.input { padding-right: 26px; }

.adv-details {
  width: 100%;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

/* ---------- Status Pills (semantic only) ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: var(--fs-small);
  font-weight: 500;
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
  white-space: nowrap;
}
.pill.pos { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill.neg { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill.warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }

.notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-small);
  color: var(--muted);
}
.notice-bar strong { color: var(--text); font-weight: 500; }

/* ---------- Canvases & Spectrum Visualization ---------- */
.viz-box {
  position: relative;
  width: 100%;
  border-radius: 4px;
  background: #0e0e12;
  border: 1px solid var(--rule);
  overflow: hidden;
}
.viz-box.spectrum { height: 290px; }
.viz-box.waterfall { height: 185px; }
.viz-box.logic { height: 148px; }
.viz-box.inspector-wave { height: 150px; }

.viz-box canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.canvas-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: var(--fs-small);
  color: var(--text);
  box-shadow: var(--shadow); /* taste-skill-ignore: floating chart tooltip */
  z-index: 10;
  white-space: nowrap;
}

/* ---------- Compact Ranked Rows ---------- */
.rows { display: grid; }
.row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  padding: 5px 0;
  font-size: var(--fs-small);
}
.row-item + .row-item { border-top: 1px solid var(--rule); }
.row-item .row-k { color: var(--text); font-weight: 500; }
.row-item .row-v { color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Filter Tabs ---------- */
.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tabs button {
  position: relative;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-hover) ease;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); }
.tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--accent);
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th {
  height: 36px;
  padding: 0 10px;
  text-align: left;
  font-weight: 400;
  font-size: var(--fs-small);
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  font-size: var(--fs-body);
  white-space: nowrap;
}
tbody tr { cursor: pointer; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[aria-selected="true"] td { background: var(--raised); }
tbody tr[aria-selected="true"] td:first-child { border-left: 1px solid var(--accent); }
th.n, td.n { text-align: right; }
.truncate { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Inspector Details & Key-Value Wells ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}
.kv-item { min-width: 0; }
.kv-item .kv-k { font-size: var(--fs-small); color: var(--muted); }
.kv-item .kv-v { margin-top: 2px; font-weight: 500; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code-well {
  background: #0e0e12;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  word-break: break-all;
  max-height: 92px;
  overflow-y: auto;
}

.switch {
  appearance: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--control);
  position: relative;
  cursor: pointer;
  flex: none;
  transition: background-color var(--t-ui) ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  transition: transform var(--t-ui) var(--ease-out);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }

.empty {
  display: grid;
  place-items: center;
  min-height: 110px;
  padding: 18px;
  border: 1px dashed var(--control);
  border-radius: var(--radius-card);
  color: var(--muted);
  text-align: center;
  font-size: var(--fs-body);
}
#recent-hits-wrap { flex: 1; display: flex; flex-direction: column; }
#recent-hits-wrap .empty { flex: 1; min-height: 140px; width: 100%; }

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--raised);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 150ms ease;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text);
}
.card-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.log-box {
  background: #0e0e12;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px;
  height: 160px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--muted);
}
.log-box .log-ok { color: var(--pill-positive-ink); }
.log-box .log-warn { color: var(--pill-warning-ink); }
.log-box .log-ctrl { color: var(--accent); }

/* ---------- Bar List from charts.js ---------- */
.bar-list { display: grid; gap: 10px; }
.bar-row { display: grid; gap: 4px; }
.bar-row-head { display: flex; justify-content: space-between; font-size: var(--fs-small); }
.bar-row-track { height: 6px; background: var(--raised); border-radius: 2px; overflow: hidden; }
.bar-row-fill { height: 100%; background: var(--chart-1); }

/* ---------- Responsive: Tablet & Phone Bottom Rail ---------- */
@media (max-width: 1080px) {
  .canvas { padding: 20px; }
  .span-7, .span-6, .span-5 { grid-column: span 12; }
}

@media (max-width: 860px) {
  :root { --gap: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .canvas { padding: 16px 16px 84px; }

  .sidebar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    border-right: 0;
    border-top: 1px solid var(--border);
    flex-direction: row;
    padding: 0 8px;
    justify-content: space-around;
  }
  .brand-mark, .rail-sep, .rail-bottom { display: none; }
  .nav-list {
    flex-direction: row;
    justify-content: space-around;
    height: 100%;
    gap: 0;
  }
  .nav-item {
    flex-direction: column;
    gap: 3px;
    height: 100%;
    flex: 1;
  }
  .nav-item .nav-label {
    display: block;
    font-size: 11px;
    line-height: 1.1;
  }
  .nav-item[aria-current="page"]::after {
    top: 0;
    bottom: auto;
    left: 20%;
    right: 20%;
    width: auto;
    height: 1px;
  }

  .kpis {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi + .kpi { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-left: 1px solid var(--border); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}
