/* The component library. Every shell loads this; each screen's own file only arranges these on
 * the page (R1-D24). A component defined here must not be redefined in admin.css, tech.css or
 * portal.css.
 *
 * Owns: panel and card, page header, button, field and input, table, status chip, tag plate (in
 * base.css), tabs, dialog, toast, empty state, list row, and the inspection blocks.
 *
 * No colour, radius or shadow literal: tokens only.
 */

/* ---- Panel ---------------------------------------------------------------------------
 * Separation by a 1 px border and spacing, never by a shadow (rule 1).
 */
.panel,
.card {
  background: var(--panel);
  border: var(--border) solid var(--line);
  border-radius: var(--radius);
}
.panel-pad,
.card { padding: var(--space-4); }
.card h1 { margin-bottom: var(--space-1); }
.card > p { color: var(--muted); }

/* ---- Page header ---------------------------------------------------------------------
 * A page opens with its name and a one-line figures row, not a banner or four KPI tiles (rule 7).
 */
.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.view-head h1 { font-size: var(--text-xl); }
.view-head p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
}
.figures b { color: var(--ink); font-weight: var(--weight-bold); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }

/* ---- Buttons --------------------------------------------------------------------------
 * Verbs, sentence case, no pill shapes (rules 3 and 8).
 */
.button,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-admin);
  padding: 0 var(--space-3);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-decoration: none;
  transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}
.button:hover:not(:disabled),
.secondary-button:hover:not(:disabled) { background: var(--panel-sunk); }

.button.primary,
.primary-button {
  color: var(--brand-ink);
  background: var(--brand);
  border-color: var(--brand);
}
.button.primary:hover:not(:disabled),
.primary-button:hover:not(:disabled) { background: var(--brand-strong); border-color: var(--brand-strong); }

.button.danger { color: var(--fail-ink); border-color: var(--fail); }
.button.danger:hover:not(:disabled) { background: var(--fail-tint); }

/* Quiet: an action that should not compete, e.g. Cancel beside Save. */
.button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.button.quiet:hover:not(:disabled) { background: var(--panel-sunk); color: var(--ink); }

.button.small { min-height: 30px; padding: 0 var(--space-2); font-size: var(--text-xs); }
.button:disabled,
.primary-button:disabled,
.secondary-button:disabled { opacity: 0.45; cursor: not-allowed; }

/* On the topbar, which is ink-coloured. */
.ghost-button {
  min-height: 32px;
  color: var(--panel);
  background: transparent;
  border-color: color-mix(in srgb, var(--panel) 40%, transparent);
  font-size: var(--text-xs);
}
.ghost-button:hover { background: color-mix(in srgb, var(--panel) 14%, transparent); }

/* The technician app: gloves, a ladder, one hand. Everything meets the 48 px target, including
 * the topbar chrome, which a tech taps with the same glove. */
.tech .button,
.tech .primary-button,
.tech .secondary-button { min-height: var(--tap); font-size: var(--text-md); padding: 0 var(--space-4); }
.tech .ghost-button { min-height: var(--tap); font-size: var(--text-sm); }
.tech .topbar { height: auto; padding-top: var(--space-1); padding-bottom: var(--space-1); }
.primary-button.big { min-height: var(--tap-lg); font-size: var(--text-lg); width: 100%; }
.primary-button.as-link,
.secondary-button.as-link { text-decoration: none; }
.primary-button.disabled { opacity: 0.45; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: var(--tap-admin);
  height: var(--tap-admin);
  border: var(--border) solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  background: none;
}
.icon-button:hover:not(:disabled) { border-color: var(--line); color: var(--ink); background: var(--panel); }
.icon-button:disabled { opacity: 0.35; }

