/* ─────────────────────────────────────────────────────────────────────────
   Narbis Edge: HRV clinician dashboard stylesheet.

   Every colour, type role, radius and spacing step comes from
   narbis-tokens.css, the token file this dashboard shares with the EEG
   dashboard and that mirrors the Edge apps' theme. This file holds no raw
   colour. `node tools/contrast-check.mjs` fails if one appears, if any text
   here drops below 12 px, or if a text pair falls under 4.5:1 in either theme.

   Type follows the apps: sentence case, weights 400 and 500, tabular figures
   on everything. Shapes follow the apps: 8 px chips and inputs, 12 px cards,
   28 px dialogs, pill buttons.
   ───────────────────────────────────────────────────────────────────────── */

@import url('narbis-tokens.css');

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: var(--type-body-small-size);
  line-height: var(--type-body-small-line);
  letter-spacing: var(--type-body-small-tracking);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Kept for markup that still asks for it; body already sets tabular figures. */
.tnum { font-variant-numeric: tabular-nums; }

button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ── Chrome ─────────────────────────────────────────────────────────────── */

/* The app bar: a 2 px brand-cyan rule along its top edge (decorative, both
   themes), then the bar on the card surface. */
.topbar {
  background: var(--surface-1);
  border-top: 2px solid var(--brand-accent);
  border-bottom: 1px solid var(--outline-variant);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1480px;
  margin: 0 auto;
  min-height: var(--app-bar-height);
  padding: var(--space-2) var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

/* The brand: the original NARBIS logo (assets/brand/), a hairline, then the
   product name. Markup: assets/brand/README.md.

   Two logo files, one per theme: the white wordmark on dark, the black
   wordmark on light and in print. --show-on-dark / --show-on-light swap with
   the theme in narbis-tokens.css. In both, the mark is the brand's pure cyan.

   Both PNGs carry clear space above and below the ink (34 % above, 19 %
   below). The <img> box has the ink's own aspect, and object-fit/position crop
   the clear space away, so the ink centres on the bar at any size: the image
   is scaled to the box width and the box sits 65 % of the overflow down. */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: none;
  color: var(--on-surface);
  text-decoration: none;
}
.brand-logo {
  flex: none;
  width: 125px;
  height: 21px;
  object-fit: cover;
  object-position: 50% 65%;
}
.brand-logo-on-dark { display: var(--show-on-dark); }
.brand-logo-on-light { display: var(--show-on-light); }
.brand-rule {
  flex: none;
  width: 1px;
  height: 28px;
  background: var(--outline-variant);
}
.brand-product { display: flex; flex-direction: column; min-width: 0; }
.brand-product-name {
  font-size: var(--type-title-small-size);
  line-height: 18px;
  font-weight: var(--type-title-small-weight);
  letter-spacing: var(--type-title-small-tracking);
  white-space: nowrap;
}
.brand-product-role {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  font-weight: 400;
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
  white-space: nowrap;
}

.nav { display: flex; gap: var(--space-1); flex: 1 1 auto; flex-wrap: wrap; }
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-4);
  border-radius: var(--shape-full);
  text-decoration: none;
  color: var(--on-surface-variant);
  font-size: var(--type-label-large-size);
  line-height: var(--type-label-large-line);
  font-weight: var(--type-label-large-weight);
  letter-spacing: var(--type-label-large-tracking);
  white-space: nowrap;
}
.nav a:hover { background: var(--state-hover); color: var(--on-surface); }
/* The active item carries the brand: a cyan wash, cyan text on dark and the
   deep cyan on light (tokens: --nav-active-fill / --nav-active-text). */
.nav a[aria-current='page'] { background: var(--nav-active-fill); color: var(--nav-active-text); }
.nav .count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  margin-left: var(--space-2);
  border-radius: var(--shape-full);
  background: var(--tone-warning-fill);
  color: var(--tone-warning-text);
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  font-weight: var(--type-label-small-weight);
  letter-spacing: 0;
}

.topbar-right { display: flex; align-items: center; gap: var(--space-3); flex: none; }

/* "Sample data": a badge, not a button. */
.pill-demo {
  display: inline-flex;
  align-items: center;
  flex: none;
  border-radius: var(--shape-small);
  padding: 2px var(--space-2);
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
  font-size: var(--type-label-medium-size);
  line-height: var(--type-label-medium-line);
  font-weight: var(--type-label-medium-weight);
  letter-spacing: var(--type-label-medium-tracking);
  white-space: nowrap;
}

