/* ==========================================================================
   Bloki HQ — operations console
   Hand-authored, no build step. Served straight from priv/static.

   Colour system: the Bloki brand surface — warm cream #FBF3D6 with paper
   cards and near-black ink, 2px "sticker" outlines and solid pop shadows,
   Fredoka for display and Space Mono for data. Light-only by deliberate
   choice: it is the brand's identity and we only style what we validate.

   The categorical series ramp below is the documented data-viz palette —
   the same eight hues as the previous dark console, re-stepped for light
   ground and validated against the surfaces charts actually render on
   (paper #FFFDF5 cards; cream #FBF3D6 plane): lightness band, chroma
   floor, adjacent CVD separation (worst ΔE 9.1), normal-vision floor
   (19.6) all pass. Three series (aqua, yellow, magenta) sit below 3:1
   contrast on paper — the relief rule applies, so charts always render on
   paper cards and keep their legends, direct labels and table views. Do
   not hand-edit a series hex — re-run the validator instead.

   Bloki brand colours (yellow #F4CB3B, mint #92E2C7, ink #1A1A1A) drive
   *chrome* only — nav, buttons, the live pulse. They are never used to
   encode data, so they never compete with a series colour for meaning.

   Status colours are a fixed scale with reserved meaning. The raw marks
   (#0ca30c…) keep 3:1-ish on paper for fills and dots and always ship
   with icon + label; status *text* uses the darker -text steps, which
   clear 4.5:1 on every surface including cream-deep.
   ========================================================================== */

/* Brand faces, vendored from the iOS app bundle — no CDN, same as every
   other asset here. Fredoka carries display; Space Mono carries data. */

@font-face {
  font-family: "Fredoka";
  src: url("/assets/fonts/Fredoka-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Fredoka";
  src: url("/assets/fonts/Fredoka-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Fredoka";
  src: url("/assets/fonts/Fredoka-SemiBold.ttf") format("truetype");
  font-weight: 600 700;
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url("/assets/fonts/SpaceMono-Regular.ttf") format("truetype");
  font-weight: 400 500;
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url("/assets/fonts/SpaceMono-Bold.ttf") format("truetype");
  font-weight: 600 700;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Surfaces */
  --plane: #fbf3d6;
  --surface: #fffdf5;
  --surface-raised: #ffffff;
  --surface-sunken: #f6ecc4;
  --surface-hover: #f8f0ce;

  /* Ink */
  --ink: #1a1a1a;
  --ink-2: #45423b;
  --ink-3: #6b6760;
  --ink-4: #8f897b;

  /* Lines */
  --hairline: rgba(26, 26, 26, 0.12);
  --hairline-strong: rgba(26, 26, 26, 0.22);
  --grid: rgba(26, 26, 26, 0.08);
  --axis: rgba(26, 26, 26, 0.3);
  --outline: 2px solid var(--ink);

  /* Brand chrome (never encodes data) */
  --brand: #f4cb3b;
  --brand-ink: #1a1a1a;
  --brand-dim: rgba(244, 203, 59, 0.35);
  --brand-line: #d8a912;
  --pulse: #92e2c7;

  /* Sticker pop shadows (solid ink offsets, the brand's shadow language) */
  --pop-sm: 0 2px 0 var(--ink);
  --pop: 0 3px 0 var(--ink);
  --pop-lg: 0 6px 0 var(--ink);
  --shadow-soft: 0 2px 8px rgba(26, 26, 26, 0.06);
  --shadow-float: 0 8px 24px rgba(26, 26, 26, 0.1);

  /* Status — fixed scale, reserved meaning, always shipped with icon + label.
     Bare tokens are the marks (fills, dots); -text steps are for type. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-text: #006300;
  --warning-text: #7a5300;
  --serious-text: #9c3a0f;
  --critical-text: #c22f2f;

  /* Categorical series (validated, fixed order, never cycled) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* Sequential / ordinal blue ramp (light → dark). The light end starts at
     the ramp's step 250 so the first ordinal step still clears 2:1 on paper. */
  --seq-100: #cde2fb;
  --seq-200: #86b6ef;
  --seq-300: #5598e7;
  --seq-400: #3987e5;
  --seq-500: #256abf;
  --seq-600: #184f95;

  /* Type */
  --sans: "Fredoka", "Baloo 2", system-ui, -apple-system, sans-serif;
  --mono: "Space Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  /* Geometry */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  --sidebar-w: 236px;
  --topbar-h: 60px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--plane);
  color: var(--ink-2);
  font: 13px/1.6 var(--mono);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--brand-dim);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Micro-typography
   -------------------------------------------------------------------------- */

.eyebrow {
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.muted {
  color: var(--ink-3);
}

.nowrap {
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.hq-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.hq-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--surface);
  border-right: var(--outline);
}

.hq-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.hq-cube {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(150deg, #ffe07a, var(--brand) 55%, #e3b229);
  border: var(--outline);
  position: relative;
  flex: none;
}

.hq-cube::before,
.hq-cube::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--ink);
}

