/* ==========================================================================
   KPS Warranty — Application shell
   Graphite chrome on the left, paper work surface on the right.
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.side {
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--chrome);
  border-right: 1px solid var(--chrome-line);
  overflow: hidden;
  z-index: var(--z-sticky);
}

.side__brand {
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h); flex: none;
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--chrome-line);
  text-decoration: none;
  color: var(--chrome-ink);
}
.side__mark { width: 26px; height: 26px; flex: none; }
.side__name {
  display: flex; flex-direction: column; line-height: 1.1; min-width: 0;
}
.side__name b {
  font-size: var(--t-13); font-weight: 700; letter-spacing: -0.01em;
  font-variation-settings: "wdth" 108;
}
.side__name span {
  font-size: 9.5px; font-weight: 550; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--chrome-ink-2);
}

.side__scroll { flex: 1 1 auto; overflow-y: auto; padding: var(--s-3) var(--s-2) var(--s-4); }
.side__scroll::-webkit-scrollbar-thumb { background: var(--chrome-3); border-color: var(--chrome); }

.nav-group { margin-bottom: var(--s-4); }
.nav-group__label {
  padding: var(--s-2) var(--s-3) var(--s-1);
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.13em;
  text-transform: uppercase; color: color-mix(in oklab, var(--chrome-ink-2) 78%, transparent);
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: var(--s-3);
  height: 32px; padding: 0 var(--s-3);
  border-radius: var(--r-2);
  color: var(--chrome-ink-2);
  font-size: var(--t-13); font-weight: 500;
  text-decoration: none; white-space: nowrap;
  transition: background-color var(--d-state) var(--ease-out),
              color var(--d-state) var(--ease-out);
}
.nav-item .icon { width: 16px; height: 16px; flex: none; opacity: 0.9; }
.nav-item .grow { overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: var(--chrome-2); color: var(--chrome-ink); }
}
.nav-item[aria-current="page"] {
  background: var(--chrome-2);
  color: var(--chrome-ink);
  font-weight: 600;
}
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--stamp);
}
.nav-item__count {
  font-family: var(--font-data); font-size: var(--t-11); font-weight: 500;
  padding: 1px 5px; border-radius: var(--r-full);
  background: var(--chrome-3); color: var(--chrome-ink-2);
}
.nav-item[aria-current="page"] .nav-item__count { background: var(--stamp); color: var(--ink-invert); }

.nav-dot { width: 7px; height: 7px; border-radius: 2px; flex: none; }

.side__foot {
  flex: none;
  padding: var(--s-3);
  border-top: 1px solid var(--chrome-line);
}

/* who you are / role control */
.whoami {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: var(--s-2);
  border-radius: var(--r-2);
  color: var(--chrome-ink); text-align: left;
  transition: background-color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .whoami:hover { background: var(--chrome-2); } }
.avatar {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-2);
  background: var(--chrome-3); color: var(--chrome-ink);
  font-size: var(--t-11); font-weight: 700; letter-spacing: 0.02em;
}
.whoami__txt { min-width: 0; line-height: 1.25; }
.whoami__txt b { display: block; font-size: var(--t-12); font-weight: 600; }
.whoami__txt span { display: block; font-size: var(--t-11); color: var(--chrome-ink-2); }

/* ==========================================================================
   MAIN
   ========================================================================== */

.main { display: flex; flex-direction: column; min-width: 0; background: var(--surface); }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h); flex: none;
  padding: 0 var(--s-5);
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}
.topbar__crumbs {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-12); color: var(--ink-3); min-width: 0;
}
.topbar__crumbs a { color: var(--ink-3); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .topbar__crumbs a:hover { color: var(--ink); } }
.topbar__crumbs b { color: var(--ink); font-weight: 600; }
.topbar__sep { color: var(--ink-3); }

.side-toggle { display: none; }

