/* Mr Producer: design system.
 *
 * One place for colour, type, spacing, and every component. Screens compose
 * these; screens do not invent their own styles.
 *
 * Principles, in the order they win arguments:
 *   1. The work comes first. This is an operational tool, not a showcase.
 *   2. Restraint. Whitespace, weight and position before borders and colour.
 *   3. One accent, used only for things you can act on.
 *   4. A box means "this is a separate object", not "this is content".
 *   5. Nothing below 13px that a person has to read.
 *
 * The brand appears in exactly two places: the accent, which is the panto
 * magenta darkened until it is legible, and the wordmark. That is the whole
 * of it. Everything else is neutral so the figures can be read.
 */

/* ============================================================== tokens == */
:root {
  /* Neutrals, warmed very slightly so the app does not read as clinical. */
  --bg:#F4F3F1;
  --surface:#FFFFFF;
  --surface-2:#FAF9F7;
  --surface-sunk:#ECEAE6;
  --line:rgba(23,20,28,.10);
  --line-strong:rgba(23,20,28,.18);

  --text:#1A171F;
  --text-2:#5B5664;   /* 6.4:1 on the page. Anything a person reads uses this. */
  --text-3:#8A8492;   /* 3.3:1. Shapes and dividers only, never words. */
  --text-on-accent:#FFFFFF;

  /* One accent: the show's magenta, darkened to 7:1 on white. */
  --accent:#8E24AA;
  --accent-press:#6F1A86;
  --accent-wash:#F6EAF9;
  --accent-line:rgba(142,36,170,.30);

  /* Semantic. Never the only signal: always paired with a word or a shape. */
  --ok:#15703F;      --ok-wash:#E3F2E8;
  --warn:#8A5300;    --warn-wash:#FBEFD9;
  --bad:#B3261E;     --bad-wash:#FBE9E7;
  --info:#1B5E9E;    --info-wash:#E6F0F9;

  /* The one piece of show gold left, for the ticket rail and the wordmark. */
  --gold:#C98A12;

  /* Type. Six styles, no more. */
  --font:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-brand:"Bebas Neue", var(--font);
  /* Sized in rem so the whole scale follows the reader's own browser setting.
     Spacing stays in px: the layout should not treble in size because
     somebody asked for larger text. */
  --fs-title:1.625rem;  --lh-title:1.15;   --fw-title:700;
  --fs-section:1.0625rem; --lh-section:1.25; --fw-section:600;
  --fs-body:1rem;       --lh-body:1.45;
  --fs-sub:0.875rem;    --lh-sub:1.4;
  --fs-meta:0.8125rem;  --lh-meta:1.35;
  --fs-label:0.6875rem; --ls-label:.06em;

  /* Spacing: 4px base, eight steps, nothing off-scale. */
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px;
  --sp-5:20px; --sp-6:24px; --sp-7:32px; --sp-8:48px;

  /* Shape: four sizes and a pill, and nothing in between. A radius that is
     not one of these is a mistake, not a decision. */
  --r-xs:4px; --r-sm:8px; --r-control:10px; --r-group:12px; --r-sheet:16px; --r-pill:999px;
  --r-focus:6px;
  --icon:24px; --icon-sm:20px; --icon-xs:18px;
  --shadow-1:0 1px 2px rgba(23,20,28,.06);
  --shadow-2:0 8px 28px rgba(23,20,28,.14);

  --col-value:104px; --col-owner:132px; --col-state:124px;
  --rail-compact:80px; /* the tablet rail: icons and a word, no more */
  --tap:48px;       /* the primary controls */
  --tap-min:44px;   /* the smallest anything gets: Apple's floor */
  --nav-h:56px;   /* bottom tab bar */
  --rail-w:232px; /* desktop sidebar */
  --dur:200ms;
  --ease:cubic-bezier(.2,.7,.3,1);
  color-scheme: light;
}