.hq-cube::before {
  left: 6px;
}

.hq-cube::after {
  right: 6px;
}

.hq-wordmark {
  font: 600 16px/1 var(--sans);
  letter-spacing: 0.01em;
  color: var(--ink);
}

.hq-wordmark span {
  color: var(--ink-3);
  font-weight: 500;
}

.hq-navgroup {
  margin: 14px 0 6px;
  padding: 0 8px;
}

.hq-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  color: var(--ink-2);
  font: 500 13.5px/1.3 var(--sans);
  border: 1.5px solid transparent;
  transition: background 120ms ease, color 120ms ease;
}

.hq-nav:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.hq-nav[aria-current="page"] {
  background: var(--brand);
  border-color: var(--ink);
  color: var(--ink);
}

.hq-nav .ico {
  color: var(--ink-3);
  flex: none;
}

.hq-nav[aria-current="page"] .ico {
  color: var(--ink);
}

.hq-nav-count {
  margin-left: auto;
  font: 600 11px/1 var(--mono);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.hq-sidebar-foot {
  margin-top: auto;
  padding: 12px 8px 0;
  border-top: 1px solid var(--hairline);
  display: grid;
  gap: 8px;
}

.hq-whoami {
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
}

.hq-whoami strong {
  display: block;
  color: var(--ink-2);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Topbar + page
   -------------------------------------------------------------------------- */

.hq-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.hq-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: rgba(251, 243, 214, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: var(--outline);
}

.hq-title {
  font: 600 17px/1.2 var(--sans);
  letter-spacing: 0;
  color: var(--ink);
  margin: 0;
}

.hq-subtitle {
  font-size: 12px;
  color: var(--ink-3);
}

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

.hq-page {
  padding: 22px 24px 56px;
  display: grid;
  gap: 18px;
  align-content: start;
}

/* --------------------------------------------------------------------------
   Live indicator
   -------------------------------------------------------------------------- */

.hq-live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--ink);
  background: var(--surface);
  font: 700 10px/1 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}

.hq-live:hover {
  background: var(--surface-hover);
}

.hq-live .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pulse);
  box-shadow: 0 0 0 1.5px var(--ink);
  flex: none;
}

.hq-live[data-live="true"] .dot {
  animation: hq-pulse 2s ease-in-out infinite;
}

.hq-live[data-live="false"] .dot {
  background: var(--ink-4);
}

@keyframes hq-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 1.5px rgba(146, 226, 199, 0.45);
  }
  50% {
    opacity: 0.65;
    box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 6px rgba(146, 226, 199, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hq-live[data-live="true"] .dot {
    animation: none;
  }
}

/* --------------------------------------------------------------------------
   Cards & grid
   -------------------------------------------------------------------------- */

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
}

.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }

.card {
  background: var(--surface);
  border: var(--outline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hairline);
}

.card-head h2,
.card-head h3 {
  margin: 0;
  font: 600 14px/1.3 var(--sans);
  color: var(--ink);
}

.card-head .hint {
  font-size: 12px;
  color: var(--ink-3);
}

.card-head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  padding: 16px;
  min-width: 0;
}

.card-body.flush {
  padding: 0;
}

.card-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */

.tile {
  background: var(--surface);
  border: var(--outline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px 12px;
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.tile.is-link:hover {
  background: var(--surface-raised);
  transform: translateY(-2px);
  box-shadow: var(--pop);
}

.tile-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.tile-value {
  font: 600 27px/1.05 var(--sans);
  letter-spacing: 0;
  color: var(--ink);
}

.tile-value .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-3);
  margin-left: 3px;
  letter-spacing: 0;
}

.tile-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 18px;
}

.tile-spark {
  margin-left: auto;
  flex: none;
}

.hero {
  font: 600 clamp(38px, 5vw, 52px) / 1 var(--sans);
  letter-spacing: -0.01em;
  color: var(--ink);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: 700 11px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.delta[data-dir="up"] { color: var(--good-text); }
.delta[data-dir="down"] { color: var(--critical-text); }
.delta[data-dir="up"][data-good="false"] { color: var(--critical-text); }
.delta[data-dir="down"][data-good="false"] { color: var(--good-text); }
.delta[data-dir="flat"] { color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Pills, badges, status
   -------------------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--hairline-strong);
  background: var(--surface-raised);
  font: 700 10px/1.5 var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}

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

.pill[data-tone="good"] { color: var(--good-text); border-color: rgba(0, 99, 0, 0.45); }
.pill[data-tone="warning"] { color: var(--warning-text); border-color: rgba(122, 83, 0, 0.45); }
.pill[data-tone="serious"] { color: var(--serious-text); border-color: rgba(156, 58, 15, 0.45); }
.pill[data-tone="critical"] { color: var(--critical-text); border-color: rgba(194, 47, 47, 0.5); }
.pill[data-tone="brand"] { color: var(--brand-ink); border-color: var(--ink); background: var(--brand); }
.pill[data-tone="neutral"] { color: var(--ink-3); }

.pill.plain {
  background: transparent;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--mono);
}

/* --------------------------------------------------------------------------
   Buttons & controls — the sticker language: paper face, 2px ink outline,
   solid pop shadow, and a press that physically travels the shadow's height.
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: var(--outline);
  background: var(--surface-raised);
  color: var(--ink);
  font: 500 13px/1.2 var(--sans);
  cursor: pointer;
  box-shadow: var(--pop-sm);
  transition: background 120ms ease, transform 80ms ease, box-shadow 80ms ease;
}

.btn:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 var(--ink);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--ink);
  color: var(--brand-ink);
  font-weight: 600;
}

.btn-primary:hover {
  background: #efc12e;
  border-color: var(--ink);
  color: var(--brand-ink);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--surface-hover);
}

.btn-ghost:active {
  transform: none;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon {
  padding: 7px;
  width: 32px;
  height: 32px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--ink);
  background: var(--surface-sunken);
}

.seg a,
.seg button {
  padding: 4px 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-3);
  font: 700 11px/1.4 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.seg a:hover,
.seg button:hover {
  color: var(--ink);
}

.seg [aria-pressed="true"],
.seg [aria-current="true"] {
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: 0 0 0 1.5px var(--ink);
}

.field {
  display: grid;
  gap: 6px;
}

.field > span {
  font: 700 10px/1.2 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--r);
  border: var(--outline);
  background: var(--surface-raised);
  color: var(--ink);
  font: 400 13px/1.4 var(--mono);
}

input::placeholder {
  color: var(--ink-4);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-dim);
}

select {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%),
    linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 51%, calc(100% - 10px) 51%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline);
}

.filters .grow {
  flex: 1 1 220px;
  min-width: 180px;
}

.filters select {
  width: auto;
  min-width: 130px;
  padding-block: 7px;
  font-size: 12px;
}

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

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

table.data th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 9px 14px;
  background: var(--surface-sunken);
  border-bottom: 1.5px solid var(--ink);
  font: 700 10px/1.4 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  white-space: nowrap;
}

table.data th a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
}

table.data th a:hover {
  color: var(--ink-2);
}

table.data th[aria-sort] a {
  color: var(--ink);
}

table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(26, 26, 26, 0.08);
  color: var(--ink-2);
  vertical-align: middle;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data tbody tr:hover td {
  background: rgba(26, 26, 26, 0.035);
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data a.rowlink {
  color: var(--ink);
  border-bottom: 1px solid var(--hairline-strong);
}

table.data a.rowlink:hover {
  color: var(--ink);
  border-bottom: 2px solid var(--brand-line);
}

.id-chip {
  font: 500 11px/1.5 var(--mono);
  color: var(--ink-3);
}

.kv {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: 8px 18px;
  font-size: 13px;
}

/* Lets a dt/dd pair be wrapped in one element (so it can be iterated) while
   still laying out as two columns of the parent grid. */
