:root {
  --canvas: #f4f3ee;
  --surface: #fffefa;
  --surface-muted: #edeee8;
  --ink: #18211b;
  --muted: #626b64;
  --subtle: #7b837d;
  --line: #dddfd6;
  --line-strong: #c6cabf;
  --nav: #14271f;
  --lime: #d8f169;
  --green: #28704f;
  --green-soft: #e3f2e8;
  --blue: #2b629b;
  --blue-soft: #e7eff8;
  --amber: #945b18;
  --amber-soft: #fff0d8;
  --red: #a33f35;
  --red-soft: #fae6e2;
  /* Healthy boards shade from --cell-ok-low (no jobs) to --cell-ok-high (10k+
     jobs). Problem colours are the only saturated marks, validated for
     colour-blind separation from each other and from both ends of the ramp. */
  --cell-ok-low: #d6e0d5;
  --cell-ok-high: #5f8f71;
  --cell-failing: #b3342b;
  --cell-degraded: #c9860f;
  --cell-stale: #4f5863;
  --cell-idle: #a9afa8;
  --shadow-small: 0 1px 2px rgb(24 33 27 / 4%), 0 5px 18px rgb(24 33 27 / 4%);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button { color: inherit; font: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
:focus-visible { outline: 3px solid rgb(43 98 155 / 30%); outline-offset: 2px; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.skip-link { position: fixed; z-index: 100; top: 10px; left: 10px; transform: translateY(-180%); border-radius: 7px; background: var(--ink); padding: 8px 12px; color: white; }
.skip-link:focus { transform: none; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 222px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; min-height: 100vh; height: 100vh; display: flex; flex-direction: column; background: #15251e; padding: 22px 12px; color: #f0f4f1; }
/* .brand lockup lives in navigation.css so every page shares one wordmark. */
.side-nav { display: grid; gap: 2px; margin-top: 18px; }
.side-nav p { margin: 13px 10px 4px; color: rgb(255 255 255 / 40%); font: 10px var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.side-nav a { display: flex; align-items: center; gap: 8px; border-radius: 8px; padding: 8px 10px; color: rgb(255 255 255 / 67%); font-size: 14px; font-weight: 400; }
.side-nav a:hover, .side-nav a.active { background: #22372d; color: white; }
.side-nav a.active .nav-icon { color: var(--lime); }
.side-nav b { margin-left: auto; border-radius: 20px; background: rgb(255 255 255 / 10%); padding: 1px 6px; font: 10px var(--mono); font-weight: 400; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; }

.workspace { min-width: 0; width: 100%; max-width: 1660px; margin: 0 auto; padding: 30px 36px 60px; }
.page-header { display: flex; align-items: baseline; justify-content: space-between; gap: 25px; }
.page-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.page-header h1 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -.035em; }
.clock { color: var(--muted); font: 600 12px var(--mono); white-space: nowrap; }

.stat-sep { color: var(--line-strong); }

.source-section { min-width: 0; margin-top: 26px; }
.section-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 4px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.section-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.section-header h2 { margin: 0; color: var(--muted); font: 600 12px var(--mono); letter-spacing: .01em; }
.section-header h2 strong { color: var(--ink); }
.stale-note { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; background: var(--amber-soft); padding: 4px 9px; color: var(--amber); font-size: 9px; font-weight: 720; white-space: nowrap; }
.stale-note[hidden] { display: none; }
.stale-note i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.legend-row { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: flex-end; }
.legend-key { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font: 600 11px var(--mono); white-space: nowrap; }
.legend-key i { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 1px; }
.legend-key b { color: var(--ink); font-weight: 700; }
.legend-key.ok i { width: 26px; flex-basis: 26px; background: linear-gradient(90deg, var(--cell-ok-low), var(--cell-ok-high)); }
.legend-key.failing i { background: var(--cell-failing); }
.legend-key.degraded i { background: var(--cell-degraded); }
.legend-key.stale i { background: var(--cell-stale); }
.legend-key.paused i { background: var(--cell-idle); }
.legend-key.never i { border: 1px solid var(--line-strong); background: var(--surface); }
/* Zero-count states stay in the row so it never reflows, but step back. */
.legend-key.zero { opacity: .45; }

/* One band per large provider, one cell per board. The long tail shares a
   band that opens into a small band per provider. */
.wall { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 16px; }
.band { min-width: 0; display: grid; gap: 6px; }
.band-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.band-label strong { font-size: 13px; line-height: 1.2; }
.band-label span { color: var(--subtle); font: 500 11px var(--mono); }
.band canvas { display: block; cursor: crosshair; touch-action: none; }
.tail-toggle { width: 100%; border: 0; background: transparent; padding: 0; text-align: left; }
.tail-toggle strong { display: inline-flex; align-items: center; gap: 4px; }
.tail-toggle .chev { width: 14px; height: 14px; color: var(--subtle); transition: transform .15s; }
.tail-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.tail-toggle:hover strong { color: var(--green); }
.tail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 28px; margin-top: 6px; }
.band.mini { gap: 4px; }
.band.mini .band-label strong { font-size: 12px; }

.board-tip { position: fixed; z-index: 50; min-width: 190px; max-width: 300px; opacity: 0; transform: translateY(4px); transition: opacity .08s; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 10px 12px; box-shadow: 0 8px 28px rgb(24 33 27 / 14%); font-size: 12px; pointer-events: none; }
.board-tip.visible { opacity: 1; transform: none; }
.tip-name { margin-bottom: 7px; overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.tip-row { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); }
/* Values share the labels' face; tabular figures keep digits aligned. */
.tip-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.state { min-height: 320px; display: grid; place-items: center; align-content: center; border: 1px dashed var(--line-strong); border-radius: 15px; background: var(--surface); margin-top: 14px; padding: 35px; text-align: center; }
.state-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 14px; background: var(--surface-muted); color: var(--muted); }
.state-icon.error { background: var(--red-soft); color: var(--red); }
.state h2 { margin: 13px 0 4px; font-size: 18px; }
.state p { max-width: 420px; margin: 0; color: var(--muted); }
.state button { margin-top: 16px; border: 1px solid var(--ink); border-radius: 9px; background: var(--ink); padding: 8px 13px; color: white; font-weight: 720; }
.spinner { width: 23px; height: 23px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-state p { margin-top: 10px; }
@keyframes spin { to { transform: rotate(1turn); } }

@media (max-width: 1100px) {
  .tail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .section-header { align-items: flex-start; flex-direction: column; gap: 8px; }
  .legend-row { justify-content: flex-start; }
}

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

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; min-height: 0; flex-direction: row; align-items: center; padding: 11px 15px; }
  .brand { padding: 0; }
  .side-nav { max-width: calc(100vw - 145px); display: flex; overflow-x: auto; margin-left: auto; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav p { display: none; }
  .side-nav a { flex: 0 0 auto; }
  .side-nav a.active { order: -1; }
  .workspace { padding: 27px 18px 45px; }
  .legend-key i { width: 9px; height: 9px; }
}

@media (max-width: 560px) {
  .workspace { padding: 22px 13px 40px; }
  .page-header { align-items: flex-start; flex-direction: column; gap: 4px; }
  .page-title { flex-wrap: wrap; gap: 4px 12px; }
  .page-header h1 { font-size: 22px; }
}

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