/* Avid OS, Version C "Bento". Base stylesheet.
   Spec: docs/01_design/BENTO_DIRECTION.md. Brand tokens: docs/01_design/BRAND.md.
   Station styles live in styles/<station>.css and scope themselves with [data-station="<id>"].

   Contract for station builders:
   - #app is a 12-column bento grid. A direct child with span-N takes N columns; anything else spans the row.
   - .bento is the same grid for a nested group. Spans: .span-1 to .span-12. Height: .rows-2 (row unit 140 px).
   - .tile is the only surface. Variants: .tile-mist, .tile-blue (hero only), .tile-ink (one per screen).
   - .tile-label, .tile-title, .big (.is-xl), .big-sub, .tile-action, .btn-primary, .btn-light, .btn-text. */

/* ---------- 1. Tokens ----------
   The Statement values live in styles/tokens.css (ported from design-18). The names below are Version C's own,
   kept so every station stylesheet keeps working, and pointed at the Statement palette. */
:root {
  --deep-ink: var(--slate-deep);
  --deep-ink-2: var(--slate);
  --blue-gradient: linear-gradient(135deg, #0091DA 0%, #0077B3 100%);
  --ink-disabled: var(--ink-4);
  --on-dark: #FFFFFF;
  --on-dark-2: rgba(255, 255, 255, 0.78);
  --on-dark-3: rgba(255, 255, 255, 0.6);
  --mist: var(--slate-wash);
  --surface-2: var(--surface-warm);
  --surface-3: var(--track);

  /* Status, retuned to the Statement inks */
  --good: var(--on-track);  --good-ink: var(--on-track-ink);  --good-tint: var(--on-track-tint);
  --warn: var(--watch);     --warn-ink: var(--watch-ink);     --warn-tint: var(--watch-tint);
  --bad:  var(--behind);    --bad-ink:  var(--behind-ink);    --bad-tint:  var(--behind-tint);

  --font-sans: var(--font);
  --font-serif: var(--serif);
  --fs-label: 11px;
  --fs-small: 13px;
  --fs-body: 14px;
  --fs-card-title: 19px;
  --fs-section: 28px;
  --fs-station: 32px;
  --fs-big: 38px;
  --fs-big-xl: 64px;
  --fs-kpi: 38px;
  --tracking-title: -0.005em;
  --tracking-label: 0.12em;

  --space-half: 4px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --gutter: 16px;
  --row: 140px;
  --radius-sm: var(--r-sm);
  --radius: var(--r);
  --radius-lg: var(--r-lg);
  --radius-tile: var(--r-lg);
  --radius-pill: var(--pill);
  --hairline: 1px solid var(--line);
  --shadow-tile: var(--shadow-1);
  --shadow-tile-hover: var(--shadow-2);
  --shadow-float: var(--shadow-2);
  --shadow-hair: 0 1px 2px rgba(29, 59, 79, 0.06);
  --focus-ring: 0 0 0 3px rgba(0, 145, 218, 0.35);
  --t: 200ms var(--ease);

  --topbar-h: 0px;
  --content-max: 1312px;
  --content-pad: 36px;
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-weight: 700; }
ul, ol { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--avid-blue-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
::selection { background: var(--avid-blue-tint); color: var(--avid-blue-ink); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Top bar: gone. The rail and masthead live in styles/shell.css. ---------- */

/* ---------- 4. Stage, station grid, footer ---------- */
.stage {
  min-height: calc(100vh - var(--topbar-h)); display: flex; flex-direction: column;
  /* Room for the Ask Avid launcher (52 px, 24 px from the edge) plus 16 px, so it never covers the last row. */
  padding-bottom: calc(52px + 24px + 16px + var(--dock-lift, 0px));
}

#app,
.bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: auto; /* tiles carry the 140 px row unit as min-height, so headers stay compact */
  gap: var(--gutter);
  align-content: start;
}
#app {
  flex: 1;
  width: 100%; max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-3) var(--content-pad) var(--space-5);
  outline: none;
}
/* Anything without a span takes the full row. Zero specificity, so .span-N always wins. */
:where(#app, .bento) > * { grid-column: 1 / -1; min-width: 0; }
.bento { grid-column: 1 / -1; }
.bento.is-equal > * { grid-column: auto; }

.span-1 { grid-column: span 1; }  .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-10 { grid-column: span 10; } .span-11 { grid-column: span 11; } .span-12 { grid-column: 1 / -1; }
.rows-2 { grid-row: span 2; }
.rows-3 { grid-row: span 3; }

.app-footer {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--space-2) var(--content-pad) var(--space-4);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-align: center;
}
.app-footer-privacy {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2); font-weight: 600;
}
.app-footer-privacy svg { color: var(--good); }
.app-footer-credit { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-3); }
.credit-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cabinet-brass); }
.credit-name { font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 11px; }

