/* KARVED HQ — design system.
   Dark navy is the default theme; [data-theme="light"] on <html> switches to the cream/white version.
   Brand palette only (navy, gold, white, warm grey, bronze, cream) plus one muted warning tone
   (#B4532A) reserved for problems and negative money. Chart colours come from the --chart-* tokens,
   which app.js / finance.js / cash.js / overview.js read at draw time. */
:root {
  --navy-deep: #0d1129;
  --navy-mid: #111828;
  --gold: #c4a44a;
  --gold-light: #e8d5a3;
  --warm-grey: #b8b0a0;
  --bronze: #6a6458;
  --warning: #b4532a;

  --bg: #0d1129;
  --surface: #111828;
  --surface-2: #151d31;
  --soft: rgba(255, 255, 255, 0.045);
  --text: #ffffff;
  --heading: #ffffff;
  --text-2: #b8b0a0;
  --text-muted: #b8b0a0;
  --text-faint: #6a6458;
  --line: rgba(232, 213, 163, 0.15);
  --line-strong: rgba(232, 213, 163, 0.26);
  --primary: #e8d5a3;
  --primary-hover: #f3e6c4;
  --primary-wash: rgba(232, 213, 163, 0.08);
  --primary-ring: rgba(232, 213, 163, 0.35);
  --accent: #c4a44a;
  --accent-light: #e8d5a3;
  --accent-text: #e8d5a3;
  --accent-ring: rgba(196, 164, 74, 0.4);
  --accent-gradient: linear-gradient(110deg, #c4a44a, #e8d5a3);
  --positive: #3cc985;
  --negative: #ef6b6b;
  --negative-ring: rgba(239, 107, 107, 0.4);
  --btn-ink: #17182a;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.18);
  --card-shadow: var(--shadow);
  --radius: 14px;
  --radius-sm: 8px;
  --gap: 18px;
  --head: 'Norwester', Impact, sans-serif;
  --body: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23E8D5A3' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");

  /* Data colours: distinct hues, checked for colour-blind separation on the navy cards. */
  --chart-1: #3987e5;        /* blue: main series */
  --chart-1-hover: #5c9df0;
  --chart-2: #d95926;        /* orange: second series, e.g. clients lost */
  --chart-2-hover: #e8743f;
  --chart-green: #199e70;
  --chart-violet: #9085e9;
  --chart-yellow: #c98500;   /* your pay on the Overview (after operating blue, fixed orange, discretionary violet) */
  --chart-muted: #6b7488;    /* grey: unknown / not recorded */
  --chart-muted-hover: #848ca0;
  --chart-grid: rgba(255, 255, 255, 0.07);
  --chart-axis: rgba(255, 255, 255, 0.18);
  --chart-wash: rgba(57, 135, 229, 0.14);
  --chart-crosshair: rgba(255, 255, 255, 0.3);
  --chart-heat-rgb: 57, 135, 229;
  --chart-heat-ink-strong: #ffffff;
  --chart-heat-ink-weak: #ffffff;
  --tooltip-bg: #080c1c;
  --tooltip-border: rgba(232, 213, 163, 0.25);
  --tooltip-text: #ffffff;
  --tooltip-body: #b8b0a0;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f5f0e8;
  --surface: #ffffff;
  --surface-2: #fbf8f2;
  --soft: rgba(24, 20, 119, 0.035);
  --text: #181477;
  --heading: #181477;
  --text-2: #57566b;
  --text-muted: #57566b;
  --text-faint: #77736b;
  --line: rgba(24, 20, 119, 0.13);
  --line-strong: rgba(24, 20, 119, 0.22);
  --primary: #181477;
  --primary-hover: #2a2596;
  --primary-wash: rgba(24, 20, 119, 0.07);
  --primary-ring: rgba(24, 20, 119, 0.35);
  --accent-text: #78601f;
  --accent-ring: rgba(164, 126, 34, 0.45);
  --positive: #12804f;
  --negative: #c63737;
  --negative-ring: rgba(198, 55, 55, 0.4);
  --shadow: 0 12px 36px rgba(24, 20, 119, 0.055);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23181477' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");

  --chart-1: #2a78d6;
  --chart-1-hover: #4a8fe0;
  --chart-2: #eb6834;
  --chart-2-hover: #f08356;
  --chart-green: #12966a;
  --chart-violet: #6250d6;
  --chart-yellow: #eda100;
  --chart-muted: #9aa1ae;
  --chart-muted-hover: #b0b6c1;
  --chart-grid: rgba(24, 20, 119, 0.09);
  --chart-axis: rgba(24, 20, 119, 0.22);
  --chart-wash: rgba(42, 120, 214, 0.1);
  --chart-crosshair: rgba(24, 20, 119, 0.35);
  --chart-heat-rgb: 42, 120, 214;
  --chart-heat-ink-strong: #ffffff;
  --chart-heat-ink-weak: #181477;
  --tooltip-bg: #181477;
  --tooltip-border: rgba(255, 255, 255, 0.2);
  --tooltip-text: #ffffff;
  --tooltip-body: #e8d5a3;
  color-scheme: light;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--body);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
  transition: background 0.2s, color 0.2s;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.app { max-width: 1500px; margin: 0 auto; padding: 26px 34px 54px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 2px 0 24px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.logo-wrap { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 10px; }
.logo { display: block; height: 42px; width: auto; }
/* Brand rule: no gold logo on light backgrounds, so in light mode it sits on a navy tile. */
:root[data-theme='light'] .logo-wrap { background: var(--navy-deep); padding: 5px; }
:root[data-theme='light'] .logo-wrap .logo { height: 32px; }
.brand-word { font-family: var(--head); font-size: 22px; line-height: 1; color: var(--heading); letter-spacing: 0.06em; text-transform: uppercase; }
.brand-sub { font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text-muted); margin-top: 5px; }
.top-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.topbar .status[hidden] { display: none; }

/* ---------- page intro ---------- */
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 30px 0 22px; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); }
h1 {
  font-family: var(--head);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  color: var(--heading);
  font-size: 34px;
  line-height: 1.05;
  margin: 7px 0 0;
}
.intro-note { color: var(--text-muted); font-size: 13px; margin-top: 8px; }
.date-control { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 5px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: 24px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: 13px 17px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--gold-light); border-bottom-color: var(--gold); }
:root[data-theme='light'] .tabs a.active { color: var(--primary); }
.tabs a:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.badge.good, .badge.demo { color: var(--accent-text); border-color: var(--accent-ring); }
.badge.warn { color: var(--negative); border-color: var(--negative-ring); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 15px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.btn-gold { background: var(--accent-gradient); border-color: var(--gold); color: var(--btn-ink); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-primary { background: var(--accent-gradient); border-color: var(--gold); color: var(--btn-ink); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 9px 12px; }
.btn-ghost:hover { border-color: var(--gold); }
.btn-ghost.unlocked { color: var(--accent-text); border-color: var(--accent-ring); }
.btn-ghost.unlocked::before { content: ''; width: 6px; height: 6px; background: var(--accent); transform: rotate(45deg); }
.btn-edit {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--primary);
  border-radius: 5px;
  padding: 3px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.btn-edit:hover { border-color: var(--gold); background: var(--primary-wash); }
.btn-table {
  flex: none;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 9px;
}
.btn-table:hover { color: var(--text); border-color: var(--gold); }
.btn-table[aria-pressed='true'] { color: var(--primary); border-color: var(--primary-ring); }
.link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.btn:focus-visible, .btn-edit:focus-visible, .btn-table:focus-visible, select:focus-visible, .seg button:focus-visible, summary:focus-visible, input:focus-visible, .link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn[disabled] { opacity: 0.5; cursor: progress; }

/* ---------- banners ---------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--soft);
  border: 1px solid var(--line);
  border-left: 2px solid var(--gold);
  padding: 11px 14px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 18px;
}
.banner > p { margin: 0; flex: 1 1 320px; }
.banner p + p { margin-top: 6px; }
.banner strong { color: var(--text); font-weight: 600; }
.banner a { color: var(--primary); }
.banner.warn { border-left-color: var(--negative); }
#banner .banner { display: block; }
.fin-status { margin-bottom: 0; }
.fin-status:empty { display: none; }

/* ---------- filters ---------- */
.filters { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 18px; }
.seg { display: inline-flex; gap: 2px; background: var(--soft); border: 1px solid var(--line); padding: 3px; border-radius: 8px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--text-muted); padding: 6px 10px; border-radius: 5px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed='true'] { background: var(--surface-2); color: var(--text); font-weight: 600; box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12); }
.select { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-faint); }
.select span { font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; font-size: 10px; }
.select select {
  appearance: none;
  background: var(--surface-2) var(--chevron) no-repeat right 11px center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 32px 8px 10px;
  color: var(--text);
  font-size: 12px;
  max-width: 230px;
}