.clinician { display: flex; align-items: center; gap: 10px; }
.clinician .who {
  font-size: var(--type-label-large-size);
  line-height: var(--type-label-large-line);
  font-weight: var(--type-label-large-weight);
  letter-spacing: var(--type-label-large-tracking);
}
.clinician .where {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
}
.clinician .where a { color: var(--primary); }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: grid;
  place-items: center;
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  font-weight: var(--type-label-small-weight);
  letter-spacing: 0;
  flex: none;
}
.avatar.sm { width: 28px; height: 28px; }

main { max-width: 1480px; margin: 0 auto; padding: var(--section-gap) var(--gutter) var(--space-14); }

/* ── Page furniture ─────────────────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-bottom: var(--section-gap);
}
h1 {
  font-size: var(--type-headline-medium-size);
  line-height: var(--type-headline-medium-line);
  font-weight: var(--type-headline-medium-weight);
  letter-spacing: var(--type-headline-medium-tracking);
  margin: 0 0 var(--space-1);
  text-wrap: balance;
}
.page-head .sub { color: var(--on-surface-variant); }
.head-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Buttons are pills, 40 px tall: outlined by default, filled for the one
   call to action on a view. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-5);
  border-radius: var(--shape-full);
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--primary);
  font-size: var(--type-label-large-size);
  line-height: var(--type-label-large-line);
  font-weight: var(--type-label-large-weight);
  letter-spacing: var(--type-label-large-tracking);
  text-align: center;
  white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn:active { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: color-mix(in srgb, var(--on-primary) 8%, var(--primary)); }
.btn-primary:active { background: color-mix(in srgb, var(--on-primary) 12%, var(--primary)); }
.btn-sm {
  min-height: var(--control-height-compact);
  padding: 0 var(--space-4);
  font-size: var(--type-label-medium-size);
  line-height: var(--type-label-medium-line);
}
.btn[disabled] { opacity: 0.5; cursor: default; }
.btn[disabled]:hover { background: transparent; }
.btn-primary[disabled]:hover { background: var(--primary); }
a.btn { text-decoration: none; }

.tiles {
  display: grid;
  gap: var(--card-gap);
  margin-bottom: var(--section-gap);
  grid-template-columns: repeat(auto-fit, minmax(min(215px, 100%), 1fr));
}
.tile {
  background: var(--surface-1);
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-medium);
  padding: var(--card-padding);
}
.tile .k {
  font-size: var(--type-label-medium-size);
  line-height: var(--type-label-medium-line);
  font-weight: var(--type-label-medium-weight);
  letter-spacing: var(--type-label-medium-tracking);
  color: var(--on-surface-variant);
  margin-bottom: var(--space-2);
}
.tile .v {
  font-size: var(--type-headline-large-size);
  line-height: var(--type-headline-large-line);
  font-weight: var(--type-headline-large-weight);
  letter-spacing: var(--type-headline-large-tracking);
}
.tile .v small {
  font-size: var(--type-title-medium-size);
  line-height: var(--type-title-medium-line);
  font-weight: 400;
  letter-spacing: 0;
  color: var(--on-surface-variant);
}
.tile .d { color: var(--on-surface-variant); margin-top: var(--space-2); }
.tile .n {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  color: var(--on-surface-variant);
  margin-top: var(--space-1);
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-medium);
  overflow: hidden;
}
.card + .card { margin-top: var(--card-gap); }
.card-head {
  padding: var(--card-padding);
  border-bottom: 1px solid var(--outline-variant);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.card-head h2 {
  font-size: var(--type-title-medium-size);
  line-height: var(--type-title-medium-line);
  font-weight: var(--type-title-medium-weight);
  letter-spacing: var(--type-title-medium-tracking);
  margin: 0;
}
.card-head .note { color: var(--on-surface-variant); margin-top: 2px; }
.card-body { padding: var(--card-padding); }

/* Segmented buttons: one outlined pill, the selected segment in
   secondary-container (the M3 default). */
.segmented {
  display: inline-flex;
  max-width: 100%;
  border: 1px solid var(--outline);
  border-radius: var(--shape-full);
  overflow-x: auto;
}
.segmented button {
  flex: none;
  white-space: nowrap;
  min-height: var(--control-height-compact);
  padding: 0 var(--space-3);
  color: var(--on-surface);
  font-size: var(--type-label-large-size);
  line-height: var(--type-label-large-line);
  font-weight: var(--type-label-large-weight);
  letter-spacing: var(--type-label-large-tracking);
}
.segmented button + button { border-left: 1px solid var(--outline); }
.segmented button:hover { background: var(--state-hover); }
.segmented button[aria-pressed='true'] { background: var(--secondary-container); color: var(--on-secondary-container); }

