/* 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%; }
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 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { text-decoration: none; }
.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); color: var(--on-accent); filter: brightness(0.92); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.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); color: var(--text-3); }
.field .error { font-size: var(--fs-xs); color: var(--danger); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger-border); }
.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);
}
.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); }
@media (max-width: 1100px) {
  .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 { overflow-x: auto; }
.table { width: 100%; font-size: var(--fs-base); }
.table th {
  padding: 10px var(--s-4); text-align: left; white-space: nowrap;
  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); }
.table tr:last-child td { border-bottom: 0; }
.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 0.12s ease, box-shadow 0.12s ease;
  color: inherit; text-decoration: none;
}
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; }
.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 */
.empty { padding: var(--s-8) var(--s-6); text-align: center; color: var(--text-3); }
.empty h3 { font-size: var(--fs-md); color: var(--text); margin-bottom: var(--s-1); }
.empty p { max-width: 420px; margin: 0 auto; }

/* 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: 20px; height: 20px; margin-top: 1px; }
.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: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { display: block; margin-top: 2px; font-size: var(--fs-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; align-items: center; gap: var(--s-3); flex-shrink: 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); }
}

/* 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;
}
