/* ==========================================================================
   TestBoot design system
   Calm, premium, trustworthy. No gradients. No emoji. No stock illustrations.
   Status always carries a word — never colour alone.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* --- Tokens -------------------------------------------------------------- */
:root {
  /* Ground and surface */
  --tb-navy:        #0F172A;   /* top bar, primary text */
  --tb-ground:      #F5F6FA;   /* page background */
  --tb-surface:     #FFFFFF;   /* cards */
  --tb-border:      #E2E8F0;   /* 1px card border, table rules */
  --tb-border-soft: #EDF1F6;

  /* Text */
  --tb-text:        #0F172A;
  --tb-text-2:      #475569;   /* secondary — 4.5:1 on white */
  --tb-text-3:      #64748B;   /* tertiary, on white only at >=14px semibold */

  /* Accent */
  --tb-indigo:      #6366F1;   /* marks, rules, current step */
  --tb-indigo-btn:  #4F46E5;   /* filled buttons */
  --tb-indigo-dark: #4338CA;   /* button hover */
  --tb-indigo-tint: #EEF2FF;   /* tint fills */

  /* Verdicts */
  --tb-pass:        #047857;  --tb-pass-bg:    #ECFDF5;
  --tb-fail:        #B91C1C;  --tb-fail-bg:    #FEF2F2;
  --tb-blocked:     #92400E;  --tb-blocked-bg: #FFFBEB;

  /* Severity */
  --tb-p1:          #B91C1C;  --tb-p1-bg:      #FEF2F2;
  --tb-p2:          #92400E;  --tb-p2-bg:      #FFFBEB;
  --tb-p3:          #475569;  --tb-p3-bg:      #F1F5F9;

  /* Agent strip */
  --tb-agent-bg:    #F8FAFC;
  --tb-agent-border:#E2E8F0;

  /* Shape and rhythm */
  --tb-radius:      14px;
  --tb-radius-sm:   10px;
  --tb-radius-pill: 999px;
  --tb-gap:         16px;
  --tb-pad:         20px;
  --tb-max:         1360px;

  /* Type */
  --tb-font:        'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tb-mono:        'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  /* Touch */
  --tb-touch:       44px;   /* minimum target */
  --tb-touch-lg:    56px;   /* Pass / Fail / Blocked on phone */
}

/* --- Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--tb-font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--tb-text);
  background: var(--tb-ground);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;           /* never a horizontal page scroll */
}

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; color: var(--tb-text-2); text-transform: uppercase; letter-spacing: 0.04em; }

