/* ==========================================================================
   Components and layout. Every colour here comes from tokens.css by role.

   Layout utilities are hand-written rather than pulled from a Tailwind CDN:
   the demo has to run with no network dependency, and that constraint outranks
   the convenience. Class names match the utility conventions they replace.
   ========================================================================== */

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

/* Cross-fades a full-page navigation in browsers that support the CSS-only
   View Transitions API (Chromium). A no-op everywhere else — Safari and
   Firefox simply navigate as they always did. Nothing to feature-detect,
   nothing that can break. */
@view-transition { navigation: auto; }

::selection { background: var(--brand); color: var(--on-brand); }

/* The browser default focus ring is a hard blue rectangle that clashes with
   this palette. A visible, brand-toned ring stands in for it — but only for
   keyboard focus, so a mouse click never leaves a ring behind. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Thin, themed scrollbars — the OS default reads as a leftover of the browser
   chrome inside an app this deliberately styled. */
* { scrollbar-width: thin; scrollbar-color: var(--axis) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background-color: var(--axis);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 20px;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-muted); }

button, a, select, summary, .disclose { -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 17px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }

/* -- layout utilities ------------------------------------------------------ */
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { justify-content: center; }
.baseline { align-items: baseline; }
.start { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 18px; } .mt-6 { margin-top: 26px; }

