/* ═══════════════════════════════════════════════════════
   ui.css — shared primitives (design system v1, "quiet ledger")

   The catalogue with markup snippets is docs/specs/design-system.md. Tokens
   live in styles.css :root; this file has no :root and no colour literal of
   its own — everything is var(). tests/test_design_system_invariants.py
   holds it to that, and to these rules, so the cascade probe stays clean:

   - Every selector starts with `.pds-`; the only descendants are structural
     children (th, td, tbody tr, legend, svg, i). No IDs, no bare element
     selectors, no `!important`, no numeric z-index.
   - State is `aria-pressed` / `aria-selected` / `aria-current` / `aria-sort`
     / `:disabled`, never a bare `.active` / `.up` / `.down` — pages already
     own those names with other meanings.
   - Inherited properties (colour, font-size, weight, family, tracking,
     white-space) are declared on the container, never on a leaf like `td`, so a page's
     single-class colour (`.pds-pos` on a cell) wins at (0,1,0) with no
     compound selector. docs/specs/fixes/css-cascade-sweep-triage.md.
   - Polarity, never direction: `--pos` / `--neg` say good / bad. Whether "up"
     is good is the page's call (Remakes: no; Check-In: yes) and it maps in
     the template.

   Loaded by base.html, base_scan.html and login.html right after styles.css
   and before any page sheet, so an equal-specificity page rule still wins by
   source order while a page is mid-migration.
   ═══════════════════════════════════════════════════════ */

/* ── Page header ─────────────────────────────────────────── */
.pds-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  border-left: 4px solid var(--red);
  padding-left: var(--space-4);
  margin-bottom: 22px;
}
.pds-title {
  font-family: var(--font-display);
  font-size: var(--type-title);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.2px;
  line-height: 1;
  color: var(--text-primary);
  margin: 0;
}
.pds-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin: var(--space-2) 0 0;
  max-width: 70ch;
}
.pds-meta {
  font-size: var(--type-meta);
  color: var(--text-muted);
  margin: 3px 0 0;
}
.pds-header__actions {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Section head ────────────────────────────────────────── */
.pds-sec-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--type-body);
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--text-primary);
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border-hairline);
  margin: 0 0 14px;
}
.pds-hint {
  font-size: var(--type-meta);
  font-weight: 400;
  color: var(--text-muted);
}

/* ── Stat row ────────────────────────────────────────────────
   One framed surface, hairline dividers, no coloured tiles. The frame is the
   outer element (a <fieldset> when it wants a <legend> cutting the border, a
   <div> otherwise); the cells sit in a wrapping flex row whose 1px gap shows
   the hairline colour through, so the rules survive any wrap without
   nth-child arithmetic — and because the cells grow, a short last row
   stretches across rather than leaving grey holes. The inner box clips its
   own corners so the cells never poke past the frame's radius. A
   category-coloured stat marks its LABEL with a `__dot` (colour inline from
   Python — it is data), never its value. */
.pds-stats {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--stats-frame, var(--red-frame));
  border-radius: var(--radius-lg);
  box-shadow: var(--panel-shadow, none);
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}
.pds-stats__legend {
  margin-left: 14px;
  padding: 0 8px;
  font-size: var(--type-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label-ink, var(--text-muted));
}
.pds-stats__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border-hairline);
  border-radius: calc(var(--radius-lg) - 1px);
  overflow: hidden;
}
.pds-stat {
  flex: 1 1 var(--stat-min, 150px);
  background: var(--bg-card);
  padding: var(--space-4) 18px;
  min-width: 0;
}
.pds-stat__k {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--type-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label-ink, var(--text-muted));
  margin-bottom: 7px;
}
.pds-stat__v {
  display: block;
  font-size: var(--type-stat);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.pds-stat__s {
  font-size: var(--type-caption);
  color: var(--text-secondary);
  margin-top: 5px;
}
.pds-stat__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
/* A stat that filters what is below it (Airway Hold, Call Notes): a <button>
   in the row, pressed = tinted with a red rule along its foot. One that opens
   another page (Airway Planning) is an <a> with the same look: hence the
   color and text-decoration, which the label and value set for themselves. */
.pds-stat--btn {
  font: inherit;
  color: inherit;
  text-align: left;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.pds-stat--btn:hover { background: var(--bg-soft); }
.pds-stat--btn[aria-pressed="true"] {
  background: var(--select-tint, var(--red-tint));
  box-shadow: inset 0 -3px 0 var(--red);
}
.pds-stat--btn:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }

/* ── Panel ───────────────────────────────────────────────── */
.pds-panel {
  background: var(--bg-card);
  border: 1px solid var(--panel-border, var(--border-hairline));
  border-radius: var(--radius-lg);
  box-shadow: var(--panel-shadow, none);
  padding: 18px 20px;
  min-width: 0;
}
.pds-panel--rail { padding: 12px; }
/* A panel led by a titled band edge to edge: the panel drops its padding,
   the band (`__head`) and the body (`__body`) carry their own. */
.pds-panel--flush { padding: 0; overflow: hidden; }
.pds-panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  padding: 10px var(--space-4);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-control-soft);
  font-size: var(--type-body);
  font-weight: 700;
  color: var(--text-primary);
}
.pds-panel__title { margin: 0; font: inherit; white-space: nowrap; }
.pds-panel__hint {
  font-size: var(--type-meta);
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
}
/* The band's count (a `.pds-count`), pushed to its right edge. */
.pds-panel__n { margin-left: auto; }

