/* TransferDesk base: reset, type and the shared components (docs/REDESIGN.md §4.3). Colours come from tokens.css. */

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
img, svg { display: block; max-width: 100%; }
svg { flex-shrink: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

/* Type */
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
h1 { letter-spacing: -0.025em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }
p { margin: 0; }
p + p { margin-top: var(--s-3); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
code, kbd, pre { font-family: var(--font-mono); font-size: 0.92em; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }

.muted { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.strong { font-weight: 600; }
.mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 14px;
  font-size: var(--fs-base); font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--r);
  background: transparent; color: var(--text);
  text-decoration: none;
  transition: background-color var(--dur-1) ease, border-color var(--dur-1) ease, color var(--dur-1) ease,
              box-shadow var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.btn:hover { text-decoration: none; }
.btn:not(:disabled):not([aria-disabled="true"]):active { transform: scale(0.97); }
.btn > svg:last-child:not(:first-child) { transition: transform var(--dur-2) var(--ease-out); }
@media (hover: hover) {
  .btn:not(:disabled):hover > svg:last-child:not(:first-child) { transform: translateX(2px); }
  .btn-primary:not(:disabled):hover { box-shadow: 0 4px 12px -4px rgba(14, 107, 84, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
  .btn-secondary:not(:disabled):hover { box-shadow: var(--shadow-sm); }
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(14, 21, 19, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.10); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--muted-bg); color: var(--text); }
.btn-danger { background: var(--danger); color: var(--on-accent); box-shadow: var(--shadow-xs); }
.btn-danger:hover { background: var(--danger-hover); color: var(--on-accent); }
.btn-danger-quiet { background: var(--surface); border-color: var(--danger-border); color: var(--danger); box-shadow: var(--shadow-xs); }
.btn-danger-quiet:hover { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn:focus-visible { box-shadow: var(--focus); }
.btn-danger:focus-visible, .btn-danger-quiet:focus-visible { box-shadow: var(--focus-danger); }
/* A submit button while its form is on the way (app.js): a spinner in place of its icon. */
.btn.is-busy, .btn.is-busy:disabled { cursor: progress; pointer-events: none; opacity: 0.85; }
.btn.is-busy > svg { display: none; }
.btn.is-busy::before {
  content: ""; width: 14px; height: 14px; flex-shrink: 0; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: td-spin 0.7s linear infinite;
}
.link-button {
  border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500;
}
.link-button:hover { color: var(--accent-hover); text-decoration: underline; }

/* Form fields */
.field { display: grid; gap: 6px; margin-bottom: var(--s-4); }
.field > label, .field .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea,
.input {
  width: 100%; min-height: 38px; padding: 8px var(--s-3);
  font-size: var(--fs-base); line-height: 1.4; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder, .input::placeholder { color: var(--text-3); }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus);
}
.field .hint { font-size: var(--fs-xs); line-height: 1.45; color: var(--text-3); }
.field .error { font-size: var(--fs-xs); font-weight: 500; line-height: 1.45; color: var(--danger); }
.field.invalid input, .field.invalid select, .field.invalid textarea,
.field [aria-invalid="true"], .input[aria-invalid="true"] { border-color: var(--danger); }
.field.invalid input:focus, .field.invalid select:focus, .field.invalid textarea:focus,
.field [aria-invalid="true"]:focus, .input[aria-invalid="true"]:focus { border-color: var(--danger); box-shadow: var(--focus-danger); }
.field input:disabled, .field select:disabled, .field textarea:disabled, .input:disabled {
  color: var(--text-3); background: var(--surface-3); box-shadow: none; cursor: not-allowed;
}
/* A required field marks its label; "req" marks one by hand, "optional" says a field may stay empty. */
.field:has(> input:required, > select:required, > textarea:required) > label::after,
.field > label.req::after { content: "*"; margin-left: 3px; font-weight: 600; color: var(--danger); }
.optional { margin-left: 4px; font-weight: 400; color: var(--text-3); }
/* A form column at a comfortable width; field pairs that sit side by side on a wide screen */
.form-narrow { max-width: var(--form-max); }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s-4); }
@media (max-width: 640px) { .field-pair { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-5); }
.check { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-base); }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Chips: one status, one colour */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 var(--s-2);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap;
  color: var(--muted); background: var(--muted-bg); border: 1px solid var(--muted-border);
  border-radius: var(--r-pill);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.chip.plain::before { display: none; }