.kv .kv-pair {
  display: contents;
}

.kv dt {
  font: 700 10px/1.7 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.kv dd {
  margin: 0;
  color: var(--ink-2);
  min-width: 0;
  overflow-wrap: anywhere;
}

pre.json {
  margin: 0;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--surface-sunken);
  border: 1px solid var(--hairline);
  font: 12px/1.6 var(--mono);
  color: var(--ink-2);
  overflow-x: auto;
  max-height: 340px;
}

/* --------------------------------------------------------------------------
   Charts (server-rendered SVG)
   -------------------------------------------------------------------------- */

.chart {
  display: block;
  width: 100%;
  overflow: visible;
}

.chart .grid-line {
  stroke: var(--grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart .axis-line {
  stroke: var(--axis);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.chart .tick {
  fill: var(--ink-3);
  font: 400 10px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}

.chart .tick-x {
  text-anchor: middle;
}

.chart .tick-y {
  text-anchor: end;
}

.chart .label {
  fill: var(--ink-2);
  font: 600 11px/1 var(--sans);
}

.chart .series-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .series-area {
  opacity: 0.1;
}

.chart .end-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart .hit {
  fill: transparent;
  cursor: crosshair;
}

.chart .hit:hover + .hover-mark,
.chart .hit:focus + .hover-mark {
  opacity: 1;
}

.chart .hover-mark {
  opacity: 0;
  pointer-events: none;
}

.chart .crosshair {
  stroke: var(--hairline-strong);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.sparkline {
  display: block;
}

.sparkline .spark-line {
  fill: none;
  stroke: var(--ink-4);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.sparkline .spark-head {
  fill: var(--ink);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  padding: 2px 0 0;
  margin: 0;
  list-style: none;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}

.legend .swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.legend .val {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 11px;
}

/* Funnel — ordinal ramp, one hue, monotone lightness */

.funnel {
  display: grid;
  gap: 3px;
}

.funnel-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  position: relative;
  overflow: hidden;
  background: var(--surface-sunken);
}

.funnel-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--r-sm);
}

/* Only the two real grid children are promoted — targeting every child would
   also catch the absolutely-positioned fill and drop it back into the grid. */
.funnel-step > .funnel-name,
.funnel-step > .funnel-meta {
  position: relative;
}

.funnel-name {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}

.funnel-meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}

.funnel-count {
  font: 600 15px/1 var(--sans);
  color: var(--ink);
}

.funnel-pct {
  font: 500 11px/1 var(--mono);
  color: var(--ink-3);
  min-width: 42px;
  text-align: right;
}

/* Meter — fill carries the value in the dark ramp step; the track is the
   ramp's lightest step so the pair reads as one component on paper. */

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--seq-100);
  overflow: hidden;
}

.meter > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--seq-500);
}

.meter[data-tone="warning"] > i { background: var(--warning); }
.meter[data-tone="critical"] > i { background: var(--critical); }
.meter[data-tone="good"] > i { background: var(--good); }

/* --------------------------------------------------------------------------
   Empty / error / flash
   -------------------------------------------------------------------------- */

.empty {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
  padding: 34px 16px;
  color: var(--ink-3);
}

.empty strong {
  color: var(--ink-2);
  font-weight: 500;
}

.empty .ico {
  color: var(--ink-4);
}

/* Below the topbar, so a toast can never sit on top of the range picker or
   the live toggle — the two controls someone reaches for while reading one. */
.flash-group {
  position: fixed;
  top: calc(var(--topbar-h) + 10px);
  right: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 36px));
}

.flash {
  padding: 11px 14px;
  border-radius: var(--r);
  border: var(--outline);
  background: var(--surface-raised);
  color: var(--ink-2);
  font-size: 13px;
  box-shadow: var(--pop);
  cursor: pointer;
}