/* ── Count pill ──────────────────────────────────────────────
   A count beside a heading: ink pill, white figure. */
.pds-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--text-primary);
  color: var(--text-on-dark);
  font-size: var(--type-caption);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pds-panel__body { padding: 14px var(--space-4); }

/* ── Boxed page ──────────────────────────────────────────────
   A page opts in with `pds-boxed` on its root: its panels and stat row get a
   border you can see and a lift, on the deeper `--bg-ground` (styles.css
   `body:has(.pds-boxed)`). White on #F5F5F5 is 1.09:1 and the hairline
   1.16:1, so on a busy page the boxes melted into the ground. Tokens only:
   the panel, the stat row and the rail read them, so nothing reaches into
   any of them. */
.pds-boxed {
  --panel-border: var(--border-control-soft);
  --panel-shadow: var(--shadow-card);
  --stats-frame: var(--border-control-soft);
  /* Stat and filter labels: #999 is 2.85:1 at 10-11px, under AA; #666 is
     5.74:1, the column-header call in docs/specs/design-system.md. */
  --label-ink: var(--text-secondary);
  /* A pressed tile or a picked row: --red-tint is 1.09:1 on white, so only
     the red rule showed the pick. */
  --select-tint: var(--red-select);
}

/* ── Table ───────────────────────────────────────────────────
   Neutralises the element rules in styles.css (dark sticky header, zebra,
   pointer on every th) at one class higher specificity. Inherited text
   properties sit on `.pds-tbl`; `td` carries only box properties, so a cell
   class like `.pds-pos` colours it without a compound selector. `white-space`
   is inherited too, so it lives here: on `td` it beat every page's
   `.x-cell { white-space: normal }` (0,1,0) and the Teams chips on
   /incomplete-calls/admin could not wrap. A box property a cell class must
   override (padding, vertical-align) takes the `td.x-cell` form, the same
   (0,1,1) won by source order. Sorting is one mechanism: the template sets
   `aria-sort` on the active header. */
.pds-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-table);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pds-tbl th {
  background: none;
  position: static;
  z-index: auto;
  cursor: default;
  user-select: auto;
  text-align: left;
  font-size: var(--type-label);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--border-hairline);
}
.pds-tbl th:hover { background: none; }
.pds-tbl td {
  padding: 9px 12px 9px 0;
  border-bottom: 1px solid var(--border-row);
  vertical-align: top;
}
.pds-tbl tbody tr:last-child td { border-bottom: 0; }
/* No zebra. Stated on the row, not on :nth-child(even): at (0,1,2) this
   beats the legacy stripe by source order while a page's own status tint
   (`.pds-tbl tbody tr.overdue-row`, one class more) still beats it. */
.pds-tbl tbody tr { background: none; }
.pds-tbl tbody tr:hover { background: var(--bg-table-alt); }
.pds-tbl--compact td { padding: 6px 12px 6px 0; }
.pds-tbl--compact th { padding-bottom: 6px; }
.pds-tbl--sticky th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--bg-card);
}
.pds-tbl__total td {
  border-top: 2px solid var(--text-primary);
  font-weight: 600;
}
/* Compound like `th.pds-center` below: `.pds-tbl th` sets cursor and
   user-select, and a bare `.pds-th-sort` (0,1,0) never beat it. */