.chip.tone-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip.tone-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip.tone-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.chip.tone-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip.tone-muted { color: var(--muted); background: var(--muted-bg); border-color: var(--muted-border); }
.chip.tone-restricted { color: var(--restricted); background: var(--restricted-bg); border-color: var(--restricted-border); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs); padding: var(--s-6);
  transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
}
@media (hover: hover) {
  a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); text-decoration: none; }
}
a.card:active { transform: translateY(0) scale(0.995); }
.card + .card { margin-top: var(--s-5); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-4); }
.card-head h2 { font-size: var(--fs-md); font-weight: 600; }
.card-head p { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: var(--s-5) var(--s-6) 0; }
.card-flush > .card-head:has(+ .table-wrap, + .rows, + table) { padding-bottom: var(--s-4); margin-bottom: 0; border-bottom: 1px solid var(--border); }

/* Grids */
.grid { display: grid; gap: var(--s-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
/* Under 1024 the sidebar slides away (app.css): the columns stack at the same point, so nothing is squeezed between. */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  /* Number tiles stay two across on a phone: four stacked would fill the whole first screen. */
  .grid-4:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
}
.stack > * + * { margin-top: var(--s-5); }
.grid > .card + .card { margin-top: 0; }

/* Tables */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.table { width: 100%; font-size: var(--fs-base); font-variant-numeric: tabular-nums; }
.table caption { padding: 0 0 var(--s-2); text-align: left; font-size: var(--fs-sm); color: var(--text-3); }
.table th {
  padding: 10px var(--s-4); text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3);
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.table td { padding: 14px var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: var(--s-6); }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: var(--s-6); }
/* A table of seven or more columns (js/app.js marks it) keeps its cells closer together. */
.table-dense th, .table-dense td { padding-left: var(--s-3); padding-right: var(--s-3); }
/* Phones: a table turns into one card a row (js/app.js marks it .table-stack and names each cell after its column);
   chips and buttons wrap instead of pushing the page sideways. */
@media (max-width: 720px) {
  .table th, .table td, .card-flush .table th:first-child, .card-flush .table td:first-child,
  .card-flush .table th:last-child, .card-flush .table td:last-child { padding-left: var(--s-3); padding-right: var(--s-3); }
  .chip { max-width: 100%; height: auto; min-height: 22px; padding-block: 3px; line-height: 1.2; white-space: normal; }
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-stack thead { display: none; }
  .table-stack tbody > tr { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); }
  .table-stack tbody > tr:last-child { border-bottom: 0; }
  .table-stack tbody > tr > * {
    display: block; position: relative; width: auto !important; min-width: 0 !important; max-width: none !important;
    padding: 3px 0 !important; border: 0; white-space: normal !important; text-align: left !important; overflow-wrap: anywhere;
    background: none !important;
  }
  .table-stack tbody > tr > [data-label]:not(.stack-main) { min-height: 26px; padding-left: 104px !important; }
  .table-stack tbody > tr > [data-label]:not(.stack-main)::before {
    content: attr(data-label); position: absolute; left: 0; top: 5px; width: 92px;
    font-size: var(--fs-sm); font-weight: 400; color: var(--text-3); white-space: normal;
  }
  .table-stack .stack-main { order: -1; padding-bottom: var(--s-2) !important; }
  .table-stack .stack-empty { display: none !important; }
  .tabs { flex-wrap: wrap; overflow-x: visible; }
}
.table tr:last-child td { border-bottom: 0; }
.table tbody td { transition: background-color var(--dur-1) ease; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table .right { text-align: right; }
a.row-title { font-weight: 500; color: var(--text); }
a.row-title:hover { color: var(--accent); }
.list .row-title { font-weight: 600; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-4); font-size: var(--fs-sm); color: var(--text-3); }