.page { padding: var(--s-6) var(--s-5) var(--s-16); flex: 1 1 auto; min-width: 0; }
.page--flush { padding: 0; }
.page__head {
  display: flex; align-items: flex-start; gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.page__title { font-size: var(--t-24); font-weight: 650; letter-spacing: -0.022em; }
.page__lede {
  font-size: var(--t-13); color: var(--ink-3);
  margin-top: var(--s-1); max-width: 72ch; line-height: var(--lh-body);
}
.page__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

.section { margin-bottom: var(--s-8); }
.section__head {
  display: flex; align-items: baseline; gap: var(--s-3);
  margin-bottom: var(--s-3); flex-wrap: wrap;
}
.section__title { font-size: var(--t-14); font-weight: 650; letter-spacing: -0.005em; }
.section__note { font-size: var(--t-12); color: var(--ink-3); }

/* toolbar above tables/boards */
.toolbar {
  display: flex; align-items: center; gap: var(--s-3);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-3) var(--r-3) 0 0;
  border-bottom: 0;
}
.toolbar + .panel { border-radius: 0 0 var(--r-3) var(--r-3); }
.toolbar__sep { width: 1px; align-self: stretch; background: var(--hairline); margin: 0 var(--s-1); }

/* fixed bulk-action bar (FR-18) */
.bulkbar {
  position: sticky; bottom: var(--s-4);
  z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--s-3);
  margin: var(--s-4) 0 0;
  padding: var(--s-3) var(--s-4);
  background: var(--chrome); color: var(--chrome-ink);
  border: 1px solid var(--chrome-line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-3);
  transform: translateY(0); opacity: 1;
  transition: transform var(--d-modal) var(--ease-out), opacity var(--d-modal) var(--ease-out);
}
.bulkbar[hidden] { display: none; }
@starting-style { .bulkbar { transform: translateY(12px); opacity: 0; } }
.bulkbar b { font-family: var(--font-data); font-weight: 600; }
.bulkbar .btn {
  --btn-bg: var(--chrome-2); --btn-ink: var(--chrome-ink); --btn-line: var(--chrome-3);
  --btn-bg-hover: var(--chrome-3); --btn-line-hover: var(--chrome-ink-2);
  --btn-ink-hover: var(--chrome-ink);
}
.bulkbar .btn--primary { --btn-bg: var(--stamp); --btn-line: var(--stamp); --btn-ink: var(--ink-invert); }

/* impersonation banner (FR-4) */
.impersonating {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-5);
  background: var(--warn-bg);
  border-bottom: 1px solid var(--warn-line);
  color: var(--warn);
  font-size: var(--t-12); font-weight: 600;
}
.impersonating .icon { width: 15px; height: 15px; }

/* stat strip — a row of measured values, not a hero-metric card grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--hairline);
  border-radius: var(--r-3);
  overflow: hidden;
  background: var(--surface);
}
.stat {
  padding: var(--s-4);
  border-right: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  min-width: 0;
}
.stat:last-child { border-right: 0; }
.stat__k {
  font-size: var(--t-11); font-weight: 650; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3);
}
.stat__v {
  font-size: var(--t-30); font-weight: 600; letter-spacing: -0.03em;
  line-height: 1.1; margin-top: var(--s-2);
  font-variant-numeric: tabular-nums;
}
.stat__v small { font-size: var(--t-14); font-weight: 550; color: var(--ink-3); letter-spacing: 0; }
.stat__d { font-size: var(--t-12); color: var(--ink-3); margin-top: var(--s-1); }

/* grid helpers */
.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.split { display: grid; gap: var(--s-5); align-items: start; }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr) 340px; } }
@media (min-width: 1100px) { .split--wide { grid-template-columns: minmax(0, 1fr) 420px; } }
.sticky-aside { position: sticky; top: calc(var(--topbar-h) + var(--s-5)); }

/* ==========================================================================
   RESPONSIVE — structural, not fluid type
   ========================================================================== */

@media (max-width: 1099px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; inset: 0 auto 0 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform var(--d-modal) var(--ease-drawer);
    box-shadow: var(--shadow-3);
  }
  .app[data-side="open"] .side { transform: translateX(0); }
  .app[data-side="open"]::after {
    content: ""; position: fixed; inset: 0;
    z-index: calc(var(--z-sticky) - 1);
    background: oklch(0.17 0.004 285 / 0.4);
  }
  .side-toggle { display: inline-flex; }
  .page { padding: var(--s-5) var(--s-4) var(--s-16); }
  .topbar { padding: 0 var(--s-4); }
}

