/* Bank Reconciliation System — design tokens, layout and components. No build step; served as-is. */

:root {
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f2f4f7;
  --border: #e5e8ef;
  --border-2: #eaecf0;
  --border-strong: #d0d5dd;
  --text: #0b1426;
  --text-2: #344054;
  --text-3: #475467;
  --text-4: #667085;
  --text-5: #98a2b3;

  --brand: #13294b;
  --primary: #2152d6;
  --primary-hover: #1a44b4;
  --primary-soft: #eef4ff;
  --primary-ink: #3538cd;
  --primary-line: #c7d7fe;
  --focus: #2152d6;

  --ok: #17b26a;    --ok-ink: #067647;    --ok-soft: #ecfdf3;    --ok-line: #abefc6;
  --review: #f79009; --review-ink: #b54708; --review-soft: #fffaeb; --review-line: #fedf89;
  --bad: #f04438;   --bad-ink: #b42318;   --bad-soft: #fef3f2;   --bad-line: #fecdca;
  --muted: #98a2b3; --muted-ink: #475467; --muted-soft: #f2f4f7;

  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .28);
  --appbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --surface: #111a2b; --surface-2: #0f1726; --surface-3: #18233a;
    --border: #1f2b42; --border-2: #1f2b42; --border-strong: #2d3b57;
    --text: #e8ecf4; --text-2: #c9d1df; --text-3: #a9b4c6; --text-4: #8794aa; --text-5: #6b7891;
    --brand: #0e1a30; --primary: #5b8cff; --primary-hover: #7aa2ff; --primary-soft: #1a2850; --primary-ink: #a9beff; --primary-line: #2b3f78; --focus: #7aa2ff;
    --ok: #2fd08a; --ok-ink: #5fe0a6; --ok-soft: #0f2e22; --ok-line: #1d5a40;
    --review: #f5a524; --review-ink: #f7c46c; --review-soft: #33260b; --review-line: #5c4512;
    --bad: #f97066; --bad-ink: #fda29b; --bad-soft: #3a1614; --bad-line: #6b2620;
    --muted: #6b7891; --muted-ink: #a9b4c6; --muted-soft: #18233a;
    --shadow-xs: none; --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --surface: #111a2b; --surface-2: #0f1726; --surface-3: #18233a;
  --border: #1f2b42; --border-2: #1f2b42; --border-strong: #2d3b57;
  --text: #e8ecf4; --text-2: #c9d1df; --text-3: #a9b4c6; --text-4: #8794aa; --text-5: #6b7891;
  --brand: #0e1a30; --primary: #5b8cff; --primary-hover: #7aa2ff; --primary-soft: #1a2850; --primary-ink: #a9beff; --primary-line: #2b3f78; --focus: #7aa2ff;
  --ok: #2fd08a; --ok-ink: #5fe0a6; --ok-soft: #0f2e22; --ok-line: #1d5a40;
  --review: #f5a524; --review-ink: #f7c46c; --review-soft: #33260b; --review-line: #5c4512;
  --bad: #f97066; --bad-ink: #fda29b; --bad-soft: #3a1614; --bad-line: #6b2620;
  --muted: #6b7891; --muted-ink: #a9b4c6; --muted-soft: #18233a;
  --shadow-xs: none; --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03); --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg);
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-4); }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: 15px; height: 15px; }
.i-xs { width: 12px; height: 12px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
kbd { font: 500 11px var(--mono); color: var(--text-4); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; background: var(--surface); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-4); }

/* Tones */
.tone-ok { background: var(--ok); }
.tone-review { background: var(--review); }
.tone-bad { background: var(--bad); }
.tone-muted { background: var(--muted); }
.tone-soft-ok { background: var(--ok-soft); color: var(--ok-ink); }
.tone-soft-review { background: var(--review-soft); color: var(--review-ink); }
.tone-soft-bad { background: var(--bad-soft); color: var(--bad-ink); }
.tone-soft-muted { background: var(--muted-soft); color: var(--muted-ink); }
.tone-soft-primary { background: var(--primary-soft); color: var(--primary-ink); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.tone-ok { box-shadow: 0 0 0 3px var(--ok-soft); }
.status-dot.tone-bad { box-shadow: 0 0 0 3px var(--bad-soft); }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; white-space: nowrap; list-style: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn::-webkit-details-marker { display: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-xs), inset 0 -1px 0 rgba(0, 0, 0, .12); }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-secondary:disabled { color: var(--text-5); cursor: default; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-4);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.link { border: 0; padding: 0; background: none; color: inherit; font: inherit; text-align: left; }
.link:hover { color: var(--primary); text-decoration: underline; }