.search {
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: var(--shape-small);
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  width: min(240px, 100%);
}
.search::placeholder { color: var(--on-surface-variant); opacity: 1; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px var(--space-3);
  font-size: var(--type-title-small-size);
  line-height: var(--type-title-small-line);
  font-weight: var(--type-title-small-weight);
  letter-spacing: var(--type-title-small-tracking);
  color: var(--on-surface-variant);
  border-bottom: 1px solid var(--outline-variant);
  white-space: nowrap;
}
tbody td { padding: var(--space-3); border-bottom: 1px solid var(--outline-variant); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.row-link:hover { background: var(--surface-2); cursor: pointer; }
.cell-main { font-weight: 500; }
.cell-sub {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
  margin-top: 2px;
}
.muted { color: var(--on-surface-variant); }
.dash { color: var(--on-surface-variant); }

/* The trainings table on a client's page: one line per training. Tighter cells; a short
   header with its unit under it (the full label is the header's title); the sensor in full,
   caveat and all; a gate's reason too long for its column ends in an ellipsis; the flags are
   one count, and a visually hidden list a screen reader reads. Where the card is narrower than
   the table, .table-wrap scrolls sideways as it does for every table. */
.trainings { font-variant-numeric: tabular-nums; }
.trainings thead th { padding: var(--space-2) 5px; vertical-align: bottom; }
.trainings tbody td { position: relative; padding: var(--space-2) 5px; white-space: nowrap; vertical-align: middle; }
.trainings thead th:first-child, .trainings tbody td:first-child { padding-left: var(--space-3); }
.trainings thead th:last-child, .trainings tbody td:last-child { padding-right: var(--space-3); }
.trainings .th-unit {
  display: block;
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  font-weight: 400;
}
.trainings .clip { display: block; max-width: 7.5em; overflow: hidden; text-overflow: ellipsis; }
.trainings .flag-count { cursor: help; padding: 1px var(--space-2); }
.trainings .flag-list {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
/* A cut reason, or the flag list, in full: over its row on one line, so the table's scroll box
   never clips it, on hover, on focus (the reason and the count are Tab stops) and on a tap.
   Escape hides it until the focus or the pointer leaves the cell (tip-hush, app.js; WCAG
   1.4.13). It is the cell's own text, which a screen reader reads once, in the cell. */
@media screen {
  .trainings td:not(.tip-hush) > .clip:hover::after,
  .trainings td:not(.tip-hush) > .clip:focus::after,
  .trainings td:not(.tip-hush):hover > .flag-list,
  .trainings td:not(.tip-hush):focus-within > .flag-list {
    z-index: 2;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid var(--outline-variant);
    border-radius: var(--shape-extra-small);
    background: var(--surface-2);
    box-shadow: var(--shadow-1);
    color: var(--on-surface);
  }
  .trainings td:not(.tip-hush) > .clip:hover::after,
  .trainings td:not(.tip-hush) > .clip:focus::after {
    content: attr(data-full);
    content: attr(data-full) / "";
    position: absolute;
    left: 1px;
    padding: 2px var(--space-1);
  }
  .trainings td:not(.tip-hush):hover > .flag-list,
  .trainings td:not(.tip-hush):focus-within > .flag-list {
    right: var(--space-2);
    display: flex;
    gap: var(--space-2);
    width: auto;
    height: auto;
    padding: 2px var(--space-2);
    overflow: visible;
    clip-path: none;
    list-style: none;
    font-size: var(--type-label-medium-size);
    line-height: var(--type-label-medium-line);
    letter-spacing: var(--type-label-medium-tracking);
  }
  .trainings .flag-list > li + li { padding-left: var(--space-2); border-left: 1px solid var(--outline-variant); }
  /* The focus ring moves onto the popover while it shows. */
  .trainings td:not(.tip-hush) > .clip:focus-visible,
  .trainings td:not(.tip-hush) > .flag-count:focus-visible { outline-color: transparent; }
  .trainings td:not(.tip-hush) > .clip:focus-visible::after,
  .trainings td:not(.tip-hush):has(> .flag-count:focus-visible) > .flag-list { outline: 2px solid var(--primary); outline-offset: 2px; }
}
/* On paper the trainings table wraps again and prints every flag in full. */
@media print {
  .trainings tbody td { white-space: normal; }
  .trainings .clip { max-width: none; overflow: visible; }
  .trainings .flag-count { display: none; }
  .trainings .flag-list { position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal; padding-left: var(--space-4); }
}

/* ── Status vocabulary: every state carries a label, never colour alone ── */

/* Tonal pills: a wash of the tone and text pulled toward on-surface, so the
   label reads at 4.5:1 or better on a card in both themes. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: var(--shape-small);
  padding: 3px var(--space-2);
  background: var(--tone-neutral-fill);
  color: var(--tone-neutral-text);
  font-size: var(--type-label-medium-size);
  line-height: var(--type-label-medium-line);
  font-weight: var(--type-label-medium-weight);
  letter-spacing: var(--type-label-medium-tracking);
  white-space: nowrap;
}
.stack > .chip + .chip { margin-top: 6px; }
.chip-good { background: var(--tone-good-fill); color: var(--tone-good-text); }
.chip-warning { background: var(--tone-warning-fill); color: var(--tone-warning-text); }
.chip-serious { background: var(--tone-error-fill); color: var(--tone-error-text); }
.chip-critical { background: var(--error-container); color: var(--on-error-container); }
.chip-neutral { background: var(--tone-neutral-fill); color: var(--tone-neutral-text); }
.chip-brand { background: var(--tone-brand-fill); color: var(--tone-brand-text); }
button.chip { cursor: pointer; }
button.chip:hover { box-shadow: inset 0 0 0 1px currentColor; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-line { display: flex; align-items: center; gap: var(--space-2); font-weight: 500; }

@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.live-dot { animation: pulse-dot 1.6s ease-in-out infinite; }

.stack { display: flex; flex-direction: column; align-items: flex-start; }

/* ── Charts ─────────────────────────────────────────────────────────────── */

.frame + .frame { margin-top: var(--space-5); }
.frame-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-2); }
.frame-title {
  font-size: var(--type-title-small-size);
  line-height: var(--type-title-small-line);
  font-weight: var(--type-title-small-weight);
  letter-spacing: var(--type-title-small-tracking);
}
.frame-unit {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
}
.frame svg { display: block; width: 100%; height: auto; }

