/*
 * TASCO Growth Platform — component library (v2).
 * Pairs with public/js/console/ui.js. Legacy class names (.btn.primary, .badge.ok, .card, .kpi,
 * .table-wrap, .field, .alert, .toast, .drawer, .tabs, .empty, .skeleton, dl.kv, .timeline…) are
 * kept so existing pages and the customer app render unchanged while they migrate.
 */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-14);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
}
body.customer { font-size: var(--fs-16); --control-h: var(--tap); }
img { max-width: 100%; height: auto; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: var(--lh-tight); margin: 0 0 var(--sp-3); color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-24); font-weight: var(--fw-semibold); }
h2 { font-size: var(--fs-16); font-weight: var(--fw-semibold); }
h3 { font-size: var(--fs-14); font-weight: var(--fw-semibold); }
p { margin: 0 0 var(--sp-3); }
code, pre, .mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: var(--fs-13); }
.xs { font-size: var(--fs-12); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.strong { font-weight: var(--fw-semibold); }
.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; }
.skip-link { position: absolute; left: var(--sp-3); top: -60px; background: var(--primary); color: var(--primary-contrast); padding: var(--sp-2) var(--sp-4); border-radius: var(--radius); z-index: var(--z-tooltip); }
.skip-link:focus { top: var(--sp-3); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.icon { flex: 0 0 auto; display: inline-block; vertical-align: middle; }
hr, .divider { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }

/* ---------- Layout helpers ---------- */
.stack > * + * { margin-top: var(--sp-4); }
.stack-sm > * + * { margin-top: var(--sp-2); }
.stack-lg > * + * { margin-top: var(--sp-5); }
.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.row.tight { gap: var(--sp-2); }
.row.spread { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: var(--gutter); grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* 12-column page grid: <div class="grid-12"><div class="span-8">…</div><div class="span-4">…</div></div> */
.grid-12 { display: grid; gap: var(--gutter); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid-12 > * { grid-column: span 12; min-width: 0; }
@media (min-width: 1024px) {
  .grid-12 > .span-3 { grid-column: span 3; } .grid-12 > .span-4 { grid-column: span 4; } .grid-12 > .span-5 { grid-column: span 5; }
  .grid-12 > .span-6 { grid-column: span 6; } .grid-12 > .span-7 { grid-column: span 7; } .grid-12 > .span-8 { grid-column: span 8; }
  .grid-12 > .span-9 { grid-column: span 9; }
}
.section + .section { margin-top: var(--gutter); }

/* ---------- Page header ---------- */
.page-header { display: flex; gap: var(--sp-4); align-items: flex-end; justify-content: space-between; margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-header .ph-text { min-width: 0; flex: 1 1 360px; }
.page-header h1 { margin: 0; font-size: var(--fs-24); font-weight: var(--fw-semibold); letter-spacing: -0.015em; }
.page-header h1:focus { outline: none; }
.page-header .ph-sub { margin: var(--sp-1) 0 0; color: var(--text-muted); font-size: var(--fs-14); max-width: 90ch; }
.page-header .ph-meta { margin-top: var(--sp-2); display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.page-header .ph-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.page-header .ph-back { display: inline-flex; align-items: center; gap: var(--sp-1); font-size: var(--fs-13); color: var(--text-muted); text-decoration: none; margin-bottom: var(--sp-2); font-weight: var(--fw-medium); }
.page-header .ph-back:hover { color: var(--text); }
/* legacy pageHead() */
.page-head { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; justify-content: space-between; margin-bottom: var(--sp-5); }
.page-head h1 { margin: 0; }
.page-head p { margin: var(--sp-1) 0 0; color: var(--text-muted); }
.page-head-text { flex: 1 1 320px; min-width: 0; }
.page-head-actions { flex: 0 0 auto; justify-content: flex-end; gap: var(--sp-2); }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--radius);
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-size: var(--fs-14); font-weight: var(--fw-semibold); line-height: 1.2; cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-xs); transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  position: relative; user-select: none;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn.primary { --btn-bg: var(--primary); --btn-fg: var(--primary-contrast); --btn-border: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.secondary { --btn-bg: var(--surface); }
.btn.accent { --btn-bg: var(--accent); --btn-fg: #fff; --btn-border: var(--accent); }
.btn.danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-border: var(--danger-border); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.danger.solid { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn.ghost { --btn-bg: transparent; --btn-border: transparent; box-shadow: none; color: var(--text-muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.link { --btn-bg: transparent; --btn-border: transparent; box-shadow: none; color: var(--link); padding: 0 var(--sp-1); min-height: auto; }
.btn.link:hover { text-decoration: underline; background: transparent; }
.btn.small, .btn.sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-13); gap: 6px; }
.btn.lg { min-height: 48px; padding: 0 var(--sp-5); font-size: var(--fs-16); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn.block { width: 100%; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"] > * { visibility: hidden; }
.btn[aria-busy="true"]::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--btn-fg); border-right-color: transparent; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: var(--control-h); min-width: var(--control-h); padding: 0; }
.icon-btn.small, .icon-btn.sm { width: var(--control-h-sm); min-width: var(--control-h-sm); }
.btn .btn-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-pill); background: var(--danger); color: #fff; font-size: 10px; font-weight: var(--fw-bold); line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- Tooltips (CSS-only; text from data-tooltip) ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%) translateY(-2px);
  background: var(--tooltip-bg); color: var(--tooltip-fg); font-size: var(--fs-12); font-weight: var(--fw-medium); line-height: 1.35; padding: 5px 8px; border-radius: var(--radius-sm);
  white-space: nowrap; max-width: 280px; pointer-events: none; opacity: 0; transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); z-index: var(--z-tooltip); box-shadow: var(--shadow-md);
}
[data-tooltip-wrap]::after { white-space: normal; width: max-content; }
[data-tooltip-pos="right"]::after { left: calc(100% + 8px); top: 50%; transform: translateY(-50%); }
[data-tooltip-pos="top"]::after { top: auto; bottom: calc(100% + 6px); }
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translateX(-50%); }
[data-tooltip][aria-expanded="true"]::after { display: none; }
[data-tooltip-pos="right"]:hover::after, [data-tooltip-pos="right"]:focus-visible::after { transform: translateY(-50%); }
.info-tip { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 0; background: transparent; color: var(--text-subtle); border-radius: 50%; cursor: help; vertical-align: middle; }
.info-tip:hover { color: var(--text); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--sp-5); box-shadow: var(--shadow-xs); min-width: 0; }
.card > h2, .card > h3 { margin-bottom: var(--sp-4); font-size: var(--fs-16); }
.card.flush { padding: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); min-height: 56px; }
.card-header h2, .card-header h3 { margin: 0; font-size: var(--fs-16); font-weight: var(--fw-semibold); }
.card-header .card-sub { margin: 2px 0 0; font-size: var(--fs-13); color: var(--text-muted); }
.card-header .card-actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: 0; }
.card-footer { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-card) var(--radius-card); }
.card.c2 { padding: 0; }
.card.c2.no-header .card-body { padding-top: var(--sp-5); }

