/* ============================================================================
   House components. Depends on tokens.css.

   Every class here exists because a build needed it and reinvented it badly.
   The app shell is the important one: it is what keeps a screen from
   collapsing back into a grid of cards.

   The layout here is read off opes (`src/components/workspace/Sidebar.tsx`,
   `PipelineTable.tsx`, `CandidateRow.tsx` at origin/main), not off a list of
   rules. Rules say what to avoid; a reference says what to make. Four things
   came across, and each one is a shape the previous build did not have:

     1. the rail groups destinations under real labels and PINS AN ACCOUNT
        BLOCK to the bottom, theme toggle inline beside it
     2. tabs carry COUNTS, so the shape of the work is visible before a click
     3. rows are TWO-LINE — identity on top, its context beneath in one muted
        line — instead of a wide table of single-value columns
     4. exactly one column encodes with COLOUR, and the colour lands on the
        NUMBER rather than on a chip behind it
   ============================================================================ */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--t-md) / var(--leading) var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* ── shell ─────────────────────────────────────────────────────────────────
   Rail on the left, topbar across the content, content fills the rest.
   No page-level scroll: the content pane scrolls, the chrome stays put. */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  height: 100vh;
  overflow: hidden;
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
}

.rail {
  border-right: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── the lockup ────────────────────────────────────────────────────────────
   IT FOLLOWS THE THEME. It used to be a fixed navy panel in both themes, and
   the reason was mechanical rather than editorial: the wordmark shipped as an
   <img> whose paths were `fill="white"`, so CSS could not recolour it and the
   ground had to stay dark or the mark disappeared. The artwork is inline now
   and takes `currentColor`, so the block is chrome like every other surface —
   it sits on the rail's own background and the mark inherits the text colour.

   What stays fixed is the cyan rule: it is the accent stroke from the mark, the
   house "OMMAX / HOSTING" slash drawn rather than typed, and a "/" in the body
   face beside real artwork is the join showing. */
.lockup {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-4);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  flex: none;
}
.lockup-mark {
  width: 74px;
  height: auto;
  display: block;
  /* The wordmark reads as ink, not as a link or an accent: near-black on
     light, near-white on dark, which is what `--fg` already means. */
  color: var(--fg);
}
.lockup-rule {
  width: 1px;
  height: 18px;
  background: var(--brand-accent);
  transform: skewX(-18deg);
}
.lockup-product {
  color: var(--fg);
  font-size: var(--t-sm);
  font-weight: 500;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
}

.rail-scroll { overflow-y: auto; min-height: 0; flex: 1; padding-bottom: var(--s-2); }
.rail-group { padding: var(--s-4) var(--s-2) var(--s-1); }
.rail-group-label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-2) var(--s-2);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--fg-3);
}
.rail-count { color: var(--fg-4); font-variant-numeric: tabular-nums; }
.rail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  padding: 6px var(--s-2);
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: var(--t-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.rail-item .slug { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item:hover { background: var(--bg-3); color: var(--fg); }
.rail-item[aria-current='true'] {
  /* Fill, ink and weight — and no left accent bar. Accent belongs in data
     encoding and the focus ring; a stripe in the rail puts a hue in the
     chrome of every screen. The active mark here is the same `--bg-3` an
     active row uses everywhere else, so selection is one idea. */
  background: var(--bg-3);
  color: var(--fg);
  font-weight: 600;
}
/* A count, so the rail says how much is behind a destination before it opens. */
.rail-badge {
  font-size: var(--t-xs);
  color: var(--fg-4);
  font-variant-numeric: tabular-nums;
}
.rail-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--idle); flex: none; }
.rail-dot[data-state='ok']   { background: var(--ok); }
.rail-dot[data-state='bad']  { background: var(--bad); }