/* Dark mode is designed, not inverted: the greys are built from the same warm
   hue, and the accent is lifted rather than the background simply flipped. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#131116; --surface:#1D1A21; --surface-2:#232029; --surface-sunk:#17151B;
    --line:rgba(255,255,255,.10); --line-strong:rgba(255,255,255,.18);
    --text:#F3F1F5; --text-2:#B5AFBC; --text-3:#8B8494;
    --accent:#D486EC; --accent-press:#E7B4F5; --accent-wash:#2C1C33;
    --accent-line:rgba(212,134,236,.35); --text-on-accent:#26102E;
    --ok:#5BD08A; --ok-wash:#14301F; --warn:#E2AE5A; --warn-wash:#332711;
    --bad:#F2877F; --bad-wash:#341814; --info:#7CB5EA; --info-wash:#132635;
    --gold:#E2AE5A;
    --shadow-1:0 1px 2px rgba(0,0,0,.4); --shadow-2:0 8px 28px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
[data-theme="dark"] {
  --bg:#131116; --surface:#1D1A21; --surface-2:#232029; --surface-sunk:#17151B;
  --line:rgba(255,255,255,.10); --line-strong:rgba(255,255,255,.18);
  --text:#F3F1F5; --text-2:#B5AFBC; --text-3:#8B8494;
  --accent:#D486EC; --accent-press:#E7B4F5; --accent-wash:#2C1C33;
  --accent-line:rgba(212,134,236,.35); --text-on-accent:#26102E;
  --ok:#5BD08A; --ok-wash:#14301F; --warn:#E2AE5A; --warn-wash:#332711;
  --bad:#F2877F; --bad-wash:#341814; --info:#7CB5EA; --info-wash:#132635;
  --gold:#E2AE5A;
  --shadow-1:0 1px 2px rgba(0,0,0,.4); --shadow-2:0 8px 28px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ============================================================== base ==== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--fs-body); line-height: var(--lh-body);
  overscroll-behavior-y: none; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: var(--fw-section); line-height: var(--lh-section); }
p { margin: 0 0 var(--sp-3); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-focus); }
.num { font-variant-numeric: tabular-nums; }
.vis-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* Someone who has asked their system for less transparency gets a solid bar
   rather than a blurred one. The separation is then carried by the border. */
@media (prefers-reduced-transparency: reduce) {
  .tabbar { background: var(--surface); backdrop-filter: none; }
  .scrim { background: rgba(23, 20, 28, .72); }
}

/* ============================================================== shell === */
.app { display: grid; min-height: 100dvh; grid-template-rows: 1fr auto; }

/* Desktop navigation: a persistent rail, so the whole application is visible
   and nothing important hides behind a menu. */