.field { display: grid; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.field-label small { font-size: 11px; font-weight: 600; color: var(--text-5); text-transform: uppercase; letter-spacing: .04em; }
.input {
  height: 40px; width: 100%; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input-sm { height: 34px; padding: 0 8px; font-size: 13px; width: auto; }

.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-3); }
.segmented button { height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; font-size: 12.5px; font-weight: 600; color: var(--text-4); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid transparent; }
.alert .i { margin-top: 1px; }
.alert-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); }
.alert-review { background: var(--review-soft); border-color: var(--review-line); color: var(--review-ink); }
.alert-body { display: grid; gap: 6px; min-width: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge-ok { background: var(--ok-soft); color: var(--ok-ink); border-color: var(--ok-line); }
.badge-review { background: var(--review-soft); color: var(--review-ink); border-color: var(--review-line); }
.badge-bad { background: var(--bad-soft); color: var(--bad-ink); border-color: var(--bad-line); }
.badge-muted { background: var(--muted-soft); color: var(--muted-ink); border-color: var(--border); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title h2 { font-size: 13px; font-weight: 600; color: var(--text-3); }
.card-title span { font-size: 12px; color: var(--text-4); }
.card-title-lg { padding: 18px 22px; border-bottom: 1px solid var(--border-2); }
.card-title-lg > div { display: grid; gap: 2px; }
.card-title-lg h2 { font-size: 15px; font-weight: 700; color: var(--text); }

/* ---------- Menus ---------- */
details[data-menu] { position: relative; }
details[data-menu] > summary { list-style: none; cursor: pointer; }
details[data-menu] > summary::-webkit-details-marker { display: none; }
.menu {
  position: absolute; top: calc(100% + 8px); z-index: 40; min-width: 260px; padding: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
}
.menu-right { right: 0; }
.menu-label { padding: 8px 10px 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-4); }
.menu-head { display: grid; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--border-2); margin-bottom: 6px; font-size: 13px; }
.menu-head span { color: var(--text-4); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 13.5px; text-align: left;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item-text { display: grid; }
.menu-item-text small { font-size: 12px; color: var(--text-4); }
.menu-item-danger { color: var(--bad-ink); margin-top: 4px; border-top: 1px solid var(--border-2); border-radius: 0 0 8px 8px; }
.menu-item-danger:hover { background: var(--bad-soft); color: var(--bad-ink); }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30; height: var(--appbar-h);
  display: flex; align-items: center; gap: 20px; padding: 0 28px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: #13294b; box-shadow: var(--shadow-xs); }
.brand-mark svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark svg path:last-child { stroke: #4ade9b; }
.modules { display: flex; gap: 2px; padding: 4px; border-radius: var(--radius-sm); background: var(--surface-3); }
.module { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 7px; color: var(--text-4); font-weight: 600; font-size: 13px; }
.module.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.module.is-disabled { color: var(--text-5); cursor: not-allowed; }
.module em { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; background: var(--border); color: var(--text-4); }
.mod-short { display: none; }
.appbar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.appbar-divider { width: 1px; height: 28px; background: var(--border); }
.appbar-search { position: relative; display: flex; align-items: center; }
.appbar-search .i { position: absolute; left: 12px; color: var(--text-4); pointer-events: none; }
.appbar-search input {
  width: 300px; height: 38px; padding: 0 64px 0 38px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 13px;
}
.appbar-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); background: var(--surface); }
.appbar-search kbd { position: absolute; right: 8px; pointer-events: none; }
.appbar .theme-toggle { --tt-track: var(--surface-3); --tt-icon: var(--text-4); --tt-knob: var(--surface); --tt-active: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.user-menu summary { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: var(--radius-sm); color: var(--text); }
.user-menu summary:hover { background: var(--surface-3); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-size: 12.5px; font-weight: 700; }
.user-id { display: grid; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11.5px; color: var(--text-4); }

.page { display: flex; flex-direction: column; gap: 20px; padding: 24px 28px 40px; min-width: 0; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-title { display: grid; gap: 10px; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-4); }
.crumbs [aria-current] { color: var(--text-2); font-weight: 500; }
.title-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title-row h1 { font-size: 26px; font-weight: 700; letter-spacing: -.025em; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.run-switcher summary {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-xs);
}
.run-switcher summary:hover { border-color: var(--border-strong); }
.run-switcher .mono { font-size: 12px; font-weight: 500; }
.run-switcher-when { font-size: 12.5px; color: var(--text-4); }
.run-menu { left: 0; width: 380px; max-height: 420px; overflow-y: auto; }
.run-option { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--text); }
a.run-option:hover { background: var(--surface-3); color: var(--text); }
.run-option.is-current { background: var(--primary-soft); }
.run-option.is-failed { opacity: .8; cursor: default; }
.run-option-main { flex: 1; display: grid; min-width: 0; }
.run-option-main b { font-size: 13px; font-weight: 600; }
.run-option-main small { font-size: 12px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.run-option-rate { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-3); }