/* ── account block, pinned to the bottom of the rail ─────────────────────── */
.account {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}
.account-who { min-width: 0; flex: 1; }
.account-name {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-roles {
  font-size: var(--t-xs);
  color: var(--fg-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--h-sm); height: var(--h-sm);
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--fg-3);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }
/* One icon, two states, no JS swap: the theme that is ON hides its own glyph. */
:root[data-theme='dark'] .i-moon,
:root:not([data-theme='dark']) .i-sun { display: none; }

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* ── topbar: a title, live state beneath it, one primary action ──────────── */
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title { min-width: 0; }
.topbar-title h1 {
  margin: 0;
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: var(--track-display);
  line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* The live state. `synced 2m ago` in opes; here it is what the control plane
   said and when it said it, because a console whose header cannot answer "is
   this current" makes every number on screen a guess. */
.topbar-title p {
  margin: 1px 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--t-xs);
  color: var(--fg-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-title p b { color: var(--fg-2); font-weight: 600; }
.topbar-title p .hot { color: var(--bad); font-weight: 600; }
.pulse {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok); flex: none;
}
.pulse[data-state='stale'] { background: var(--warn); }
.pulse[data-state='bad']   { background: var(--bad); }
.topbar-spacer { margin-left: auto; }

.content { overflow: auto; padding: var(--s-5) var(--s-5) var(--s-7); min-height: 0; }
.content > * + * { margin-top: var(--s-6); }

/* ── section: a hairline and a label, NOT a bordered box ──────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-4);
}
.section-head h2 {
  margin: 0;
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  white-space: nowrap;
}
.section-head p { margin: 0; color: var(--fg-3); font-size: var(--t-sm); }
.section-head .spacer { margin-left: auto; }

/* ── tabs, with counts ────────────────────────────────────────────────────
   The count is the point: it says how much is behind a tab before anybody
   clicks it, so "Runs 20 · Variables 1" is already an answer. */
.tabs { display: flex; gap: var(--s-4); border-bottom: 1px solid var(--border); }
.tabs button {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  border: 0; background: 0; font: inherit; font-size: var(--t-sm);
  color: var(--fg-3); padding: var(--s-2) 0; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--fg); }
.tabs button[aria-current='true'] { color: var(--fg); font-weight: 600; border-bottom-color: var(--fg); }
.tabs .n {
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
  color: var(--fg-4);
  background: var(--bg-3);
  border-radius: var(--r-sm);
  padding: 1px 5px;
}
.tabs button[aria-current='true'] .n { color: var(--fg-2); }
.tabs .n[data-tone='bad'] { color: var(--bad); background: var(--bad-soft); }

/* ── console table ───────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.tbl th {
  position: sticky;
  top: 0;
  background: var(--bg);
  text-align: left;
  font-size: var(--t-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--fg-3);
  padding: var(--s-2);
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.tbl td { padding: var(--s-2); border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--bg-2); }
.tbl tbody tr.open-row { cursor: pointer; }
.tbl .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* A proportional 1 is narrower than a 4, so a figure that updates re-flows the
   row by a pixel or two every time it changes. */
.tbl td, .mono, .facts .v { font-variant-numeric: tabular-nums; }
/* Horizontal only. A vertical cap here puts a second scroller inside a pane
   that already scrolls, and the row at the boundary is cut through the middle
   of its own text — which reads as a rendering fault rather than as "there is
   more below". The sticky header still sticks, against the content pane. */
.tbl-wrap { overflow-x: auto; }

/* ── the two-line row ─────────────────────────────────────────────────────
   Identity on top, its context beneath in ONE muted line. This is the shape
   opes uses for a candidate and it is why its table reads as a list of things
   rather than a spreadsheet: the second line absorbs every field that would
   otherwise have become a column nobody can scan. */
.cell-lead { font-weight: 600; color: var(--fg); }
.cell-sub {
  margin-top: 1px;
  font-size: var(--t-xs);
  color: var(--fg-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 46ch;
}
.tbl td.shrink, .tbl th.shrink { width: 1%; white-space: nowrap; }

/* ── the ONE colour column ────────────────────────────────────────────────
   Colour lands on the NUMBER, never on a chip behind it. A zero is muted so
   the eye only stops where something is wrong; opes does exactly this with a
   fit score, and it is the reason its table has one focal point per row. */
.figure {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-lg);
  font-weight: 600;
  color: var(--fg-3);
}
.figure[data-tone='bad']  { color: var(--bad); }
.figure[data-tone='warn'] { color: var(--warn); }
.figure[data-tone='ok']   { color: var(--fg); }