.rail { display: none; }
.rail-brand {
  font-family: var(--font-brand); font-size: 24px; letter-spacing: .04em;
  color: var(--gold); padding: var(--sp-5) var(--sp-4) var(--sp-2);
}
.rail-brand small {
  display: block; font-family: var(--font); font-size: var(--fs-meta);
  letter-spacing: 0; color: var(--text-2); font-weight: 500;
}
.rail nav { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2); }
.rail nav button {
  display: flex; align-items: center; gap: var(--sp-3);
  background: none; border: 0; border-radius: var(--r-control);
  padding: var(--sp-3); min-height: 44px; cursor: pointer;
  font-size: var(--fs-sub); font-weight: 500; color: var(--text-2); text-align: left;
}
.rail nav button:hover { background: var(--surface-sunk); color: var(--text); }
.rail nav button[aria-current="page"] { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.rail nav button .count {
  margin-left: auto; background: var(--bad); color: #fff; border-radius: var(--r-pill);
  font-size: var(--fs-label); min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.rail nav button[aria-current="page"] .count { background: var(--accent); }

/* Mobile navigation: a bottom tab bar within thumb reach. */
.tabbar {
  position: sticky; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  position: relative; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-height: var(--nav-h); color: var(--text-2);
  font-size: var(--fs-label); font-weight: 600; letter-spacing: .01em;
}
.tabbar button[aria-current="page"] { color: var(--accent); }
.tabbar .count {
  position: absolute; top: 6px; left: calc(50% + 6px);
  background: var(--bad); color: #fff; border-radius: var(--r-pill);
  font-size: 10px; min-width: 17px; height: 17px; padding: 0 5px;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.icon { width: var(--icon); height: var(--icon); flex: none; stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon.xs { width: var(--icon-xs); height: var(--icon-xs); }

/* ============================================================== page ==== */
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { max-width: 720px; margin: 0 auto; padding: var(--sp-4) var(--sp-4) var(--sp-8); }
.page[hidden] { display: none; }

/* Page header: where am I, what matters, what is the main action. */
.page-head { margin-bottom: var(--sp-5); }
.page-head .eyebrow {
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-2); margin-bottom: var(--sp-1);
}
.page-head h1 { font-size: var(--fs-title); font-weight: var(--fw-title); line-height: var(--lh-title); }
.page-head .lede { color: var(--text-2); font-size: var(--fs-sub); margin-top: var(--sp-2); }
/* One actions strip, used wherever buttons sit in a line. Context adds the
   margin; the strip itself is the same everywhere. */
.acts { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.page-head .acts { margin-top: var(--sp-4); }

/* Section: a label and breathing room, not another box. */
.section { margin-top: var(--sp-7); }
.section:first-of-type { margin-top: var(--sp-5); }
.section > header { display: flex; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-2); padding: 0 var(--sp-1); }
.section > header h2 {
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-2);
}
.section > header .aside { margin-left: auto; font-size: var(--fs-meta); color: var(--text-2); }
.section > header .aside button {
  background: none; border: 0; color: var(--accent); font-size: var(--fs-meta);
  font-weight: 600; cursor: pointer; padding: var(--sp-1) var(--sp-2); min-height: 32px;
}
.section .note { padding: var(--sp-2) var(--sp-1) 0; font-size: var(--fs-meta); color: var(--text-2); }

/* ======================================================= grouped list === */
/* The workhorse. Anything that is a set of things uses this. */
.group {
  background: var(--surface); border-radius: var(--r-group);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.group + .group { margin-top: var(--sp-3); }
.row {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; min-height: var(--tap); padding: var(--sp-3) var(--sp-4);
  background: none; border: 0; text-align: left; color: inherit;
  position: relative;
}
.row + .row::before {
  content: ""; position: absolute; top: 0; left: var(--sp-4); right: 0;
  height: 1px; background: var(--line);
}
.row.tappable { cursor: pointer; }
.row.tappable:hover { background: var(--surface-2); }
.row.tappable:active { background: var(--surface-sunk); }
.row .lead { flex: none; color: var(--text-3); display: flex; }
/* Title over sub, always. Left inline they read as one run-on sentence on a
   wide screen, which is exactly where there is most room to separate them. */
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .title { display: block; font-size: var(--fs-body); line-height: 1.3; }
.row .sub { display: block; font-size: var(--fs-meta); color: var(--text-2); margin-top: 2px; line-height: var(--lh-meta); }
.row .value, .list-head .value {
  flex: none; width: var(--col-value); text-align: right;
  color: var(--text-2); font-size: var(--fs-body); font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row .value.strong { color: var(--text); font-weight: 600; }
/* An owner column on a wide screen, folded into the line beneath on a narrow
   one, so the same list works on a phone and at a desk. */
.list-head {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4) var(--sp-2);
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-2);
}
.list-head .main { flex: 1; min-width: 0; }

.list-head .spacer { width: 18px; flex: none; }

.col-owner {
  display: flex; justify-content: flex-end; align-items: center;
  flex: none; width: var(--col-owner); text-align: right; color: var(--text-2);
  font-size: var(--fs-sub); white-space: nowrap; overflow: hidden;
}
.col-state {
  display: flex; justify-content: flex-end; align-items: center;
  flex: none; width: var(--col-state); text-align: right; color: var(--text-2);
  font-size: var(--fs-sub); white-space: nowrap; overflow: hidden;
}
.list-head .col-state { justify-content: flex-end; }

/* The bell. A dot, not a number, until there is something to count. */
.bell { position: relative; flex: none; }
.bell .dot {
  position: absolute; top: 4px; right: 4px;
  min-width: 17px; height: 17px; padding: 0 var(--sp-1); border-radius: var(--r-pill);
  background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}
.note-row .when { color: var(--text-2); font-size: var(--fs-meta); }

/* The only text utilities. Semantic, not decorative: they say what a piece of
   text means, never what colour somebody fancied. */
.t-bad { color: var(--bad); }
.t-bad-strong { color: var(--bad); font-weight: 600; }
.t-ok-strong { color: var(--ok); font-weight: 600; }
.t-muted { color: var(--text-2); }
.t-warn-strong { color: var(--warn); font-weight: 600; }
.t-ok { color: var(--ok); }
.t-dim { color: var(--text-3); }
.t-done { text-decoration: line-through; color: var(--text-3); }

/* A group used as a plain panel of prose rather than a list of rows. */
.group.panel { padding: var(--sp-4); }

/* A readout that stays in view while a long list scrolls under it. */
.readout.sticky { position: sticky; top: 0; z-index: 10; }

/* The milestone tick. A real target, not a 20px dot. */
.tick { width: var(--tap-min); height: var(--tap-min); }

/* Ticket prices in What if: one row a tier, three prices across. */
.price-grid {
  display: grid; grid-template-columns: auto repeat(3, 1fr);
  gap: var(--sp-2); align-items: center; margin-top: var(--sp-3);
}
.price-grid input { min-height: 42px; text-align: right; padding: 0 var(--sp-2); }

/* An input that holds a small number and should not stretch to the row. */
.input.narrow, input.narrow { width: 110px; text-align: right; }

/* A switch used as a row control carries no target of its own: the row is
   the target. */
.switch.inline-control { min-height: auto; }

textarea.tall { min-height: 140px; }

/* Spacing utilities, on the same 4px scale as everything else, for the few
   places a component cannot own its own margin. */
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-4 { margin-bottom: var(--sp-4); }

/* A heading inside a sheet: the record's own name, then what it is. */
.sheet .lead-title { font-size: var(--fs-title); font-weight: var(--fw-title); line-height: var(--lh-title); }
.sheet .lead-sub { color: var(--text-2); font-size: var(--fs-sub); margin-top: var(--sp-1); }
.row.warn-row .lead { color: var(--warn); }
.row .lead .icon { width: 20px; height: 20px; }
.note-row.unread .title::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: var(--sp-2); vertical-align: middle;
}
.only-wide { display: none; }
@media (min-width: 700px) {
  .only-wide { display: inline-flex; }
  .only-narrow { display: none; }
}
.row .chev { flex: none; width: 18px; display: flex; align-items: center; color: var(--text-3); }
.row .chev .icon { width: 18px; height: 18px; stroke-width: 2; }
.row.danger .title { color: var(--bad); }
.row.inset-full + .row::before { left: 0; }

/* A row that carries a control keeps the control at the trailing edge. */
.row .control { flex: none; display: flex; align-items: center; gap: var(--sp-2); }
.row select.inline, .row input.inline {
  min-height: var(--tap-min); padding: 0 var(--sp-2); font-size: var(--fs-sub);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  color: var(--text); max-width: 150px;
}

/* ============================================================= metrics = */
/* Figures presented as a read-out, not as a wall of cards. */
.readout { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border-radius: var(--r-group); overflow: hidden; box-shadow: var(--shadow-1); }
.readout > div { background: var(--surface); padding: var(--sp-3) var(--sp-4) var(--sp-4); }
.readout .k { font-size: var(--fs-meta); color: var(--text-2); }
.readout .v { font-size: 24px; font-weight: 600; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.readout .m { font-size: var(--fs-meta); color: var(--text-2); margin-top: 2px; }
.readout .v.bad { color: var(--bad); } .readout .v.ok { color: var(--ok); } .readout .v.warn { color: var(--warn); }
@media (min-width: 560px) { .readout { grid-template-columns: repeat(4, 1fr); } }

/* The single headline figure at the top of Today. It sits inside a group, so
   it carries the group's own padding rather than a screen telling it to. */
.headline { padding: var(--sp-4); }
.headline .big {
  font-size: 44px; font-weight: 700; line-height: 1; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.headline .of { font-size: var(--fs-sub); color: var(--text-2); margin-top: var(--sp-2); }

/* Progress rail: sold, forecast and the target, in one line. */
.rail-bar { margin-top: var(--sp-3); }
.rail-bar .track { position: relative; height: 8px; border-radius: var(--r-xs); background: var(--surface-sunk); overflow: hidden; }
.rail-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--gold); border-radius: var(--r-xs); }
.rail-bar .ghost { position: absolute; top: 0; bottom: 0; background: var(--gold); opacity: .28; }
.rail-bar .mark { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-2); }
.rail-bar .mark.bad { background: var(--bad); }
.rail-bar .keys { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); font-size: var(--fs-meta); color: var(--text-2); }
.rail-bar .keys b { color: var(--text); font-variant-numeric: tabular-nums; }
.rail-bar .keys i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ============================================================ buttons == */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-5); border: 0; border-radius: var(--r-control);
  font-size: var(--fs-sub); font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--text-on-accent);
  transition: background var(--dur) var(--ease);
}
.btn:hover { background: var(--accent-press); }
/* A pressed state every variant inherits, so a tap is acknowledged before
   anything else has had time to happen. */
