/* Stats v2 — component kit atoms shared across views.
   Anything used by 2+ views lives here; view-specific styling stays in the view module.
   Card size follows content weight — there is deliberately NO uniform grid class. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---- type atoms ---- */

.microlabel {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
}

.num, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.verdict {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-verdict);
  line-height: 1.05;
}

/* ---- surfaces ---- */

.card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 12px;
  padding: 14px 18px;
}

.card--absent {           /* honest absence: dashed, plain words, never faked */
  border-style: dashed;
  border-color: var(--hairline-strong);
}

.card--stage {            /* the fun-slot stage awaiting a tenant */
  background: rgba(244, 113, 181, .05);
  border: 1.5px dashed rgba(244, 113, 181, .4);
}

.hairline-top { border-top: 1px solid var(--hairline); }

/* ---- meter (quota/runway) ---- */

.meter-track {
  position: relative;
  height: 5px;
  background: var(--track);
  border-radius: 2px;
}

.meter-fill { height: 100%; border-radius: 2px; }
.meter-fill--claude { background: var(--claude); }
.meter-fill--codex { background: var(--codex); }

.pace-tick {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 9px;
  background: var(--ink);
  opacity: .8;
}

.pace-tick--hot { background: var(--warn); opacity: 1; }

/* ---- dial (quota window as a clock face) ---- */

/* Face on the left, text beside it — the stacked form cost a lot of header
   height for a label narrower than the ring it sat under. */
.dial {
  display: flex;
  align-items: center;
  gap: calc(6px * var(--fs-scale));
  flex-shrink: 0;
}

.dial-face {
  position: relative;
  width: calc(26px * var(--fs-scale));
  flex-shrink: 0;
}

.dial--lg .dial-face { width: calc(58px * var(--fs-scale)); }

.dial-meta { min-width: 0; line-height: 1.3; }

.dial-svg { display: block; width: 100%; height: auto; overflow: visible; }

.dial-track { fill: none; stroke: var(--track); stroke-width: 9; }
.dial-track--absent { stroke: var(--hairline-strong); stroke-dasharray: 4 6; }

.dial-arc {
  fill: none;
  stroke-width: 9;
  stroke-linecap: butt;
  transition: stroke-dasharray .5s ease;
}

/* The tick is where an even burn would sit right now — the second clock. */
.dial-tick { stroke: var(--ink); stroke-width: 3; opacity: .85; }
.dial-tick--hot { stroke: var(--warn); stroke-width: 4; opacity: 1; }

.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dial-pct { font-size: var(--fs-sm); color: var(--ink); font-weight: 700; }
.dial--lg .dial-pct { font-size: var(--fs-2xl); }
.dial-pct--hot { color: var(--warn); }
.dial-absent { font-size: var(--fs-sm); color: var(--ink-4); }
.dial--lg .dial-absent { font-size: var(--fs-xl); }

.dial-label { font-size: var(--fs-micro); white-space: nowrap; }
.dial--lg .dial-label { font-size: var(--fs-tiny); }
.dial-reset { font-size: var(--fs-micro); color: var(--ink-4); white-space: nowrap; }
.dial-pace { font-size: var(--fs-micro); color: var(--ink-4); white-space: nowrap; }
.dial-pace--hot { color: var(--warn); }

/* Producer heartbeat: green while the uploader is reporting, red once it has
   gone quiet past 30 min. Separate from the figure's own validity. */
.dial-dot {
  display: inline-block;
  width: calc(5px * var(--fs-scale));
  height: calc(5px * var(--fs-scale));
  border-radius: 99px;
  margin-right: calc(4px * var(--fs-scale));
  vertical-align: baseline;
}
.dial-dot--fresh { background: var(--good); }
.dial-dot--cold { background: var(--crit); }

/* ---- session spans (timeline bars) ---- */