/* ---- Fields and inputs ---------------------------------------------------------------- */
.field,
.form-field { display: block; margin-bottom: var(--space-3); min-width: 0; }
.form-field { display: flex; flex-direction: column; gap: var(--space-1); }
.field > span,
.form-field > span {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.field small,
.form-field small { color: var(--muted); font-size: var(--text-xs); }

.control,
.field input,
.field select,
.field textarea,
.form-field input,
.form-field select,
.form-field textarea,
dialog input,
dialog select,
dialog textarea {
  width: 100%;
  min-height: var(--tap-admin);
  padding: 0 var(--space-2);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  /* 16px stops iOS zooming the page when a field takes focus. */
  font-size: var(--text-md);
}
.tech .field input,
.tech .field textarea,
.tech .field select { min-height: var(--tap); }
.field textarea,
.form-field textarea,
dialog textarea { padding: var(--space-2); min-height: 72px; resize: vertical; line-height: var(--leading-normal); }
.field input:disabled,
.form-field input:disabled { background: var(--panel-sunk); color: var(--muted); }
.field input.invalid,
.control.invalid { border-color: var(--fail); }
.field input[type="checkbox"],
.field input[type="radio"] { width: auto; min-height: 0; }
input[type="color"] { width: 48px; height: var(--tap-admin); padding: 2px; }

.check-row { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap-admin); font-size: var(--text-sm); }
.check-row input { width: 18px; height: 18px; }
/* A radio with its consequence spelled out beside it (Settings → clock mode, R1-D27). */
.radio-rows { display: flex; flex-direction: column; gap: var(--space-2); }
.radio-row { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: start; padding: var(--space-2); border: var(--border) solid var(--line); border-radius: var(--radius); }
.radio-row input { margin-top: 3px; }
.radio-row p { margin: 2px 0 0; font-size: var(--text-sm); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.form-grid .wide { grid-column: 1 / -1; }
.inline-fields { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* ---- Messages -------------------------------------------------------------------------
 * Status colours carry an icon or a word as well, so the meaning survives in greyscale (rule 5).
 */
.form-error,
.notice {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-left: var(--border-thick) solid var(--fail);
  border-radius: var(--radius);
  color: var(--fail-ink);
  background: var(--fail-tint);
  font-size: var(--text-sm);
}
.notice.info { border-left-color: var(--info); color: var(--info-ink); background: var(--info-tint); }
.notice.warn,
.status-note { border-left-color: var(--warn); color: var(--warn-ink); background: var(--warn-tint); }
.notice.ok { border-left-color: var(--ok); color: var(--ok-ink); background: var(--ok-tint); }
.status-note {
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
  border-left: var(--border-thick) solid var(--warn);
  border-radius: var(--radius);
  font-size: var(--text-sm);
}
.empty-state { padding: var(--space-6); text-align: center; color: var(--muted); }

/* ---- Status chips ---------------------------------------------------------------------- */
.pill,
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-sunk);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}
.pill.ok, .chip.ok { color: var(--ok-ink); background: var(--ok-tint); }
.pill.warn, .chip.warn { color: var(--warn-ink); background: var(--warn-tint); }
.pill.bad, .chip.fail { color: var(--fail-ink); background: var(--fail-tint); }
.pill.info, .chip.info { color: var(--info-ink); background: var(--info-tint); }
.pill.off { color: var(--muted); background: var(--panel-sunk); }
.dot { width: 8px; height: 8px; border-radius: var(--radius-dot); background: currentColor; flex: 0 0 auto; }

/* ---- Tables ---------------------------------------------------------------------------
 * Dense and left-aligned on admin screens, instead of card grids (rule 7).
 */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  color: var(--muted);
  background: var(--panel-sunk);
  border-bottom: var(--border) solid var(--line);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td { padding: var(--space-2) var(--space-3); border-bottom: var(--border) solid var(--line); vertical-align: top; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--brand-tint); }
.data-table tr.retired td { color: var(--muted); }
.table-scroll { max-height: calc(100vh - 230px); overflow: auto; }

/* ---- Tabs ------------------------------------------------------------------------------ */
.tabs { display: flex; gap: var(--space-4); border-bottom: var(--border) solid var(--line); margin-bottom: var(--space-4); }
.tabs a, .tabs button {
  padding: var(--space-2) 0;
  border: 0;
  border-bottom: var(--border-thick) solid transparent;
  background: none;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-decoration: none;
}
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }

/* ---- Dialog and toast ------------------------------------------------------------------
 * The only two things allowed to float, and so the only users of --shadow-pop.
 */