/* Line icons sit on the text baseline rather than riding above it. */
.ico { flex: none; vertical-align: -2px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 18px; } .mb-6 { margin-bottom: 26px; }
.hide { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono-num { font-variant-numeric: tabular-nums; }

/* -- top bar --------------------------------------------------------------- */
.topbar {
  background: var(--brand-deep);
  color: #fff;
  padding: 0 var(--page-pad);
  height: 46px;
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.topbar .brand small {
  font-weight: 400;
  font-size: var(--text-micro);
  color: rgba(255, 255, 255, 0.62);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nav { display: flex; gap: 2px; height: 100%; align-items: stretch; }
.nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  color: rgba(255, 255, 255, 0.78);
  font-size: var(--text-body);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.nav a {
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.nav a.active { color: #fff; border-bottom-color: var(--brand); background: rgba(255, 255, 255, 0.09); }
.topbar .spacer { flex: 1 1 auto; }
.topbar .meta { font-size: var(--text-micro); color: rgba(255, 255, 255, 0.62); font-variant-numeric: tabular-nums; }

.theme-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  height: 24px;
  padding: 0 8px;
  font: inherit;
  font-size: var(--text-micro);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.theme-toggle { transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.theme-toggle:hover { background: rgba(255, 255, 255, 0.1); }
/* the moon/sun glyph swaps instantly today; a quarter turn makes the swap read
   as a change rather than a flicker */
.theme-toggle svg { transition: transform var(--dur-slow) var(--ease); }
.theme-toggle:active svg { transform: rotate(-25deg); }


/* Dense tables stay readable up to a point; past roughly 1700px the eye loses
   the row on the way across. Content stops there and centres. */
main {
  padding: var(--page-pad);
  max-width: 1720px;
  margin: 0 auto;
}

/* A render pass on first load should not animate in — only state changes
   that happen after the page has settled should ease. */
main { animation: page-in var(--dur-slow) var(--ease); }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }

/* -- page heading ---------------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head .sub { color: var(--text-secondary); font-size: var(--text-small); margin-top: 2px; }
.eyebrow {
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

/* -- cards ----------------------------------------------------------------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card > .card-head {
  padding: 9px 12px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-1);
}
.card > .card-body { padding: 12px; }
.card-head h2, .card-head h3 { font-size: 13px; }
.card-head .hint { font-size: var(--text-micro); color: var(--text-muted); }

/* -- KPI tiles ------------------------------------------------------------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 1240px) { .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 10px 12px 11px;
  display: block;
  color: inherit;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
a.kpi:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  text-decoration: none;
}
.kpi .label {
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  display: block;
  margin-bottom: 5px;
}
.kpi .value { font-size: var(--text-kpi); font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; }
.kpi .foot { font-size: var(--text-micro); color: var(--text-secondary); margin-top: 4px; }
.kpi.flagged { border-left: 3px solid var(--status-serious); }
.kpi.flagged .value { color: var(--status-critical); }

/* -- tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-body);
}
table.grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 6px 9px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
table.grid th.num, table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td {
  height: var(--row-height);
  padding: 4px 9px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  background: var(--surface-1);
  transition: background-color var(--dur) var(--ease);
}
table.grid tbody tr:hover td { background: var(--brand-soft); }
table.grid tbody tr.selected td { background: var(--brand-soft); }
table.grid td.tight { padding: 2px 9px; }
table.grid a.rowlink { color: var(--text-primary); font-weight: 500; }
table.grid a.rowlink:hover { color: var(--brand); }
.subtle { color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.micro { font-size: var(--text-micro); }
.small { font-size: var(--text-small); }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* Group headers for a customer holding several sites. */
tr.group-head td {
  background: var(--surface-2);
  font-weight: 600;
  border-bottom: 1px solid var(--rule);
  height: 30px;
}
tr.group-head td:hover { background: var(--surface-2); }
.disclose {
  background: none;
  border: 0;
  padding: 0 6px 0 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
}
.disclose svg { transition: transform var(--dur) var(--ease); }
/* toggleGroup() adds .open when the rows underneath are hidden — the chevron
   points at what will happen next, not at the current state. */
.disclose.open svg { transform: rotate(-90deg); }

/* -- acuity ---------------------------------------------------------------- */
.acuity-stripe { border-left: 4px solid transparent; }
.acuity-critical .acuity-stripe, td.acuity-critical { border-left-color: var(--status-critical); }
.acuity-urgent   .acuity-stripe, td.acuity-urgent   { border-left-color: var(--status-serious); }
.acuity-watch    .acuity-stripe, td.acuity-watch    { border-left-color: var(--status-warning); }
.acuity-stable   .acuity-stripe, td.acuity-stable   { border-left-color: var(--status-good); }

.acuity-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-micro);
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 7px 2px 5px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  border: 1px solid transparent;
}
.acuity-chip svg { flex: none; }
.chip-critical { color: var(--status-critical); background: var(--status-critical-soft); border-color: var(--status-critical); }
.chip-urgent   { color: var(--status-serious);  background: var(--status-serious-soft);  border-color: var(--status-serious); }
.chip-watch    { color: var(--status-warning);  background: var(--status-warning-soft);  border-color: var(--status-warning); }
.chip-stable   { color: var(--status-good);     background: var(--status-good-soft);     border-color: var(--status-good); }

/* Dark surfaces need the ink lifted off the soft fill. */
:root[data-theme="dark"] .chip-critical,
:root[data-theme="dark"] .chip-urgent,
:root[data-theme="dark"] .chip-watch,
:root[data-theme="dark"] .chip-stable { color: var(--text-primary); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip-critical,
  :root:not([data-theme="light"]) .chip-urgent,
  :root:not([data-theme="light"]) .chip-watch,
  :root:not([data-theme="light"]) .chip-stable { color: var(--text-primary); }
}

/* -- flag chips: outline, several to a row --------------------------------- */
.flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-micro);
  line-height: 1.5;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  white-space: nowrap;
}
.flag.danger  { border-color: var(--status-critical); color: var(--status-critical); }
.flag.warn    { border-color: var(--status-serious);  color: var(--status-serious); }
.flag.notice  { border-color: var(--status-warning);  color: var(--text-secondary); }
.flag.brandy  { border-color: var(--brand); color: var(--brand); }
.flag-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* -- banner bar: modelled on an EHR patient header ------------------------- */
.banner {
  background: var(--brand-deep);
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 5;
  border: 1px solid var(--brand-deep);
  box-shadow: var(--shadow-hover);
}
.banner .banner-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.banner .banner-sub { font-size: var(--text-small); color: rgba(255, 255, 255, 0.72); }
.banner-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 8px;
}
.banner-cell { padding: 0 14px 0 0; margin-right: 14px; border-right: 1px solid rgba(255, 255, 255, 0.16); }
.banner-cell:last-child { border-right: 0; }
.banner-cell .k {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 600;
}
.banner-cell .v { font-size: var(--text-body); font-variant-numeric: tabular-nums; color: #fff; }
.banner-cell .v.warnink { color: var(--status-warning); }
.banner-cell .v.critink { color: #ff9c9c; }

/* -- tabs ------------------------------------------------------------------ */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin: 14px 0 0; }
.tabs a {
  padding: 7px 12px;
  font-size: var(--text-body);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tabs a:hover { color: var(--text-primary); text-decoration: none; }
.tabs a.active { color: var(--text-primary); border-bottom-color: var(--brand); font-weight: 600; }

/* -- draft pane: everything drafts, a person sends ------------------------- */
.draft {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-1);
  box-shadow: var(--shadow-card);
}
.draft > .draft-head {
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
  padding: 6px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-secondary);
}
.draft > .draft-body { padding: 12px; }
.draft .field-row {
  display: flex;
  gap: 10px;
  padding: 3px 0;
  border-bottom: 1px solid var(--rule);
  font-size: var(--text-small);
}
.draft .field-row:last-child { border-bottom: 0; }
.draft .field-row .k { width: 92px; flex: none; color: var(--text-muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; font-weight: 600; padding-top: 2px; }
.draft .field-row .v { color: var(--text-primary); }
.email-body {
  white-space: pre-wrap;
  font-size: var(--text-body);
  line-height: 1.55;
  padding: 10px 0 2px;
  border-top: 1px solid var(--rule);
  margin-top: 6px;
}

.btn {
  font: inherit;
  font-size: var(--text-small);
  border: 1px solid var(--brand);
  background: var(--brand);
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  color: var(--on-brand);
  border-radius: var(--radius);
  padding: 5px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(11, 11, 11, 0.06);
  transition: filter var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease), color var(--dur) var(--ease),
    background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { filter: brightness(1.08); box-shadow: var(--shadow-card); transform: translateY(-1px); text-decoration: none; }
.btn:active { filter: brightness(0.97); box-shadow: none; transform: translateY(0); }
.btn.secondary { background: var(--surface-1); background-image: none; color: var(--text-primary); border-color: var(--border); }
.btn.secondary:hover { border-color: var(--brand); color: var(--brand); }
.btn.small { padding: 3px 8px; font-size: var(--text-micro); }
.btn[disabled], .btn.disabled {
  background: var(--surface-2);
  background-image: none;
  color: var(--text-muted);
  border-color: var(--rule);
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
  transform: none;
}
.btn-note { font-size: var(--text-micro); color: var(--text-muted); }

/* -- filters --------------------------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  background: var(--surface-1);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.filters label { font-size: var(--text-micro); text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
select, input[type="text"], input[type="search"], input[type="date"], textarea {
  font: inherit;
  font-size: var(--text-small);
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 7px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
select:hover, input:hover, textarea:hover { border-color: var(--axis); }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus-ring);
}

/* -- timeline -------------------------------------------------------------- */
.timeline { display: flex; align-items: stretch; gap: 0; margin: 4px 0 2px; }
.tl-step { flex: 1 1 0; padding: 8px 12px; border-right: 1px solid var(--rule); position: relative; }
.tl-step:last-child { border-right: 0; }
.tl-step .k { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; }
.tl-step .v { font-size: var(--text-body); font-variant-numeric: tabular-nums; }
.tl-step.done { background: var(--surface-2); }
.tl-step.now { background: var(--brand-soft); border-top: 2px solid var(--brand); }
.tl-step.now .k { color: var(--brand); }

/* -- steps ----------------------------------------------------------------- */
.step-head { display: flex; align-items: center; gap: 9px; }
.step-num {
  width: 20px; height: 20px; flex: none;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  font-size: var(--text-micro);
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.step-num.blocked { background: var(--status-critical); color: #fff; }
.step-num.done { background: var(--status-good); color: #fff; }

.blocker {
  border: 1px solid var(--status-critical);
  border-left: 4px solid var(--status-critical);
  background: var(--status-critical-soft);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: var(--text-small);
}
.notice-box {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--brand);
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: var(--text-small);
}

/* -- pipeline -------------------------------------------------------------- */
.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 1100px) { .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pipe-col { background: var(--surface-1); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-card); display: flex; flex-direction: column; }
.pipe-col > header {
  padding: 7px 10px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
  font-size: var(--text-micro);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex; justify-content: space-between; align-items: center;
}
.pipe-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pcard {
  border: 1px solid var(--rule);
  border-left: 4px solid var(--rule);
  border-radius: var(--radius);
  padding: 7px 9px;
  background: var(--surface-1);
  display: block;
  color: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.pcard:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
  text-decoration: none;
}
.pcard.acuity-critical { border-left-color: var(--status-critical); }
.pcard.acuity-urgent { border-left-color: var(--status-serious); }
.pcard.acuity-watch { border-left-color: var(--status-warning); }
.pcard.acuity-stable { border-left-color: var(--status-good); }
.pcard .t { font-weight: 600; font-size: var(--text-small); }
.pcard .m { font-size: var(--text-micro); color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* -- charts ---------------------------------------------------------------- */
/* Charts carry their own width/height and a max-width, so they render at 1:1
   and only ever scale down. Without this an SVG stretches to its container and
   magnifies its own type — chart labels reached 28px against 13px body text. */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: var(--font-sans); fill: var(--text-secondary); }
.chart .val { fill: var(--text-primary); font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--rule); stroke-width: 1; }
.chart .axisline { stroke: var(--axis); stroke-width: 1; }
.chart .lbl { font-size: 11px; }
.chart .tick { font-size: 10px; fill: var(--text-muted); }
.chart-toggle { display: flex; gap: 6px; align-items: center; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  font-size: var(--text-micro);
  color: var(--text-secondary);
  align-items: center;
}
.legend .sw {
  width: 8px; height: 8px;
  border-radius: 2px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: 0;
}
.legend-item { display: inline-flex; align-items: center; white-space: nowrap; }
.legend-item strong { color: var(--text-primary); margin-left: 2px; }

/* -- delta ink ------------------------------------------------------------- */
.delta-neg { color: var(--status-critical); }
.delta-pos { color: var(--status-good); }
.zebra-none tbody tr td { background: var(--surface-1); }

/* -- misc ------------------------------------------------------------------ */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: var(--text-small); }
.kv dt { color: var(--text-muted); text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; font-weight: 600; padding-top: 2px; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
/* align-items:start so a short card sits at its own height instead of being
   stretched to match a taller neighbour and trailing empty space. */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.empty { padding: 22px; text-align: center; color: var(--text-muted); font-size: var(--text-small); }
.doc-note {
  font-size: var(--text-micro);
  color: var(--text-secondary);
  border-left: 3px solid var(--status-good);
  padding: 3px 0 3px 8px;
}
.doc-note.query { border-left-color: var(--status-warning); }
/* Pipeline columns run long; scroll them independently rather than letting
   one tall column set the height of the whole board. */
.pipe-scroll { max-height: 340px; overflow-y: auto; }
/* Sortable column headings. */
a.sortlink { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
a.sortlink:hover { color: var(--brand); text-decoration: none; }
a.sortlink::after { content: "⇅"; font-size: 9px; opacity: .45; }
/* A small "?" beside a column heading, for columns worth a one-line explanation. */
.helpdot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-left: 4px; border-radius: 50%;
  border: 1px solid var(--border); color: var(--text-muted);
  font-size: 9px; font-weight: 700; cursor: help; vertical-align: 1px;
}
.helpdot:hover { border-color: var(--brand); color: var(--brand); }

/* Annual contracted value carries a breakdown under the headline number.
   Splitting facility fee from admin fee is a theme through this revision. */
.kpi .breakdown {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 1px 10px;
  font-size: var(--text-micro);
  color: var(--text-secondary);
}
.kpi .breakdown .v { font-variant-numeric: tabular-nums; text-align: right; color: var(--text-primary); }

/* Demo-only role switcher in the header. Labelled as such — there is no login. */
.acting-select {
  background: rgba(255,255,255,.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: var(--radius);
  font-size: var(--text-micro);
  padding: 2px 5px;
}
.acting-select option { color: var(--text-primary); }
/* Approval chain — Generated -> Pending -> Approved -> Email drafted */
.approval-chain { display: flex; flex-direction: column; gap: 0; }
.approval-step { display: grid; grid-template-columns: 26px 1fr; gap: 10px;
  padding: 8px 0 8px 0; position: relative; }
.approval-step + .approval-step { border-top: 1px solid var(--rule); }
.approval-dot { width: 22px; height: 22px; border-radius: 50%; display: grid;
  place-items: center; font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); }
.approval-step.done .approval-dot { background: var(--brand-soft);
  color: var(--brand-deep); border-color: var(--brand); }
.approval-step.now  .approval-dot { background: var(--brand); color: var(--on-brand);
  border-color: var(--brand); }
.approval-label { font-weight: 600; font-size: 12.5px; }
.approval-step.todo .approval-label { color: var(--text-muted); font-weight: 500; }
.approval-step.now  .approval-label { color: var(--brand-deep); }
label.check { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px;
  line-height: 1.4; cursor: pointer; }
label.check input { margin-top: 2px; }
tr.muted-row td { color: var(--text-muted); }
.field-block { display: block; }
.field-block textarea, form textarea { width: 100%; box-sizing: border-box;
  font: inherit; font-size: 12.5px; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-1); color: var(--text-primary);
  resize: vertical; }