.span-bar { position: absolute; border-radius: 3px; }
.span-bar--claude { background: var(--claude); }
.span-bar--codex { background: var(--codex); }
.span-bar--live {
  background: var(--accent);
  animation: pulse 2s infinite;
}
.span-bar--live-tail {
  background: linear-gradient(90deg, rgba(244, 113, 181, .5), var(--accent));
  animation: pulse 2.5s infinite;
}
.span-bar--selected { outline: 1.5px solid var(--ink); outline-offset: 1.5px; }

.lineage-stem { position: absolute; width: 1px; background: var(--codex-stem); }

/* ---- handoff block ---- */

.handoff {
  border-left: 2px solid var(--handoff);
  background: var(--handoff-bg);
  border-radius: 0 8px 8px 0;
  padding: 7px 12px;
}

.handoff-tag {
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--handoff);
}

.handoff-body {
  font-size: var(--fs-md);
  color: var(--ink-handoff-body);
  line-height: 1.55;
  margin-top: 4px;
}

.handoff-next {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  margin-top: 4px;
  font-style: italic;
}

.handoff-teaser {          /* collapsed one-liner: ▸ handoff · project · feeling */
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--handoff);
  cursor: pointer;
}

/* ---- bar rows (label / track / value) ---- */

.barrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.barrow-track { flex: 1; height: 6px; background: var(--track-faint); border-radius: 2px; }
.barrow-fill { height: 100%; border-radius: 2px; }
.barrow-value {
  text-align: right;
  color: var(--ink);
  /* A squeezed flex item breaks its text: "282 pv" wrapped onto a second line
     beside the visitor count whenever the row ran out of room. A value cell
     is one token — it shortens the bar, it does not fold. */
  white-space: nowrap;
}

/* ---- chips ---- */

.chip {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 99px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-2);
}
.chip b { color: var(--ink-4); font-weight: 400; }

/* ---- live markers ---- */

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 99px;
  animation: pulse 2s infinite;
}
.live-dot--session { background: var(--accent); }
.live-dot--reader { background: var(--series-4); }

.now-line { position: absolute; border-left: 1.5px solid var(--accent-dim); }
.now-label {
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--accent);
  font-weight: 700;
}

/* ---- buttons / actions ---- */

.btn {
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink-3);
  background: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn:hover { color: var(--ink); border-color: rgba(255, 255, 255, .3); }

/* ---- data tables (dense mono rows) ---- */

.trow {
  display: flex;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.thead {
  display: flex;
  border-bottom: 1px solid var(--hairline-strong);
  padding-bottom: 5px;
}

/* ---- period pills (windowed views) ---- */

.pills { display: inline-flex; gap: 4px; }

.pill {
  background: none;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 99px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  letter-spacing: .06em;
  color: var(--ink-3);
  cursor: pointer;
}
.pill:hover { color: var(--ink); }
.pill--active { color: var(--accent); border-color: rgba(244, 113, 181, .5); }

/* ---- view chrome: header + the three states (js/kit/ui.js) ---- */

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;      /* baseline, everywhere — six views disagreed */
  flex-wrap: wrap;
  gap: 8px;
}

.view-header-label { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.view-header-note { font-size: var(--fs-tiny); color: var(--ink-4); }
.view-header-right { display: flex; align-items: center; gap: 10px; }

.state-loading {
  color: var(--ink-4);
  font-size: var(--fs-sm);
  padding: 40px;
  text-align: center;
}
.state-loading--inline { padding: 12px 0; text-align: left; }

.state-fail {
  max-width: 480px;
  margin: 48px auto;
  text-align: center;
  font-size: var(--fs-base);
  color: var(--ink-2);
}

.state-absent {
  font-size: var(--fs-md);
  color: var(--ink-4);
  padding: 14px 18px;
  margin-top: 8px;
}
.state-absent-why { color: var(--ink-4); opacity: .8; }

/* ---- select (Live's site filter — was fully inline) ---- */

.select {
  background: var(--raised);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 8px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-tiny);
  color: var(--ink-2);
  cursor: pointer;
}