dialog {
  width: min(680px, calc(100vw - var(--space-6)));
  max-height: calc(100vh - var(--space-7));
  padding: 0;
  border: var(--border) solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  background: var(--panel);
}
dialog::backdrop { background: color-mix(in srgb, var(--ink) 45%, transparent); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-4); border-bottom: var(--border) solid var(--line); }
.dialog-head h2 { font-size: var(--text-lg); }
.dialog-body { padding: var(--space-4); overflow: auto; max-height: calc(100vh - 190px); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: var(--border) solid var(--line); background: var(--panel-sunk); }
.dialog-error {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-left: var(--border-thick) solid var(--fail);
  color: var(--fail-ink);
  background: var(--fail-tint);
  font-size: var(--text-sm);
}

.toast-stack { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 50; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  max-width: 380px;
  padding: var(--space-3);
  border-radius: var(--radius);
  color: var(--panel);
  background: var(--ink);
  box-shadow: var(--shadow-pop);
  font-size: var(--text-sm);
}
.toast.error { background: var(--fail-ink); }

/* ---- List rows -------------------------------------------------------------------------- */
.record-list { margin: 0; padding: 0; list-style: none; background: var(--panel); border: var(--border) solid var(--line); border-radius: var(--radius); }
.record-list li + li { border-top: var(--border) solid var(--line); }
.record-list a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-1) var(--space-3);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  color: inherit;
  text-decoration: none;
}
.record-list a:hover { background: var(--brand-tint); }
.record-list strong { font-size: var(--text-md); }
.record-list span { grid-column: 1; color: var(--muted); font-size: var(--text-sm); }
.record-list .badge { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.badge {
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  background: var(--panel-sunk);
  color: var(--muted);
  font-size: var(--text-xs);
  font-style: normal;
  font-weight: var(--weight-bold);
}
.badge.warn { background: var(--warn-tint); color: var(--warn-ink); }
.badge.wait { background: var(--info-tint); color: var(--info-ink); }
.badge.bad { background: var(--fail-tint); color: var(--fail-ink); }

/* ---- Icons ------------------------------------------------------------------------------
 * One inline-SVG set, 20px, 1.75px stroke, currentColor, always beside a text label (rule 9).
 */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ==========================================================================================
 * Inspection blocks: one card per check, rendered from a template snapshot by shared/blocks.js.
 * Class names are unchanged from the first version; only the values moved to tokens.
 * ========================================================================================== */

.block-section { margin-bottom: var(--space-5); }
.block-section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  margin-bottom: var(--space-3);
  background: var(--paper);
  border-bottom: var(--border) solid var(--line);
}
.block-section-title h3 { font-size: var(--text-md); }
.section-progress { color: var(--muted); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.section-progress.complete { color: var(--ok); }

.block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-2); }

.block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: var(--border) solid var(--line);
  /* The status shows as a left rule as well as a word, so colour is never the only cue. */
  border-left: var(--border-thick) solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  scroll-margin: 80px;
}
.block:focus { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
.block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.block-label { font-size: var(--text-sm); font-weight: var(--weight-bold); line-height: var(--leading-tight); }
.tech .block-label { font-size: var(--text-md); }
.required-mark { color: var(--fail); text-decoration: none; }
.type-chip {
  flex: 0 0 auto;
  padding: 2px var(--space-2);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel-sunk);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--space-1); }