.pds-tbl th.pds-th-sort { cursor: pointer; user-select: none; }
.pds-th-sort:hover { color: var(--text-primary); }
.pds-tbl th[aria-sort="ascending"]::after { content: " \25B2"; font-size: 9px; }
.pds-tbl th[aria-sort="descending"]::after { content: " \25BC"; font-size: 9px; }
.pds-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.pds-right { text-align: right; }
.pds-center { text-align: center; }
/* `.pds-tbl th` sets text-align at (0,1,1), so a bare .pds-right on a header
   cell would lose; compounded, a numeric column's header lines up with it. */
.pds-tbl th.pds-right { text-align: right; }
.pds-tbl th.pds-center { text-align: center; }
.pds-mut { color: var(--text-muted); }
.pds-pos { color: var(--pos); }
.pds-neg { color: var(--neg); }
.pds-warn { color: var(--warn); }

/* ── Tabs (underline) ────────────────────────────────────── */
.pds-tabs {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-hairline);
}
.pds-tab {
  border: 0;
  background: none;
  padding: 0 0 10px;
  margin-bottom: -1px;
  font-family: inherit;
  font-size: var(--type-tab);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.pds-tab:hover { color: var(--text-secondary); }
.pds-tab[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--red);
}
.pds-tab:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ── Segmented control ───────────────────────────────────────
   Joined buttons; the pressed one carries its state with a solid ink fill
   (17:1 on the white group) rather than a tint. The group is outlined in the
   interactive grey, and the dividers inside it in the soft one. */
.pds-seg {
  display: inline-flex;
  align-items: stretch;
  background: var(--bg-card);
  border: 1.5px solid var(--border-control);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pds-seg__btn {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: var(--seg-fs, 12.5px);
  font-weight: 600;
  color: var(--text-secondary);
  padding: 0 var(--seg-px, 14px);
  min-height: calc(var(--control-h) - 4px);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.pds-seg__btn + .pds-seg__btn { border-left: 1.5px solid var(--border-control-soft); }
.pds-seg__btn:hover:not(:disabled):not([aria-pressed="true"]) {
  background: var(--bg-soft);
  color: var(--text-primary);
}
.pds-seg__btn[aria-pressed="true"] {
  background: var(--text-primary);
  color: var(--text-on-dark);
  font-weight: 700;
}
.pds-seg__btn[aria-pressed="true"] + .pds-seg__btn { border-left-color: var(--text-primary); }
.pds-seg__btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pds-seg__btn:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
/* Brand red is 2.87:1 on the ink fill, under the 3:1 a focus ring needs. */
.pds-seg__btn[aria-pressed="true"]:focus-visible { outline-color: var(--text-on-dark); }

/* ── Buttons ─────────────────────────────────────────────────
   `--primary` is the routine action (outlined, fills on hover); `--solid` the
   one action a screen leads with; `--ghost` the occasional one. One primary
   per screen. */
.pds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-h);
  padding: 0 16px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--type-meta);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.pds-btn:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.pds-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.pds-btn--primary { color: var(--red); border-color: var(--red); }
.pds-btn--primary:hover:not(:disabled) { background: var(--red); color: var(--text-on-dark); }
.pds-btn--solid { background: var(--red); border-color: var(--red); color: var(--text-on-dark); }
.pds-btn--solid:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.pds-btn--ink { background: var(--text-primary); border-color: var(--text-primary); color: var(--text-on-dark); }
/* --black and --text-primary are the same #1A1A1A, so the hover has to
   lighten, not darken: the secondary grey keeps white text at 5.7:1. */