.btn:active { filter: brightness(.94); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.secondary { background: var(--surface); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line); }
.btn.secondary:hover { background: var(--accent-wash); }
.btn.only-icon { padding: 0; width: var(--tap); min-width: var(--tap); }

.call-row {
  display: grid; gap: var(--sp-2); margin-bottom: var(--sp-3);
  grid-template-columns: 84px 1fr 44px; align-items: center;
}
.call-row input[name="ct"] { grid-column: 1; grid-row: 1; }
.call-row input[name="cw"] { grid-column: 2; grid-row: 1; }
.call-row input[name="cf"] { grid-column: 1 / span 2; grid-row: 2; }
.call-row .btn { grid-column: 3; grid-row: 1 / span 2; color: var(--text-3); }
@media (min-width: 700px) {
  .call-row { grid-template-columns: 84px 200px 1fr 44px; }
  .call-row input[name="cf"] { grid-column: 3; grid-row: 1; }
  .call-row .btn { grid-column: 4; grid-row: 1; }
}
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* A receipt photograph on a spend sheet. Big enough to read a total off,
   small enough not to take the screen. */
.receipt {
  border: 1px dashed var(--line-strong); border-radius: var(--r-control);
  padding: var(--sp-3); text-align: center; background: var(--bg);
}
.receipt img {
  display: block; width: 100%; max-height: 320px;
  object-fit: contain; border-radius: var(--r-sm); background: #fff;
}
.receipt .acts { justify-content: center; margin-top: var(--sp-3); }
.receipt .hint { margin-top: var(--sp-2); }