.segmented.wrap { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.segment {
  min-height: var(--tap);
  padding: var(--space-1) var(--space-2);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
.segment[aria-pressed="true"] { color: var(--panel); border-color: transparent; }
.segment-ok[aria-pressed="true"], .segment-pass[aria-pressed="true"], .segment-done[aria-pressed="true"] { background: var(--ok); }
.segment-attention[aria-pressed="true"], .segment-not_done[aria-pressed="true"] { background: var(--warn); }
.segment-fail[aria-pressed="true"] { background: var(--fail); }
.segment-na[aria-pressed="true"], .segment-__na[aria-pressed="true"] { background: var(--muted); }
.segmented.wrap .segment[aria-pressed="true"] { background: var(--ink); }

.input-wrap { display: flex; align-items: baseline; flex: 1; min-width: 0; border-bottom: var(--border-thick) solid var(--line-strong); }
.input-wrap input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}
.input-wrap input:focus { outline: 0; }
.block .input-wrap input[type="text"] { min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
.input-wrap:focus-within { border-bottom-color: var(--brand); }
.input-wrap input.invalid { color: var(--fail); }
.numpad-display {
  width: 100%; min-width: 0; min-height: var(--tap-lg); padding: 0;
  border: 0; color: var(--ink); background: transparent;
  font-family: var(--font-mono); font-size: var(--text-2xl); font-weight: var(--weight-bold); text-align: left;
}
.unit-label { margin-left: var(--space-1); color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap; }

.measure-row, .adjust-row { display: flex; align-items: flex-end; gap: var(--space-2); }
.mini-label { display: flex; flex-direction: column; flex: 1; min-width: 0; color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: 0.05em; text-transform: uppercase; }
.na-toggle {
  flex: 0 0 auto;
  min-height: var(--tap-admin);
  padding: 0 var(--space-3);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}
.na-toggle[aria-pressed="true"] { color: var(--panel); background: var(--muted); border-color: transparent; }

.action-extras { display: flex; gap: var(--space-2); align-items: flex-end; }
.detail-input, .block textarea {
  width: 100%;
  min-height: 42px;
  padding: var(--space-2);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  font-size: var(--text-md);
  resize: vertical;
}

.derived .derived-value { display: block; height: 42px; line-height: 42px; color: var(--info); font-family: var(--font-mono); font-size: var(--text-2xl); font-weight: var(--weight-bold); }
.behaviour-derived { border-left-color: var(--info); border-left-style: dashed; }

.photo-button {
  min-height: var(--tap);
  border: var(--border) dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--panel);
  font-weight: var(--weight-bold);
}

.block-issue { display: flex; flex-direction: column; gap: var(--space-2); }
.issue-label { display: flex; flex-direction: column; gap: var(--space-1); color: var(--muted); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: 0.05em; text-transform: uppercase; }
.block-issue.note-missing textarea { border-color: var(--fail); background: var(--fail-tint); }
.quick-findings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.finding-button {
  min-height: var(--tap-lg); padding: var(--space-2); border: var(--border) solid var(--line-strong);
  border-radius: var(--radius); color: var(--ink); background: var(--panel); font-weight: var(--weight-bold);
}
.finding-button[aria-pressed="true"] { border-color: var(--warn); color: var(--warn-ink); background: var(--warn-tint); }

.block-help summary { cursor: pointer; color: var(--brand); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.block-help p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-xs); line-height: var(--leading-normal); }

.block-foot { display: flex; justify-content: space-between; gap: var(--space-2); min-height: 15px; font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: 0.05em; text-transform: uppercase; }
/* Not uppercased: the expected range carries units, and uppercasing turns µA into MA and
 * in. w.c. into IN. W.C., which a technician has to stop and decode. */
.block-expected { color: var(--muted); text-transform: none; letter-spacing: 0; }
.block-status { color: var(--muted); text-align: right; }

.block[data-status="ok"], .block[data-status="done"] { border-left-color: var(--ok); background: var(--ok-tint); }
.block[data-status="ok"] .block-status, .block[data-status="done"] .block-status { color: var(--ok-ink); }
.block[data-status="low"] { border-left-color: var(--info); background: var(--info-tint); }
.block[data-status="low"] .block-status { color: var(--info-ink); }
.block[data-status="high"], .block[data-status="fail"] { border-left-color: var(--fail); background: var(--fail-tint); }
.block[data-status="high"] .block-status, .block[data-status="fail"] .block-status { color: var(--fail-ink); }
.block[data-status="attention"] { border-left-color: var(--warn); background: var(--warn-tint); }
.block[data-status="attention"] .block-status { color: var(--warn-ink); }
.block[data-status="na"] { opacity: 0.75; }
.block[data-status="missing"] .block-status { color: var(--fail-ink); }