@media (max-width: 767px) {
  .page__title { font-size: var(--t-20); }
  .stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
  .stat__v { font-size: var(--t-24); }
  .toolbar { padding: var(--s-3); }
  .bulkbar { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}

/* ==========================================================================
   PRINT — settlement statements have to survive a printer
   ========================================================================== */

@media print {
  .side, .topbar, .page__actions, .toolbar, .bulkbar, .no-print { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .page { padding: 0; }
  .panel { border-color: #ccc; box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* ---- claim photos ------------------------------------------------------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: var(--s-2); }
.img-thumb {
  border: 1px solid var(--hairline); border-radius: var(--r-2);
  overflow: hidden; cursor: pointer; background: var(--surface-3);
  transition: border-color var(--d-state) var(--ease-out), transform var(--d-press) var(--ease-out);
}
.img-thumb:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .img-thumb:hover { border-color: var(--hairline-3); } }
.img-thumb svg { width: 100%; height: auto; display: block; }
.lightbox { border: 1px solid var(--hairline); border-radius: var(--r-2); overflow: hidden; }
.lightbox svg { width: 100%; height: auto; }

/* ---- workbench grouping ------------------------------------------------- */
.col__group { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-3); }
.col__group-head {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-2);
  font-size: var(--t-11); font-weight: 650;
  letter-spacing: 0.02em; color: var(--ink-3);
}
.col__group-head .icon { width: 13px; height: 13px; }

/* ==========================================================================
   EMAIL PREVIEW — what the recipient will actually see, on the white ground
   an email client renders on regardless of the platform's theme.
   ========================================================================== */
.email {
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-2);
  overflow: hidden;
  background: #fff;
  color: #1a1a1c;
}
.email__head {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid #e4e4e7;
  background: #fafafa;
  font-size: var(--t-13);
  display: flex; flex-direction: column; gap: 2px;
}
.email__label {
  display: inline-block; min-width: 58px;
  color: #71717a; font-size: var(--t-12); font-weight: 600;
}
.email__body {
  padding: var(--s-5);
  font-size: var(--t-14); line-height: 1.55;
  max-height: 640px; overflow-y: auto;
}
.email__body h2 { font-size: 19px; font-weight: 650; color: #18181b; }
.email__body h3 { font-size: 14px; font-weight: 650; color: #18181b; }
.email__body p { color: #3f3f46; }
.email__pre {
  margin: 0; padding: var(--s-5);
  font-family: var(--font-data); font-size: var(--t-12); line-height: 1.6;
  color: #27272a; white-space: pre; overflow-x: auto;
  max-height: 640px; overflow-y: auto;
}
table.email-tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 4px; }
table.email-tbl th, table.email-tbl td {
  padding: 6px 8px; border-bottom: 1px solid #e4e4e7; text-align: left;
}
table.email-tbl thead th {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: #71717a;
  border-bottom: 1px solid #d4d4d8;
}
table.email-tbl tfoot th { border-top: 1px solid #d4d4d8; border-bottom: 0; color: #18181b; }

/* ==========================================================================
   COMBOBOX — property search with inline creation
   Rendered as a positioned list inside a relative wrapper. The wrapper is
   never inside an overflow-hidden container, so it cannot be clipped.
   ========================================================================== */
.combo { position: relative; }
.combo__list {
  position: absolute; z-index: var(--z-dropdown);
  top: calc(100% + 4px); left: 0; right: 0;
  max-height: 300px; overflow-y: auto;
  padding: var(--s-1);
  background: var(--surface);
  border: 1px solid var(--hairline-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
}
.combo__item {
  display: flex; align-items: center; gap: var(--s-2);
  width: 100%; padding: var(--s-2);
  border-radius: 4px;
  font-size: var(--t-13); color: var(--ink-2);
  text-align: left;
  transition: background-color var(--d-state) var(--ease-out);
}
.combo__item b { color: var(--ink); font-weight: 600; }
@media (hover: hover) and (pointer: fine) {
  .combo__item:hover { background: var(--surface-3); }
}
.combo__item--new { border-top: 1px solid var(--hairline); margin-top: var(--s-1); color: var(--stamp); }
.combo__item--new b { color: var(--stamp); }

/* ==========================================================================
   CHOICE GRID — radio cards for a short, meaningful list
   ========================================================================== */
.choice-grid {
  display: grid; gap: var(--s-2);
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.choice {
  display: flex; align-items: flex-start; gap: var(--s-2);
  padding: var(--s-3);
  border: 1px solid var(--hairline);
  border-radius: var(--r-2);
  cursor: pointer;
  transition: border-color var(--d-state) var(--ease-out),
              background-color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .choice:hover { border-color: var(--hairline-3); }
}
.choice:has(input:checked) { border-color: var(--stamp); background: var(--stamp-soft); }
.choice input {
  appearance: none; flex: none;
  width: 15px; height: 15px; margin-top: 2px;
  border: 1px solid var(--hairline-3); border-radius: 50%;
  display: grid; place-content: center;
  transition: border-color var(--d-state) var(--ease-out), background-color var(--d-state) var(--ease-out);
}
.choice input:checked { border-color: var(--stamp); background: var(--stamp); }
.choice input::after {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-invert); transform: scale(0);
  transition: transform var(--d-press) var(--ease-out);
}
.choice input:checked::after { transform: scale(1); }
.choice__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.choice__name { font-size: var(--t-13); font-weight: 550; color: var(--ink); }
.choice__note {
  display: flex; align-items: center; gap: 4px;
  font-size: var(--t-11); color: var(--ink-3);
}

/* ==========================================================================
   WORKFLOW DIAGRAM
   ========================================================================== */
.flow-wrap { overflow-x: auto; padding: var(--s-5); background: var(--surface-2); }
.flow { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.flow__box {
  fill: var(--surface);
  stroke: var(--hairline-2);
  stroke-width: 1;
  transition: stroke var(--d-state) var(--ease-out), fill var(--d-state) var(--ease-out);
}
.flow__node[data-on="true"] .flow__box { stroke: var(--stamp); stroke-width: 2; fill: var(--stamp-soft); }
.flow__name { font-size: 12px; font-weight: 600; fill: var(--ink); }
.flow__meta { font-size: 9.5px; fill: var(--ink-3); }
.flow__label text { font-size: 9.5px; font-weight: 650; }
.flow__dot { stroke-width: 1; }
.flow__dot.tone-neutral  { fill: var(--hairline-3); stroke: var(--hairline-3); }
.flow__dot.tone-info     { fill: var(--info); stroke: var(--info); }
.flow__dot.tone-progress { fill: none; stroke: var(--info); }
.flow__dot.tone-active   { fill: var(--ink); stroke: var(--ink); }
.flow__dot.tone-accept   { fill: var(--accept); stroke: var(--accept); }
.flow__dot.tone-decline  { fill: var(--decline); stroke: var(--decline); }
.flow__dot.tone-no-fault { fill: var(--no-fault); stroke: var(--no-fault); }
.flow__dot.tone-pending  { fill: var(--warn); stroke: var(--warn); }
@media (hover: hover) and (pointer: fine) {
  .flow__node { cursor: pointer; }
  .flow__node:hover .flow__box { stroke: var(--hairline-3); }
}
.flow-legend {
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5);
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--hairline);
  font-size: var(--t-12); color: var(--ink-3);
}
.flow-legend span { display: inline-flex; align-items: center; gap: var(--s-2); }
.flow-legend i { display: inline-block; }

/* role visibility matrix */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--t-12); }
.matrix th, .matrix td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--hairline); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; white-space: nowrap; }
.matrix thead th {
  font-size: var(--t-11); font-weight: 650; letter-spacing: 0.03em;
  text-transform: uppercase; color: var(--ink-3);
  background: var(--surface-2); border-bottom: 1px solid var(--hairline-2);
  position: sticky; top: 0;
}
.matrix .mk { display: inline-grid; place-content: center; width: 20px; height: 20px; border-radius: 5px; }
.matrix .mk--rw { background: var(--stamp-soft); color: var(--stamp); }
.matrix .mk--r  { background: var(--surface-3); color: var(--ink-3); }
.matrix .mk--no { color: var(--hairline-2); }