/* ---------- 5. Page header (the only text outside tiles) ---------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) 0 var(--space-1);
  grid-row: auto;
}
.page-header-text { min-width: 0; }
.eyebrow {
  font-size: var(--fs-label); font-weight: 600;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-3);
}
.page-title {
  margin-top: 6px;
  font-size: var(--fs-station); font-weight: 800; line-height: 1.08;
  letter-spacing: var(--tracking-title);
  color: var(--ink);
}
.page-subtitle { margin-top: 8px; font-size: var(--fs-body); color: var(--ink-2); max-width: 760px; }
.page-actions { display: flex; align-items: center; gap: var(--space-1); flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- 6. Tile ---------- */
.tile {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0; min-height: var(--row);
  background: var(--surface);
  border-radius: var(--radius-tile);
  padding: var(--space-3);
  box-shadow: var(--shadow-tile);
  color: var(--ink);
  transition: transform var(--t), box-shadow var(--t), background var(--t);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-tile-hover); }
.tile.is-flush { padding: 0; overflow: hidden; }
.tile.is-interactive { cursor: pointer; }
.tile.is-selected { box-shadow: 0 0 0 2px var(--avid-blue), var(--shadow-tile); }
.rows-2.tile { min-height: calc(var(--row) * 2 + var(--gutter)); }

.tile-mist { background: var(--mist); box-shadow: 0 4px 14px rgba(16, 32, 48, 0.05); }
.tile-blue { background: var(--blue-gradient); color: var(--on-dark); box-shadow: 0 14px 34px rgba(0, 119, 179, 0.28); }
.tile-blue:hover { box-shadow: 0 20px 40px rgba(0, 119, 179, 0.34); }
.tile-ink { background: var(--deep-ink); color: var(--on-dark); box-shadow: 0 14px 34px rgba(16, 32, 48, 0.24); }
.tile-ink:hover { box-shadow: 0 20px 40px rgba(16, 32, 48, 0.3); }