.grid-2 { display: grid; gap: var(--card-gap); grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); }
.grid-3 { display: grid; gap: var(--card-gap); grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
/* Cards side by side in a grid are spaced by the gap, not by the stacking margin;
   a card after a grid keeps the card gap. */
.grid-2 > .card + .card, .grid-3 > .card + .card { margin-top: 0; }
.grid-2 + .card, .grid-3 + .card { margin-top: var(--card-gap); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); }
.kv dt { color: var(--on-surface-variant); }
.kv dd { margin: 0; font-weight: 500; text-align: right; }

.metric-row { display: flex; gap: var(--space-6); flex-wrap: wrap; }
.metric .k {
  font-size: var(--type-label-medium-size);
  line-height: var(--type-label-medium-line);
  font-weight: var(--type-label-medium-weight);
  letter-spacing: var(--type-label-medium-tracking);
  color: var(--on-surface-variant);
}
.metric .v {
  font-size: var(--type-stat-value-size);
  line-height: var(--type-stat-value-line);
  font-weight: var(--type-stat-value-weight);
  letter-spacing: 0;
}
.metric .v small {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  font-weight: 400;
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
}

/* Cut-point strip for questionnaire bands. */
.bands { display: flex; height: 8px; border-radius: var(--shape-extra-small); overflow: hidden; margin: var(--space-2) 0 var(--space-1); }
.bands span { flex: 1; }
.band-marker { position: relative; height: 12px; }
.band-marker i {
  position: absolute; top: -3px; width: 2px; height: 13px; background: var(--on-surface); border-radius: 1px;
}

/* Pacer ring: mirrors what the client sees on the handset. */
.pacer { display: grid; place-items: center; padding: 6px 0; }
.pacer-ring { position: relative; width: 168px; height: 168px; display: grid; place-items: center; }
.pacer-ring .halo {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--primary);
  animation: breathe 10.9s ease-in-out infinite;
}
.pacer-ring .core {
  position: absolute; width: 52%; height: 52%; border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  animation: breathe 10.9s ease-in-out infinite;
}
.pacer-ring .label { position: relative; text-align: center; }
.pacer-ring .phase {
  font-size: var(--type-label-large-size);
  line-height: var(--type-label-large-line);
  font-weight: var(--type-label-large-weight);
  letter-spacing: var(--type-label-large-tracking);
  color: var(--primary);
}
.pacer-ring .rate {
  font-size: var(--type-stat-value-size);
  line-height: var(--type-stat-value-line);
  font-weight: var(--type-stat-value-weight);
}
.pacer-ring .rate small {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  font-weight: 400;
  color: var(--on-surface-variant);
}
@keyframes breathe {
  0%, 100% { transform: scale(0.72); }
  45% { transform: scale(1); }
  50% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .pacer-ring .halo, .pacer-ring .core { animation: none; transform: scale(0.86); }
  .live-dot { animation: none; }
}

.legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

.rule-note {
  color: var(--on-surface-variant);
  border-left: 2px solid var(--outline-variant);
  padding-left: var(--space-3);
  margin-top: var(--space-4);
  max-width: 68ch;
}

footer {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 var(--gutter) var(--space-10);
  color: var(--on-surface-variant);
  text-align: center;
  text-wrap: balance;
}
/* The within-subject statement closes every page under a hairline. */
body > footer {
  padding-top: var(--space-6);
  border-top: 1px solid var(--outline-variant);
}

/* The brand mark heads the sign-in card (decorative: brand cyan on both themes). */
.dialog.signin::before {
  content: '';
  display: block;
  width: 36px;
  height: 36px;
  margin-bottom: var(--space-4);
  background: var(--brand-accent);
  -webkit-mask: url('assets/brand/narbis-mark.svg') center / contain no-repeat;
  mask: url('assets/brand/narbis-mark.svg') center / contain no-repeat;
}

.plan-card {
  background: var(--surface-2);
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-medium);
  padding: var(--card-padding);
}
.plan-card h3 {
  font-size: var(--type-title-medium-size);
  line-height: var(--type-title-medium-line);
  font-weight: var(--type-title-medium-weight);
  letter-spacing: var(--type-title-medium-tracking);
  margin: 0 0 2px;
}
.plan-card .who {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
  margin-bottom: var(--space-3);
}
.plan-card dl { margin: 0; }

.note-item { border-left: 2px solid var(--primary-container); padding-left: var(--space-3); }
.note-item + .note-item { margin-top: var(--space-4); }
.note-item .when {
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
  margin-bottom: 2px;
}

/* ── Dialogs ───────────────────────────────────────────────────────────── */

.modal {
  position: fixed; inset: 0; z-index: 50; background: var(--scrim);
  display: grid; place-items: start center; overflow-y: auto; padding: 6vh var(--space-4) var(--space-8);
}
.dialog {
  position: relative;
  width: min(760px, 100%);
  background: var(--surface-2);
  border-radius: var(--shape-extra-large);
  padding: var(--space-6);
  box-shadow: var(--shadow-3);
}
/* A dialog holds the focus itself only while its pressed button waits for an answer; it is not a
   control, so it draws no ring (its buttons and fields keep theirs). */