/* Stats */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs); padding: var(--s-5) var(--s-5) var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-2);
  transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) var(--ease-out), transform var(--dur-2) var(--ease-out);
  color: inherit; text-decoration: none;
}
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; }
@media (hover: hover) { a.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); } }
a.stat:active { transform: scale(0.99); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.stat-top .icon-box { width: 32px; height: 32px; }
.stat-top .icon-box svg { width: 16px; height: 16px; }
.stat-label { font-size: var(--fs-sm); font-weight: 500; color: var(--text-3); }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-hint { font-size: var(--fs-xs); color: var(--text-3); }
.stat .spark { margin-top: var(--s-1); }

/* Empty states: an icon, one line, the next step (fragments/ui :: empty, emptyState) */
.empty {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--s-8) var(--s-6); text-align: center; color: var(--text-3);
}
.empty-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-bottom: var(--s-3);
  color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.empty-icon svg { width: 20px; height: 20px; }
.empty h3 { font-size: var(--fs-md); color: var(--text); margin-bottom: var(--s-1); }
.empty p { max-width: 420px; margin: 0 auto; font-size: var(--fs-sm); line-height: 1.5; }
.empty .actions { justify-content: center; margin-top: var(--s-4); }
.card > .empty:only-child, .card-head + .empty { padding-top: var(--s-6); padding-bottom: var(--s-6); }
.empty.empty-sm { padding: var(--s-6) var(--s-4); }
.empty.empty-sm .empty-icon { width: 32px; height: 32px; margin-bottom: var(--s-2); }
.empty.empty-sm .empty-icon svg { width: 16px; height: 16px; }
/* A dashed frame for an empty state that stands alone on a page, with no card around it */
.empty.empty-framed { border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); }
/* "Nothing here" as one quiet line inside a card or a table cell */
.none { padding: var(--s-3) 0; font-size: var(--fs-sm); color: var(--text-3); }
.table td.none { padding: var(--s-6) var(--s-4); text-align: center; }