/* A month heading inside a long list, so a register of seventy payments can
   still be read down. */
.pay-month {
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-2);
  border-top: 1px solid var(--line);
}
.group > .pay-month:first-child { border-top: 0; padding-top: var(--sp-2); }

/* Looking at somebody else's app. Deliberately unlike everything else, so it
   is never mistaken for part of the app it is sitting on top of. */
.preview-bar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-4);
  background: var(--text); color: var(--surface);
  font-size: var(--fs-meta); line-height: var(--lh-meta);
}
.preview-bar b { color: var(--surface); }
.preview-bar .btn { background: var(--surface); color: var(--text); flex: none; }
.preview-bar .btn:hover { background: var(--surface-2); }
@media (min-width: 600px) { .preview-bar { padding: var(--sp-2) var(--sp-5); } }

/* The countdown. Four cells that tick, large enough to be read across a
   rehearsal room, with the detail kept quiet underneath. */
.countdown {
  background: var(--surface); border-radius: var(--r-group);
  box-shadow: var(--shadow-1); padding: var(--sp-4) var(--sp-4) var(--sp-3);
  margin-bottom: var(--sp-4);
}
.countdown .clock {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2); text-align: center;
}
.countdown .clock > div { min-width: 0; }
.countdown .clock b {
  display: block; font-size: 34px; font-weight: 700; line-height: 1.05;
  letter-spacing: -0.02em; color: var(--accent); font-variant-numeric: tabular-nums;
}
.countdown .clock span {
  display: block; margin-top: 2px;
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-2);
}
.countdown .w { margin-top: var(--sp-3); }
.countdown .w b { display: block; font-size: var(--fs-sub); line-height: 1.3; }
.countdown .w span { display: block; color: var(--text-2); font-size: var(--fs-meta); margin-top: 2px; }
.countdown.done .w b { font-size: var(--fs-body); }
@media (min-width: 700px) {
  .countdown { padding: var(--sp-5) var(--sp-5) var(--sp-4); }
  .countdown .clock b { font-size: 46px; }
}
.btn.tertiary { background: none; color: var(--accent); padding: 0 var(--sp-2); }
.btn.tertiary:hover { background: var(--accent-wash); }

/* Destructive, and quiet with it. A delete should be findable and never the
   brightest thing on the screen. */
.btn.danger { background: none; color: var(--bad); }
.btn.danger:hover { background: var(--bad-wash); }

/* A back button sits flush with the title above it rather than indented by
   its own padding. */
.btn.back { margin-left: calc(var(--sp-2) * -1); }