/* ---------- Overview ---------- */
.overview { display: flex; gap: 16px; flex-wrap: wrap; }
.overview > .card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.ov-rate { flex: 1 1 300px; }
.ov-flow { flex: 2 1 520px; }
.ov-inputs { flex: 1 1 300px; }
.rate-body { display: flex; align-items: center; gap: 22px; }
.ring { position: relative; width: 128px; height: 128px; flex: none; }
.ring svg { width: 128px; height: 128px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring-track { stroke: var(--surface-3); }
.ring-seg { stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray .7s cubic-bezier(.2, .7, .2, 1); }
.ring-ok { stroke: var(--ok); }
.ring-review { stroke: var(--review); }
.ring-bad { stroke: var(--bad); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label b { font-size: 25px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: 11.5px; color: var(--text-4); }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 11px; flex: 1; min-width: 0; font-size: 13px; }
.legend li { display: flex; align-items: center; gap: 10px; color: var(--text-3); }
.legend li span:not(.swatch) { flex: 1; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.legend-total { padding-top: 10px; border-top: 1px dashed var(--border); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.flow { display: grid; gap: 4px; }
.flow-row {
  display: grid; grid-template-columns: minmax(150px, 190px) minmax(60px, 1fr) 44px minmax(90px, 150px); align-items: center; gap: 14px;
  padding: 8px 10px; margin: 0 -10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); text-align: left;
}
.flow-row:hover { background: var(--surface-2); }
.flow-label { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.flow-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; flex: none; }
.flow-icon .i { stroke-width: 2.4; }
.flow-track { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.flow-fill { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .7s cubic-bezier(.2, .7, .2, 1); }
.flow-count { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.flow-amount { text-align: right; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inputs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.inputs > li { display: flex; gap: 12px; min-width: 0; }
.input-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary-ink); }
.input-icon .i { width: 16px; height: 16px; }
.input-text { display: grid; gap: 2px; min-width: 0; }
.input-text b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.input-text > span { font-size: 12px; color: var(--text-4); }
.input-files summary { font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer; width: max-content; }
.input-files ol { margin: 6px 0 0; padding-left: 18px; max-height: 160px; overflow-y: auto; font-size: 12px; color: var(--text-3); }
.input-skipped { align-items: flex-start; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--review-soft); border: 1px solid var(--review-line); color: var(--review-ink); font-size: 12.5px; }
.input-skipped .i { margin-top: 2px; }

/* ---------- Results ---------- */
.results { overflow: hidden; }
.tabs { display: flex; gap: 6px; padding: 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { display: flex; flex-direction: column; gap: 8px; min-width: 124px; padding: 14px 10px 12px; border: 0; background: none; text-align: left; }
.tab-label { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; color: var(--text-4); white-space: nowrap; }
.tab:hover .tab-label { color: var(--text-2); }
.tab-count { min-width: 24px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: center; }
.tab-bar { display: flex; gap: 2px; height: 4px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.tab-bar span { width: 0; transition: width .6s cubic-bezier(.2, .7, .2, 1); }
.tab[aria-selected="true"] { box-shadow: inset 0 -2px 0 var(--primary); }
.tab[aria-selected="true"] .tab-label { color: var(--text); }
.tab[aria-selected="true"] .tab-count { background: var(--primary-soft); color: var(--primary-ink); }

.toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-3); font-size: 12.5px; font-weight: 600;
}
.filter-chip .n { font-variant-numeric: tabular-nums; opacity: .75; }
.filter-chip:hover { border-color: var(--border-strong); }
.filter-chip[aria-pressed="true"] { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.filter-chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.toolbar-end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; }
.search .i { position: absolute; left: 11px; color: var(--text-4); pointer-events: none; }
.search input { width: 240px; height: 34px; padding: 0 12px 0 36px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13px; }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

.table-wrap { position: relative; overflow: auto; }
.results .table-wrap { max-height: 72vh; min-height: 240px; }
table.grid { width: 100%; min-width: 1180px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.grid th {
  position: sticky; top: 0; z-index: 2; padding: 10px 12px; text-align: left; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--text-4); font-size: 12px; font-weight: 600; cursor: pointer; user-select: none;
}
.grid th:first-child, .grid td:first-child { padding-left: 16px; }
.grid th:last-child, .grid td:last-child { padding-right: 16px; }
.grid th:hover { color: var(--text-2); }
.grid th.num, .grid td.num { text-align: right; }
.grid th .sort { display: inline-block; width: 10px; margin-left: 4px; color: var(--primary); }
.grid td { padding: 13px 12px; border-bottom: 1px solid var(--surface-3); vertical-align: middle; }
.grid.is-compact td { padding-top: 7px; padding-bottom: 7px; }
.grid.is-compact .two .sub, .grid.is-compact .avatar-sm { display: none; }
.grid tbody tr { cursor: pointer; transition: background .1s; }
.grid tbody tr.no-drill { cursor: default; }
.grid tbody tr:hover td { background: var(--surface-2); }
.grid tbody tr.is-selected td { background: var(--primary-soft); }
.grid .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .amt { font-weight: 600; }
.grid .dim { color: var(--text-4); }
.grid .note { color: var(--text-3); font-size: 12.5px; max-width: 260px; white-space: normal; }
.grid .refs { font-family: var(--mono); font-size: 12px; }
.two { display: grid; gap: 2px; min-width: 0; }
.two .main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.two .sub { font-size: 12px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.party .two { min-width: 170px; }
.refs .main, .refs .sub { max-width: none; overflow: visible; }
.party { display: flex; align-items: center; gap: 10px; }
.party .main { font-weight: 600; }
.avatar-sm { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; font-size: 11.5px; font-weight: 700; }
.av-0 { background: #eef4ff; color: #3538cd; } .av-1 { background: #f4f3ff; color: #5925dc; } .av-2 { background: #ecfdf3; color: #067647; }
.av-3 { background: #fdf2fa; color: #c11574; } .av-4 { background: #fff6ed; color: #c4320a; } .av-5 { background: #f0f9ff; color: #026aa2; }
:root[data-theme="dark"] .avatar-sm { background: var(--surface-3); color: var(--text-2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar-sm { background: var(--surface-3); color: var(--text-2); } }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px; border-radius: 999px; border: 1px solid transparent; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); } .pill-ok .dot { background: var(--ok); }
.pill-review { background: var(--review-soft); border-color: var(--review-line); color: var(--review-ink); } .pill-review .dot { background: var(--review); }
.pill-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); } .pill-bad .dot { background: var(--bad); }
.trail { display: inline-flex; align-items: center; }
.trail .leg { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.trail .link-line { width: 14px; height: 2px; background: var(--border); }
.leg-ok { background: var(--ok); box-shadow: 0 0 0 2px var(--ok-soft); }
.leg-review { background: var(--review); box-shadow: 0 0 0 2px var(--review-soft); }
.leg-bad { background: var(--surface); box-shadow: inset 0 0 0 2px var(--bad); }
.leg-skip { background: var(--border-strong); }
.diff-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.diff-chip.is-diff { background: var(--bad-soft); color: var(--bad-ink); }
.grid-state { padding: 48px 16px; text-align: center; color: var(--text-4); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.pager b { color: var(--text); }
.pager-controls { display: flex; align-items: center; gap: 8px; }
.pager-controls label { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Summary (reconciliation statement) ---------- */
.panel[data-panel="summary"] { padding: 24px; }
.brs { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.brs-main { flex: 3 1 700px; min-width: 0; display: grid; gap: 14px; }
.brs-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brs-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brs-head p { margin-top: 4px; font-size: 12.5px; color: var(--text-4); }
.brs-actions { display: flex; gap: 8px; }
.brs-table-wrap { overflow-x: auto; border: 1px solid var(--border-2); border-radius: var(--radius-md); }
.brs-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 13px; }
.brs-table th, .brs-table td { padding: 11px 12px; border-bottom: 1px solid var(--surface-3); text-align: left; font-weight: 400; }
.brs-table th:first-child { padding-left: 16px; }
.brs-table td:last-child, .brs-table th:last-child { padding-right: 16px; }
.brs-table thead th { background: var(--surface-2); color: var(--text-4); font-size: 12px; font-weight: 600; border-bottom-color: var(--border-2); }
.brs-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.brs-label { display: grid; gap: 2px; font-weight: 600; }
.brs-label small { font-size: 12px; font-weight: 400; color: var(--text-4); }
.brs-opening { background: var(--primary-soft); }
.brs-opening td, .brs-opening th { font-weight: 700; border-bottom-color: var(--border-strong); }
.brs-section th { background: var(--surface-2); font-size: 12.5px; font-weight: 600 !important; color: var(--text-2); padding-top: 12px; padding-bottom: 12px; }
.brs-badge { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.brs-line td { font-weight: 600; }
.brs-part th { padding-left: 48px !important; font-size: 12.5px; color: var(--text-3); }
.brs-part td { font-size: 12.5px; color: var(--text-3); padding-top: 9px; padding-bottom: 9px; }
.brs-none { color: var(--text-4) !important; font-style: italic; }
.brs-subtotal th, .brs-subtotal td { font-weight: 600; background: var(--surface-2); border-bottom-color: var(--border-strong); }
.brs-table .is-diff { color: var(--bad-ink); font-weight: 600; }
.brs-table tfoot th, .brs-table tfoot td { background: #13294b; color: #fff; border: 0; padding-top: 14px; padding-bottom: 14px; font-weight: 700; font-size: 14px; }
.brs-table tfoot small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
.brs-bridge { flex: 1 1 320px; display: grid; gap: 16px; padding: 20px; border: 1px solid var(--border-2); border-radius: 14px; background: var(--surface-2); }
.brs-bridge h3 { font-size: 15px; font-weight: 700; }
.brs-bridge p { font-size: 12.5px; color: var(--text-4); margin-top: 4px; }
.bridge { list-style: none; margin: 0; padding: 0; }
.bridge li { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-2); }
.bridge li.bridge-start { border-top: 0; }
.bridge li.bridge-end { border-top: 2px solid var(--text); }
.bridge-sign { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 50%; font-weight: 700; font-size: 13px; }
.bridge-sign.is-total { background: #13294b; color: #fff; }
.bridge-text { flex: 1; display: grid; gap: 2px; min-width: 0; font-size: 13px; }
.bridge-text small { font-size: 12px; color: var(--text-4); }
.bridge-amount { font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tie { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid transparent; }
.tie-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); }
.tie-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); }
.next-steps { display: grid; gap: 8px; }
.next-steps > span { font-size: 12px; font-weight: 600; color: var(--text-3); }
.next-step {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13px; text-align: left;
}
.next-step:hover { border-color: var(--border-strong); }
.next-step .i { color: var(--text-4); }
.empty-note { display: flex; align-items: center; gap: 10px; padding: 16px; border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-3); }

/* ---------- Drawer (line detail) ---------- */
.drawer-backdrop, .sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(12, 17, 29, .45); backdrop-filter: blur(2px); }
.drawer {
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 51; width: min(560px, calc(100vw - 24px));
  display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg);
  transform: translateX(110%); transition: transform .24s cubic-bezier(.2, .7, .2, 1); visibility: hidden;
}
.drawer.is-open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--border-2); }
.drawer-kicker { font-size: 12px; color: var(--text-4); font-weight: 600; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.drawer-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; word-break: break-word; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px 28px; display: grid; gap: 14px; align-content: start; }
.trail-steps { display: grid; }
.trail-step { position: relative; padding: 0 0 14px 34px; }
.trail-step::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--border-2); }
.trail-step:last-child::before { display: none; }
.trail-node { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--text-4); }
.trail-node .i { width: 13px; height: 13px; stroke-width: 2.6; }
.trail-step.is-ok .trail-node { background: var(--ok-soft); color: var(--ok-ink); }
.trail-step.is-bad .trail-node { background: var(--bad-soft); color: var(--bad-ink); }
.trail-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 13.5px; margin-bottom: 8px; line-height: 24px; }
.trail-title span { font-weight: 600; font-size: 12px; color: var(--text-4); }
.kv { display: grid; grid-template-columns: 136px minmax(0, 1fr); gap: 7px 12px; padding: 14px; margin: 0; border: 1px solid var(--border-2); border-radius: var(--radius-md); background: var(--surface-2); font-size: 13px; }
.kv dt { color: var(--text-4); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; display: flex; align-items: center; gap: 6px; }
.kv dd.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.copy { border: 0; background: none; padding: 3px; color: var(--text-4); border-radius: 5px; display: inline-grid; }
.copy:hover { color: var(--primary); background: var(--primary-soft); }
.copy .i { width: 13px; height: 13px; }
.callout { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid transparent; }
.callout strong { display: block; }
.callout-ok { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok-ink); }
.callout-review { background: var(--review-soft); border-color: var(--review-line); color: var(--review-ink); }
.callout-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad-ink); }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mini-table th, .mini-table td { padding: 8px; border-bottom: 1px solid var(--border-2); text-align: left; }
.mini-table th { color: var(--text-4); font-weight: 600; }
.mini-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.section-title { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-4); }