p { margin: 0 0 12px; }
a { color: var(--tb-indigo-btn); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Every ID, build code, commit, file path and session is monospace. */
code, kbd, samp, .tb-mono,
.tb-id, .tb-build, .tb-commit, .tb-path, .tb-session {
  font-family: var(--tb-mono);
  font-size: 0.92em;
  font-variant-ligatures: none;
}

/* Tabular numbers in tables. */
table { font-variant-numeric: tabular-nums; }

/* Focus is always visible. */
:focus-visible {
  outline: 2px solid var(--tb-indigo-btn);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Layout ------------------------------------------------------------- */
.tb-shell { min-height: 100vh; display: flex; flex-direction: column; }

.tb-topbar {
  background: var(--tb-navy);
  color: #fff;
  padding: 0 var(--tb-pad);
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: var(--tb-gap);
  flex-wrap: wrap;              /* menus wrap at phone width */
}
.tb-topbar a { color: #CBD5E1; }
.tb-topbar a:hover, .tb-topbar a[aria-current="page"] { color: #fff; text-decoration: none; }

.tb-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.tb-nav a {
  padding: 8px 12px;
  border-radius: var(--tb-radius-sm);
  font-size: 14px;
  font-weight: 500;
  min-height: var(--tb-touch);
  display: inline-flex;
  align-items: center;
}
.tb-nav a[aria-current="page"] { background: rgba(255,255,255,0.10); }

.tb-main {
  flex: 1;
  width: 100%;
  max-width: var(--tb-max);
  margin: 0 auto;
  padding: var(--tb-pad);
}

.tb-grid { display: grid; gap: var(--tb-gap); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.tb-row  { display: flex; gap: var(--tb-gap); flex-wrap: wrap; align-items: center; }
.tb-stack > * + * { margin-top: var(--tb-gap); }

/* Side panels stack at phone width. */
.tb-split { display: grid; gap: var(--tb-gap); grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .tb-split { grid-template-columns: 1fr; } }

/* --- Logo (one component, so the real logo swaps in) -------------------- */
.tb-logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; }
.tb-logo__mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--tb-indigo);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.tb-logo__mark svg { width: 17px; height: 17px; stroke: #fff; stroke-width: 2.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round; }

/* --- Card --------------------------------------------------------------- */
.tb-card {
  background: var(--tb-surface);
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius);
  padding: var(--tb-pad);
}
.tb-card--flush { padding: 0; overflow: hidden; }
.tb-card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--tb-gap);
  padding-bottom: 12px; margin-bottom: 12px;
  border-bottom: 1px solid var(--tb-border-soft);
  flex-wrap: wrap;
}

/* Section heading with the indigo rule. */
.tb-h2-rule { border-left: 4px solid var(--tb-indigo); padding-left: 12px; }

/* --- Stat tile ---------------------------------------------------------- */
.tb-stat { background: var(--tb-surface); border: 1px solid var(--tb-border); border-radius: var(--tb-radius); padding: 16px; }
.tb-stat__label { font-size: 13px; font-weight: 500; color: var(--tb-text-2); margin-bottom: 4px; }
.tb-stat__value { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tb-stat__note  { font-size: 12px; color: var(--tb-text-2); margin-top: 2px; }

/* --- Buttons ------------------------------------------------------------ */
.tb-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: var(--tb-touch);
  padding: 10px 16px;
  border-radius: var(--tb-radius-sm);
  border: 1px solid var(--tb-border);
  background: var(--tb-surface);
  color: var(--tb-text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.tb-btn:hover { background: #F8FAFC; }
.tb-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tb-btn--primary { background: var(--tb-indigo-btn); border-color: var(--tb-indigo-btn); color: #fff; }
.tb-btn--primary:hover { background: var(--tb-indigo-dark); border-color: var(--tb-indigo-dark); }

.tb-btn--quiet { background: transparent; border-color: transparent; color: var(--tb-text-2); }
.tb-btn--quiet:hover { background: #F1F5F9; color: var(--tb-text); }

.tb-btn--danger { background: var(--tb-surface); border-color: #FCA5A5; color: var(--tb-fail); }
.tb-btn--danger:hover { background: var(--tb-fail-bg); }

.tb-btn--block { width: 100%; }

/* Verdict buttons — phone-first, at least 56px high. */
.tb-verdicts { display: grid; gap: 10px; }
.tb-verdict {
  min-height: var(--tb-touch-lg);
  font-size: 16px; font-weight: 600;
  border-radius: var(--tb-radius-sm);
  border: 1.5px solid;
  cursor: pointer;
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.tb-verdict--pass    { color: var(--tb-pass);    border-color: var(--tb-pass);    background: var(--tb-pass-bg); }
.tb-verdict--fail    { color: var(--tb-fail);    border-color: var(--tb-fail);    background: var(--tb-fail-bg); }
.tb-verdict--blocked { color: var(--tb-blocked); border-color: var(--tb-blocked); background: var(--tb-blocked-bg); }
.tb-verdict[aria-pressed="true"] { box-shadow: inset 0 0 0 2px currentColor; }

/* --- Chips -------------------------------------------------------------- */
.tb-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--tb-radius-pill);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  background: #F1F5F9; color: var(--tb-text-2);
}
/* Verdicts — the word is the signal; colour only supports it. */
.tb-chip--pass    { background: var(--tb-pass-bg);    color: var(--tb-pass); }
.tb-chip--fail    { background: var(--tb-fail-bg);    color: var(--tb-fail); }
.tb-chip--blocked { background: var(--tb-blocked-bg); color: var(--tb-blocked); }
.tb-chip--notrun  { background: #F1F5F9;              color: var(--tb-text-2); }
/* Severity */
.tb-chip--p1 { background: var(--tb-p1-bg); color: var(--tb-p1); }
.tb-chip--p2 { background: var(--tb-p2-bg); color: var(--tb-p2); }
.tb-chip--p3 { background: var(--tb-p3-bg); color: var(--tb-p3); }
/* Review verdict */
.tb-chip--ready       { background: var(--tb-pass-bg);    color: var(--tb-pass); }
.tb-chip--ready-notes { background: var(--tb-blocked-bg); color: var(--tb-blocked); }
.tb-chip--not-ready   { background: var(--tb-fail-bg);    color: var(--tb-fail); }
/* Source */
.tb-chip--agent { background: var(--tb-indigo-tint); color: var(--tb-indigo-btn); }

/* --- Agent badge: every Claude-made thing carries this ------------------ */
.tb-agent-badge {
  background: var(--tb-agent-bg);
  border: 1px solid var(--tb-agent-border);
  border-radius: var(--tb-radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--tb-text-2);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
}
.tb-agent-badge__who { font-weight: 600; color: var(--tb-text); }
.tb-agent-badge dt { display: inline; font-weight: 500; }
.tb-agent-badge dd { display: inline; margin: 0 0 0 4px; font-family: var(--tb-mono); }

/* --- Key marker: human-only actions ------------------------------------- */
.tb-key {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  color: var(--tb-indigo-btn);
  background: var(--tb-indigo-tint);
  border-radius: var(--tb-radius-pill);
  padding: 3px 10px;
}
.tb-key__note { font-weight: 500; color: var(--tb-text-2); background: none; padding: 0; }

/* --- Fix loop strip: New > Confirmed > Fix ready > Retest > Closed ------- */
.tb-loop { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; list-style: none; margin: 0; padding: 0; }
.tb-loop li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--tb-text-2); }
.tb-loop li + li::before { content: ''; width: 14px; height: 1px; background: var(--tb-border); }
.tb-loop__step { padding: 4px 10px; border-radius: var(--tb-radius-pill); background: #F1F5F9; font-weight: 500; }
.tb-loop li[aria-current="step"] .tb-loop__step {
  background: var(--tb-indigo-tint); color: var(--tb-indigo-btn); font-weight: 600;
}
.tb-loop li[data-done="true"] .tb-loop__step { color: var(--tb-text); }

/* --- Passport header: confidence ring ----------------------------------- */
.tb-ring { display: inline-grid; place-items: center; width: 92px; height: 92px; position: relative; }
.tb-ring svg { transform: rotate(-90deg); width: 92px; height: 92px; }
.tb-ring__track { stroke: var(--tb-border); stroke-width: 8; fill: none; }
.tb-ring__fill  { stroke: var(--tb-indigo); stroke-width: 8; fill: none; stroke-linecap: round; }
.tb-ring__fill--under { stroke: var(--tb-fail); }
.tb-ring__text { position: absolute; text-align: center; }
.tb-ring__score { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tb-ring__bar   { font-size: 11px; color: var(--tb-text-2); }

/* --- Tables: wide tables scroll inside their own box -------------------- */
.tb-tablebox { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tb-table th, .tb-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--tb-border-soft); vertical-align: top; }
.tb-table th {
  font-size: 12px; font-weight: 600; color: var(--tb-text-2);
  text-transform: uppercase; letter-spacing: 0.04em;
  background: #F8FAFC; white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.tb-table tbody tr:hover { background: #FAFBFD; }
.tb-table td.tb-num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Forms -------------------------------------------------------------- */
.tb-field { display: block; margin-bottom: var(--tb-gap); }
/* A field standing in a filter row: share the width, don't push the row about.
   Nine pages ask for this class, so it belongs in the system, not in a page. */
.tb-filter { flex: 1 1 200px; min-width: 0; margin-bottom: 0; }
.tb-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.tb-hint  { font-size: 12px; color: var(--tb-text-2); margin-top: 4px; }
.tb-input, .tb-select, .tb-textarea {
  width: 100%;
  font-family: inherit; font-size: 15px;
  min-height: var(--tb-touch);
  padding: 10px 12px;
  border: 1px solid var(--tb-border);
  border-radius: var(--tb-radius-sm);
  background: var(--tb-surface);
  color: var(--tb-text);
}
.tb-textarea { min-height: 96px; resize: vertical; }
.tb-input:focus, .tb-select:focus, .tb-textarea:focus { border-color: var(--tb-indigo); }
.tb-input[aria-invalid="true"] { border-color: var(--tb-fail); }

/* --- States: every list has empty, loading and error -------------------- */
.tb-state { text-align: center; padding: 40px 20px; color: var(--tb-text-2); }
.tb-state__title { font-weight: 600; color: var(--tb-text); margin-bottom: 4px; }
.tb-state--error { color: var(--tb-fail); }
.tb-skeleton {
  height: 14px; border-radius: 4px;
  background: #EEF1F5;
  animation: tb-pulse 1.4s ease-in-out infinite;
}
@keyframes tb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .tb-skeleton { animation: none; } }

/* --- Sticky save bar (phone run screen) -------------------------------- */
.tb-sticky-save {
  position: sticky; bottom: 0;
  background: var(--tb-surface);
  border-top: 1px solid var(--tb-border);
  padding: 12px var(--tb-pad);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  margin: var(--tb-gap) calc(var(--tb-pad) * -1) 0;
}

/* --- On the navy bar ----------------------------------------------------
   .tb-btn--quiet is #475569, which measures 7.02:1 on the #F5F6FA page ground
   but only 2.36:1 on navy - well under 4.5:1. Anything quiet sitting in the top
   bar uses these instead. Raised by worker-2, 2026-10-08; ratios measured, not
   estimated. */
.tb-topbar .tb-btn--quiet,
.tb-btn--onnavy {
  color: #CBD5E1;                    /* 12.02:1 on #0F172A */
  background: transparent;
  border-color: transparent;
}
.tb-topbar .tb-btn--quiet:hover,
.tb-btn--onnavy:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.10);
}
.tb-topbar .tb-btn {                 /* an outlined button on navy */
  border-color: rgba(255, 255, 255, 0.22);
  background: transparent;
  color: #E2E8F0;
}
.tb-topbar .tb-btn:hover { background: rgba(255, 255, 255, 0.10); color: #fff; }
.tb-topbar .tb-btn--primary {
  background: var(--tb-indigo-btn);
  border-color: var(--tb-indigo-btn);
  color: #fff;
}
.tb-topbar :focus-visible { outline-color: #fff; }

/* --- Sign in ------------------------------------------------------------
   One centred column. No top bar on this page, so the logo runs dark. */
.tb-signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--tb-pad);
}
.tb-signin__box { width: 100%; max-width: 420px; }
.tb-signin__head { text-align: center; margin-bottom: var(--tb-gap); }
.tb-signin__head .tb-logo { justify-content: center; margin-bottom: 10px; }
.tb-signin__tag { font-size: 13px; color: var(--tb-text-2); margin: 0; }
.tb-signin__foot {
  text-align: center; margin-top: var(--tb-gap);
  font-size: 12px; color: var(--tb-text-2);
}

/* The logo is white for the navy bar; this is the version for light ground. */
.tb-logo--dark { color: var(--tb-text); }

/* --- Toast --------------------------------------------------------------
   Lives above everything, announces itself to screen readers, and never
   blocks the sticky Save bar on a phone. */
.tb-toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.tb-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--tb-radius-sm);
  border: 1px solid var(--tb-border);
  background: var(--tb-surface);
  color: var(--tb-text);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.13);
  animation: tb-toast-in 160ms ease-out;
}
.tb-toast--pass  { border-color: var(--tb-pass);    background: var(--tb-pass-bg);    color: var(--tb-pass); }
.tb-toast--fail  { border-color: var(--tb-fail);    background: var(--tb-fail-bg);    color: var(--tb-fail); }
.tb-toast--busy  { border-color: var(--tb-indigo);  background: var(--tb-indigo-tint); color: var(--tb-indigo-btn); }
.tb-toast__close {
  margin-left: 4px; border: 0; background: none; cursor: pointer;
  color: inherit; font-size: 15px; line-height: 1; padding: 2px 4px;
  min-height: auto;
}
@keyframes tb-toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tb-toast { animation: none; } }

/* --- Utilities ---------------------------------------------------------- */
.tb-muted  { color: var(--tb-text-2); }
.tb-small  { font-size: 12px; }
.tb-right  { margin-left: auto; }
.tb-nowrap { white-space: nowrap; }
.tb-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Phone: 360-390px, one case per screen ----------------------------- */
@media (max-width: 480px) {
  :root { --tb-pad: 16px; --tb-gap: 12px; }
  body { font-size: 15px; }
  h1 { font-size: 20px; }
  .tb-main { padding: var(--tb-pad); }
  .tb-stat__value { font-size: 24px; }
  .tb-card { border-radius: var(--tb-radius-sm); }
  .tb-btn { width: 100%; }
  .tb-row > .tb-btn { width: auto; }
}

@media print {
  .tb-topbar, .tb-sticky-save, .tb-btn { display: none !important; }
  body { background: #fff; }
  .tb-card { border-color: #CBD5E1; }
}