.pds-btn--ink:hover:not(:disabled) { background: var(--text-secondary); border-color: var(--text-secondary); }
.pds-btn--danger { color: var(--neg); border-color: var(--neg); }
.pds-btn--danger:hover:not(:disabled) { background: var(--neg); color: var(--text-on-dark); }
/* Ink outline: a reset or an escape (Clear, Close, Cancel) — fills ink on press. */
.pds-btn--outline { border-color: var(--text-primary); color: var(--text-primary); }
.pds-btn--outline:active:not(:disabled) { background: var(--text-primary); color: var(--text-on-dark); }
.pds-btn--ghost {
  height: auto;
  min-height: var(--control-h);
  flex-wrap: wrap;
  row-gap: 1px;
  padding: 7px 14px;
  border: var(--btn-ghost-bw, 1px) solid var(--btn-ghost-border, var(--border-hairline));
  border-radius: var(--radius-sm);
  background: var(--btn-ghost-bg, none);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.pds-btn--ghost:hover:not(:disabled) { border-color: var(--red); color: var(--red); }
/* A second, quieter line under the label ("12 months", "4,120 rows"): takes
   the whole row so an icon beside the label stays on the first line. */
.pds-btn__sub {
  flex-basis: 100%;
  text-align: center;
  font-size: var(--type-label);
  font-weight: 500;
  color: var(--text-muted);
}
.pds-btn--ghost:hover:not(:disabled) .pds-btn__sub { color: var(--red); }
.pds-btn--link {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--red);
  font-size: var(--type-meta);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.pds-btn--link:hover:not(:disabled) { color: var(--red-dark); }
.pds-btn--icon { width: var(--control-h); padding: 0; }
/* min-height too: `--ghost` sets `height: auto; min-height: --control-h` for
   its second line, and min-height beats height, so ghost+sm rendered 36px. */
.pds-btn--sm {
  height: var(--control-h-sm);
  min-height: var(--control-h-sm);
  padding: 0 12px;
  font-size: var(--type-caption);
}
.pds-btn--sm.pds-btn--icon { width: var(--control-h-sm); }
.pds-btn--kiosk {
  min-height: var(--control-h-kiosk);
  height: auto;
  padding: 0 24px;
  border-radius: var(--radius-xl);
  font-size: var(--kiosk-btn-fs, 19px);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pds-btn--kiosk:active:not(:disabled) { transform: scale(0.97); }

/* ── Inputs ──────────────────────────────────────────────── */
.pds-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.pds-filters__label {
  font-size: var(--type-caption);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--label-ink, var(--text-muted));
}
.pds-input,
.pds-select {
  height: var(--control-h);
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  outline: none;
}
.pds-input:focus-visible,
.pds-select:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.pds-input::placeholder { color: var(--text-muted); }
.pds-select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%23333333' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.pds-input--search { min-width: 220px; }

/* ── Chips ───────────────────────────────────────────────────
   State reads as a chip, not a sentence — the audience works here. */
.pds-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--type-caption);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  background: var(--bg-soft);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pds-chip--pos { background: var(--pos-bg); color: var(--pos); }
.pds-chip--neg { background: var(--neg-bg); color: var(--neg); }
.pds-chip--warn { background: var(--warn-bg); color: var(--warn); }
.pds-chip--info { background: var(--info-bg); color: var(--info); }
.pds-chip--ink { background: var(--text-primary); color: var(--text-on-dark); }
.pds-chip--none { background: transparent; color: var(--text-muted); }
.pds-chip--sq { border-radius: var(--radius-sm); padding: 1px 7px; }
/* A value chip ("vs last mo +3.2%"): sentence case, with a quieter key. */
.pds-chip--text {
  gap: 4px;
  padding: 1px 7px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.pds-chip__k { font-weight: 500; opacity: 0.8; }
/* A category-coloured chip (partials/_category_chip.html) leads with a
   `__dot`; like `.pds-stat__dot`, its colour is data, set inline. */
.pds-chip__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.pds-chip--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ── Delta (text form; chip form is .pds-chip--pos/--neg) ── */
.pds-delta { font-size: var(--type-meta); font-weight: 700; white-space: nowrap; }
.pds-delta--pos { color: var(--pos); }
.pds-delta--neg { color: var(--neg); }
.pds-delta--flat { color: var(--text-muted); font-weight: 500; }

/* ── Rail (a list of rows that drives a detail panel) ──────── */
.pds-rail {
  border: 1px solid var(--red-frame);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  overflow: hidden;
}
.pds-rail__h {
  font-size: var(--type-label);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 7px;
  background: var(--red-wash);
}
.pds-rail__row {
  display: grid;
  grid-template-columns: 1fr auto 12px;
  gap: 10px;
  align-items: baseline;
  align-content: center;
  min-height: 52px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border-row);
  border-left: 3px solid transparent;
  padding: 9px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--type-body);
  color: var(--text-primary);
  transition: background 0.12s;
}
.pds-rail__row:hover { background: var(--bg-soft); }
.pds-rail__row:last-child { border-bottom: 0; }
.pds-rail__row[aria-current="true"] {
  background: var(--select-tint, var(--red-tint));
  border-left-color: var(--red);
  font-weight: 600;
}
.pds-rail__row:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.pds-rail__n { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.pds-rail__go {
  color: var(--border-control-soft);
  font-size: 15px;
  line-height: 1;
  transition: color 0.12s, transform 0.12s;
}
.pds-rail__row:hover .pds-rail__go { color: var(--red); transform: translateX(2px); }
.pds-rail__row[aria-current="true"] .pds-rail__go { color: var(--red); }

/* ── Pager ───────────────────────────────────────────────── */
.pds-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--type-meta);
  color: var(--text-secondary);
}
.pds-pager__n { font-variant-numeric: tabular-nums; }