.tile-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2);
  margin-bottom: 14px;
}
.tile-label {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-label); font-weight: 600; line-height: 1.4;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-3);
}
.tile-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill);
  background: var(--mist); color: var(--ink);
  font-size: 11px; font-weight: 700; letter-spacing: 0;
}
.tile-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.tile-note { font-size: 12px; color: var(--ink-3); font-weight: 500; line-height: 1.45; }
.tile-title { font-size: var(--fs-card-title); font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.tile-action { margin-top: auto; padding-top: var(--space-2); display: flex; justify-content: flex-end; gap: 8px; }

.tile-blue .tile-label, .tile-ink .tile-label { color: var(--on-dark-3); }
.tile-blue .tile-label { color: rgba(255, 255, 255, 0.82); }
.tile-blue .tile-count, .tile-ink .tile-count { background: rgba(255, 255, 255, 0.16); color: #fff; }
.tile-blue .tile-note, .tile-ink .tile-note { color: var(--on-dark-3); }
.tile-mist .tile-count { background: var(--surface); }

/* One level of nesting only: a tile placed inside a tile becomes part of it. */
.tile .tile { box-shadow: none; transform: none; animation: none; min-height: 0; border-radius: var(--radius); }
.tile .tile:hover { transform: none; box-shadow: none; }
.tile .tile.is-flush { background: transparent; border-radius: 0; overflow: visible; }
.tile:not(.tile-mist) .tile:not(.is-flush):not(.tile-blue):not(.tile-ink) { background: var(--mist); padding: var(--space-2); }
.tile-mist .tile:not(.is-flush) { background: var(--surface); padding: var(--space-2); }
.tile > .tile + .tile, .tile > .tile + *:not(.tile-action) { margin-top: 12px; }

/* Card header kept for the A call shape */
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); margin-bottom: 12px; }
.card-title { font-size: 18px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.card-subtitle { font-size: var(--fs-small); color: var(--ink-2); margin-top: 2px; }
.card-footer { margin-top: auto; padding-top: var(--space-2); display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tile-blue .card-subtitle, .tile-ink .card-subtitle { color: var(--on-dark-2); }

/* Stagger in: tiles fade and rise 8 px, 60 ms apart. app.js sets --i on each top-level tile. */
#app.is-entering .tile { animation: tile-in 480ms var(--ease) backwards; animation-delay: calc(var(--i, 0) * 60ms); }
#app.is-entering .tile .tile { animation: none; }
#app.is-entering > .page-header { animation: tile-in 360ms var(--ease) backwards; }
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- 7. Big numbers ---------- */
.bignum { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bignum .tile-label { margin-bottom: 6px; }
.big {
  font-size: var(--fs-big); font-weight: 700; line-height: 1.02;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.big.is-xl { font-size: var(--fs-big-xl); }
.big small { font-size: 0.4em; font-weight: 600; color: var(--ink-3); margin-left: 6px; letter-spacing: 0; }
.tile-blue .big small, .tile-ink .big small { color: var(--on-dark-2); }
.big-sub {
  margin-top: 8px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
  font-size: var(--fs-small); color: var(--ink-2); font-weight: 500; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.tile-blue .big-sub, .tile-ink .big-sub { color: var(--on-dark-2); }

.stat .big { margin-top: auto; }
.stat .tile-head { margin-bottom: 10px; }
.stat-chart { margin-top: 12px; color: var(--avid-blue); }
.tile-blue .stat-chart, .tile-ink .stat-chart { color: #fff; }

.trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-variant-numeric: tabular-nums; }
.trend svg { width: 14px; height: 14px; }
.trend.is-up { color: var(--good-ink); }
.trend.is-down { color: var(--bad-ink); }
.trend.is-flat { color: var(--ink-3); }
.tile-blue .trend, .tile-ink .trend { color: #fff; }
.tile-ink .trend.is-up { color: #7FD3A8; }

/* ---------- 8. Micro charts (inline SVG, color from currentColor) ---------- */
.chart { overflow: visible; }
.spark-line { fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.spark-area { fill: currentColor; opacity: 0.12; }
.spark-dot { fill: currentColor; stroke: var(--surface); stroke-width: 2; }
.tile-blue .spark-dot { stroke: var(--avid-blue-strong); }
.tile-ink .spark-dot { stroke: var(--deep-ink); }
.bars .bar { fill: currentColor; opacity: 0.22; }
.bars .bar.is-hi { opacity: 1; }
.tile-blue .bars .bar, .tile-ink .bars .bar { opacity: 0.35; }
.tile-blue .bars .bar.is-hi, .tile-ink .bars .bar.is-hi { opacity: 1; }

.ring { position: relative; flex: none; color: var(--avid-blue); }
.ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--surface-3); }
.ring-arc { fill: none; stroke: currentColor; stroke-linecap: round; transition: stroke-dasharray 600ms var(--ease); }
.tile-mist .ring-track { stroke: #DCE4EC; }
.tile-blue .ring, .tile-ink .ring { color: #fff; }
.tile-blue .ring-track, .tile-ink .ring-track { stroke: rgba(255, 255, 255, 0.2); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; color: var(--ink); }
.ring-caption { margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.tile-blue .ring-value, .tile-ink .ring-value { color: #fff; }
.tile-blue .ring-caption, .tile-ink .ring-caption { color: var(--on-dark-2); }

/* ---------- 9. Layout helpers ---------- */
.grid { gap: var(--gutter); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: var(--space-1); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); font-size: var(--fs-small); }
.tile-blue .muted, .tile-ink .muted { color: var(--on-dark-2); }
.tile-blue .subtle, .tile-ink .subtle { color: var(--on-dark-3); }

/* Two panes: main pane span-8, context panel span-4 tile */
.two-pane { align-items: start; grid-auto-rows: auto; }
.two-pane-list { min-width: 0; display: flex; flex-direction: column; gap: var(--gutter); }
.two-pane-panel {
  position: sticky; top: calc(var(--topbar-h) + var(--space-2));
  max-height: calc(100vh - var(--topbar-h) - var(--space-4));
  overflow-y: auto;
  padding: 0 var(--space-3);
}
.two-pane-panel:hover { transform: none; }
.panel-section { padding: 20px 0; border-bottom: var(--hairline); }
.panel-section:last-child { border-bottom: 0; }
.panel-section > .tile-label { margin-bottom: 12px; }
.panel-actions {
  position: sticky; bottom: 0;
  margin: 0 calc(var(--space-3) * -1);
  padding: var(--space-2) var(--space-3);
  background: var(--surface); border-top: var(--hairline);
  display: flex; gap: var(--space-1);
}

/* Sticky bottom action bars (the review send bar, the task Mark done bar, and any future .sticky-actions).
   While one is on the page, the Ask Avid dock lifts above it so it never hides the bar's right end.
   The lift is the bar height (about 76 px) plus the bar's 16 px offset, less the dock's own 24 px, plus a 12 px gap. */
body:has(.adv-sendbar, .ops-bar, .sticky-actions) { --dock-lift: 80px; }

/* ---------- 10. Table inside a tile ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.table th {
  text-align: left; white-space: nowrap;
  padding: 0 12px 10px;
  font-size: var(--fs-label); font-weight: 600;
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line-strong);
}
.table td { padding: 14px 12px; border-bottom: var(--hairline); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tr:last-child td { border-bottom: 0; }
.table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .is-strong { font-weight: 700; }
.table tbody tr { transition: background var(--t); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-clickable:hover { background: var(--mist); }
.table tbody tr.is-selected { background: var(--avid-blue-tint); }
.table.is-dense td { padding: 11px 12px; }
.table.is-dense td:first-child { padding-left: 0; }
.table.is-dense td:last-child { padding-right: 0; }
:where(#app, .bento) > .tile.is-flush > .table-wrap { padding: var(--space-3) var(--space-3) var(--space-2); }

/* ---------- 11. Badge, entity tag, dot, progress ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; line-height: 1;
  white-space: nowrap;
  background: var(--mist); color: var(--ink-2);
}
.badge.is-good { background: var(--good-tint); color: var(--good-ink); }
.badge.is-warn { background: var(--warn-tint); color: var(--warn-ink); }
.badge.is-bad { background: var(--bad-tint); color: var(--bad-ink); }
.badge.is-info { background: var(--avid-blue-tint); color: var(--avid-blue-ink); }
.badge.is-neutral { background: var(--mist); color: var(--ink-2); }
.badge.is-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); }
/* Dot plus text: no pill, the dot carries the status color. */
.badge.has-dot { background: transparent; padding: 0; height: auto; color: var(--ink); gap: 7px; }
.badge.has-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-disabled); flex: none; }
.badge.has-dot.is-good::before { background: var(--good); }
.badge.has-dot.is-warn::before { background: var(--warn); }
.badge.has-dot.is-bad::before { background: var(--bad); }
.badge.has-dot.is-info::before { background: var(--avid-blue); }
.badge.has-dot.is-bad { color: var(--bad-ink); }
.tile-blue .badge, .tile-ink .badge { background: rgba(255, 255, 255, 0.16); color: #fff; }
.tile-blue .badge.has-dot, .tile-ink .badge.has-dot { background: transparent; }

.entity-tag {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 7px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  background: var(--mist); color: var(--ink-2);
}
.entity-tag.is-awp { background: var(--avid-blue-tint); color: var(--avid-blue-ink); }
.entity-tag.is-arm { background: var(--deep-ink); color: #fff; }
.entity-tag.is-ac { background: var(--mist); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.entity-tags { display: inline-flex; gap: 4px; }
.tile-ink .entity-tag, .tile-blue .entity-tag { background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: none; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-disabled); flex: none; }
.dot.is-good { background: var(--good); }
.dot.is-warn { background: var(--warn); }
.dot.is-bad { background: var(--bad); }
.dot.is-info { background: var(--avid-blue); }

.progress { height: 6px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--avid-blue); transition: width 400ms var(--ease); }
.progress.is-good > span { background: var(--good); }
.progress.is-warn > span { background: var(--warn); }
.progress.is-bad > span { background: var(--bad); }
.tile-mist .progress { background: #DCE4EC; }
.tile-blue .progress, .tile-ink .progress { background: rgba(255, 255, 255, 0.2); }
.tile-blue .progress > span, .tile-ink .progress > span { background: #fff; }
/* Live progress along the top edge of a hero tile */
.tile-progress { position: absolute; left: 0; right: 0; top: 0; height: 4px; border-radius: 0; background: rgba(255, 255, 255, 0.18); }
.tile-progress > span { border-radius: 0 2px 2px 0; }

/* ---------- 12. Pill buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 20px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-small); font-weight: 700; line-height: 1;
  white-space: nowrap;
  transition: background var(--t), color var(--t), box-shadow var(--t), transform var(--t);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--avid-blue-strong); color: #fff; box-shadow: 0 6px 16px rgba(0, 119, 179, 0.28); }
.btn-primary:hover { background: var(--avid-blue-ink); box-shadow: 0 8px 20px rgba(0, 119, 179, 0.34); }
.btn-secondary { background: var(--mist); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-3); }
.tile-mist .btn-secondary, .page-actions .btn-secondary { background: var(--surface); box-shadow: var(--shadow-hair); }
.btn-light { background: #fff; color: var(--deep-ink); box-shadow: 0 6px 16px rgba(16, 32, 48, 0.16); }
.btn-light:hover { background: #F4F8FB; }
.tile-blue .btn-light { color: var(--avid-blue-strong); }
.btn-text { height: auto; padding: 6px 4px; color: var(--avid-blue-strong); background: transparent; }
.btn-text:hover { color: var(--avid-blue-ink); text-decoration: underline; text-underline-offset: 3px; }
.tile-blue .btn-text, .tile-ink .btn-text { color: #fff; }
.btn-danger { background: var(--mist); color: var(--bad-ink); }
.btn-danger:hover { background: var(--bad-tint); }
.btn-lg { height: 52px; padding: 0 28px; font-size: var(--fs-body); }
.btn-lg svg { width: 20px; height: 20px; }
.btn-sm { height: 32px; padding: 0 14px; font-size: 12px; }
.btn-block { width: 100%; }

/* ---------- 13. Avatar ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--avid-blue); color: #fff;
  font-size: 13px; font-weight: 700; letter-spacing: 0.02em;
}
.avatar.c-0 { background: #0091DA; color: #fff; }
.avatar.c-1 { background: #1A2733; color: #fff; }
.avatar.c-2 { background: #7CC4EA; color: #0B3A55; }
.avatar.c-3 { background: #0077B3; color: #fff; }
.avatar.c-4 { background: #4A6278; color: #fff; }
.avatar.c-5 { background: #BFE0F3; color: #0B3A55; }
.avatar.is-blue { background: var(--avid-blue); color: #fff; }
.avatar.is-dark { background: var(--deep-ink); color: #fff; }
.avatar.is-neutral { background: var(--surface-3); color: var(--ink-2); }
.avatar.is-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.is-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.is-xl { width: 64px; height: 64px; font-size: 20px; }
.tile-ink .avatar.c-1 { background: #3A4D5E; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -8px; }

/* ---------- 14. Empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: var(--space-1);
  padding: var(--space-5) var(--space-4);
  background: var(--mist);
  border-radius: var(--radius);
}
:where(#app) > .empty { background: var(--surface); border-radius: var(--radius-tile); box-shadow: var(--shadow-tile); }
.empty-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--avid-blue-tint); color: var(--avid-blue-strong);
  margin-bottom: var(--space-1);
}
.empty-icon svg { width: 24px; height: 24px; }
.empty-title { font-size: 18px; font-weight: 700; }
.empty-body { font-size: var(--fs-small); color: var(--ink-2); max-width: 520px; }
.empty .btn { margin-top: var(--space-2); }

/* ---------- 15. Phone frame (Client Station) ---------- */
.phone-stage { display: flex; justify-content: center; padding: var(--space-2) 0; }
.phone {
  position: relative; flex: none;
  width: 390px; height: 844px;
  border-radius: 56px;
  background: #0E1620;
  padding: 12px;
  box-shadow: 0 0 0 1px #2C3742, 0 30px 60px rgba(16, 32, 48, 0.22);
}
.phone-screen {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 44px;
  overflow: hidden;
  background: var(--canvas);
  display: flex; flex-direction: column;
}
.phone-status {
  flex: none; height: 48px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.phone-island {
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 34px; border-radius: var(--radius-tile); background: #0E1620; z-index: 2;
}
.phone-body { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; }
.phone-body::-webkit-scrollbar { display: none; }
.phone-home { flex: none; height: 28px; display: flex; align-items: center; justify-content: center; }
.phone-home::after { content: ""; width: 134px; height: 5px; border-radius: 4px; background: var(--ink); }
.phone .tile { border-radius: var(--radius-lg); padding: 16px; min-height: 0; }

/* ---------- 16. Lists, key value, quote, fields, toast ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
  border-bottom: var(--hairline);
  transition: background var(--t);
}
.list-item:first-child { padding-top: 2px; }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item.is-clickable { cursor: pointer; border-radius: 12px; }
.list-item.is-clickable:hover { background: var(--mist); box-shadow: -10px 0 0 var(--mist), 10px 0 0 var(--mist); }
.list-item.is-selected { background: var(--avid-blue-tint); }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-size: 14px; font-weight: 700; line-height: 1.35; }
.list-item-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.tile-ink .list-item, .tile-blue .list-item { border-color: rgba(255, 255, 255, 0.12); }
.tile-ink .list-item-meta, .tile-blue .list-item-meta { color: var(--on-dark-3); }
.tile-ink .list-item.is-clickable:hover { background: rgba(255, 255, 255, 0.06); box-shadow: -10px 0 0 rgba(255, 255, 255, 0.06), 10px 0 0 rgba(255, 255, 255, 0.06); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 10px var(--space-3); font-size: var(--fs-small); }
.kv dt { color: var(--ink-3); font-weight: 500; }
.kv dd { color: var(--ink); font-weight: 600; }
.tile-ink .kv dt, .tile-blue .kv dt { color: var(--on-dark-3); }
.tile-ink .kv dd, .tile-blue .kv dd { color: #fff; }

.quote {
  position: relative;
  background: var(--mist);
  border-radius: 12px;
  padding: 12px 16px 12px 19px;
  font-size: var(--fs-small); line-height: 1.55; color: var(--ink);
  overflow: hidden;
}
.quote::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--avid-blue); }
.tile-mist .quote { background: var(--surface); }
.tile-ink .quote, .tile-blue .quote { background: rgba(255, 255, 255, 0.1); color: #fff; }
.tile-ink .quote::before, .tile-blue .quote::before { background: #fff; }
.quote-meta { display: block; margin-bottom: 4px; font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.04em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tile-ink .quote-meta, .tile-blue .quote-meta { color: var(--on-dark-3); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--ink-3); }
.input {
  height: 40px; padding: 0 14px;
  border: 0; border-radius: 12px;
  background: var(--mist); font-size: var(--fs-small); font-weight: 500;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow var(--t), background var(--t);
}
.input:focus { outline: none; background: var(--surface); box-shadow: inset 0 0 0 1px var(--avid-blue), var(--focus-ring); }
.tile-mist .input { background: var(--surface); }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.search .input { padding-left: 38px; width: 280px; border-radius: var(--radius-pill); background: var(--surface); box-shadow: var(--shadow-hair); }

.divider { height: 1px; background: var(--line); margin: var(--space-2) 0; border: 0; }

.toast {
  position: fixed; left: 50%; bottom: var(--space-4);
  transform: translate(-50%, 8px);
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: var(--radius-pill);
  background: var(--deep-ink); color: #fff;
  font-size: var(--fs-small); font-weight: 600;
  box-shadow: 0 14px 34px rgba(16, 32, 48, 0.28);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t), transform var(--t);
  z-index: 50;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 18px; height: 18px; color: #7FD3A8; }

/* Skeleton loader, used instead of spinners */
.skeleton { background: var(--surface-3); border-radius: var(--radius-sm); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* ---------- 16b. Drillable numbers ----------
   ui.stat({ drill }) renders the tile as <a class="tile stat is-drill">; ui.bigNumber(..., { drill }) as <a class="bignum is-drill">.
   A quiet chevron sits top right and slides on hover. */
a.tile, a.bignum { color: inherit; text-decoration: none; }
a.tile:hover, a.bignum:hover { text-decoration: none; }
.tile-blue.is-drill, .tile-ink.is-drill { color: var(--on-dark); }
.drill-chevron {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  color: var(--ink-3); background: transparent;
  transition: transform var(--t), background var(--t), color var(--t);
}
.is-drill:hover .drill-chevron, .is-drill:focus-visible .drill-chevron { transform: translateX(2px); background: var(--mist); color: var(--avid-blue-strong); }
.tile-blue .drill-chevron, .tile-ink .drill-chevron { color: var(--on-dark-3); }
.tile-blue.is-drill:hover .drill-chevron, .tile-ink.is-drill:hover .drill-chevron { background: rgba(255, 255, 255, 0.16); color: #fff; }
.tile-mist.is-drill:hover .drill-chevron { background: var(--surface); }
.tile.is-drill:focus-visible { box-shadow: var(--focus-ring), var(--shadow-tile); border-radius: var(--radius-tile); }
a.bignum.is-drill { border-radius: var(--radius); margin: -6px; padding: 6px; transition: background var(--t); }
a.bignum.is-drill:hover { background: var(--mist); }
.tile-blue a.bignum.is-drill:hover, .tile-ink a.bignum.is-drill:hover { background: rgba(255, 255, 255, 0.08); }
.bignum .tile-label .drill-chevron, .bignum .big .drill-chevron { margin-left: 6px; vertical-align: middle; }

/* ---------- 16c. Compact density ----------
   A page mode, not a new design. Set on #app: data-density="compact" (or class is-compact).
   app.js resets it on every route; a station sets it with meta.density = 'compact' or in render.
   Tile padding 16 px, rows 36 px, 13 px body, numbers 28 to 36 px. Labels stay the same. */
#app[data-density="compact"], #app.is-compact {
  --row: 96px;
  --gutter: 12px;
  --fs-body: 13px;
  --fs-big: 30px;
  --fs-big-xl: 36px;
  --fs-card-title: 16px;
  --fs-station: 30px;
  font-size: 13px;
  padding-top: var(--space-2);
}
:is(#app[data-density="compact"], #app.is-compact) .tile { padding: var(--space-2); border-radius: var(--radius-lg); }
:is(#app[data-density="compact"], #app.is-compact) .tile.is-flush { padding: 0; }
:is(#app[data-density="compact"], #app.is-compact) .tile-head { margin-bottom: 8px; }
:is(#app[data-density="compact"], #app.is-compact) .big-sub { margin-top: 6px; font-size: 12px; }
:is(#app[data-density="compact"], #app.is-compact) .page-header { padding: var(--space-1) 0 0; }
:is(#app[data-density="compact"], #app.is-compact) .page-subtitle { font-size: 13px; margin-top: 4px; }
:is(#app[data-density="compact"], #app.is-compact) .table td { height: 36px; padding: 6px 10px; }
:is(#app[data-density="compact"], #app.is-compact) .table th { padding: 0 10px 8px; }
:is(#app[data-density="compact"], #app.is-compact) .table th:first-child,
:is(#app[data-density="compact"], #app.is-compact) .table td:first-child { padding-left: 0; }
:is(#app[data-density="compact"], #app.is-compact) .table th:last-child,
:is(#app[data-density="compact"], #app.is-compact) .table td:last-child { padding-right: 0; }
:is(#app[data-density="compact"], #app.is-compact) .list-item { padding-top: 6px; padding-bottom: 6px; }
:is(#app[data-density="compact"], #app.is-compact) .btn { height: 32px; padding: 0 14px; font-size: 13px; }
:where(#app[data-density="compact"], #app.is-compact) > .tile.is-flush > .table-wrap { padding: var(--space-2) var(--space-2) var(--space-1); }

/* Locked station: a calm tile, never an error. */
.locked-tile .empty-icon { color: var(--avid-blue-strong); }

/* ---------- 17. Responsive ---------- */
@media (max-width: 1360px) {
  :root { --fs-big: 42px; --fs-big-xl: 56px; --content-pad: 28px; }
}
@media (max-width: 1100px) {
  .span-3 { grid-column: span 6; }
  .span-4, .span-5, .span-7, .span-8 { grid-column: 1 / -1; }
  .two-pane-panel { position: static; max-height: none; }
}
/* Phone and small tablet: the station control becomes its own scrollable pill row under the logo.
   The page itself never scrolls sideways. */
@media (max-width: 800px) {
  :root { --topbar-h: 60px; --content-pad: 16px; --fs-big: 40px; --fs-big-xl: 52px; }
  html, body { overflow-x: clip; }

  /* Shell guards so no station pushes the page sideways on a phone. */
  .tile-head { min-width: 0; }
  .tile-head > :first-child { min-width: 0; }
  .tile-label { min-width: 0; overflow-wrap: anywhere; }
  .entity-tags { flex-wrap: wrap; }
  .page-header { flex-wrap: wrap; align-items: flex-start; }
  .page-actions { flex: 1 1 100%; max-width: 100%; justify-content: flex-start; }
  #app .page-actions .search, #app .page-actions .search .input { width: 100%; max-width: 100%; }
  /* The data map keeps its desktop shape and scrolls inside its own tile. */
  [data-station="data"] .dl-hero { overflow-x: auto; overscroll-behavior-x: contain; }
  [data-station="data"] .dl-map { min-width: 960px; }
  #app[data-station="team"] .tm-people { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #app[data-station="operations"] .ops-q-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .span-3, .span-6, .span-9, .span-10, .span-11 { grid-column: 1 / -1; }
  .rows-2, .rows-3 { grid-row: auto; }
}

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

#app:focus, #app:focus-visible { box-shadow: none; }
.spark .spark-line, .spark .spark-dot { vector-effect: non-scaling-stroke; }