/* ---- dropzone ----------------------------------------------------------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-2); padding: var(--s-10) var(--s-5);
  border: 1.5px dashed var(--hairline-2);
  border-radius: var(--r-3);
  background: var(--surface-2);
  color: var(--ink-3);
  cursor: pointer; text-align: center;
  transition: border-color var(--d-state) var(--ease-out), background-color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .dropzone:hover { border-color: var(--stamp); background: var(--stamp-soft); color: var(--stamp); }
}
.dropzone__title { font-size: var(--t-14); font-weight: 600; color: var(--ink); }
.dropzone:hover .dropzone__title { color: var(--stamp); }
.dropzone__note { font-size: var(--t-12); }

/* ---- date-code chips ---------------------------------------------------- */
.code-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 26px; padding: 0 var(--s-2);
  border: 1px solid var(--hairline); border-radius: var(--r-2);
  background: var(--surface-2);
  text-decoration: none; color: var(--ink);
  transition: border-color var(--d-state) var(--ease-out), background-color var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .code-chip:hover { border-color: var(--stamp); background: var(--stamp-soft); }
}
.code-chip__yr {
  font-family: var(--font-data); font-size: var(--t-11); font-weight: 600;
  color: var(--ink-3); padding-left: var(--s-1);
  border-left: 1px solid var(--hairline);
}
.code-chip__yr--miss { color: var(--warn); }