/* ── Modal ─────────────────────────────────────────────────
   One backdrop, one card, one z scale. `--top` is for a modal that opens from
   inside another; the work-order sheet sits above both on --z-top. */
.pds-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.pds-modal-backdrop--top { z-index: var(--z-modal-2); }
.pds-modal {
  display: flex;
  flex-direction: column;
  width: min(var(--modal-w, 720px), 100%);
  max-height: 85vh;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
}
.pds-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-hairline);
}
.pds-modal__title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -0.1px;
  line-height: 1;
  color: var(--text-primary);
  margin: 0;
}
.pds-modal__close {
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.pds-modal__close:hover { background: var(--bg-soft); color: var(--text-primary); }
.pds-modal__close:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.pds-modal__body { padding: 16px 20px; overflow: auto; min-height: 0; }
.pds-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-hairline);
}

/* ── Empty state ─────────────────────────────────────────── */
/* `td.pds-empty` too: as a table row the padding has to beat `.pds-tbl td`,
   the same (0,1,1) won by source order. One selector list, one value. */
.pds-empty,
td.pds-empty {
  padding: 40px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.pds-empty__title {
  font-size: var(--type-body);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.pds-empty__hint { font-size: var(--type-meta); }

/* ── Spinner ─────────────────────────────────────────────── */
.pds-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-hairline);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: pds-spin 0.8s linear infinite;
}
.pds-spinner--lg { width: 48px; height: 48px; border-width: 4px; }
.pds-spinner--inline { vertical-align: middle; margin-right: 8px; }
.pds-spinner-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-2);
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes pds-spin { to { transform: rotate(360deg); } }

/* ── Toast (static/js/pds.js pdsToast) ───────────────────── */
.pds-toast-region {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.pds-toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--text-primary);
  color: var(--text-on-dark);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-modal);
  white-space: nowrap;
}
.pds-toast--pos { background: var(--pos); }
.pds-toast--neg { background: var(--neg); }

/* ── Banner (shell-wide notices) ─────────────────────────── */
.pds-banner {
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
}
.pds-banner--error { background: var(--neg-bg); color: var(--neg); }
.pds-banner--warn { background: var(--warn-bg); color: var(--warn); }
.pds-banner--info { background: var(--info-bg); color: var(--info); }
.pds-banner--pos { background: var(--pos-bg); color: var(--pos); }

/* ── Chart wrapper + HTML legend ──────────────────────────── */
.pds-chart { position: relative; height: var(--chart-h, 250px); }
.pds-chart--sm { --chart-h: 180px; }
.pds-chart--lg { --chart-h: 320px; }
.pds-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: var(--type-caption);
  color: var(--text-secondary);
}
.pds-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: -1px;
}

/* ── Icon (sprite symbols in partials/_icons.html) ───────── */
.pds-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.pds-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: none;
  vertical-align: -3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Density ─────────────────────────────────────────────────
   Same primitives, re-tokened on a wrapper. `.pds-display` is a wall
   screen (Case Locations opts in with ?display=1) — read from across a
   room; `.pds-kiosk` the scan iPads — ≥64px targets under a glove. */
.pds-display {
  --type-table: 16px;
  --type-label: 12px;
  --type-body: 16px;
  --type-stat: 34px;
  --type-title: 40px;
  --control-h: 44px;
}
.pds-display .pds-tbl th {
  color: var(--text-primary);
  border-bottom: 2px solid var(--text-primary);
}
.pds-display .pds-tbl td { padding: 12px 14px 12px 0; }
.pds-kiosk {
  --control-h: 64px;
  --control-h-sm: 48px;
  --type-body: 17px;
  --type-table: 15px;
  --radius-md: 12px;
  --radius-lg: 12px;
  /* Under a glove a pick-from card needs a visible edge and a white face,
     and the mode tabs read from arm's length. */
  --btn-ghost-bw: 1.5px;
  --btn-ghost-border: var(--border-control);
  --btn-ghost-bg: var(--bg-card);
  --seg-fs: 17px;
  --seg-px: 22px;
}

@media (prefers-reduced-motion: reduce) {
  .pds-spinner { animation-duration: 2s; }
  .pds-rail__row:hover .pds-rail__go { transform: none; }
  .pds-tab,
  .pds-seg__btn,
  .pds-btn,
  .pds-rail__row,
  .pds-rail__go { transition: none; }
}