/* ── status word: ink and weight, not a pill on every row ─────────────────
   A chip per row turns a table into confetti. The outcome is a WORD, with a
   2px lead-in rule carrying the state colour, so one glance down the column
   reads as a column and not as a row of badges. */
.state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--t-sm);
  color: var(--fg-2);
  white-space: nowrap;
}
.state::before {
  content: '';
  width: 2px; height: 12px; border-radius: 1px;
  background: var(--idle);
  flex: none;
}
.state[data-tone='ok']::before   { background: var(--ok); }
.state[data-tone='bad']::before  { background: var(--bad); }
.state[data-tone='warn']::before { background: var(--warn); }
.state[data-tone='bad']  { color: var(--fg); font-weight: 600; }

/* A chip survives for the few places a state is the ONLY thing in its box —
   a header fact, a rollout row — never for a table column. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.chip.ok   { color: var(--ok);   background: var(--ok-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.bad  { color: var(--bad);  background: var(--bad-soft); }
.chip.mute { color: var(--fg-3); background: var(--bg-3); }

/* ── run strip: one cell per run, the shape of a history at a glance ─────── */
.runs { display: flex; gap: 2px; align-items: flex-end; }
.runs i {
  display: block;
  width: 5px;
  height: 20px;
  border-radius: 1px;
  background: var(--bg-3);
  transition: transform var(--dur) var(--ease);
}
.runs i[data-state='succeeded'] { background: var(--ok); }
.runs i[data-state='failed']    { background: var(--bad); }
.runs i[data-state='running']   { background: var(--warn); }
.runs i:hover { transform: scaleY(1.25); }

/* ── segmented control ───────────────────────────────────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r-md); overflow: hidden; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: var(--t-sm);
  padding: 5px var(--s-3);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button[aria-pressed='true'] { background: var(--bg-3); color: var(--fg); }

/* ── inputs ──────────────────────────────────────────────────────────────── */
.field, select.field {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 5px var(--s-2);
  font: inherit;
  font-size: var(--t-sm);
}
.field::placeholder { color: var(--fg-3); }

/* ── note: a caveat that belongs on screen, not hidden in a tooltip ──────── */
.note {
  border-left: 2px solid var(--warn);
  background: var(--bg-2);
  color: var(--fg-2);
  padding: var(--s-2) var(--s-3);
  font-size: var(--t-sm);
}

/* ── empty state ──────────────────────────────────────────────────────────
   Says what is missing, why, and what makes it stop being missing. Never
   "check back later" — that is a screen admitting it has nothing to say and
   asking the reader to come back and find out whether it still has nothing. */
.empty {
  border: 1px dashed var(--border-2);
  border-radius: var(--r-md);
  background: var(--bg-2);
  padding: var(--s-6) var(--s-5);
  text-align: center;
}
.empty h3 { margin: 0; font-size: var(--t-sm); font-weight: 600; color: var(--fg); }
.empty p { margin: var(--s-2) auto 0; max-width: 62ch; font-size: var(--t-sm); color: var(--fg-3); }
.empty .row { justify-content: center; margin-top: var(--s-4); }

/* ── focus, ported from opes ─────────────────────────────────────────────── */
:where(button, a, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--fg-4);
  outline-offset: 2px;
}

/* ── motion ───────────────────────────────────────────────────────────────
   There is deliberately no fade-in-from-below load animation here. It is the
   default in every shadcn block, v0 component and Lovable page, which makes it
   a recognised slop tell: it signals "polished" while doing nothing for the
   user. Motion in this kit earns its place by explaining a state CHANGE, so it
   lives on the components that change (rail hover, run-strip hover, segmented
   control) and nowhere else. See ai-slop-symptoms.md "Performative motion". */