/* Alerts */
.alert {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border: 1px solid var(--muted-border); border-radius: var(--r);
  background: var(--muted-bg); color: var(--muted); font-size: var(--fs-base);
}
.alert > svg { width: 18px; height: 18px; margin-top: 1px; }
.alert > span, .alert > div, .alert > p { flex: 1; min-width: 0; }
.alert a:not(.btn) { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.alert [data-dismiss] {
  display: inline-grid; place-items: center; width: 24px; height: 24px; margin: -2px -4px -2px auto;
  border-radius: var(--r-sm); opacity: 0.75;
}
.alert [data-dismiss]:hover { opacity: 1; text-decoration: none; }
.alert [data-dismiss] svg { width: 16px; height: 16px; }
.alert.tone-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.alert.tone-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.alert.tone-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.alert.tone-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.alert.tone-restricted { color: var(--restricted); background: var(--restricted-bg); border-color: var(--restricted-border); }
.alert [data-dismiss] { margin-left: auto; color: inherit; }

/* Bars and legends */
.bar { display: flex; height: 8px; overflow: hidden; border-radius: var(--r-pill); background: var(--muted-bg); }
.bar .seg { height: 100%; min-width: 2px; }
.bar .seg + .seg { border-left: 2px solid var(--surface); }
.bar .seg.tone-ok { background: var(--ok-fill); }
.bar .seg.tone-warn { background: var(--warn-fill); }
.bar .seg.tone-danger { background: var(--danger-fill); }
.bar .seg.tone-info { background: var(--info-fill); }
.bar .seg.tone-muted { background: var(--muted-fill); }
.bar .seg.tone-restricted { background: var(--restricted-fill); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); margin: var(--s-4) 0 0; padding: 0; list-style: none; }
.legend li, .legend-item { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend .count { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.dot { background: var(--muted-fill); }

/* Chart colours (SVG fill and stroke, HTML background): series c1..c7 and the status tones */
.fill-c1 { fill: var(--c1); } .stroke-c1 { stroke: var(--c1); } .bg-c1 { background: var(--c1); }
.fill-c2 { fill: var(--c2); } .stroke-c2 { stroke: var(--c2); } .bg-c2 { background: var(--c2); }
.fill-c3 { fill: var(--c3); } .stroke-c3 { stroke: var(--c3); } .bg-c3 { background: var(--c3); }
.fill-c4 { fill: var(--c4); } .stroke-c4 { stroke: var(--c4); } .bg-c4 { background: var(--c4); }
.fill-c5 { fill: var(--c5); } .stroke-c5 { stroke: var(--c5); } .bg-c5 { background: var(--c5); }
.fill-c6 { fill: var(--c6); } .stroke-c6 { stroke: var(--c6); } .bg-c6 { background: var(--c6); }
.fill-c7 { fill: var(--c7); } .stroke-c7 { stroke: var(--c7); } .bg-c7 { background: var(--c7); }
.fill-ok { fill: var(--ok-fill); } .stroke-ok { stroke: var(--ok-fill); } .bg-ok { background: var(--ok-fill); }
.fill-warn { fill: var(--warn-fill); } .stroke-warn { stroke: var(--warn-fill); } .bg-warn { background: var(--warn-fill); }
.fill-danger { fill: var(--danger-fill); } .stroke-danger { stroke: var(--danger-fill); } .bg-danger { background: var(--danger-fill); }
.fill-info { fill: var(--info-fill); } .stroke-info { stroke: var(--info-fill); } .bg-info { background: var(--info-fill); }
.fill-muted { fill: var(--muted-fill); } .stroke-muted { stroke: var(--muted-fill); } .bg-muted { background: var(--muted-fill); }
.fill-restricted { fill: var(--restricted-fill); } .stroke-restricted { stroke: var(--restricted-fill); } .bg-restricted { background: var(--restricted-fill); }

/* Charts (ui/charts/Charts): server-drawn SVG, coloured only by the classes above */
.chart { width: 100%; min-width: 0; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--text-3); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis-line { stroke: var(--border-strong); stroke-width: 1; }
.chart .track { fill: var(--muted-bg); }
.chart .bar-label { font-size: var(--fs-sm); fill: var(--text-2); }
.chart .bar-value { font-size: var(--fs-sm); font-weight: 600; fill: var(--text); font-variant-numeric: tabular-nums; }
.chart .col-value { font-weight: 600; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.chart .area { fill-opacity: 0.12; }
.chart-donut { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-5) var(--s-6); }
.donut { position: relative; width: 148px; height: 148px; flex-shrink: 0; }
.chart .donut svg { width: 100%; height: 100%; }
.donut .donut-track { stroke: var(--muted-bg); }
.donut-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.donut-value { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.donut-label { margin-top: 2px; max-width: 96px; font-size: var(--fs-xs); line-height: 1.3; color: var(--text-3); }
.chart-donut .legend { flex: 1 1 180px; flex-direction: column; flex-wrap: nowrap; gap: var(--s-2); margin: 0; }
.chart-donut .legend li { display: flex; }
.legend-label { flex: 1; min-width: 0; }
.legend-inline { margin-top: var(--s-3); }
.chart-empty svg { border: 1px dashed var(--border-strong); border-radius: var(--r); background: var(--surface-2); }
.chart-empty text { font-size: var(--fs-sm); fill: var(--text-3); }
.spark { width: 100%; height: 32px; overflow: visible; }
.spark-empty { border-bottom: 1px dashed var(--border-strong); }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: 6px; font-size: var(--fs-sm); }
.meter-label { font-weight: 500; color: var(--text); }
.meter-value { color: var(--text-2); font-variant-numeric: tabular-nums; }
.meter + .meter { margin-top: var(--s-4); }

/* Icon boxes: a status colour behind an icon */
.icon-box {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0;
  color: var(--muted); background: var(--muted-bg); border: 1px solid var(--muted-border); border-radius: var(--r);
}
.icon-box svg { width: 18px; height: 18px; }
.icon-box.tone-ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.icon-box.tone-warn { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.icon-box.tone-danger { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.icon-box.tone-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.icon-box.tone-restricted { color: var(--restricted); background: var(--restricted-bg); border-color: var(--restricted-border); }
.icon-box.tone-accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-border); }

/* Actions: a row of buttons */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }

/* Tabs */
.tabs {
  display: flex; gap: var(--s-1); margin: 0 0 var(--s-5); padding: 0;
  border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: var(--s-2); height: 40px; padding: 0 var(--s-3); margin-bottom: -1px;
  font-size: var(--fs-base); font-weight: 500; white-space: nowrap; color: var(--text-3); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px;
  font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--muted-bg); border-radius: var(--r-pill);
}
.tab.on .count { color: var(--accent); background: var(--accent-soft); }

/* Pager */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-3) var(--s-6); font-size: var(--fs-sm); color: var(--text-3); border-top: 1px solid var(--border);
}
.pager .btn[aria-disabled="true"] { pointer-events: none; }