.mb-1 { margin-bottom: 5px; }
/* Offline copy only — explains a control that cannot act without a server. */
.offline-toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  max-width: 560px; background: var(--brand-deep); color: #fff; font-size: 12.5px;
  line-height: 1.45; padding: 11px 15px; border-radius: 6px; z-index: 9999;
  box-shadow: 0 8px 26px rgba(0,0,0,.28); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; }
.offline-toast.on { opacity: 1; transform: translate(-50%, 0); }
/* Resolving a payment exception in place, rather than noting it and moving on. */
.resolve-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.resolve-row label { display: inline-flex; align-items: center; gap: 5px; }
.resolve-row select, .resolve-row input[type="text"] {
  font: inherit; font-size: 12px; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-1); color: var(--text-primary); max-width: 320px; }
/* Report builder on Receivables. */
.report-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.report-form label { display: flex; flex-direction: column; gap: 3px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.report-form select, .report-form input[type="date"] {
  font: inherit; font-size: 12.5px; text-transform: none; letter-spacing: 0;
  color: var(--text-primary); padding: 4px 7px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-1); }
.gap-3 { gap: 16px; }
/* Notes thread — internal, on the record it concerns. */
.note-thread { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--rule); }
.note { padding: 10px 0; }
.note + .note { border-top: 1px solid var(--rule); }
.note-head { display: flex; align-items: baseline; gap: 8px; font-size: 12.5px; }
.note-body { font-size: 12.5px; line-height: 1.5; color: var(--text-secondary);
  margin-top: 3px; white-space: pre-wrap; }