/* ---------- KPI tiles ---------- */
.kpi-strip { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: var(--gutter); }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--sp-4) var(--sp-5); box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 6px; min-width: 0; text-align: left; font: inherit; color: inherit; }
button.kpi-tile { cursor: pointer; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
button.kpi-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
button.kpi-tile:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.kpi-tile .kpi-label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); color: var(--text-muted); font-weight: var(--fw-medium); }
.kpi-tile .kpi-label .icon { color: var(--text-subtle); }
.kpi-tile .kpi-value-row { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.kpi-tile .kpi-value { font-size: var(--fs-24); font-weight: var(--fw-semibold); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--text); line-height: 1.2; }
.kpi-tile .kpi-hint { font-size: var(--fs-12); color: var(--text-subtle); }
.kpi-tile .kpi-spark { margin-top: 2px; color: var(--chart-1); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-12); font-weight: var(--fw-semibold); padding: 1px 6px; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.delta.good { color: var(--ok); background: var(--ok-bg); }
.delta.bad { color: var(--danger); background: var(--danger-bg); }
.delta.flat { color: var(--text-muted); background: var(--neutral-bg); }
/* legacy kpi() */
.kpi { display: flex; flex-direction: column; gap: 6px; padding: var(--sp-4) var(--sp-5); }
.kpi .value { font-size: var(--fs-24); font-weight: var(--fw-semibold); color: var(--text); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .label { color: var(--text-muted); font-size: var(--fs-13); font-weight: var(--fw-medium); }
.kpi .hint { font-size: var(--fs-12); color: var(--text-subtle); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field .field-label { font-weight: var(--fw-medium); font-size: var(--fs-13); color: var(--text); display: inline-flex; align-items: center; gap: var(--sp-1); }
.field .req { color: var(--danger); }
.field .opt { color: var(--text-subtle); font-weight: var(--fw-regular); }
.field .help { font-size: var(--fs-12); color: var(--text-subtle); }
.field .error, .error { font-size: var(--fs-13); color: var(--danger); }
.field .error:empty, .error:empty { display: none; }
.field .error:not(:empty) { display: flex; align-items: center; gap: var(--sp-1); }
input, select, textarea {
  font: inherit; font-size: var(--fs-14); color: var(--text); background: var(--surface); border: 1px solid var(--border-input);
  border-radius: var(--radius); min-height: var(--control-h); padding: 0 var(--sp-3); width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); box-shadow: var(--shadow-xs);
}
body.customer input, body.customer select, body.customer textarea { font-size: var(--fs-16); }
textarea { min-height: 112px; resize: vertical; padding: var(--sp-2) var(--sp-3); line-height: var(--lh); }
textarea.code { font-family: var(--mono); font-size: var(--fs-13); min-height: 360px; }
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
input:hover, select:hover, textarea:hover { border-color: var(--gray-400); }
input:focus-visible, select:focus-visible, textarea:focus-visible, input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
input[disabled], select[disabled], textarea[disabled] { background: var(--surface-3); color: var(--text-subtle); cursor: not-allowed; }
input[readonly] { background: var(--surface-2); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-subtle) 50%), linear-gradient(135deg, var(--text-subtle) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
select.sm, input.sm { min-height: var(--control-h-sm); font-size: var(--fs-13); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 10px; color: var(--text-subtle); pointer-events: none; }
.input-group > input { padding-left: 34px; }
.input-group > .ig-suffix { position: absolute; right: 8px; color: var(--text-subtle); font-size: var(--fs-12); pointer-events: none; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3) var(--sp-4); margin: 0; min-width: 0; }
fieldset.plain { border: 0; padding: 0; }
legend { font-weight: var(--fw-medium); font-size: var(--fs-13); padding: 0 var(--sp-1); }
fieldset.plain legend { padding: 0; margin-bottom: var(--sp-2); }
.check { display: flex; gap: var(--sp-3); align-items: center; min-height: 32px; line-height: 1.4; cursor: pointer; }
.check .check-desc { display: block; font-size: var(--fs-12); color: var(--text-subtle); }
body.customer .check { min-height: var(--tap); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 18px; padding: 0; margin: 0; flex: 0 0 18px; accent-color: var(--primary); box-shadow: none; cursor: pointer; }
.check input[type="checkbox"], .check input[type="radio"] { align-self: center; }
.radio-group { display: flex; flex-direction: column; gap: var(--sp-1); }
.radio-group.inline { flex-direction: row; flex-wrap: wrap; gap: var(--sp-4); }
/* Switch: <label class="switch"><input type="checkbox" role="switch"><span class="switch-track"></span>Label</label> */
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 36px; height: 20px; border-radius: var(--radius-pill); background: var(--border-strong); position: relative; flex: 0 0 36px; transition: background var(--dur-fast) var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur-fast) var(--ease); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus-ring); }
.switch input:disabled + .switch-track { opacity: 0.5; }
/* Segmented control */
.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); }
.segmented button { border: 0; background: transparent; font: inherit; font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-muted); min-height: calc(var(--control-h-sm) - 4px); padding: 0 var(--sp-3); border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.form-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; padding-top: var(--sp-2); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: var(--fs-12); font-weight: var(--fw-medium); line-height: 18px; white-space: nowrap;
  color: var(--neutral); background: var(--neutral-bg); border: 1px solid var(--neutral-border);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.badge.ok, .badge.success { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.badge.warn, .badge.warning { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.badge.danger, .badge.error { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.badge.info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.badge.neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-border); }
.badge.brand { color: var(--primary-soft-text); background: var(--primary-soft); border-color: transparent; }
.badge.hot { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.badge.warm { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.badge.nurture { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-border); }
.badge.count { padding: 0 6px; min-width: 20px; justify-content: center; font-weight: var(--fw-semibold); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 var(--sp-3); border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-13); font-weight: var(--fw-medium); cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--surface-3); }
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-soft-text); }
.chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.chip .chip-count { font-size: var(--fs-12); color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { color: inherit; }
.chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.plate-tag { display: inline-flex; align-items: center; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; padding: 1px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); white-space: nowrap; font-size: var(--fs-13); }