.dialog[tabindex="-1"]:focus { outline: none; }
.dialog h2 {
  font-size: var(--type-title-large-size);
  line-height: var(--type-title-large-line);
  font-weight: var(--type-title-large-weight);
  letter-spacing: var(--type-title-large-tracking);
  margin: 0 var(--space-10) var(--space-3) 0;
}
.dialog p {
  margin: 0 0 var(--space-3);
  font-size: var(--type-body-medium-size);
  line-height: var(--type-body-medium-line);
  letter-spacing: var(--type-body-medium-tracking);
}
.m-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: var(--control-height);
  height: var(--control-height);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--on-surface-variant);
}
.m-close:hover { background: var(--state-hover); }
.field { display: block; margin: 0 0 var(--space-4); }
.field > span {
  display: block;
  font-size: var(--type-title-small-size);
  line-height: var(--type-title-small-line);
  font-weight: var(--type-title-small-weight);
  letter-spacing: var(--type-title-small-tracking);
  color: var(--on-surface-variant);
  margin-bottom: 6px;
}
.field input, .field select {
  width: 100%;
  min-height: var(--control-height);
  background: var(--surface-2);
  border: 1px solid var(--outline);
  border-radius: var(--shape-small);
  padding: var(--space-2) var(--space-3);
  font-size: var(--type-body-medium-size);
  line-height: var(--type-body-medium-line);
  letter-spacing: var(--type-body-medium-tracking);
}
.field input:focus-visible, .field select:focus-visible { border-color: var(--primary); }
.field input[aria-invalid="true"] { border-color: var(--error); }
/* A number with its unit after it (the plan's pacer rate): not a caption, so none of .field > span. */
.field > .field-unit { display: flex; align-items: center; gap: var(--space-2); margin: 0; font: inherit; letter-spacing: inherit; color: inherit; }
.field > .field-unit input { width: 9em; flex: none; }
.field small, .m-panel small {
  display: block;
  font-size: var(--type-label-small-size);
  line-height: var(--type-label-small-line);
  letter-spacing: var(--type-label-small-tracking);
  color: var(--on-surface-variant);
  margin-top: 6px;
}
.m-grid { display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); margin: 6px 0 var(--space-4); }
.m-panel {
  background: var(--surface-1);
  border: 1px solid var(--outline-variant);
  border-radius: var(--shape-medium);
  padding: var(--space-3) var(--space-4);
}
.m-panel .k {
  font-size: var(--type-label-medium-size);
  line-height: var(--type-label-medium-line);
  font-weight: var(--type-label-medium-weight);
  letter-spacing: var(--type-label-medium-tracking);
  color: var(--on-surface-variant);
  margin-bottom: var(--space-2);
}
.qr { background: var(--qr-light); border-radius: var(--shape-small); padding: var(--space-2); width: min(200px, 100%); }
.qr svg { display: block; width: 100%; height: auto; }
.code {
  font-size: var(--type-stat-value-size);
  line-height: var(--type-stat-value-line);
  font-weight: var(--type-stat-value-weight);
  letter-spacing: 0.06em;
  margin: var(--space-1) 0 10px;
}
.code span { white-space: nowrap; }
.m-status { display: flex; gap: var(--space-2); align-items: flex-start; color: var(--on-surface-variant); margin-bottom: var(--space-1); }
.m-status .dot { margin-top: 6px; }
.m-error { color: var(--error); margin: calc(-1 * var(--space-1)) 0 var(--space-3); }
.m-info { color: var(--fit-good); margin: calc(-1 * var(--space-1)) 0 var(--space-3); }
.m-actions { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; margin-top: var(--space-2); }

@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; }
  .dialog { padding: var(--space-5) var(--space-4); border-radius: var(--shape-large); }
}

/* ── join.html: the client's page behind an invite link or QR code ──────── */

body.join {
  font-size: var(--type-body-medium-size);
  line-height: var(--type-body-medium-line);
  letter-spacing: var(--type-body-medium-tracking);
}
.join main { max-width: 560px; padding: var(--space-8) var(--gutter) var(--space-14); }
/* The same brand block as the dashboard's app bar, one size up, with a brand
   rule under it. */
.join-brand {
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-5);
  border-bottom: 2px solid var(--brand-accent);
}
.join-brand .brand-logo { width: 155px; height: 26px; }
.join-brand .brand-rule { height: 34px; }
.join-brand .brand-product-name {
  font-size: var(--type-title-medium-size);
  line-height: var(--type-title-medium-line);
}
.join h1 { margin-bottom: var(--space-3); }
.join p { margin: 0 0 var(--space-4); color: var(--on-surface-variant); }
.join p b, .join li b { color: var(--on-surface); font-weight: 500; }
.join-card { margin: var(--space-4) 0; }
.join-card.card + .join-card.card { margin-top: var(--space-4); }
.join-k {
  margin: 0 0 var(--space-2);
  font-size: var(--type-title-small-size);
  line-height: var(--type-title-small-line);
  font-weight: var(--type-title-small-weight);
  letter-spacing: var(--type-title-small-tracking);
  color: var(--on-surface-variant);
}
.join-code {
  font-size: var(--type-timer-size);
  line-height: var(--type-timer-line);
  font-weight: var(--type-timer-weight);
  letter-spacing: 0.06em;
  overflow-wrap: break-word;
  margin-bottom: var(--space-4);
}
.join-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.join-steps { padding-left: var(--space-5); margin: 0; color: var(--on-surface-variant); }
.join-steps li { margin-bottom: var(--space-2); }
.join-card p:last-child { margin-bottom: 0; }
.join-note {
  margin-top: var(--space-3);
  font-size: var(--type-body-small-size);
  line-height: var(--type-body-small-line);
  letter-spacing: var(--type-body-small-tracking);
}
.join .join-warn { color: var(--error); }

/* ── Print: the light tokens (narbis-tokens.css forces them), no chrome ── */

@media print {
  .no-print { display: none !important; }
  html, body { background: var(--surface-2); }
  .card, .tile, .plan-card { break-inside: avoid; }
  .modal { display: none; }
}