/* Month-close strip — HEA's three stages, visible from any of the three screens. */
.month-strip { display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 14px; background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: var(--radius); }
.ms-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 600; }
.ms-stages { display: flex; align-items: center; gap: 4px; list-style: none;
  margin: 0; padding: 0; flex-wrap: wrap; }
.ms-stages li { display: flex; align-items: baseline; gap: 6px; }
.ms-stages li + li::before { content: "›"; color: var(--text-muted); margin-right: 4px; }
.ms-stages a { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px;
  font-weight: 600; color: var(--text-secondary); text-decoration: none;
  padding: 2px 7px; border-radius: 4px; }
.ms-stages a:hover { background: var(--surface-1); text-decoration: none; }
.ms-stages .n { display: inline-grid; place-items: center; width: 16px; height: 16px;
  border-radius: 50%; font-size: 10px; background: var(--surface-1);
  border: 1px solid var(--border); color: var(--text-muted); }
.ms-stages li.current a { color: var(--brand-deep); background: var(--brand-soft); }
.ms-stages li.current .n { background: var(--brand); color: var(--on-brand);
  border-color: var(--brand); }
.ms-blurb { font-size: 11px; color: var(--text-muted); }
.ms-stages li:not(.current) .ms-blurb { display: none; }
.ms-dates { display: flex; gap: 16px; list-style: none; margin: 0 0 0 auto; padding: 0;
  flex-wrap: wrap; }