.flash[data-kind="error"] {
  border-color: var(--critical-text);
  color: var(--critical-text);
}

.flash[data-kind="info"] {
  border-color: var(--ink);
}

/* --------------------------------------------------------------------------
   Sign-in
   -------------------------------------------------------------------------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(900px 480px at 16% -6%, rgba(146, 226, 199, 0.35), transparent 60%),
    radial-gradient(900px 480px at 88% 4%, rgba(224, 205, 239, 0.4), transparent 55%),
    var(--plane);
}

.auth-panel {
  width: min(100%, 384px);
  background: var(--surface);
  border: var(--outline);
  border-radius: 24px;
  padding: 28px 26px 24px;
  box-shadow: var(--pop-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 20px;
}

.auth-panel h1 {
  margin: 0 0 4px;
  font: 600 20px/1.25 var(--sans);
  letter-spacing: 0;
  color: var(--ink);
}

.auth-panel p.lede {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--ink-3);
}

.auth-panel form {
  display: grid;
  gap: 14px;
}

.auth-panel .btn {
  width: 100%;
  padding: 11px 14px;
}

.auth-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 14px;
  font: 700 10px/1 var(--mono);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.auth-sep::before,
.auth-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.auth-note {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--ink-4);
  text-align: center;
}

.auth-note a {
  color: var(--ink-3);
  border-bottom: 1px solid var(--hairline);
}

.auth-error {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1.5px solid rgba(194, 47, 47, 0.5);
  background: rgba(208, 59, 59, 0.08);
  color: var(--critical-text);
  font-size: 13px;
}

.auth-ok {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1.5px solid rgba(0, 99, 0, 0.45);
  background: rgba(12, 163, 12, 0.08);
  color: var(--good-text);
  font-size: 13px;
}

.code-input {
  font: 700 22px/1.2 var(--mono) !important;
  letter-spacing: 0.35em;
  text-align: center;
  text-indent: 0.35em;
}

.dev-code {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1.5px dashed var(--ink);
  background: var(--brand-dim);
  font: 700 12px/1.4 var(--mono);
  color: var(--ink);
  text-align: center;
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

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

.row.tight {
  gap: 6px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--ink-3);
}

.pager .spacer {
  margin-left: auto;
}

.bar-list {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 140px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.bar-row .name {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row .track {
  height: 10px;
  border-radius: 3px;
  background: rgba(26, 26, 26, 0.07);
  overflow: hidden;
}

.bar-row .track > i {
  display: block;
  height: 100%;
  border-radius: 0 4px 4px 0;
}

.bar-row .val {
  font: 500 12px/1 var(--mono);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

.feed {
  display: grid;
  max-height: 420px;
  overflow-y: auto;
}

.feed-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 16px;
  border-bottom: 1px solid rgba(26, 26, 26, 0.08);
  font-size: 13px;
}

.feed-item:last-child {
  border-bottom: 0;
}

.feed-item .when {
  font: 500 11px/1.5 var(--mono);
  color: var(--ink-4);
  white-space: nowrap;
}

.feed-item .what {
  color: var(--ink-2);
  min-width: 0;
  overflow-wrap: anywhere;
}

.feed-item .what b {
  color: var(--ink);
  font-weight: 500;
}

@media (max-width: 1080px) {
  .span-3 { grid-column: span 6; }
  .span-4 { grid-column: span 6; }
  .span-5 { grid-column: span 12; }
  .span-7 { grid-column: span 12; }
  .span-8 { grid-column: span 12; }
  .span-9 { grid-column: span 12; }
}

@media (max-width: 820px) {
  .hq-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .hq-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: 0;
    border-bottom: var(--outline);
    padding: 12px;
  }

  .hq-brand {
    padding: 0 8px 0 4px;
  }

  .hq-navgroup {
    display: none;
  }

  .hq-sidebar-foot {
    margin-left: auto;
    margin-top: 0;
    border-top: 0;
    padding: 0;
  }

  .hq-page {
    padding: 16px 14px 44px;
  }

  .span-2,
  .span-3,
  .span-4,
  .span-6 {
    grid-column: span 12;
  }
}