/* ---------- Banners, alerts, toasts ---------- */
.banner, .alert { display: flex; gap: var(--sp-3); align-items: flex-start; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); border: 1px solid var(--info-border); background: var(--info-bg); color: var(--text); }
.alert { display: block; }
.banner .banner-icon { margin-top: 1px; }
.banner .banner-body { flex: 1; min-width: 0; }
.banner .banner-title { font-weight: var(--fw-semibold); margin: 0; }
.banner .banner-text { margin: 2px 0 0; color: var(--text-muted); }
.banner .banner-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.banner.info .banner-icon { color: var(--info); }
.banner.ok, .alert.ok { background: var(--ok-bg); border-color: var(--ok-border); }
.banner.ok .banner-icon { color: var(--ok); }
.banner.warn, .alert.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.banner.warn .banner-icon { color: var(--warn); }
.banner.danger, .alert.danger { background: var(--danger-bg); border-color: var(--danger-border); }
.banner.danger .banner-icon { color: var(--danger); }
.alert.info { background: var(--info-bg); border-color: var(--info-border); }
.toasts { position: fixed; right: var(--sp-5); bottom: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); z-index: var(--z-toast); width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: var(--sp-3); align-items: flex-start; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4); box-shadow: var(--shadow-lg); animation: toast-in var(--dur-slow) var(--ease); }
.toast .toast-icon { color: var(--info); margin-top: 1px; }
.toast.ok .toast-icon { color: var(--ok); }
.toast.warn .toast-icon { color: var(--warn); }
.toast.danger .toast-icon { color: var(--danger); }
.toast .toast-body { flex: 1; min-width: 0; font-size: var(--fs-14); }
.toast .toast-title { font-weight: var(--fw-semibold); }
.toast .toast-ref { display: block; font-size: var(--fs-12); color: var(--text-subtle); margin-top: 2px; }
.toast .btn { margin: -4px -4px 0 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card .table-wrap, .data-table .table-wrap { border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
.card > .table-wrap:first-child { border-top: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); }
caption { text-align: left; }
th, td { text-align: left; padding: 10px var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-weight: var(--fw-medium); font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; letter-spacing: 0.01em; position: sticky; top: 0; z-index: 1; height: 40px; padding-top: 0; padding-bottom: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tr.clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
tr[aria-selected="true"] td { background: var(--primary-soft); }
td.num, th.num, td.align-right, th.align-right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.align-center, th.align-center { text-align: center; }
td.nowrap, .nowrap, .plate-cell { white-space: nowrap; }
td.num-text, th.num-text { text-align: right; }
td code { overflow-wrap: anywhere; }
td.nowrap code { overflow-wrap: normal; }
td.actions-cell { width: 1%; white-space: nowrap; text-align: right; padding-top: 4px; padding-bottom: 4px; }
td.select-cell, th.select-cell { width: 1%; padding-right: 0; }
.cell-primary { font-weight: var(--fw-medium); color: var(--text); }
.cell-sub { display: block; font-size: var(--fs-12); color: var(--text-subtle); }
.trunc { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
td.trunc-cell { max-width: 0; width: 30%; }
td.trunc-cell .trunc { width: 100%; }
.ref { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.btn.copy { min-height: 24px; width: 24px; padding: 0; color: var(--text-subtle); box-shadow: none; border-color: transparent; background: transparent; }
.btn.copy:hover { color: var(--text); background: var(--surface-3); }
tr.group-head td { border-bottom: none; }
tr.group-line td { padding-top: 2px; padding-bottom: 2px; border-bottom: none; color: var(--text-muted); }
tr.group-total td { font-weight: var(--fw-semibold); background: var(--surface-2); }
th.sortable { padding: 0; }
th .sort-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 4px; width: 100%; height: 40px; padding: 0 var(--sp-4); cursor: pointer; color: inherit; font: inherit; }
th.num .sort-btn, th.align-right .sort-btn { justify-content: flex-end; }
th .sort-btn:hover { color: var(--text); }
th .sort-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
th .sort-btn .icon { opacity: 0.45; }
th[aria-sort="ascending"] .sort-btn .icon, th[aria-sort="descending"] .sort-btn .icon { opacity: 1; color: var(--text); }
/* DataTable shell */
.data-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-xs); min-width: 0; overflow: hidden; }
.card .data-table { border: 0; box-shadow: none; border-radius: 0; }
.dt-toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.dt-toolbar .dt-search { flex: 0 1 300px; min-width: 200px; }
.dt-toolbar .dt-search input { min-height: var(--control-h-sm); font-size: var(--fs-13); }
.dt-toolbar .dt-filters { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.dt-toolbar .dt-filters select { width: auto; min-height: var(--control-h-sm); font-size: var(--fs-13); }
.dt-toolbar .dt-spacer { flex: 1; }
.dt-bulk { display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-2) var(--sp-4); background: var(--primary-soft); color: var(--primary-soft-text); font-size: var(--fs-13); font-weight: var(--fw-medium); border-bottom: 1px solid var(--border); }
.data-table .table-wrap { border: 0; border-radius: 0; }
.dt-footer { display: flex; gap: var(--sp-4); align-items: center; justify-content: flex-end; flex-wrap: wrap; padding: var(--sp-2) var(--sp-4); border-top: 1px solid var(--border); font-size: var(--fs-13); color: var(--text-muted); }
.dt-footer select { width: auto; min-height: 30px; font-size: var(--fs-13); padding-left: var(--sp-2); }
.dt-footer .dt-range { font-variant-numeric: tabular-nums; }
.dt-footer .row { gap: var(--sp-2); }
.dt-empty { padding: var(--sp-6) var(--sp-4); }
.skeleton-row td { padding-top: 14px; padding-bottom: 14px; }
/* legacy pager */
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; font-size: var(--fs-13); }