.ms-dates li { display: flex; flex-direction: column; font-size: 11px; }
.ms-dates .k { color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ms-dates .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.ms-dates li.done .v { color: var(--text-secondary); }
.ms-dates li.now .v { color: var(--brand); }
@media (max-width: 1100px) { .ms-dates { margin-left: 0; } }
/* Receivables carries three sections; this makes them reachable. */
.jump-bar { display: flex; align-items: center; gap: 14px; font-size: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.jump-bar span { color: var(--text-muted); text-transform: uppercase;
  letter-spacing: .04em; font-size: 11px; }
.jump-bar a { color: var(--brand); font-weight: 600; }
/* A request that never happened is not the same as one still to come. */
.approval-step.skipped .approval-dot { background: var(--surface-2); color: var(--text-muted);
  border-style: dashed; }
.approval-step.skipped .approval-label { color: var(--text-muted); font-weight: 500;
  text-decoration: line-through; text-decoration-color: var(--axis); }
/* --- Tier 5: working together -------------------------------------------- */
.bell { position: relative; }
.bell > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center;
  gap: 3px; color: rgba(255,255,255,.86); padding: 4px 7px; border-radius: 5px; position: relative; }
.bell > summary::-webkit-details-marker { display: none; }
.bell > summary:hover { background: rgba(255,255,255,.10); }
.bell-count { background: var(--status-critical); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 15px; height: 15px; border-radius: 8px; display: inline-grid; place-items: center;
  padding: 0 4px; }
.bell-panel { position: absolute; right: 0; top: 28px; width: 360px; z-index: 200;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); overflow: hidden;
  animation: pop-in var(--dur-slow) var(--ease); transform-origin: top right; }
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.97) translateY(-3px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
details.inline-action[open] > form { animation: pop-in var(--dur-slow) var(--ease); transform-origin: top left; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; background: var(--surface-2); border-bottom: 1px solid var(--rule);
  font-size: 12px; color: var(--text-primary); }
.bell-item { border-bottom: 1px solid var(--rule); }
.bell-item button, .bell-item a { display: block; width: 100%; text-align: left; background: none;
  border: 0; padding: 8px 11px; cursor: pointer; font: inherit; color: var(--text-primary); }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { border-left: 3px solid var(--brand); }
.bell-kind { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); }
.bell-kind.k-approval { color: var(--status-warning); }
.bell-kind.k-mention { color: var(--brand); }
.bell-text { display: block; font-size: 12.5px; line-height: 1.4; }
.bell-empty { padding: 14px 11px; font-size: 12.5px; color: var(--text-muted); }
.bell-foot { display: block; padding: 8px 11px; font-size: 12px; background: var(--surface-2);
  color: var(--brand); font-weight: 600; }