/* Block buttons inside a sheet space themselves, so no screen has to say how
   far apart its own buttons should be. */
.sheet .content > .btn.block { margin-top: var(--sp-4); }
.sheet .content > .btn.block + .btn.block { margin-top: var(--sp-2); }
.btn.destructive { background: var(--bad); color: #fff; }
.btn.destructive:hover { filter: brightness(.9); }
.btn.quiet { background: var(--surface-sunk); color: var(--text); }
.btn.quiet:hover { background: var(--line); }
.btn.sm { min-height: var(--tap-min); padding: 0 var(--sp-3); font-size: var(--fs-meta); }
.btn.block { width: 100%; }
.btn .icon { width: 20px; height: 20px; }

.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  background: none; border: 0; border-radius: var(--r-control); cursor: pointer; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--text); }

/* ============================================================= status == */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px var(--sp-2); border-radius: 6px;
  font-size: var(--fs-meta); font-weight: 600; line-height: 1.3;
}
.badge.ok { background: var(--ok-wash); color: var(--ok); }
.badge.warn { background: var(--warn-wash); color: var(--warn); }
.badge.bad { background: var(--bad-wash); color: var(--bad); }
.badge.info { background: var(--info-wash); color: var(--info); }
.badge.neutral { background: var(--surface-sunk); color: var(--text-2); }
/* A shape as well as a colour, so status never depends on colour alone. */
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.badge.squareish::before { border-radius: 2px; }

/* ============================================================= notice == */
/* Something that needs attention. One line of what, one of why, then the act. */
.notice {
  display: flex; gap: var(--sp-3); padding: var(--sp-4);
  background: var(--surface); border-radius: var(--r-group);
  box-shadow: var(--shadow-1); border-left: 3px solid var(--info);
}
.notice + .notice { margin-top: var(--sp-3); }
.notice.warn { border-left-color: var(--warn); }
.notice.bad { border-left-color: var(--bad); }
.notice .icon { color: var(--info); }
.notice.warn .icon { color: var(--warn); }
.notice.bad .icon { color: var(--bad); }
.notice .body { flex: 1; min-width: 0; }
.notice h3 { font-size: var(--fs-body); font-weight: 600; line-height: 1.3; }
.notice p { font-size: var(--fs-sub); color: var(--text-2); margin: var(--sp-1) 0 0; }
.notice .acts { margin-top: var(--sp-3); }

details.disclose > summary {
  list-style: none; cursor: pointer; color: var(--accent);
  font-size: var(--fs-meta); font-weight: 600; padding: var(--sp-2) 0;
  display: flex; align-items: center; gap: 4px; min-height: 36px;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::after { content: "⌄"; font-size: 14px; line-height: 1; }
details.disclose[open] > summary::after { content: "⌃"; }
details.disclose .inner { font-size: var(--fs-sub); color: var(--text-2); padding-bottom: var(--sp-2); }

/* ============================================================== forms == */
.field { margin-bottom: var(--sp-4); }
.field > label { display: block; font-size: var(--fs-sub); font-weight: 600; margin-bottom: var(--sp-2); }
.field .hint { font-size: var(--fs-meta); color: var(--text-2); margin-top: var(--sp-2); }
.field .err { font-size: var(--fs-meta); color: var(--bad); margin-top: var(--sp-2); font-weight: 500; }
.input, input[type="text"], input[type="number"], input[type="date"],
input[type="password"], input[type="search"], select, textarea {
  width: 100%; min-height: var(--tap); padding: var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-control);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash);
}
.field.invalid .input, .field.invalid input { border-color: var(--bad); }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
select { appearance: none; -webkit-appearance: none; padding-right: var(--sp-7);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-sunk); color: var(--text-3); }

.switch { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 50px; height: 30px; border-radius: var(--r-pill); background: var(--line-strong);
  position: relative; cursor: pointer; transition: background var(--dur) var(--ease);
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease);
}
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }

.segmented {
  display: flex; background: var(--surface-sunk); border-radius: var(--r-control);
  padding: 3px; gap: 2px;
}
.segmented button {
  flex: 1; background: none; border: 0; border-radius: var(--r-sm); cursor: pointer;
  min-height: var(--tap-min); font-size: var(--fs-sub); font-weight: 600; color: var(--text-2);
  padding: 0 var(--sp-2); min-width: 0;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
/* Four segments on a narrow phone: let the labels shrink a step rather than
   spill out of the control. */
@media (max-width: 400px) { .segmented button { font-size: var(--fs-meta); padding: 0 var(--sp-1); } }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

.slider-row { padding: var(--sp-3) var(--sp-4); position: relative; }
.slider-row + .slider-row::before { content: ""; position: absolute; top: 0; left: var(--sp-4); right: 0; height: 1px; background: var(--line); }
.slider-row .top { display: flex; align-items: baseline; gap: var(--sp-3); }
.slider-row .nm { font-size: var(--fs-sub); font-weight: 500; }
.slider-row .val { margin-left: auto; font-size: var(--fs-body); font-weight: 600; font-variant-numeric: tabular-nums; }
.slider-row .val.unset { color: var(--bad); font-size: var(--fs-meta); font-weight: 600; }
.slider-row .why { font-size: var(--fs-meta); color: var(--text-3); margin-top: var(--sp-1); }
input[type="range"] { width: 100%; margin: var(--sp-2) 0 0; height: 28px; background: none; -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.28), inset 0 0 0 1px var(--line); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%; background: var(--surface);
  border: 1px solid var(--line-strong); cursor: pointer;
}

/* ============================================================== search = */
.searchbar { position: relative; margin-bottom: var(--sp-3); }
.searchbar .icon { position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%); color: var(--text-3); width: 20px; height: 20px; }
.searchbar input { padding-left: 42px; }
.searchbar .clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: var(--tap-min);
  padding: 0 var(--sp-3); border-radius: var(--r-pill); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: var(--fs-meta); font-weight: 600; color: var(--text-2);
}
.chip:hover { border-color: var(--line-strong); background: var(--surface-2); }
.chip:active { filter: brightness(.96); }
.chip[aria-pressed="true"] { background: var(--accent-wash); border-color: var(--accent-line); color: var(--accent); }

/* ============================================================== table == */
/* Desktop only. Below 700px every table becomes a grouped list instead. */
.table-wrap { background: var(--surface); border-radius: var(--r-group); box-shadow: var(--shadow-1); overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sub); }
th, td { text-align: left; padding: var(--sp-3) var(--sp-4); }
thead th {
  position: sticky; top: 0; background: var(--surface);
  font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label);
  text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line);
}
tbody tr + tr td { border-top: 1px solid var(--line); }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line-strong); }

/* ============================================================== sheet == */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(12,10,15,.58);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; display: flex; flex-direction: column;
  animation: rise var(--dur) var(--ease);
  box-shadow: var(--shadow-2); border: 1px solid var(--line-strong); border-bottom: 0;
}
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: var(--sp-2) auto 0; flex: none; }
.sheet > header {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); flex: none;
}
.sheet > header h2 { grid-column: 2; font-size: var(--fs-section); text-align: center; white-space: nowrap; }
.sheet > header .left { justify-self: start; } .sheet > header .right { grid-column: 3; justify-self: end; }
.sheet .content { padding: var(--sp-2) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom)); overflow-y: auto; }
@media (min-width: 700px) {
  .scrim { align-items: center; }
  .sheet { border-radius: var(--r-sheet); max-height: 86dvh; animation: fade var(--dur) var(--ease); border-bottom: 1px solid var(--line-strong); }
  .sheet .grab { display: none; }
}

/* ============================================================== toast == */
.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 70; display: flex; flex-direction: column; gap: var(--sp-2);
  width: min(440px, calc(100vw - 24px));
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--text); color: var(--bg); border-radius: var(--r-control);
  padding: var(--sp-3) var(--sp-4); box-shadow: var(--shadow-2);
  font-size: var(--fs-sub); animation: rise var(--dur) var(--ease);
}
.toast .msg { flex: 1; min-width: 0; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer;
  font-size: var(--fs-sub); padding: var(--sp-1) var(--sp-2); min-height: 36px; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.bad button { color: #fff; text-decoration: underline; }
@media (min-width: 900px) { .toasts { bottom: 20px; left: calc(50% + var(--rail-w) / 2); } }

/* ====================================================== empty & loading = */
.empty { text-align: center; padding: var(--sp-7) var(--sp-4); }
.empty .icon { width: 34px; height: 34px; color: var(--text-3); margin-bottom: var(--sp-3); }
.empty h3 { font-size: var(--fs-body); font-weight: 600; }
.empty p { font-size: var(--fs-sub); color: var(--text-2); max-width: 34ch; margin: var(--sp-2) auto var(--sp-4); }

.skeleton { background: var(--surface); border-radius: var(--r-group); padding: var(--sp-4); box-shadow: var(--shadow-1); }
.sk { height: 12px; border-radius: 6px; background: var(--surface-sunk); position: relative; overflow: hidden; }
.sk + .sk { margin-top: var(--sp-3); }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ============================================================== charts = */
.chart { background: var(--surface); border-radius: var(--r-group); box-shadow: var(--shadow-1); padding: var(--sp-3); }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-3); font-size: var(--fs-meta); color: var(--text-2); }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: middle; }