/* ---------- Menus & popovers ---------- */
.popover { position: fixed; z-index: var(--z-dropdown); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); min-width: 200px; max-width: min(380px, calc(100vw - 16px)); max-height: calc(100vh - 80px); overflow-y: auto; animation: pop-in var(--dur-fast) var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.menu { padding: var(--sp-1); }
.menu [role="menuitem"], .menu [role="menuitemradio"], .menu [role="menuitemcheckbox"] {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: 36px; padding: 0 var(--sp-3); border: 0; background: transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: var(--fs-14); color: var(--text); text-align: left; cursor: pointer; text-decoration: none;
}
.menu [role^="menuitem"] .icon { color: var(--text-subtle); }
.menu [role^="menuitem"]:hover, .menu [role^="menuitem"]:focus-visible { background: var(--surface-3); outline: none; }
.menu [role^="menuitem"][aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.menu [role^="menuitem"].danger { color: var(--danger); }
.menu [role^="menuitem"].danger .icon { color: var(--danger); }
.menu .menu-check { margin-left: auto; color: var(--primary); visibility: hidden; }
.menu [aria-checked="true"] .menu-check { visibility: visible; }
.menu .menu-heading { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-11); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); }
.menu [role="separator"] { height: 1px; background: var(--border); margin: var(--sp-1) calc(-1 * var(--sp-1)); }
.menu .menu-label { flex: 1; min-width: 0; }
.menu .menu-desc { display: block; font-size: var(--fs-12); color: var(--text-subtle); }

/* ---------- Drawer & modal ---------- */
.backdrop { position: fixed; inset: 0; background: var(--overlay); z-index: calc(var(--z-drawer) - 1); animation: fade-in var(--dur-base) var(--ease); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-xl); z-index: var(--z-drawer); display: flex; flex-direction: column; transform: translateX(100%); transition: transform var(--dur-slow) var(--ease); overflow: hidden; }
.drawer.lg { width: min(720px, 100vw); }
.drawer.sm { width: min(400px, 100vw); }
.drawer[data-open="true"] { transform: none; }
.drawer-header { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.drawer-header h2 { margin: 0; font-size: var(--fs-16); }
.drawer-header .drawer-sub { margin: 2px 0 0; font-size: var(--fs-13); color: var(--text-muted); }
.drawer-header .drawer-titles { flex: 1; min-width: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5); }
.drawer-footer { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); }
dialog { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-5); width: min(520px, calc(100vw - 32px)); max-width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-xl); }
dialog::backdrop { background: var(--overlay); }
dialog.modal { padding: 0; }
dialog.modal.lg { width: min(760px, calc(100vw - 32px)); max-width: min(760px, calc(100vw - 32px)); }
dialog.modal.sm { width: min(420px, calc(100vw - 32px)); }
.modal-header { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal-header h2 { margin: 0; flex: 1; font-size: var(--fs-16); }
.modal-body { padding: 0 var(--sp-5) var(--sp-5); color: var(--text); }
.modal-body > p:last-child { margin-bottom: 0; }
.modal-footer { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs [role="tab"] { background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 0 var(--sp-3); font: inherit; font-size: var(--fs-14); font-weight: var(--fw-medium); color: var(--text-muted); cursor: pointer; min-height: 42px; white-space: nowrap; display: inline-flex; align-items: center; gap: var(--sp-2); }
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--primary-soft-text); border-bottom-color: var(--primary); font-weight: var(--fw-semibold); }
.tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.tabs .tab-count { font-size: var(--fs-12); padding: 0 6px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tabs button[aria-selected="true"] .tab-count { background: var(--primary-soft); color: var(--primary-soft-text); }
.tab-panel { padding-top: var(--sp-5); }
.tab-panel:focus-visible { outline: none; }

/* ---------- Empty, loading ---------- */
.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--text-muted); }
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2); padding: var(--sp-7) var(--sp-4); }
.empty-state.compact { padding: var(--sp-5) var(--sp-3); }
.empty-state .es-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-subtle); margin-bottom: var(--sp-2); }
.empty-state .es-title { font-weight: var(--fw-semibold); font-size: var(--fs-16); color: var(--text); margin: 0; }
.empty-state .es-text { color: var(--text-muted); margin: 0; max-width: 46ch; }
.empty-state .es-action { margin-top: var(--sp-3); }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-sunken) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--radius-sm); min-height: 12px; }
.skeleton.text { height: 12px; }
.skeleton.title { height: 24px; width: 40%; }
.skeleton-lines > * + * { margin-top: var(--sp-2); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .btn[aria-busy="true"]::after { animation: none; } .toast, .popover, .backdrop { animation: none; } }