.task-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; }
.task-row + .task-row { border-top: 1px solid var(--rule); }
.task-check { width: 17px; height: 17px; border: 1px solid var(--axis); border-radius: 3px;
  background: var(--surface-1); cursor: pointer; display: grid; place-items: center;
  font-size: 11px; color: var(--brand); flex: none; }
.task-row.done .task-check { background: var(--brand-soft); border-color: var(--brand); }
.task-row.done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-title { font-size: 12.5px; flex: 1; }
h4.micro { text-transform: uppercase; letter-spacing: .05em; margin: 0 0 6px; }
/* A row someone actually changed on the request form — obvious which values
   were carried forward and which were set by hand. */
#reqrows tr.row-edited { background: var(--brand-soft); }
#reqrows tr.row-edited td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
#reqrows tr.row-edited input,
#reqrows tr.row-edited select { border-color: var(--brand); }
#reqrows input[type="text"],
#reqrows input[type="date"],
#reqrows select {
  font: inherit; font-size: 12.5px; padding: 3px 6px; border: 1px solid var(--border);
  border-radius: 4px; background: var(--surface-1); color: var(--text-primary); width: 100%; }
#reqrows input.num { text-align: right; font-variant-numeric: tabular-nums; }
#reqrows td { vertical-align: middle; }
.integration { padding: 12px 0; }
.integration + .integration { border-top: 1px solid var(--rule); }
.integration h4 { margin: 0; font-size: 14px; }
details.inline-action > summary { list-style: none; cursor: pointer; display: inline-block; }
details.inline-action > summary::-webkit-details-marker { display: none; }
/* The top bar gained an Activity tab and a notification bell in R4, which
   pushed it past 1596px — and it cannot wrap, so every screen scrolled
   sideways on anything narrower. It now shrinks instead of overflowing. */