/* ---- navigation preview -------------------------------------------------- */
.nav-preview {
  background: var(--chrome);
  padding: var(--s-3) var(--s-2);
  border-radius: 0 0 var(--r-3) var(--r-3);
}
.nav-preview .nav-item { cursor: default; }
.nav-preview .nav-group__label { color: color-mix(in oklab, var(--chrome-ink-2) 78%, transparent); }

/* ---- code blocks --------------------------------------------------------- */
pre.code {
  position: relative;
  margin: 0; padding: var(--s-4);
  background: var(--chrome); color: var(--chrome-ink);
  border-radius: var(--r-2);
  font-family: var(--font-data); font-size: var(--t-12); line-height: 1.6;
  overflow-x: auto; overscroll-behavior-x: contain;
}
pre.code code { font-family: inherit; font-size: inherit; white-space: pre; }
.code__copy {
  position: absolute; top: var(--s-2); right: var(--s-2);
  --btn-bg: var(--chrome-2); --btn-ink: var(--chrome-ink); --btn-line: var(--chrome-3);
  --btn-bg-hover: var(--chrome-3); --btn-line-hover: var(--chrome-ink-2);
  --btn-ink-hover: var(--chrome-ink);
  opacity: 0; transition: opacity var(--d-state) var(--ease-out);
}
pre.code:hover .code__copy, .code__copy:focus-visible { opacity: 1; }
@media (hover: none) { .code__copy { opacity: 1; } }

.method {
  display: inline-grid; place-content: center;
  min-width: 46px; height: 20px; padding: 0 6px;
  border-radius: var(--r-1);
  font-family: var(--font-data); font-size: var(--t-11); font-weight: 600;
  letter-spacing: 0.04em;
}
.method--post { background: var(--accept-bg); color: var(--accept); }
.method--get  { background: var(--info-bg); color: var(--info); }

/* ==========================================================================
   HELP CENTRE
   ========================================================================== */
.help-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.help-card {
  display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4);
  border: 1px solid var(--hairline); border-radius: var(--r-3);
  background: var(--surface); text-decoration: none;
  transition: border-color var(--d-state) var(--ease-out), box-shadow var(--d-state) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .help-card:hover { border-color: var(--hairline-3); box-shadow: var(--shadow-1); }
}
.help-card__title { font-size: var(--t-14); font-weight: 650; color: var(--ink); }
.help-card__sum { font-size: var(--t-13); color: var(--ink-2); line-height: var(--lh-body); }
.help-card__meta {
  display: flex; align-items: center; gap: var(--s-2);
  margin-top: auto; padding-top: var(--s-2); font-size: var(--t-11);
}