/* ---- lane tone boxes (Services/Home — were rgba literals built in JS) ---- */

.lane { border-radius: 12px; padding: 12px 16px; font-size: var(--fs-sm); line-height: 1.7; }
.lane--good { background: rgba(12, 163, 12, .05); border: 1px solid rgba(12, 163, 12, .2); }
.lane--warn { background: rgba(250, 178, 25, .06); border: 1px solid rgba(250, 178, 25, .35); }
.lane--crit { background: rgba(208, 59, 59, .06); border: 1px solid rgba(208, 59, 59, .35); }

/* ---- table columns ----
   A .trow and its .thead share ONE grid so head and body can never drift.
   Views set --cols; cells fall in order. Replaces five head/body width
   pairs that each declared their widths twice. */

.tgrid { display: grid; grid-template-columns: var(--cols); gap: 0 10px; align-items: baseline; }
.tgrid > .r { text-align: right; }
.tgrid > .n { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- phone: tables reflow, they do not slide ----
   Every --cols definition is fixed px riding --fs-scale, sized for desktop.
   Measured on a 390px iPhone at scale 1.5 (358px of content): Services needs
   557px, Live needs 913px, and MCP's 1fr TOOL column is starved to 62px for a
   179px name. `.main { overflow-x: auto }` caught that honestly — but on a
   phone "honest" meant P95, P99 and PROJECTS were simply never seen.

   So below 900px a .trow stops being a grid and becomes a block: the identity
   cell takes its own line, and every other cell wraps as a chip carrying its
   own column label via data-l. The .thead is then redundant and hides — which
   is also what killed the SERVICECALLS / AGENTMODELS / TOP SPANS collisions,
   where a header label was overflow:visible and painted over its neighbour
   instead of clipping. Desktop is untouched.

   A cell with NO data-l (and not first) is a continuation of the identity —
   it flows inline unlabelled. */
@media (max-width: 900px) {
  .tgrid.thead { display: none; }

  .trow.tgrid {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 14px;
    grid-template-columns: none;   /* --cols must not survive the reflow */
    padding: 7px 0;
  }

  /* The name reads as a heading for the numbers under it. */
  .trow.tgrid > :first-child {
    flex: 0 0 100%;
    min-width: 0;
    text-align: left;
  }

  /* Right-alignment is a column affordance; there are no columns here. */
  .trow.tgrid > .r,
  .trow.tgrid > .n { text-align: left; }

  .trow.tgrid > [data-l]::before {
    content: attr(data-l);
    margin-right: 5px;
    color: var(--ink-4);
    font-size: var(--fs-micro);
    letter-spacing: .1em;
  }

  /* A measured zero still has to read as measured, not as absent. */
  .trow.tgrid > [data-l] { white-space: nowrap; }
}

/* ---- collapsed explainer (kit/ui.js InfoBox) ----
   Methodology notes are reference, not headline. Collapsed by default on
   every width — on a phone the longest of them was nine lines standing
   between the plot and the table it explains. */
.infobox { margin-top: 6px; }

.infobox-summary {
  cursor: pointer;
  list-style: none;                 /* Firefox */
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: var(--fs-micro);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-4);
}
/* Safari/Chrome draw their own triangle; we supply one that matches the
   dashboard's own caret vocabulary instead. */
.infobox-summary::-webkit-details-marker { display: none; }
.infobox-summary::before { content: '▸'; font-size: var(--fs-micro); }
.infobox[open] > .infobox-summary::before { content: '▾'; }
.infobox-summary:hover { color: var(--ink-3); }

.infobox-body {
  margin-top: 4px;
  font-size: var(--fs-micro);
  line-height: 1.65;
  color: var(--ink-4);
  max-width: 78ch;                  /* prose measure, not the container's */
}