.grid-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: var(--sp-2); }
.cell {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control);
  padding: var(--sp-2) var(--sp-1); text-align: center; cursor: pointer; min-height: 60px;
}
.cell:hover { border-color: var(--accent-line); }
.cell .d { font-size: var(--fs-meta); font-weight: 600; }
.cell .t { font-size: var(--fs-label); color: var(--text-3); }
.cell .v { font-size: var(--fs-sub); font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* ============================================================ desktop == */
/* Tablet: a navigation rail rather than a phone's bottom bar. Between about
   600px and 900px there is room beside the content but not enough for labels
   in a line, so the rail goes compact: icon over word, one column. */
@media (min-width: 600px) and (max-width: 899px) {
  .app { grid-template-columns: var(--rail-compact) 1fr; grid-template-rows: 1fr; }
  .rail {
    display: flex; flex-direction: column; align-items: stretch;
    background: var(--surface); border-right: 1px solid var(--line);
    height: 100dvh; position: sticky; top: 0;
  }
  .rail-brand {
    font-size: 15px; padding: var(--sp-4) var(--sp-2) var(--sp-2); text-align: center;
    line-height: 1.05;
  }
  .rail-brand small { display: none; }
  .rail nav { padding: var(--sp-1); gap: var(--sp-1); }
  .rail nav button {
    flex-direction: column; gap: 2px; padding: var(--sp-2) var(--sp-1);
    min-height: 60px; text-align: center; font-size: var(--fs-label);
    font-weight: 600; letter-spacing: .01em;
  }
  .rail nav button .count { margin-left: 0; position: absolute; top: 6px; right: 14px; }
  .rail nav button { position: relative; }
  .rail .foot { margin-top: auto; padding: var(--sp-1); border-top: 1px solid var(--line); }
  .rail .foot .row { padding: var(--sp-2); justify-content: center; }
  .rail .foot .main { display: none; }
  .tabbar { display: none; }
  .scroll { height: 100dvh; }
  .page { max-width: 760px; padding: var(--sp-6) var(--sp-5) var(--sp-8); }
  .page-head { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: var(--sp-4); }
  .page-head .acts { margin-top: 0; grid-column: 2; grid-row: 1 / span 3; }
  .toasts { left: calc(50% + var(--rail-compact) / 2); }
}

@media (min-width: 900px) {
  .app { grid-template-columns: var(--rail-w) 1fr; grid-template-rows: 1fr; }
  .rail {
    display: flex; flex-direction: column; background: var(--surface);
    border-right: 1px solid var(--line); height: 100dvh; position: sticky; top: 0;
  }
  .rail .foot { margin-top: auto; padding: var(--sp-2); border-top: 1px solid var(--line); }
  .rail .foot .row { padding: var(--sp-2) var(--sp-3); }
  .rail .foot .sub { margin-top: 1px; }
  .tabbar { display: none; }
  .scroll { height: 100dvh; }
  .page { max-width: 860px; padding: var(--sp-7) var(--sp-6) var(--sp-8); }
  .page-head { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: var(--sp-4); }
  .page-head .acts { margin-top: 0; grid-column: 2; grid-row: 1 / span 3; }
  .row { padding: var(--sp-3) var(--sp-4); }
}
@media (min-width: 1180px) {
  .page { max-width: 1000px; }
  .page.wide { max-width: 1180px; }
}
@media print {
  .rail, .tabbar, .scrim, .toasts, .btn, .icon-btn { display: none !important; }
  .page { max-width: none; padding: 0; }
  body { background: #fff; }
}