/* Photos on a check, and the key the iOS decimal keypad does not have. */
.photo-row { display: flex; align-items: flex-start; gap: var(--space-2); }
.photo-row .photo-strip { flex: 1; }
.photo-strip { display: flex; flex-direction: column; gap: var(--space-2); }
.photo-strip .photo-button { width: 100%; }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.photo-thumbs:empty { display: none; }
.photo-thumb { position: relative; margin: 0; }
.photo-open { padding: 0; border: 0; background: none; display: block; }
.photo-thumb img { display: block; width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius); background: var(--panel-sunk); }
.photo-thumb.expanded { flex-basis: 100%; }
.photo-thumb.expanded img { width: 100%; height: auto; max-height: 420px; object-fit: contain; }
.photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-dot);
  color: var(--panel);
  background: var(--ink);
}
.sign-toggle {
  flex: 0 0 auto;
  align-self: center;
  width: 40px;
  height: var(--tap-admin);
  margin-right: var(--space-2);
  border: var(--border) solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

/* Shared SVG charts. Every shell loads this component stylesheet, so the portal and admin
   analytics use identical layout, tokens, focus treatment and table fallback. */
.chart { margin: 0 0 var(--space-5); }
.chart figcaption { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; margin-bottom: var(--space-2); }
.chart-svg { width: 100%; height: auto; max-width: 420px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: var(--text-xs); }
.chart-band { fill: var(--ok-tint); }
.chart-line { stroke: var(--brand); stroke-width: 2; }
.chart-point { fill: var(--brand); }
.chart-svg [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-2) 0; padding: 0; list-style: none; }
.chart-legend li { display: flex; gap: var(--space-2); align-items: center; font-size: var(--text-sm); }
.chart-key { width: 12px; height: 12px; background: var(--muted); }
.chart-key-circle { border-radius: var(--radius-dot); }
.chart-key-square { border-radius: 0; }
.chart-key-triangle { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.chart-key-diamond { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.chart-table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); font-size: var(--text-sm); }
.chart-table th, .chart-table td { padding: var(--space-2); border-bottom: var(--border) solid var(--line); text-align: left; }

/* The chart renderer assigns these classes, never values. HTML legend keys and SVG marks both
   receive their token colour here, so colour never leaks into a screen module. */
.chart-series-1 { fill: var(--chart-1); background: var(--chart-1); }
.chart-series-2 { fill: var(--chart-2); background: var(--chart-2); }
.chart-series-3 { fill: var(--chart-3); background: var(--chart-3); }
.chart-series-4 { fill: var(--chart-4); background: var(--chart-4); }
.chart-series-5 { fill: var(--chart-5); background: var(--chart-5); }
.chart-series-6 { fill: var(--chart-6); background: var(--chart-6); }
.chart-series-7 { fill: var(--chart-7); background: var(--chart-7); }
.chart-series-8 { fill: var(--chart-8); background: var(--chart-8); }
.chart-result-pass { fill: var(--ok); background: var(--ok); }
.chart-result-attention { fill: var(--warn); background: var(--warn); }
.chart-result-fail { fill: var(--fail); background: var(--fail); }
.chart-result-uninspected { fill: var(--muted); background: var(--muted); }

@media (max-width: 420px) {
  .block-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---- Print ------------------------------------------------------------------------------
 * Structure only: the print palette is a redefinition of the tokens, in tokens.css. Navigation,
 * toolbars and anything that only answers a tap are dropped — on paper they waste the page and
 * mislead the reader.
 */
@media print {
  .topbar,
  .admin-nav,
  .toolbar,
  .filter-bar,
  .action-bar,
  .toast-stack,
  .sync-pill,
  .icon-button,
  .button,
  .primary-button,
  .secondary-button,
  .ghost-button,
  .photo-button,
  .quality-legend-button { display: none !important; }

  /* A table that scrolls on screen has to print in full. */
  .table-scroll,
  .quality-leaderboard-scroll { max-height: none !important; overflow: visible !important; }

  .panel,
  .card,
  .block,
  .block-section,
  .quality-panel { break-inside: avoid; }
  .data-table th { background: var(--panel); border-bottom: var(--border) solid var(--ink); }

  /* Colour is gone, so the word and the border carry the status. */
  .pill,
  .chip,
  .badge { border: var(--border) solid var(--line-strong); }
  .block { border-left-width: 3px; }

  a { text-decoration: underline; }
  /* A link's destination is lost on paper, so print it. */
  .admin-main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10pt; color: var(--muted); }
}