/* Record rows: one record a line, its status on the right */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) var(--s-6);
  color: inherit; text-decoration: none; border-top: 1px solid var(--border);
}
.rows > li:first-child > .row, .rows > .row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-2); color: inherit; text-decoration: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 500; color: var(--text); overflow-wrap: anywhere; }
.row-sub { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); overflow-wrap: anywhere; }
.row-title .chip { margin-block: 1px; }
.row-side { display: flex; align-items: center; justify-content: flex-end; flex: 0 1 auto; flex-wrap: wrap; gap: var(--s-2) var(--s-3); min-width: 0; font-size: var(--fs-sm); color: var(--text-3); }
.row-side svg { width: 16px; height: 16px; color: var(--text-3); }
.card-foot { padding: var(--s-3) var(--s-6); border-top: 1px solid var(--border); font-size: var(--fs-sm); }

/* Key and value pairs */
dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-5); margin: 0; }
dl.kv dt { color: var(--text-3); }
dl.kv dd { margin: 0; color: var(--text); }

@media (max-width: 640px) {
  .card { padding: var(--s-4); }
  .card-flush { padding: 0; }
  .card-flush > .card-head { padding: var(--s-4) var(--s-4) 0; }
  .row, .pager, .card-foot { padding-left: var(--s-4); padding-right: var(--s-4); }
  .row-side .hide-sm { display: none; }
  .stat { padding: var(--s-4); }
  .stat-value { font-size: var(--fs-2xl); }
}

@media (max-width: 640px) {
  .table th, .table td { padding-left: var(--s-3); padding-right: var(--s-3); }
  .card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: var(--s-4); }
  .card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: var(--s-4); }
  .empty { padding: var(--s-7) var(--s-4); }
}

/* The confirm step (app.js builds it for data-confirm): the question, one line on what happens, two buttons */
dialog.confirm {
  width: min(440px, calc(100vw - 32px)); max-width: none; padding: 0; margin: auto;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
}
dialog.confirm::backdrop { background: var(--scrim); }
dialog.confirm[open] { animation: td-pop 0.14s ease-out; }
.confirm-body { display: flex; gap: var(--s-4); padding: var(--s-6) var(--s-6) var(--s-5); }
.confirm-body h2 { font-size: var(--fs-md); font-weight: 600; line-height: 1.4; }
.confirm-body p { margin-top: var(--s-1); font-size: var(--fs-base); color: var(--text-2); }
.confirm-foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-3) var(--s-6); background: var(--surface-2); border-top: 1px solid var(--border);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* Motion: short, and none when the person asks for less */
@keyframes td-spin { to { transform: rotate(360deg); } }
@keyframes td-pop { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes td-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes td-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes td-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes td-fade { from { opacity: 0; } to { opacity: 1; } }
/* Page to page: a short crossfade where the browser supports it (Safari 18.2+, Chrome 126+) */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.18s; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .btn.is-busy::before { animation: none; border-right-color: currentColor; opacity: 0.5; }
}

/* The mark (fragments/brand.html): two sheets, the front one ticked. A tile in ink, or ink-3 with an edge on ink. */
.logo-mark { --lm-tile: var(--ink); --lm-edge: var(--logo-edge); width: 32px; height: 32px; border-radius: 25%; box-shadow: 0 0 0 1px var(--lm-edge); overflow: visible; }
.lm-tile { fill: var(--lm-tile); }
.lm-back { fill: var(--brand-emerald); }
.lm-front { fill: var(--lime); stroke: var(--lm-tile); stroke-width: 1.6; }
.lm-check { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.lm-back, .lm-sheet { transition: transform var(--dur-3) var(--ease-spring); }
.logo-word > span { color: var(--accent); }
.brand-inverse .logo-word > span, .site-foot .logo-word > span { color: var(--lime); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  a:hover > .logo-mark .lm-back { transform: translate(1px, -1px); }
  a:hover > .logo-mark .lm-sheet { transform: translate(-1px, 1px); }
  a:hover > .logo-mark .lm-check { animation: td-draw 0.45s var(--ease-out); }
}

/* Touch screens: 44 px targets, and 16 px text in fields so iPhone Safari does not zoom in */
@media (pointer: coarse) {
  .btn { height: 44px; }
  .btn-sm { height: 38px; }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not(.code-input), select, textarea { font-size: 16px !important; }
}

/* Accessibility */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