.topbar { gap: 14px; min-width: 0; }
.topbar .nav { min-width: 0; flex: 0 1 auto; overflow-x: auto; scrollbar-width: none; }
.topbar .nav::-webkit-scrollbar { display: none; }
.topbar .brand { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 1560px) {
  .topbar .brand small { display: none; }
  .topbar .nav a { padding-left: 9px; padding-right: 9px; }
}
@media (max-width: 1400px) {
  /* the date is the first thing worth losing — it is on every screen anyway */
  .topbar > .meta:last-of-type { display: none; }
  .topbar .acting-select { max-width: 116px; }
}
@media (max-width: 1200px) {
  .topbar .nav a span, .topbar .nav a { font-size: 12px; }
  .topbar > form .meta { display: none; }
}

/* Twelve month chips in a nowrap row pushed the request form sideways, and the
   row of date and price inputs is wider than a laptop viewport. Both now stay
   inside their own box instead of moving the page. */
#preview.row { flex-wrap: wrap !important; }
#preview .flag { flex: 0 0 auto; }
#reqrows { min-width: 940px; }
#reqform .table-wrap { overflow-x: auto; max-width: 100%; }

/* --------------------------------------------------------------------------
   Top-bar utilities. The bell was a hairline glyph with no affordance, sitting
   unlabelled between the navigation and the role switcher, and Settings was
   faint text. Neither read as something you could press.
   -------------------------------------------------------------------------- */
.topbar-btn,
.bell > summary,
.theme-toggle {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: var(--text-micro);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.topbar-btn:hover,
.bell > summary:hover,
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
}

/* the bell carries a word as well as a glyph, so it is findable cold */
.bell-label { font-weight: 600; letter-spacing: .01em; }
.bell[open] > summary {
  background: var(--surface-1); color: var(--brand-deep);
  border-color: var(--surface-1);
}

/* an unread count has to survive a dark background at a glance */
.bell-count {
  background: var(--status-critical); color: #fff;
  font-size: 10.5px; font-weight: 700; line-height: 1;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; display: inline-grid; place-items: center;
  box-shadow: 0 0 0 1.5px var(--brand-deep);
}
.bell[open] .bell-count { box-shadow: none; }

/* the date is information rather than a control — quiet, but legible */
.topbar .meta { color: rgba(255, 255, 255, 0.74); }
.topbar > form .meta { color: rgba(255, 255, 255, 0.66); }
.acting-select { border-color: rgba(255, 255, 255, 0.34); }

/* a hairline between the navigation and the utilities, so the right-hand
   cluster reads as a group rather than as leftovers */
.topbar .spacer { border-right: 1px solid rgba(255, 255, 255, 0.16); margin-right: 14px; }

/* Nothing in the top bar wraps onto a second line, and the navigation keeps its
   labels — the utilities give way first, because a nav item you cannot read is
   worse than a date you cannot see. */
.topbar > * { flex: 0 0 auto; }
.topbar .meta, .topbar .acting-label { white-space: nowrap; }
.topbar .nav { flex: 0 1 auto; }
.topbar .nav a { white-space: nowrap; }
.topbar form.row { flex-wrap: nowrap; }

@media (max-width: 1600px) {
  .topbar { gap: 10px; }
  .topbar .spacer { margin-right: 10px; }
  .topbar .acting-label { display: none; }
}
@media (max-width: 1440px) {
  .topbar .topbar-date { display: none; }
  .topbar .theme-toggle span { display: none; }
  .topbar .theme-toggle { padding: 0 7px; }
}
@media (max-width: 1320px) {
  .topbar .topbar-btn span { display: none; }
  .topbar .topbar-btn { padding: 0 7px; }
}
@media (max-width: 1200px) {
  .topbar .bell-label { display: none; }
  .topbar .bell > summary { padding: 0 7px; }
}