/* long-form article body */
.article { max-width: 68ch; color: var(--ink-2); line-height: var(--lh-prose); }
.article h2 { font-size: var(--t-18); margin: var(--s-6) 0 var(--s-3); }
.article h2:first-child { margin-top: 0; }
.article h3 { font-size: var(--t-14); margin: var(--s-5) 0 var(--s-2); }
.article p { margin: 0 0 var(--s-4); }
.article strong { color: var(--ink); font-weight: 600; }
.article ul, .article ol { margin: 0 0 var(--s-4); padding-left: var(--s-5); }
.article li { margin-bottom: var(--s-2); }
.article table { width: 100%; border-collapse: collapse; margin: 0 0 var(--s-4); font-size: var(--t-13); }
.article th, .article td { padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--hairline); text-align: left; }
.article th { color: var(--ink-3); font-size: var(--t-11); text-transform: uppercase; letter-spacing: 0.03em; }
.article figure { margin: 0 0 var(--s-4); }
.article figcaption { font-size: var(--t-12); color: var(--ink-3); margin-top: var(--s-2); }

.editor-bar { display: flex; flex-wrap: wrap; gap: var(--s-1); margin-bottom: var(--s-2); }

/* ==========================================================================
   CHARTS
   Thin marks, recessive grid, text in ink tokens rather than the series
   colour, and a hover layer on every plotted form.
   ========================================================================== */
.chart-empty {
  padding: var(--s-8) var(--s-4);
  text-align: center; font-size: var(--t-13); color: var(--ink-3);
  border: 1px dashed var(--hairline); border-radius: var(--r-2);
}

/* ---- horizontal bars ---------------------------------------------------- */
.chart--bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 150px) 1fr 46px 38px;
  align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-2);
  border-radius: var(--r-2);
  transition: background-color var(--d-state) var(--ease-out);
}
.bar-row[data-href] { cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .bar-row[data-href]:hover { background: var(--surface-3); }
}
.bar-row:focus-visible { background: var(--surface-3); }
.bar-row__label {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-12); color: var(--ink-2); min-width: 0;
}
.bar-row__track { height: 10px; background: var(--surface-4); border-radius: 0 4px 4px 0; }
.bar-row__fill {
  display: block; height: 100%;
  background: var(--stamp);
  border-radius: 0 4px 4px 0;
  transition: width var(--d-modal) var(--ease-out);
}
.bar-row__value {
  font-family: var(--font-data); font-size: var(--t-12); font-weight: 600;
  color: var(--ink); text-align: right;
}
.bar-row__share {
  font-family: var(--font-data); font-size: var(--t-11);
  color: var(--ink-3); text-align: right;
}
@media (max-width: 560px) {
  .bar-row { grid-template-columns: minmax(80px, 1fr) 2fr 40px; }
  .bar-row__share { display: none; }
}

/* ---- donut -------------------------------------------------------------- */
.chart--donut { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.donut__total { font-size: 22px; font-weight: 650; fill: var(--ink); font-variant-numeric: tabular-nums; }
.donut__cap { font-size: 10px; fill: var(--ink-3); letter-spacing: 0.04em; }
.chart-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 150px; min-width: 150px; }
.chart-legend li {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) 0; margin: 0;
  border-bottom: 1px solid var(--hairline);
  font-size: var(--t-12); color: var(--ink-2);
}
.chart-legend li:last-child { border-bottom: 0; }
.chart-legend i {
  width: 10px; height: 10px; border-radius: 2px; flex: none;
  box-shadow: 0 0 0 2px var(--surface);
}
.chart-legend i.hatched {
  background-image: repeating-linear-gradient(45deg,
    transparent 0 2px, var(--surface) 2px 3px) !important;
  background-blend-mode: normal;
}
.chart-legend b { color: var(--ink); font-weight: 600; }