/* ---------- New reconciliation: sheet and form ---------- */
.sheet {
  position: fixed; top: 12px; right: 12px; bottom: 12px; z-index: 52; width: min(660px, calc(100vw - 24px));
  display: flex; flex-direction: column; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateX(110%); transition: transform .26s cubic-bezier(.2, .7, .2, 1); visibility: hidden;
}
.sheet.is-open { transform: none; visibility: visible; }
.sheet .run-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sheet-head { display: grid; gap: 18px; padding: 22px 26px 18px; border-bottom: 1px solid var(--border-2); }
.sheet-title { display: flex; align-items: flex-start; gap: 14px; }
.sheet-title > div { flex: 1; display: grid; gap: 2px; }
.sheet-title h2 { font-size: 18px; font-weight: 700; letter-spacing: -.015em; }
.sheet-title p { font-size: 13px; color: var(--text-4); }
.sheet-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: var(--primary-soft); border: 1px solid var(--primary-line); color: var(--primary-ink); }
.sheet-body { flex: 1; overflow-y: auto; padding: 20px 26px; display: grid; gap: 22px; align-content: start; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border-2); min-width: 0; }
.step-dot { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--surface-3); color: var(--text-4); font-size: 12px; font-weight: 700; }
.step-text { display: grid; line-height: 1.25; min-width: 0; }
.step-text b { font-size: 12.5px; font-weight: 600; }
.step-text small { font-size: 11.5px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.is-ok { background: var(--ok-soft); border-color: var(--ok-line); }
.step.is-ok .step-dot { background: var(--ok); color: #fff; }
.step.is-ok .step-text b, .step.is-ok .step-text small { color: var(--ok-ink); }
.step.is-warn { background: var(--review-soft); border-color: var(--review-line); }
.step.is-warn .step-dot { background: var(--review); color: #fff; }
.step.is-warn .step-text b, .step.is-warn .step-text small { color: var(--review-ink); }
.step.is-bad { background: var(--bad-soft); border-color: var(--bad-line); }
.step.is-bad .step-dot { background: var(--bad); color: #fff; }
.step.is-bad .step-text b, .step.is-bad .step-text small { color: var(--bad-ink); }

.slots { display: grid; gap: 20px; }
.slot { display: grid; gap: 10px; min-width: 0; }
.slot-head { display: flex; align-items: center; gap: 12px; }
.slot-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px; background: var(--primary-soft); border: 1px solid var(--primary-line); color: var(--primary-ink); }
.slot-title { flex: 1; display: grid; min-width: 0; }
.slot-title h3 { font-size: 15px; font-weight: 700; }
.slot-limit { font-size: 12px; color: var(--text-4); text-align: right; }
.slot-needs { display: grid; gap: 6px; }
.slot-needs > span { font-size: 12px; font-weight: 600; color: var(--text-3); }
.slot-needs > div { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-col { padding: 3px 8px; border-radius: 6px; background: var(--surface-3); font-size: 12px; color: var(--text-2); }
.file-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border-2); border-radius: var(--radius-md); overflow: hidden; max-height: 290px; overflow-y: auto; box-shadow: var(--shadow-xs); }
.file-list:empty { display: none; }
.file { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--surface-3); }
.file:last-child { border-bottom: 0; }
.file-badge { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 9px; background: var(--surface-3); color: var(--text-3); font-size: 9.5px; font-weight: 700; letter-spacing: .02em; }
.file-main { flex: 1; display: grid; gap: 2px; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: 12px; color: var(--text-4); }
.file-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.file-state.is-ok { color: var(--ok-ink); }
.file-state.is-checking { color: var(--text-4); }
.file-state.is-bad { color: var(--bad-ink); }
.file-remove { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border: 0; border-radius: 7px; background: transparent; color: var(--text-5); }
.file-remove:hover { background: var(--surface-3); color: var(--text); }
.file.is-ok .file-badge { background: var(--ok-soft); color: var(--ok-ink); }
.file.is-bad { align-items: flex-start; background: var(--bad-soft); }
.file.is-bad .file-badge { background: var(--surface); color: var(--bad-ink); box-shadow: inset 0 0 0 1px var(--bad-line); }
.file.is-bad .file-meta { color: var(--bad-ink); line-height: 1.5; }
.file-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.file-actions .btn { height: 30px; padding: 0 10px; font-size: 12px; }
.file-found { font-size: 12px; color: var(--text-4); }
.file-found summary { cursor: pointer; font-weight: 600; width: max-content; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.slot-drop {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 12px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-3); font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.slot-drop b { color: var(--primary); }
.slot-drop:hover, .slot-drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.slot-drop:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.slot.is-invalid .slot-drop { border-color: var(--bad); background: var(--bad-soft); }
.slot.is-full .slot-drop { display: none; }

.tolerances { display: grid; gap: 12px; }
.tolerances-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tolerances-head h3 { font-size: 13px; font-weight: 600; color: var(--text-2); }
.tolerance-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.form-foot { display: grid; gap: 12px; padding: 16px 26px; border-top: 1px solid var(--border-2); background: var(--surface-2); }
.form-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-status { display: grid; gap: 2px; font-size: 12.5px; color: var(--text-3); }
.form-status b { font-size: 13px; color: var(--text); }
.form-actions { display: flex; gap: 10px; }
.progress { display: grid; gap: 6px; }
.progress-track { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); border-radius: 6px; transition: width .2s; }
.progress.is-processing .progress-bar { width: 40% !important; animation: indeterminate 1.1s ease-in-out infinite; }
@keyframes indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.progress-label { font-size: 12.5px; color: var(--text-3); }

/* Inline (first run) */
.start { width: 100%; max-width: 1240px; margin: 0 auto; display: grid; gap: 28px; padding-top: 16px; }
.start-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.start-head > div { display: grid; gap: 8px; }
.start-head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.start-head p { max-width: 640px; font-size: 15px; line-height: 1.55; color: var(--text-3); }
.trust { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }
.trust .i { color: var(--ok); }
.start-form { overflow: hidden; }
.run-form.is-inline .slots { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; padding: 24px 24px 4px; }
.run-form.is-inline .slot { align-content: start; padding: 20px; border: 1.5px dashed var(--border-strong); border-radius: 14px; background: var(--surface-2); }
.run-form.is-inline .slot-head { flex-wrap: wrap; }
.run-form.is-inline .slot-limit { width: 100%; text-align: left; order: 3; }
.run-form.is-inline .slot-drop { background: var(--surface); }
.run-form.is-inline .tolerances { padding: 16px 24px 20px; }
.run-form.is-sheet .slot-needs { display: none; }
.run-form.is-sheet .slot-icon { width: 34px; height: 34px; }
.run-form.is-sheet .slot-title h3 { font-size: 14px; }

.recent { overflow: hidden; }
.recent-empty { padding: 18px 22px; color: var(--text-4); }
.list-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 820px; }
.list-table th { padding: 10px 12px; background: var(--surface-2); color: var(--text-4); font-size: 12px; font-weight: 600; text-align: left; }
.list-table td { padding: 14px 12px; border-top: 1px solid var(--surface-3); }
.list-table th:first-child, .list-table td:first-child { padding-left: 22px; }
.list-table th:last-child, .list-table td:last-child { padding-right: 22px; }
.run-cell { display: flex; align-items: center; gap: 12px; }
.run-cell > span:last-child { display: grid; gap: 2px; }
.run-cell small { font-size: 11.5px; color: var(--text-4); }
.muted-cell { color: var(--text-3); }
.rate-cell { display: flex; align-items: center; gap: 10px; }
.rate-track { width: 120px; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.rate-fill { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 999px; transition: width .6s; }
.rate-cell b { font-variant-numeric: tabular-nums; }
.action-cell { text-align: right; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600; max-width: 380px; animation: toast-in .25s ease-out; }
.toast-ok { background: var(--text); color: var(--surface); }
.toast-bad { background: var(--bad-ink); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Theme switch ---------- */
.theme-toggle {
  --tt-track: rgba(255,255,255,.14); --tt-icon: rgba(255,255,255,.7); --tt-knob: #fff; --tt-active: #13294b;
  position: relative; display: inline-flex; align-items: center; justify-content: space-between;
  width: 60px; height: 30px; padding: 0 7px; border: 0; border-radius: 999px; background: var(--tt-track); flex: none;
}
.theme-toggle .i { position: relative; z-index: 1; width: 15px; height: 15px; color: var(--tt-icon); transition: color .2s; }
.theme-toggle-knob {
  position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--tt-knob); box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .22s cubic-bezier(.2,.7,.2,1);
}
.theme-toggle .tt-sun { color: var(--tt-active); }
.theme-toggle:hover { filter: brightness(1.08); }
:root[data-theme="dark"] .theme-toggle-knob { transform: translateX(30px); }
:root[data-theme="dark"] .theme-toggle .tt-sun { color: var(--tt-icon); }
:root[data-theme="dark"] .theme-toggle .tt-moon { color: var(--tt-active); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle-knob { transform: translateX(30px); }
  :root:not([data-theme="light"]) .theme-toggle .tt-sun { color: var(--tt-icon); }
  :root:not([data-theme="light"]) .theme-toggle .tt-moon { color: var(--tt-active); }
}

/* ---------- Auth ---------- */
.auth {
  --auth-top: #f4f7fc; --auth-base: #e9eef7; --auth-g1: #cfdcf8; --auth-g2: #d2efe1;
  --auth-glow-a: .18; --auth-glow-b: .14; --auth-ink: #0f1b2d; --auth-mute: #5b6475;
  --auth-card-border: #e2e7ef; --auth-card-shadow: 0 24px 60px rgba(19, 41, 75, .14);
  min-height: 100vh; background: var(--auth-base); overflow-x: hidden;
}
:root[data-theme="dark"] .auth {
  --auth-top: #10244a; --auth-base: #0a1528; --auth-g1: #1c3d72; --auth-g2: #0f3b3a;
  --auth-glow-a: .28; --auth-glow-b: .18; --auth-ink: #ffffff; --auth-mute: rgba(255,255,255,.55);
  --auth-card-border: rgba(255,255,255,.08); --auth-card-shadow: 0 30px 80px rgba(3, 10, 25, .55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth {
    --auth-top: #10244a; --auth-base: #0a1528; --auth-g1: #1c3d72; --auth-g2: #0f3b3a;
    --auth-glow-a: .28; --auth-glow-b: .18; --auth-ink: #ffffff; --auth-mute: rgba(255,255,255,.55);
    --auth-card-border: rgba(255,255,255,.08); --auth-card-shadow: 0 30px 80px rgba(3, 10, 25, .55);
  }
}
.auth-bg {
  position: fixed; inset: 0; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(900px 620px at 12% 8%, var(--auth-g1) 0%, transparent 60%),
    radial-gradient(760px 560px at 92% 95%, var(--auth-g2) 0%, transparent 58%),
    linear-gradient(160deg, var(--auth-top) 0%, var(--auth-base) 70%);
}
.auth-glow { position: absolute; width: 540px; height: 540px; border-radius: 50%; filter: blur(110px); }
.auth-glow-a { top: -200px; left: -140px; background: #2f6bff; opacity: var(--auth-glow-a); }
.auth-glow-b { right: -160px; bottom: -220px; background: #1fbf7a; opacity: var(--auth-glow-b); }
.auth-theme { position: fixed; top: 18px; right: 18px; z-index: 2; }
.auth .theme-toggle { --tt-track: rgba(19,41,75,.1); --tt-icon: #7a8699; --tt-knob: #fff; --tt-active: #13294b; }
:root[data-theme="dark"] .auth .theme-toggle { --tt-track: rgba(255,255,255,.14); --tt-icon: rgba(255,255,255,.7); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth .theme-toggle { --tt-track: rgba(255,255,255,.14); --tt-icon: rgba(255,255,255,.7); }
}
.auth-center { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 40px 16px; }
.auth-brand-mark { color: var(--auth-ink); font-size: 18px; }
.auth-brand-mark .brand-name { display: inline; }
.auth .brand-mark { background: #13294b; }
.auth-card {
  width: min(400px, 100%); display: grid; gap: 16px; padding: 32px;
  background: var(--surface); border: 1px solid var(--auth-card-border); border-radius: 16px;
  box-shadow: var(--auth-card-shadow);
}
.auth-card-head h1 { font-size: 22px; }
.auth-card-head p { margin-top: 4px; }
.auth-foot { display: flex; align-items: center; gap: 8px; color: var(--auth-mute); font-size: 12.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .appbar-search input { width: 220px; }
  .user-id { display: none; }
}
@media (max-width: 860px) {
  .appbar { gap: 12px; padding: 0 16px; }
  .appbar-search { display: none; }
  .brand-name { display: none; }
  .page { padding: 16px 16px 32px; }
  .flow-row { grid-template-columns: minmax(120px, 1fr) 70px 36px; }
  .flow-amount { display: none; }
  .tolerance-fields, .stepper { grid-template-columns: minmax(0, 1fr); }
  .search input { width: 100%; }
  .toolbar-end, .search { flex: 1; }
  .auth-brand-mark .brand-name { display: inline; }
}
@media (max-width: 640px) {
  .module { padding: 0 10px; }
  .module em, .mod-full { display: none; }
  .mod-short { display: inline; }
  .page-actions, .page-actions .btn, .page-actions details { width: 100%; }
  .page-actions details summary { width: 100%; }
  .rate-body { flex-direction: column; align-items: stretch; }
  .ring { align-self: center; }
  .sheet-head, .sheet-body, .form-foot { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  body { background: #fff; }
  .appbar, .page-head, .overview, .tabs, .toasts, .brs-actions, .next-steps, .sheet, .sheet-backdrop, .drawer, .drawer-backdrop { display: none !important; }
  body.print-summary .panel[data-panel="grid"] { display: none !important; }
  body.print-summary .panel[data-panel="summary"] { display: block !important; padding: 0; }
  .results { border: 0; box-shadow: none; }
  .brs { display: block; }
  .brs-bridge { margin-top: 16px; break-inside: avoid; }
  .table-wrap, .brs-table-wrap { max-height: none; overflow: visible; }
  .brs-table tfoot th, .brs-table tfoot td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