/* ---------- Key-value list ---------- */
dl.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: var(--sp-2) var(--sp-4); }
:where(dl.kv, .kv-list) { margin: 0; } /* zero specificity so .stack spacing still applies */
dl.kv dt { color: var(--text-muted); font-size: var(--fs-13); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv-list { display: grid; gap: var(--sp-4) var(--sp-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .kv-list.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kv-list.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kv-list > div { min-width: 0; }
.kv-list dt { font-size: var(--fs-12); color: var(--text-subtle); font-weight: var(--fw-medium); margin-bottom: 2px; display: flex; align-items: center; gap: 4px; }
.kv-list dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.kv-list.inline > div { display: grid; grid-template-columns: minmax(120px, 40%) 1fr; gap: var(--sp-3); }

/* ---------- Avatar ---------- */
.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand-navy); color: #fff; font-size: var(--fs-12); font-weight: var(--fw-semibold); flex: 0 0 auto; letter-spacing: 0.02em; user-select: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: var(--fs-16); }
.avatar.t1 { background: #213368; } .avatar.t2 { background: #0b6b66; } .avatar.t3 { background: #93370d; } .avatar.t4 { background: #6941c6; } .avatar.t5 { background: #475467; } .avatar.t6 { background: #b42318; }

/* ---------- Stepper ---------- */
.stepper { display: flex; flex-wrap: wrap; row-gap: var(--sp-2); list-style: none; margin: 0; padding: 0; }
.stepper li { flex: 1 1 auto; display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-13); color: var(--text-muted); }
.stepper li:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--border); margin: 0 var(--sp-2); min-width: 12px; border-radius: 2px; }
.stepper li.complete:not(:last-child)::after { background: var(--accent); }
.stepper .step-marker { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 24px; border: 2px solid var(--border-strong); background: var(--surface); font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-muted); }
.stepper li.complete .step-marker { background: var(--accent); border-color: var(--accent); color: #fff; }
.stepper li.current .step-marker { border-color: var(--primary); color: var(--primary-soft-text); box-shadow: 0 0 0 3px var(--primary-soft); }
.stepper li.current { color: var(--text); font-weight: var(--fw-semibold); }
.stepper li.error .step-marker { border-color: var(--danger); background: var(--danger); color: #fff; }
.stepper .step-text { display: flex; flex-direction: column; flex: 0 0 auto; white-space: nowrap; }
.stepper li:last-child { flex: 0 1 auto; }
.stepper .step-desc { font-size: var(--fs-12); color: var(--text-subtle); font-weight: var(--fw-regular); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 var(--sp-3) var(--sp-4); }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline li.done::before { background: var(--accent); }
.tl { list-style: none; margin: 0; padding: 0; }
.tl-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--sp-3); position: relative; padding-bottom: var(--sp-4); }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 15px; top: 34px; bottom: 2px; width: 2px; background: var(--border); border-radius: 2px; }
.tl-marker { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }
.tl-item.ok .tl-marker { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.tl-item.warn .tl-marker { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.tl-item.danger .tl-marker { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.tl-item.info .tl-marker { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.tl-content { min-width: 0; padding-top: 5px; }
.tl-title { margin: 0; font-size: var(--fs-14); color: var(--text); }
.tl-meta { font-size: var(--fs-12); color: var(--text-subtle); margin-top: 2px; }
.tl-body { margin-top: var(--sp-2); font-size: var(--fs-13); color: var(--text-muted); }

/* ---------- Meter / progress / confidence ---------- */
.bar, .meter-track { height: 6px; background: var(--surface-3); border-radius: var(--radius-pill); overflow: hidden; }
.bar > span, .meter-fill { display: block; height: 100%; background: var(--accent); border-radius: var(--radius-pill); }
.meter { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meter-head { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-13); }
.meter-head .meter-value { font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.meter.ok .meter-fill { background: var(--ok); } .meter.warn .meter-fill { background: #dc6803; } .meter.danger .meter-fill { background: var(--danger); } .meter.brand .meter-fill { background: var(--primary); }
.confidence { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-12); color: var(--text-muted); white-space: nowrap; }
.confidence .segs { display: inline-flex; gap: 2px; }
.confidence .seg { width: 6px; height: 12px; border-radius: 2px; background: var(--surface-3); border: 1px solid var(--border); }
.confidence.high .seg.on { background: var(--ok); border-color: var(--ok); }
.confidence.medium .seg.on { background: #dc6803; border-color: #dc6803; }
.confidence.low .seg.on { background: var(--danger); border-color: var(--danger); }
.reasons { list-style: none; padding: 0; margin: 0; }
.reasons li { display: grid; grid-template-columns: 1fr auto; gap: 6px var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-13); }
.reasons li:last-child { border-bottom: 0; }
.reasons li .bar { grid-column: 1 / -1; }

/* ---------- Charts ---------- */
.chart { position: relative; min-width: 0; }
.chart svg { display: block; overflow: visible; }
.chart text { font-family: var(--font); font-size: 12px; fill: var(--text-muted); }
.chart .axis-label { fill: var(--text-subtle); font-size: 11px; }
.chart .value-label { fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .s1 { fill: var(--chart-1); stroke: var(--chart-1); } .chart .s2 { fill: var(--chart-2); stroke: var(--chart-2); } .chart .s3 { fill: var(--chart-3); stroke: var(--chart-3); }
.chart .s4 { fill: var(--chart-4); stroke: var(--chart-4); } .chart .s5 { fill: var(--chart-5); stroke: var(--chart-5); } .chart .s6 { fill: var(--chart-6); stroke: var(--chart-6); }
.chart .bar-rect { stroke: none; transition: opacity var(--dur-fast) var(--ease); }
.chart .bar-rect:hover { opacity: 0.85; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { stroke: none; opacity: 0.08; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .donut-track { fill: none; stroke: var(--surface-3); }
.chart .donut-seg { fill: none; }
.chart .donut-total { fill: var(--text); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); list-style: none; margin: var(--sp-3) 0 0; padding: 0; font-size: var(--fs-12); color: var(--text-muted); }
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.swatch.s1 { background: var(--chart-1); } .swatch.s2 { background: var(--chart-2); } .swatch.s3 { background: var(--chart-3); } .swatch.s4 { background: var(--chart-4); } .swatch.s5 { background: var(--chart-5); } .swatch.s6 { background: var(--chart-6); }
.donut-layout { display: flex; gap: var(--sp-5); align-items: center; flex-wrap: wrap; }
.donut-layout .chart-legend { flex-direction: column; flex-wrap: nowrap; margin: 0; flex: 1; min-width: 160px; gap: var(--sp-2); }
.donut-layout .chart-legend li { display: grid; grid-template-columns: 10px 1fr auto; gap: var(--sp-2); font-size: var(--fs-13); }
.donut-layout .chart-legend .lv { color: var(--text); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.chart-data { margin-top: var(--sp-3); font-size: var(--fs-12); }
.chart-data summary { cursor: pointer; color: var(--text-subtle); display: inline-flex; align-items: center; gap: 4px; list-style: none; }
.chart-data summary::-webkit-details-marker { display: none; }
.chart-data summary:hover { color: var(--text); }
.chart-data table { margin-top: var(--sp-2); font-size: var(--fs-12); }
.chart-data th, .chart-data td { padding: 4px var(--sp-2); height: auto; }
.sparkline { display: block; }
.sparkline path { fill: none; stroke: currentColor; stroke-width: 1.5; }

/* ---------- Disclosure ---------- */
details.disclosure { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
details.disclosure > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-muted); }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .icon { transition: transform var(--dur-fast) var(--ease); }
details.disclosure[open] > summary .icon { transform: rotate(90deg); }
details.disclosure > .disclosure-body { padding: 0 var(--sp-3) var(--sp-3); font-size: var(--fs-13); }

/* ---------- Chat (voice console) ---------- */
.chat { display: flex; flex-direction: column; gap: var(--sp-2); height: clamp(220px, 42vh, 440px); overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); }
.bubble { max-width: 85%; padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); font-size: var(--fs-14); }
.bubble.customer { align-self: flex-end; background: var(--primary-soft); border-color: transparent; }
.bubble .gloss { display: block; font-size: var(--fs-12); color: var(--text-muted); margin-top: var(--sp-1); }

/* ---------- Filters (legacy) ---------- */
.filters { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

/* Score ring (ui.scoreRing) */
.score-ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.score-ring svg { display: block; }
.score-ring-track { stroke: var(--surface-3); }
.score-ring-fill { stroke: var(--primary); transition: stroke-dasharray var(--dur-base, 200ms) var(--ease, ease); }
.score-ring.hot .score-ring-fill { stroke: var(--danger); }
.score-ring.warm .score-ring-fill { stroke: #dc6803; }
.score-ring-value { position: absolute; inset: 0; display: grid; place-items: center; font-weight: var(--fw-semibold); font-size: var(--fs-16); font-variant-numeric: tabular-nums; color: var(--text); }
.score-ring.sm .score-ring-value { font-size: var(--fs-12); }

/* ===== Workflow components & pages: claims, data quality, partners, users, operations (phase 2) ===== */
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: var(--sp-1); white-space: nowrap; }
.row-actions .btn.row-action { width: 9.5rem; justify-content: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions .btn.row-action > span { overflow: hidden; text-overflow: ellipsis; }
.row-actions .btn.row-action.muted { color: var(--text-muted); border-color: transparent; }
.row-kebab-spacer { display: inline-block; width: var(--control-h-sm); height: 1px; }
td.wf-actions { width: 1%; white-space: nowrap; text-align: right; padding-top: 6px; padding-bottom: 6px; }
.sla-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; white-space: nowrap; }
.sla-chip .sla-left { font-size: var(--fs-12); color: var(--text-subtle); font-variant-numeric: tabular-nums; padding-left: 2px; }
.vehicle-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; white-space: nowrap; }
.copy-field { display: flex; gap: var(--sp-2); align-items: center; }
.copy-field .copy-input { flex: 1; min-width: 0; font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: var(--fs-13); background: var(--surface-2); }

.wsteps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.wsteps li { display: grid; grid-template-columns: 24px 1fr; gap: var(--sp-3); position: relative; padding-bottom: var(--sp-4); }
.wsteps li:last-child { padding-bottom: 0; }
.wsteps li:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--border); }
.wsteps li.ws-complete:not(:last-child)::before { background: var(--accent); }
.wsteps .ws-marker { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); color: var(--text-subtle); }
.wsteps .ws-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .5; }
.wsteps .ws-complete .ws-marker { background: var(--accent); border-color: var(--accent); color: #fff; }
.wsteps .ws-current .ws-marker { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.wsteps .ws-current .ws-dot { opacity: 1; }
.wsteps .ws-error .ws-marker { background: var(--danger); border-color: var(--danger); color: #fff; }
.wsteps .ws-label { font-weight: var(--fw-medium); color: var(--text); line-height: 24px; }
.wsteps .ws-upcoming .ws-label { color: var(--text-subtle); font-weight: var(--fw-regular); }
.wsteps .ws-meta { font-size: var(--fs-12); color: var(--text-subtle); }
.wsteps .ws-note { margin: 4px 0 0; font-size: var(--fs-13); color: var(--text-muted); }

.wf-section + .wf-section { margin-top: var(--sp-6); }
.wf-section > h3 { margin: 0 0 var(--sp-3); font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.wf-prose { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); line-height: 1.55; }
.wf-summary { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; max-width: 30ch; white-space: normal; overflow: hidden; overflow-wrap: anywhere; }
.wf-ref { font-weight: var(--fw-medium); color: var(--text); white-space: nowrap; }
.wf-head { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.wf-photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-2); }
.wf-photo { aspect-ratio: 4 / 3; border-radius: var(--radius); border: 1px dashed var(--border-strong); background: var(--surface-2); display: grid; place-items: center; color: var(--text-subtle); }
.wf-note { padding: var(--sp-3); border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.wf-note + .wf-note { margin-top: var(--sp-2); }
.wf-note p { margin: 0 0 4px; overflow-wrap: anywhere; }
.wf-note .wf-note-meta { font-size: var(--fs-12); color: var(--text-subtle); }
.wf-chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--sp-5); }
.wf-chip-row .chip .sev { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sev.high { background: var(--danger); } .sev.medium { background: var(--warn); } .sev.low { background: var(--info); }
.wf-issue { display: flex; flex-direction: column; gap: 3px; }
.wf-issue .wf-issue-name { font-weight: var(--fw-medium); color: var(--text); }
.wf-issue .badge { align-self: flex-start; }
.wf-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.wf-compare-col { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); background: var(--surface); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.wf-compare-col.ok { border-color: var(--ok-border); background: var(--ok-bg); }
.wf-compare-col.warn { border-color: var(--warn-border); background: var(--warn-bg); }
.wf-compare-col h4 { margin: 0; font-size: var(--fs-13); display: flex; align-items: center; gap: var(--sp-2); }
.wf-options { display: grid; gap: var(--sp-2); }
.wf-option { display: grid; grid-template-columns: 20px 1fr; gap: var(--sp-3); align-items: start; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--surface); }
.wf-option:hover { background: var(--surface-2); }
.wf-option:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: var(--primary-soft); }
.wf-option input { margin-top: 3px; accent-color: var(--primary); }
.wf-option .wf-option-title { font-weight: var(--fw-medium); color: var(--text); }
.wf-option .wf-option-desc { display: block; font-size: var(--fs-12); color: var(--text-subtle); margin-top: 2px; }
.wf-option-fields { margin-top: var(--sp-3); }
.wf-card-grid { display: grid; gap: var(--gutter); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.wf-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-xs); padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.wf-tile-head { display: flex; align-items: flex-start; gap: var(--sp-3); }
.wf-tile-head .grow { min-width: 0; }
.wf-tile-title { margin: 0; font-size: var(--fs-14); font-weight: var(--fw-semibold); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-tile-sub { font-size: var(--fs-12); color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-tile-icon { width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center; flex: 0 0 36px; background: var(--primary-soft); color: var(--primary-soft-text); }
.wf-tile-icon.ok { background: var(--ok-bg); color: var(--ok); } .wf-tile-icon.warn { background: var(--warn-bg); color: var(--warn); } .wf-tile-icon.danger { background: var(--danger-bg); color: var(--danger); }
.wf-tile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.wf-tile-stats.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wf-stat-label { display: block; font-size: var(--fs-12); color: var(--text-subtle); white-space: nowrap; }
.wf-stat-value { display: block; font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wf-tile-actions { display: flex; gap: var(--sp-2); align-items: center; justify-content: flex-end; margin-top: auto; }
.wf-tile-actions .grow { flex: 1; }
.wf-dev { display: flex; flex-direction: column; gap: var(--sp-3); }
.wf-dev ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.wf-dev li { display: flex; align-items: center; gap: var(--sp-2); color: var(--text-muted); font-size: var(--fs-13); }
.wf-dev li .icon { color: var(--accent); flex: 0 0 auto; }
.wf-user { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.wf-user .wf-user-text { display: flex; flex-direction: column; min-width: 0; }
.wf-user .wf-user-name { font-weight: var(--fw-medium); color: var(--text); }
.wf-roles { display: flex; gap: 4px; flex-wrap: wrap; max-width: 280px; }
.wf-roles .badge { white-space: nowrap; }
.wf-mfa { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: var(--fs-13); }
.wf-mfa.ok { color: var(--ok); } .wf-mfa.warn { color: var(--warn); } .wf-mfa.off { color: var(--text-subtle); }
.wf-role-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.wf-role-grid .check { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border); border-radius: var(--radius); }
.wf-statement table td.wf-group-ref { font-weight: var(--fw-semibold); }
.wf-statement tr.wf-subtotal td { background: var(--surface-2); font-weight: var(--fw-medium); }
.wf-statement tr.wf-total td { background: var(--primary-soft); color: var(--primary-soft-text); font-weight: var(--fw-semibold); }
.wf-statement td.wf-indent { padding-left: var(--sp-6); color: var(--text-muted); }
.wf-health-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.wf-kv-tight .kv-list { gap: var(--sp-3) var(--sp-4); }
.wf-scope-list { display: grid; gap: var(--sp-2); }
.wf-counter { font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .wf-compare, .wf-role-grid { grid-template-columns: minmax(0, 1fr); } .wf-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.decision-footer { display: flex; gap: var(--sp-2); justify-content: flex-end; width: 100%; }
td:has(> .row-actions) { width: 1%; white-space: nowrap; text-align: right; padding-top: 6px; padding-bottom: 6px; }
td:has(> .wf-summary) { max-width: 0; width: 40%; }
td > .wf-summary { max-width: 100%; }
.card.wf-dense th, .card.wf-dense td { padding-left: var(--sp-3); padding-right: var(--sp-3); }
.card.wf-dense th:first-child, .card.wf-dense td:first-child { padding-left: var(--sp-5); }
.card.wf-dense th:last-child, .card.wf-dense td:last-child { padding-right: var(--sp-4); }
.wf-status-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.wf-status-cell .sla-chip { flex-direction: row; align-items: center; gap: 6px; }
.wf-pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-12); background: var(--surface-2); border: 1px solid var(--border); padding: var(--sp-3); border-radius: var(--radius); max-height: 320px; overflow: auto; }
.ws-fact { margin-top: 4px; font-size: var(--fs-13); }
.wf-inline-icon { display: inline-flex; align-items: flex-start; gap: 6px; }
.wf-inline-icon .icon { flex: 0 0 auto; margin-top: 3px; color: var(--text-subtle); }
.wf-photo-more { font-weight: var(--fw-semibold); font-size: var(--fs-16); color: var(--text-muted); }
.wf-prose + .kv-list { margin-top: var(--sp-2); }
.ws-fact { margin-top: 4px; font-size: var(--fs-13); }
.wf-inline-icon { display: inline-flex; align-items: flex-start; gap: 6px; }
.wf-inline-icon .icon { flex: 0 0 auto; margin-top: 3px; color: var(--text-subtle); }
.wf-photo-more { font-weight: var(--fw-semibold); font-size: var(--fs-16); color: var(--text-muted); }
.wf-prose + .kv-list { margin-top: var(--sp-2); }
.wf-assignee { display: inline-flex; align-items: center; gap: var(--sp-2); white-space: nowrap; }
.wf-origin { display: flex; flex-direction: column; min-width: 0; }
.wf-origin > span:first-child { white-space: nowrap; }
.wf-issue { min-width: 11.5rem; }
.copy-field + .kv-list { margin-top: var(--sp-4); }
.wf-tile .wf-tile-title { white-space: normal; overflow: visible; }
.wf-health-meta .wf-stat-value { white-space: normal; }
.wf-user .wf-user-text { min-width: 10rem; }
.wf-big { font-size: var(--fs-20); margin: 2px 0 6px; }
.wf-compact-actions .row-actions .btn.row-action { width: 7.5rem; }
.card .card-body > .wf-tile-stats { border-top: 0; padding-top: 0; }
.card.wf-dense .dt-toolbar .dt-search { flex: 0 1 240px; min-width: 160px; }
.wf-origin > span:first-child { white-space: normal; }
.wf-issue { min-width: 10rem; }
.wf-assignee { white-space: normal; }
td > .wf-summary { width: 0; min-width: 100%; max-width: none; }
td:has(> .wf-summary) { width: auto; max-width: none; min-width: 10rem; }
@media (max-width: 1439px) { .row-actions .btn.row-action { width: 8.75rem; } .card.wf-dense th, .card.wf-dense td { padding-left: 10px; padding-right: 10px; } }

/* ==========================================================================
   TASCO brand layer (v3 re-skin after baohiemtasco.vn) — see the teal rule in tokens.css.
   Lexend (--font-brand) for headings, navigation, buttons and KPI values; Inter (--font) for data.
   ========================================================================== */
h1, h2, h3, h4 { font-family: var(--font-brand); color: var(--heading); letter-spacing: 0; }
h1 { font-weight: var(--fw-semibold); }
h2, h3 { font-weight: var(--fw-medium); }
.btn { font-family: var(--font-brand); font-weight: var(--fw-medium); border-radius: var(--radius); letter-spacing: 0; }
.btn, .btn.secondary { --btn-fg: var(--secondary-fg); --btn-border: var(--secondary-border); }
.btn:hover, .btn.secondary:hover { background: var(--primary-soft); }
.btn.primary { --btn-bg: var(--primary); --btn-fg: var(--primary-contrast); --btn-border: var(--primary); box-shadow: none; }
.btn.ghost, .btn.link { --btn-border: transparent; }
.btn.danger { --btn-fg: var(--danger); --btn-border: var(--danger-border); }
.btn.danger.solid { --btn-fg: #fff; --btn-border: var(--danger); }
.btn.ghost:hover { background: var(--surface-3); }
/* Dense data keeps Inter: table cells, row actions and toolbars. */
td, th, td .btn, .row-actions .btn, .dt-toolbar .btn, .dt-footer .btn { font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
.btn.sm, .btn.small { font-weight: var(--fw-medium); }

/* Page title: Lexend navy 600 with a 32×3 teal accent underline. */
.page-header h1 { font-family: var(--font-brand); font-weight: var(--fw-semibold); color: var(--heading); letter-spacing: -0.005em; position: relative; padding-bottom: 10px; }
.page-header h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 32px; height: 3px; border-radius: 2px; background: var(--brand-teal); }
.page-header { align-items: flex-end; }
.card-header h2, .card-header h3, .card > h2, .card > h3 { font-family: var(--font-brand); font-weight: var(--fw-medium); color: var(--heading); }
.tabs button, .tabs [role="tab"] { font-family: var(--font-brand); font-weight: var(--fw-regular); }
.tabs button[aria-selected="true"] { color: var(--heading); font-weight: var(--fw-medium); }

/* KPI tiles: Lexend values and a teal top accent line. */
.kpi-tile { position: relative; overflow: hidden; border-top: 0; }
.kpi-tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand-teal); }
.kpi-tile .kpi-value, .kpi .value { font-family: var(--font-brand); font-weight: var(--fw-medium); color: var(--heading); letter-spacing: -0.01em; }
.kpi-tile .kpi-label { font-family: var(--font-brand); font-weight: var(--fw-regular); }

/* Selected / checked states use the light brand teal surface with navy text. */
.chip[aria-pressed="true"] { background: var(--brand-teal-tint); border-color: var(--primary); color: var(--nav-active-fg); }
.menu .menu-check { color: var(--link); }

/* ---------- Wordmark (stand-in for the official TASCO logo — see public/js/shared/brand.js) ---------- */
.wordmark { display: inline-flex; flex-direction: column; align-items: stretch; line-height: 1; font-family: var(--font-brand); color: var(--brand-navy); text-decoration: none; user-select: none; --wm-size: 26px; }
.wordmark .wm-tasco { font-size: var(--wm-size); font-weight: 700; letter-spacing: 0.06em; margin-right: -0.06em; color: var(--brand-navy); }
.wordmark .wm-ins { font-size: calc(var(--wm-size) * 0.335); font-weight: 400; letter-spacing: 0.52em; margin-right: -0.52em; margin-top: calc(var(--wm-size) * 0.14); color: var(--brand-teal-ink); white-space: nowrap; }
.wordmark.sm { --wm-size: 18px; }
.wordmark.lg { --wm-size: 40px; }
.wordmark.xl { --wm-size: 56px; }
.wordmark.white .wm-tasco, .wordmark.white .wm-ins { color: #ffffff; }
.wordmark.white .wm-ins { font-weight: 300; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wordmark:not(.navy):not(.white) .wm-tasco { color: #ffffff; } :root:not([data-theme="light"]) .wordmark:not(.navy):not(.white) .wm-ins { color: var(--brand-teal); } }
:root[data-theme="dark"] .wordmark:not(.navy):not(.white) .wm-tasco { color: #ffffff; }
:root[data-theme="dark"] .wordmark:not(.navy):not(.white) .wm-ins { color: var(--brand-teal); }