/* ---- line --------------------------------------------------------------- */
.chart--line svg { width: 100%; height: auto; }
.chart--line .grid { stroke: var(--hairline); stroke-width: 1; }
.chart--line .axis { font-size: 10px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart--line .dot { fill: var(--surface); stroke: var(--stamp); stroke-width: 2; }
.chart--line .pt:hover .dot { fill: var(--stamp); r: 4.5; }

/* ---- KPI ---------------------------------------------------------------- */
.kpi { padding: var(--s-1) 0; }
.kpi__v {
  font-size: var(--t-40); font-weight: 600; letter-spacing: -0.035em;
  line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink);
}
.kpi__v small { font-size: var(--t-16); font-weight: 550; color: var(--ink-3); letter-spacing: 0; }
.kpi__k {
  font-size: var(--t-11); font-weight: 650; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--ink-3); margin-top: var(--s-2);
}
.kpi__d { font-size: var(--t-12); color: var(--ink-3); margin-top: var(--s-1); }

/* ---- dashboard grid ----------------------------------------------------- */
.dash-panel { margin-bottom: var(--s-6); }
.dash-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--s-4); }
.widget { grid-column: span 12; }
@media (min-width: 900px) {
  .widget[data-span="3"] { grid-column: span 3; }
  .widget[data-span="4"] { grid-column: span 4; }
  .widget[data-span="5"] { grid-column: span 5; }
  .widget[data-span="6"] { grid-column: span 6; }
  .widget[data-span="7"] { grid-column: span 7; }
  .widget[data-span="8"] { grid-column: span 8; }
}
@media (min-width: 600px) and (max-width: 899px) {
  .widget[data-span="3"], .widget[data-span="4"] { grid-column: span 6; }
}

/* ---- engine checks ------------------------------------------------------ */
.check-row {
  display: grid; grid-template-columns: 18px minmax(200px, 340px) 1fr;
  align-items: start; gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px solid var(--hairline);
  font-size: var(--t-13);
}
.check-row:last-child { border-bottom: 0; }
.check-row .icon { width: 15px; height: 15px; margin-top: 2px; }
.check-row[data-pass="true"] .icon { color: var(--accept); }
.check-row[data-pass="false"] .icon { color: var(--decline); }
.check-row__name { color: var(--ink); font-weight: 500; }
.check-row__detail { color: var(--ink-3); font-size: var(--t-12); line-height: var(--lh-snug); }
@media (max-width: 700px) {
  .check-row { grid-template-columns: 18px 1fr; }
  .check-row__detail { grid-column: 2; }
}

/* ==========================================================================
   SHRINK CONTROL

   A grid or flex child defaults to `min-width: auto`, which means it refuses
   to shrink below its content. A wide table then pushes the page sideways
   even though it sits in an overflow-x container — the container is what
   cannot shrink. Every layout child is told it may.
   ========================================================================== */
.split > *, .grid > *, .stack > *, .dash-grid > *, .duo > *,
.panel, .panel__body, .section, .widget, .col, .toolbar > *,
.tour-card__body, .page > *, .stats > *, .unit > *, .board > * {
  min-width: 0;
}
.table-wrap, pre.code, .chart, .flow-wrap { max-width: 100%; }

/* Long unbroken tokens — references, emails, tracking numbers — wrap rather
   than widen the page. */
.dl dd, .ruled__v, .prose, .article { overflow-wrap: anywhere; }

@media (max-width: 767px) {
  /* Toolbars become a scrolling strip rather than a wrapping pile. */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; }
  .toolbar > * { flex: none; }
  .toolbar .search, .toolbar .grow { min-width: 190px; }
  .pill-row { flex-wrap: nowrap; }

  /* The definition list stacks; a 160px label column is most of the screen. */
  .dl { grid-template-columns: 1fr; gap: var(--s-1); }
  .dl dt { margin-top: var(--s-2); }

  .steps { overflow-x: auto; overscroll-behavior-x: contain; padding-bottom: var(--s-1); }
  .step { flex: none; }

  .tl-data { max-width: 100%; }
  .modal__body { padding: var(--s-4); }
  .modal__head, .modal__foot { padding: var(--s-4); }
}