main { transition: opacity 0.2s; }
main.loading { opacity: 0.45; pointer-events: none; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis:empty { display: none; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 18px;
  min-width: 0;
  min-height: 137px;
  display: flex;
  flex-direction: column;
}
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-faint); line-height: 1.4; }
.kpi-value {
  font-family: var(--head);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  font-size: clamp(25px, 2.5vw, 36px);
  line-height: 1;
  color: var(--heading);
  margin-top: 10px;
  overflow-wrap: anywhere;
}
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 9px; line-height: 1.55; }
.kpi-sub .delta { color: var(--text); font-weight: 600; }
.kpi-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.kpi-sub + .kpi-meta { margin-top: auto; }
.kpi > .kpi-sub:last-child { margin-bottom: 0; }
.kpi-meta span { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint); }
.kpi-meta b { color: var(--text-muted); font-weight: 500; letter-spacing: 0; }
.kpi.has-meta .kpi-sub { margin-bottom: 12px; }
.kpi.stale .kpi-label::after { content: ' · stale'; color: var(--negative); }
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }

/* ---------- cards & grid ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.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-12 { grid-column: 1 / -1; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 18px;
  min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.card h2, .card-title {
  margin: 0;
  font-family: var(--head);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--heading);
}
.card .sub { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }
.chart-box { position: relative; height: 245px; }
.chart-box.tall { height: 295px; }
.chart-box.short { height: 205px; }
.empty { display: grid; place-items: center; height: 100%; min-height: 120px; color: var(--text-muted); font-size: 13px; text-align: center; }
.section-title { font-family: var(--head); font-weight: 400; text-transform: uppercase; color: var(--heading); font-size: 17px; letter-spacing: 0.02em; margin: 30px 0 13px; }
.section-note { margin: -6px 0 14px; font-size: 12px; color: var(--text-muted); max-width: 80ch; }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 9px; }
.table-wrap:empty { border: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--soft);
  padding: 11px 13px;
  white-space: nowrap;
}
td { padding: 11px 13px; border-top: 1px solid var(--line); color: var(--text); vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted { color: var(--text-muted); }
tbody tr:hover td { background: var(--soft); }
.table-view { max-height: 360px; overflow: auto; margin-top: 4px; }
tr.selected td { background: var(--primary-wash); }
tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--gold); }
.table-tall { max-height: 540px; overflow: auto; }
.table-tall thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
td.act { text-align: right; width: 1%; }
.none { color: var(--text-faint); font-style: normal; }
.left-tag { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-text); margin-left: 6px; }
.search {
  flex: 0 1 260px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text);
}
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--negative); }
.pos { color: var(--positive); }

/* ---------- cohort heatmap ---------- */
.cohort td, .cohort th { text-align: center; padding: 0; border: 0; vertical-align: middle; background: transparent; }
.cohort th { padding: 8px 4px; }
.cohort th:first-child, .cohort td.row-head { text-align: left; padding: 0 12px 0 0; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.cohort td.size { color: var(--text-muted); font-size: 12px; padding-right: 10px; text-align: right; font-variant-numeric: tabular-nums; }
.cohort td.cell { padding: 1px; }
.cohort .cell span { display: block; min-width: 42px; padding: 7px 4px; border-radius: 4px; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.cohort tbody tr:hover td { background: transparent; }
.table-wrap:has(> .cohort) { border: 0; }
.scale { display: flex; align-items: center; gap: 10px; font-size: 12px; margin-top: 12px; color: var(--text-muted); }
.scale i { display: block; width: 140px; height: 8px; border-radius: 3px; background: linear-gradient(90deg, rgba(var(--chart-heat-rgb), 0.08), rgba(var(--chart-heat-rgb), 0.92)); }

/* ---------- data accuracy checklist ---------- */
.checklist { margin-bottom: var(--gap); }
.checklist .count {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid rgba(180, 83, 42, 0.4);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--negative);
  white-space: nowrap;
}
.checklist .count.clear { border-color: var(--accent-ring); color: var(--accent-text); }
.check-group { border-top: 1px solid var(--line); }
.check-group:first-child { border-top: 0; }
.check-group > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.check-group > summary::-webkit-details-marker { display: none; }
.check-group > summary::before {
  content: '';
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  margin-left: 2px;
}
.check-group[open] > summary::before { transform: rotate(45deg); }
.check-group > summary .title { font-weight: 600; color: var(--text); font-size: 13px; }
.check-group > summary .hint { color: var(--text-muted); font-size: 12px; }
.check-group > summary .n { margin-left: auto; font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--negative); white-space: nowrap; }
.check-group.clear > summary .n { color: var(--text-muted); }
.check-group.clear > summary { cursor: default; }
.check-group.clear > summary::before { visibility: hidden; }
.check-rows { padding: 0 0 12px 21px; }
.check-row {
  display: grid;
  grid-template-columns: 18px minmax(120px, 1.4fr) minmax(80px, 1fr) minmax(90px, 1.2fr) minmax(90px, 1.2fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.check-row:first-child { border-top: 0; }
.check-row input[type='checkbox'] { width: 16px; height: 16px; margin: 0; accent-color: var(--gold); cursor: pointer; }
.check-row .name { color: var(--text); font-weight: 500; }
.check-row .meta { color: var(--text-muted); }
.check-row .crm { color: var(--primary); font-size: 12px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.check-row .crm:hover { text-decoration: underline; }
.check-row.done .name, .check-row.done .meta { text-decoration: line-through; color: var(--text-faint); }
.check-row.done .crm { color: var(--text-faint); }
.checklist .allclear { padding: 10px 0 4px; color: var(--text-muted); font-size: 13px; }

/* ---------- data check ---------- */
details.check { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow); margin-top: 30px; }
details.check > summary { cursor: pointer; list-style: none; padding: 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
details.check > summary::-webkit-details-marker { display: none; }
details.check > summary h2 { margin: 0; font-family: var(--head); font-weight: 400; font-size: 16px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--heading); }
details.check > summary .sub { font-size: 12px; color: var(--text-muted); margin: 3px 0 0; }
details.check > summary::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--primary);
  border-bottom: 1.5px solid var(--primary);
  transform: rotate(45deg);
  transition: transform 0.2s;
}
details.check[open] > summary::after { transform: rotate(-135deg); }
.check-body { padding: 0 18px 18px; font-size: 13px; }
.check-body h3 { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-text); margin: 26px 0 10px; }
.check-body p { margin: 0 0 8px; }
.check-body ul { margin: 0; padding-left: 0; list-style: none; }
.check-body li { position: relative; padding-left: 18px; margin-bottom: 6px; }
.check-body li::before { content: ''; position: absolute; left: 2px; top: 0.65em; width: 5px; height: 5px; background: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; font-size: 12px; color: var(--text); background: var(--surface-2); }
.chip b { font-weight: 600; color: var(--text-muted); margin-left: 6px; }
.chip.churn, .chip.renew { border-color: var(--accent-ring); }
.chip.churn::after { content: 'counts as left'; margin-left: 8px; color: var(--accent-text); font-size: 11px; }
.chip.renew::after { content: 'counts as renewed'; margin-left: 8px; color: var(--accent-text); font-size: 11px; }
.flag { display: inline-block; border: 1px solid var(--accent-ring); color: var(--accent-text); border-radius: 4px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; padding: 1px 6px; }
.pipe { padding: 12px 0; border-bottom: 1px solid var(--line); }
.pipe:last-child { border-bottom: 0; }
.pipe-name { color: var(--text); font-weight: 600; }
.defs dt { color: var(--text); font-weight: 600; margin-top: 10px; }
.defs dd { margin: 2px 0 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--soft); padding: 1px 5px; border-radius: 4px; color: var(--primary); }
.foot { margin-top: 28px; font-size: 11px; color: var(--text-faint); }

/* ---------- client editor (slide-out drawer) ---------- */
.editor {
  width: min(480px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text-2);
  box-shadow: -24px 0 64px rgba(0, 0, 0, 0.25);
}
.editor[open] { animation: drawer-in 0.25s ease-out; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.editor::backdrop { background: rgba(0, 0, 0, 0.48); }
.editor form { display: flex; flex-direction: column; height: 100%; }
.unlock-dlg { width: min(420px, calc(100vw - 32px)); height: auto; max-height: calc(100dvh - 48px); margin: auto; border: 1px solid var(--line); border-radius: 16px; }
.unlock-dlg[open] { animation: none; }
.unlock-dlg form { height: auto; }
.unlock-dlg .editor-pw { padding-top: 16px; }
.editor-head { padding: 25px 25px 10px; border-bottom: 1px solid var(--line); }
.editor-head h2 { margin: 6px 0 4px; font-family: var(--head); font-weight: 400; text-transform: uppercase; font-size: 23px; color: var(--heading); }
.editor-head .sub { margin: 0 0 12px; font-size: 12px; color: var(--text-muted); }
.editor-fields { flex: 1; padding: 16px 25px 4px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.editor-field label, .editor-pw label { display: block; font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; }
.editor-field .row { display: flex; gap: 8px; align-items: center; }
.editor-field input, .editor-field select, .editor-pw input {
  flex: 1;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
}
.editor-field.changed input, .editor-field.changed select { border-color: var(--gold); background: var(--primary-wash); }
.editor-field .hint, .editor-pw .hint { margin: 5px 0 0; font-size: 12px; color: var(--text-muted); }
.editor-field .clear { flex: none; background: transparent; border: 0; color: var(--text-muted); font-size: 12px; font-weight: 600; padding: 6px 4px; }
.editor-field .clear:hover { color: var(--primary); }
.editor-pw { padding: 6px 25px 0; }
.editor-off { margin: 16px 25px 0; padding: 12px 14px; border-left: 2px solid var(--gold); background: var(--soft); border-radius: 8px; font-size: 13px; color: var(--text); }
.editor-off ol { margin: 6px 0 0; padding-left: 18px; }
.editor-msg { margin: 10px 25px 0; font-size: 13px; min-height: 1em; color: var(--text-2); }
.editor-msg.err, .notes-empty.err { color: var(--negative); }
.editor-foot { display: flex; align-items: center; gap: 10px; padding: 14px 25px 22px; border-top: 1px solid var(--line); margin-top: 12px; }
.editor-changes { margin-right: auto; font-size: 12px; color: var(--text-muted); }
.notes-block { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 4px; }
.notes-block h3 { margin: 0 0 10px; font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.notes { display: grid; gap: 10px; }
.note { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface-2); }
.note.pinned { border-color: var(--accent-ring); }
.note header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 6px; }
.note header strong { color: var(--text); font-size: 13px; }
.note-meta { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.55; color: var(--text); }
.note-text.clamped { max-height: 9.4em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.notes-empty { margin: 0; font-size: 13px; color: var(--text-muted); }
.note .link { margin-top: 6px; font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--gold);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 80;
  max-width: calc(100vw - 32px);
}

/* ---------- overview ---------- */
.stack-track { height: 17px; background: var(--soft); border-radius: 4px; overflow: hidden; display: flex; gap: 2px; margin: 6px 0 14px; }
.stack-track span { height: 100%; display: block; }
.stack-track span:first-child { border-radius: 4px 0 0 4px; }
.stack-track span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); }
.legend-item strong { color: var(--text); font-weight: 600; }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
.money-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.flow-item { border-left: 1px solid var(--line); padding-left: 12px; min-width: 0; }
.flow-item:first-child { border: 0; padding-left: 0; }
.flow-item small { display: block; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); }
.flow-item strong { display: block; font-family: var(--head); font-weight: 400; font-size: 21px; color: var(--heading); margin-top: 6px; text-transform: uppercase; }
.flow-item em { display: block; font-style: normal; font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4; }
.watch-list { display: grid; }
.watch-row { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.watch-row:first-child { padding-top: 0; }
.watch-row:last-child { border: 0; padding-bottom: 0; }
.watch-mark { color: var(--negative); font-size: 12px; font-weight: 600; line-height: 1.6; }
.watch-mark.ok { color: var(--positive); }
.watch-row strong { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.watch-row small { display: block; color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.pending-note { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.pending-note strong { color: var(--text); font-weight: 600; }
.source-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--text-faint); font-size: 11px; margin-top: 14px; }

/* ---------- finance ---------- */
.fin-explain { font-size: 13px; color: var(--text-muted); line-height: 1.7; }
.fin-explain p { margin: 0 0 10px; }
.fin-explain strong { color: var(--text); font-weight: 600; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 20px; }
.login-box { width: min(390px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 34px; box-shadow: var(--shadow); }
.login-box .logo-wrap { margin-bottom: 20px; }
.login-title { font-family: var(--head); font-weight: 400; text-transform: uppercase; font-size: 29px; line-height: 1.05; color: var(--heading); margin: 7px 0 8px; }
.login-box p { font-size: 13px; color: var(--text-muted); margin: 0 0 22px; }
.login-box input { width: 100%; padding: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--text); margin-bottom: 10px; }
.login-box .btn { width: 100%; }
.login-box .err { color: var(--negative); font-size: 13px; margin: 0 0 12px; }

.footer { padding-top: 28px; text-align: center; color: var(--text-faint); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }

/* ---------- responsive ---------- */
@media (max-width: 1050px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .span-4, .span-5, .span-6, .span-7 { grid-column: span 6; }
  .span-8 { grid-column: 1 / -1; }
  .grid-12 .span-4:last-child { grid-column: span 12; }
}
@media (max-width: 760px) {
  .grid-12 > * { grid-column: 1 / -1 !important; }
  .money-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 16px; }
  .flow-item:nth-child(3) { border: 0; padding-left: 0; }
  .check-row { grid-template-columns: 18px 1fr auto auto; }
  .check-row .meta { display: none; }
}
@media (max-width: 680px) {
  .app { padding: 16px 14px 36px; }
  .topbar { padding-bottom: 16px; }
  .brand-word { font-size: 19px; }
  .top-actions .btn { padding: 8px 10px; font-size: 11px; }
  .page-intro { align-items: flex-start; flex-direction: column; gap: 12px; padding: 22px 0 16px; }
  h1 { font-size: 29px; }
  .tabs { margin: 0 -14px 18px; padding: 0 6px; }
  .tabs a { padding: 12px 12px; }
  .kpis, .grid { gap: 10px; margin-bottom: 10px; }
  .kpi { padding: 14px; min-height: 120px; }
  .kpi-value { font-size: 26px; }
  .card { padding: 14px; border-radius: 11px; }
  .chart-box { height: 230px; }
  .chart-box.tall { height: 260px; }
  .filters { gap: 10px; }
  .select { width: 100%; justify-content: space-between; }
  .select select { max-width: none; flex: 1; }
  .card-head { flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
  .editor-foot { flex-wrap: wrap; }
  .editor-changes { flex: 1 1 100%; }
  .source-line { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 420px) {
  .kpis:not(.kpis-1) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .kpi-value { font-size: 23px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.banner-right { white-space: nowrap; font-size: 12px; color: var(--text-muted); }

/* Colour markers tying headline tiles to their chart colours */
.kpi-label .dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.watch-mark { color: var(--negative); }

/* ---------- Wio update box ---------- */
.wio-form { display: grid; gap: 10px; }
.wio-form label { display: grid; gap: 5px; font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.wio-form input { padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 14px; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.wio-form input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.wio-form .btn { margin-top: 4px; }

/* ---------- HQ fixes, coaches, admin ---------- */
.left-tag.hq-tag { color: var(--chart-1); }
.mini-select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; color: var(--text); padding: 5px 8px; font-size: 12px; }
.small { font-size: 11px; margin-top: 3px; }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo-list li label { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.todo-list li strong { color: var(--text); }
.todo-list li.done { opacity: 0.55; text-decoration: line-through; }
.todo-list input { margin-top: 3px; accent-color: var(--gold); }
.coach-flow { margin: 4px 0 12px; }
.coach-paid { margin: 0 0 6px; }
.wio-form select { padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 14px; letter-spacing: 0; text-transform: none; }

/* Admin: fix notes */
.warn-note { color: var(--negative); margin-top: 4px; line-height: 1.5; }
.good-note { color: var(--positive); margin-top: 4px; line-height: 1.5; }
tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--negative); }
tr.total-row td { border-top: 1px solid var(--line-strong); }
.mini-date { padding: 3px 6px; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--text); }

/* Overview: tiles flip over to show what's behind the number */
.kpi.flip { display: block; padding: 0; background: transparent; border: 0; box-shadow: none; cursor: pointer; perspective: 1200px; }
.kpi.flip .flip-inner { position: relative; height: 100%; transition: transform .55s cubic-bezier(.2, .7, .2, 1); transform-style: preserve-3d; }
.kpi.flip.flipped .flip-inner { transform: rotateY(180deg); }
.kpi.flip .flip-face {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--card-shadow);
  padding: 18px; min-height: 137px; height: 100%; display: flex; flex-direction: column;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.kpi.flip .flip-back { position: absolute; inset: 0; transform: rotateY(180deg); overflow: auto; }
.kpi.flip:focus-visible .flip-face { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi.flip:hover .flip-front { border-color: var(--line-strong); }
.flip-hint { float: right; margin-left: 8px; color: var(--text-faint); font-size: 13px; letter-spacing: 0; }
.flip-list { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.flip-line { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-muted); }
.flip-line b { color: var(--text); font-weight: 600; white-space: nowrap; }
.flip-line.strong span, .flip-line.strong b { color: var(--text); font-weight: 700; }
.flip-items { font-size: 11px; color: var(--text-faint); margin-top: 2px; line-height: 1.45; }
.flip-note { font-size: 11px; color: var(--text-faint); margin-top: 10px; line-height: 1.5; }
.flip-empty { font-size: 12px; color: var(--text-faint); margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .kpi.flip .flip-inner { transition: none; } }

/* Runway: safety buffer bar */
.buffer-track { position: relative; height: 14px; border-radius: 999px; background: var(--line); overflow: visible; margin-top: 6px; }
.buffer-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--chart-1); }
.buffer-goal { position: absolute; top: -5px; bottom: -5px; width: 2px; background: var(--chart-green); }
.buffer-scale { position: relative; height: 16px; font-size: 10px; color: var(--text-faint); letter-spacing: .06em; text-transform: uppercase; margin-top: 6px; }
.buffer-scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.buffer-scale span:first-child { left: 0; transform: none; }
td.negative { color: var(--negative); }

/* P&L: every cost, sorted */
table.spend tr.group-head td { padding-top: 16px; border-top: 1px solid var(--line-strong); }
table.spend tr.group-head.warn td { color: var(--negative); }
table.spend tr.sub-head td { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); padding-top: 10px; padding-bottom: 4px; border-top: 0; }

/* Admin → Money to chase: notes and tick-off */
.chase-table td.note-cell { min-width: 220px; vertical-align: top; }
.chase-note { width: 100%; min-height: 44px; resize: vertical; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 12.5px; line-height: 1.4; }
.chase-note:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.note-done { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.chase-done { margin-top: 14px; }
.chase-done > summary { cursor: pointer; color: var(--text-muted); font-size: 13px; padding: 6px 0; }

/* Sign in with an emailed code (index.html and coach.html) */
.login-step input[inputmode='numeric'] { letter-spacing: 0.3em; font-size: 18px; text-align: center; }
.login-box .login-note { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }
.login-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent-text, var(--gold)); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.btn-link[disabled] { opacity: 0.5; cursor: default; }
.pw-login { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.pw-login > summary { cursor: pointer; color: var(--text-muted); font-size: 12.5px; }
.pw-login form { margin-top: 12px; }
.signed-in { color: var(--text-muted); font-size: 12.5px; }

/* Coach page: owner's link to a coach's page and invoice (Coaches tab) */
.coach-head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.coach-head-side .btn-table { text-decoration: none; white-space: nowrap; }

/* Coach page: programme countdown. One series (time through the programme): a thin blue bar on a
   neutral track; the days left and renewal date are always written out, so colour is never the only cue. */
.cd-list { display: grid; }
.cd-row { display: grid; grid-template-columns: minmax(160px, 1.3fr) minmax(160px, 3fr) 110px 120px; gap: 16px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.cd-row:last-child { border-bottom: 0; }
.cd-head { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-faint); padding-top: 0; }
.cd-name { min-width: 0; font-size: 13px; color: var(--text); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.cd-tag { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.cd-name .cd-tag { margin-left: 0; }
.cd-tag.due { color: var(--text); border-color: var(--chart-2); }
.cd-track { position: relative; height: 8px; border-radius: 4px; background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); }
.cd-fill { position: absolute; left: 0; top: 0; bottom: 0; min-width: 4px; border-radius: 4px; background: var(--chart-1); }
.cd-row.due .cd-fill { background: var(--chart-2); }
.cd-row.paused .cd-fill { background: var(--chart-muted); }
.cd-track.cd-open { height: auto; background: none; box-shadow: none; }
.cd-track.cd-rolling { border-top: 2px dashed var(--line-strong); padding-top: 4px; }
.cd-note { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.cd-left { text-align: right; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cd-left strong { color: var(--heading); font-weight: 600; font-size: 15px; }
.cd-day { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.cd-head .cd-left, .cd-head .cd-end { font-size: inherit; color: inherit; }
.cd-end { text-align: right; font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }
.cd-row.past .cd-end { color: var(--negative); }
@media (max-width: 760px) {
  .cd-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .cd-row .cd-track { grid-column: 1 / -1; grid-row: 2; }
  .cd-head { display: none; }
  .cd-end { grid-column: 1 / -1; grid-row: 3; text-align: left; }
}

/* Coach page: invoice calculator */
.inv-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.inv-period { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.inv-period strong { color: var(--text); font-weight: 600; }
td.nowrap { white-space: nowrap; }
.inv-box th, .inv-box td { padding: 8px 10px; }
.inv-box th { white-space: normal; }
.inv-flow { margin: 0 0 14px; }
.inv-flow .flow-item strong { font-size: 19px; }
.inv-total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border: 1px solid var(--gold); border-radius: var(--radius-sm, 8px); background: var(--primary-wash); margin-bottom: 18px; }
.inv-total span { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.inv-total strong { font-family: var(--head); font-weight: 400; font-size: 26px; color: var(--heading); }
.inv-h { font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin: 18px 0 8px; }
.inv-table td.small-cell { font-size: 12px; min-width: 180px; }
.inv-table tfoot th, .inv-table tfoot td, .inv-box tfoot th, .inv-box tfoot td { border-top: 1px solid var(--line-strong); font-weight: 600; color: var(--text); }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 18px; margin-top: 6px; align-items: start; }
.inv-box { min-width: 0; }
.inv-box .inv-h { margin-top: 10px; }
.inv-terms { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.inv-terms dt { color: var(--text-muted); }
.inv-terms dd { margin: 0; color: var(--text); text-align: right; }

/* Print or save the invoice as a PDF: only the invoice, dark ink on white. */
@media print {
  body.print-invoice .topbar, body.print-invoice .page-intro, body.print-invoice #main > *:not(#coach-invoice-wrap), body.print-invoice .inv-controls, body.print-invoice #inv-msg, body.print-invoice dialog, body.print-invoice .login { display: none !important; }
  body.print-invoice .inv-box, body.print-invoice .inv-total, body.print-invoice .inv-flow { break-inside: avoid; }
  body.print-invoice .inv-h { break-after: avoid; }
  body.print-invoice, body.print-invoice * { color: #0d1129 !important; background: #fff !important; box-shadow: none !important; }
  body.print-invoice .card { border: 0; padding: 0; }
  body.print-invoice .inv-total { border: 1px solid #0d1129; }
  body.print-invoice .table-wrap { overflow: visible; border: 0; }
  body.print-invoice table { font-size: 9px; }
  body.print-invoice th, body.print-invoice td { padding: 4px 5px; white-space: normal; }
  body.print-invoice .inv-table td.small-cell { min-width: 0; font-size: 9px; }
  body.print-invoice .card-head .sub { display: none; }
}
.inv-note { margin: -8px 0 14px; }

/* Two doors: hq.karved.com.au (team) and Greg's report. The server enforces access; this only hides
   what a door can't open. */
[data-door="team"] .owner-door-only { display: none !important; }
[data-door="owner"] .team-door-only { display: none !important; }
/* The pointer from one door to the other, under the sign-in form. */
.login-box > .login-note { margin: 12px 0 0; }
.login-box .login-note a { color: var(--gold); text-decoration: underline; text-underline-offset: 2px; }
[data-theme="light"] .login-box .login-note a { color: var(--primary); }
