:root {
  color-scheme: light;
  --paper:#fff;
  --bg:#f4f6fa;
  --ink:#142039;
  --sub:#4b5b73;
  --quiet:#5d6c81;
  --line:#e0e6ef;
  --blue:#2459d7;
  --blue-deep:#1a47b9;
  --sidebar:#111d31;
  --radius:15px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size:16px;
}
*, *::before, *::after { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--ink); }
button, input, select { font:inherit; }
button, select { cursor:pointer; }
button:disabled { cursor:not-allowed; }
a { color:var(--blue-deep); text-decoration:none; }
a:hover { text-decoration:underline; }
:focus-visible { outline:3px solid #6d9af9; outline-offset:3px; }
h1, h2, h3, h4, p { margin:0; }
p { line-height:1.55; }
.icon { display:inline-block; flex:none; width:1.125rem; height:1.125rem; vertical-align:middle; }
.sr-only, .skip-link:not(:focus) { 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:focus { position:fixed; top:.5rem; left:.5rem; padding:.75rem; background:white; z-index:9; }

.sidebar { position:fixed; inset:0 auto 0 0; z-index:3; width:238px; display:flex; flex-direction:column; padding:27px 17px 15px; background:var(--sidebar); color:#d7e0ef; }
.brand { min-height:45px; display:flex; align-items:center; gap:12px; padding:0 8px; color:white; }
.brand:hover { text-decoration:none; }
.brand-icon { display:grid; width:40px; height:40px; place-items:center; background:#2b5ee3; border:1px solid #5380f2; border-radius:11px; box-shadow:0 3px 10px #02091655; }
.brand-icon .icon { width:23px; height:23px; stroke-width:1.6; }
.brand strong, .brand small, .workspace-storage strong, .workspace-storage small { display:block; }
.brand strong { color:#fff; font-size:1.04rem; font-weight:720; letter-spacing:-.025em; }
.brand small { color:#aab9d1; font-size:.78rem; margin-top:4px; }
.side-workspace { margin-top:46px; }
.side-label { padding:0 10px; margin-bottom:12px; color:#9aaac4; font-size:.75rem; font-weight:700; text-transform:uppercase; letter-spacing:.12em; }
.sidebar nav { display:grid; gap:6px; }
.sidebar nav a, .side-link { display:flex; align-items:center; gap:11px; min-height:43px; padding:0 12px; border:1px solid transparent; border-radius:8px; color:#c9d6e9; font-size:.92rem; font-weight:560; }
.sidebar nav a:hover, .side-link:hover { background:#1b2c46; color:#fff; text-decoration:none; }
.sidebar a[aria-current="page"] { background:#23395c; border-color:#355177; color:#f6f9ff; }
.sidebar a[aria-current="page"] .icon { color:#a6bfff; }
.side-bottom { display:grid; gap:14px; margin-top:auto; }
.workspace-storage { display:flex; align-items:flex-start; gap:9px; padding:14px 9px 4px; border-top:1px solid #2b3b54; }
.workspace-storage strong { color:#e7edfa; font-size:.84rem; font-weight:620; }
.workspace-storage small { margin-top:5px; color:#aab9d1; font-size:.75rem; }
.workspace-storage .icon { width:15px; height:15px; color:#9aaac4; margin-top:1px; }

.workspace { margin-left:238px; min-height:100vh; }
.topbar { position:sticky; top:0; z-index:2; min-height:64px; background:#fff; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:12px; padding:0 35px; }
.crumb { display:flex; gap:11px; align-items:center; font-size:.9rem; color:var(--quiet); }
.crumb strong { font-weight:650; color:#24364f; }
.crumb .icon { width:16px; height:16px; }
.crumb [data-icon="chevron"] .icon { width:13px; height:13px; color:#8492a6; }
.top-status { display:inline-flex; align-items:center; gap:7px; padding:6px 10px; border:1px solid #cce8da; color:#146446; background:#f3fbf7; font-size:.83rem; font-weight:650; border-radius:999px; white-space:nowrap; }
.top-status i, .stage-chip i { width:7px; height:7px; background:#289266; border-radius:50%; }
.top-status.working { background:#eef4ff; border-color:#c9d8fa; color:var(--blue-deep); }
.top-status.working i, .stage-chip i { background:var(--blue); }
.top-status.unavailable { background:#fff3ef; color:#983c26; border-color:#f3cfbf; }
.top-status.unavailable i { background:#ae432d; }

main { max-width:1440px; margin:auto; padding:34px 35px 50px; }
main:focus, .result:focus { outline:none; }
.page-heading { display:flex; justify-content:space-between; align-items:flex-end; gap:16px; margin-bottom:26px; }
.eyebrow { color:var(--blue-deep); font-size:.75rem; text-transform:uppercase; font-weight:760; letter-spacing:.115em; margin-bottom:10px; }
.page-heading h1 { margin-bottom:8px; font-size:clamp(2rem,3.1vw,2.6rem); line-height:1.09; font-weight:740; letter-spacing:-.048em; }
.page-heading p { color:var(--sub); }
.page-heading > .btn { flex:none; margin-bottom:2px; }
.run-grid, .detail-grid { display:grid; grid-template-columns:minmax(0,1.16fr) minmax(0,1fr); align-items:start; gap:20px; }
.detail-grid { grid-template-columns:minmax(0,1.65fr) minmax(295px,1fr); }
.panel { background:var(--paper); border:1px solid var(--line); border-radius:var(--radius); min-width:0; box-shadow:0 2px 6px #19284405; }
.panel-heading { padding:21px 23px 17px; display:flex; gap:12px; justify-content:space-between; align-items:flex-start; }
.panel-heading h2 { font-size:1.12rem; line-height:1.24; font-weight:710; letter-spacing:-.021em; }
.panel-heading p { color:var(--quiet); font-size:.9rem; margin-top:5px; overflow-wrap:anywhere; }
.panel-heading .text-link { margin-top:2px; }
.text-link { display:inline-flex; align-items:center; white-space:nowrap; font-weight:690; font-size:.9rem; }

#upload-content { padding:0 23px 19px; }
.dropzone, .chosen-file { width:100%; min-height:141px; border:1px dashed #b6c9eb; border-radius:11px; background:#f7faff; color:var(--ink); }
.dropzone { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; padding:17px 10px; text-align:center; }
.dropzone strong { font-size:1rem; font-weight:680; }
.dropzone > span:last-child { font-size:.875rem; color:var(--quiet); }
.dropzone:hover:not(:disabled), .dropzone.dragging, .chosen-file.dragging { background:#edf4ff; border-color:#5784e6; }
.upload-icon { display:grid; place-items:center; flex:none; width:38px; height:38px; color:var(--blue); border:1px solid #dbe7ff; background:#edf3ff; border-radius:9px; margin-bottom:2px; }
.upload-icon .icon { width:20px; height:20px; }
.chosen-file { display:flex; align-items:center; gap:10px; padding:15px; }
.chosen-file > div { flex:1; min-width:0; }
.chosen-file strong, .chosen-file small { display:block; overflow-wrap:anywhere; }
.chosen-file strong { font-size:.96rem; }
.chosen-file small { margin-top:5px; color:var(--quiet); font-size:.875rem; }
.icon-btn { display:grid; place-items:center; flex:none; width:34px; height:34px; border:1px solid var(--line); background:#fff; border-radius:7px; color:var(--sub); }
.icon-btn:hover:not(:disabled) { border-color:#a5bee9; color:var(--blue-deep); }
.icon-btn:disabled { opacity:.55; }
.upload-actions { display:flex; align-items:center; justify-content:space-between; gap:11px; margin-top:13px; }
.upload-actions > span { display:flex; align-items:center; gap:6px; color:var(--quiet); font-size:.78rem; }
.upload-actions > span .icon { width:13px; height:13px; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:38px; padding:8px 13px; border:1px solid transparent; border-radius:8px; font-size:.89rem; font-weight:670; line-height:1.15; white-space:nowrap; }
a.btn:hover { text-decoration:none; }
.btn .icon { width:16px; height:16px; }
.btn.primary { background:var(--blue); color:#fff; border-color:var(--blue); }
.btn.primary:hover:not(:disabled) { background:var(--blue-deep); border-color:var(--blue-deep); }
.btn.primary:disabled { background:#dfe8f9; border-color:#dfe8f9; color:#53688c; }
.btn.secondary { background:#fff; color:#344864; border-color:#d9e2ef; }
.btn.secondary:hover:not(:disabled) { color:var(--blue-deep); border-color:#a3bbeb; background:#f8faff; }
.inline-error { color:#9b3426; font-size:.875rem; margin:8px 0 0; }

.sample-section { border-top:1px solid var(--line); margin-top:17px; padding-top:13px; }
.sample-section h3 { font-size:.91rem; font-weight:700; margin-bottom:10px; }
.samples { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.sample { display:flex; align-items:center; gap:9px; min-width:0; text-align:left; min-height:63px; padding:8px 9px; background:#fff; border:1px solid var(--line); border-radius:9px; color:var(--ink); }
.sample:hover:not(:disabled), .sample.chosen { border-color:#83a4ec; background:#f6f9ff; }
.sample[aria-pressed="true"] { box-shadow:inset 0 0 0 1px #a1bbf6; }
.sample:disabled:not(.chosen) { opacity:.72; }
.sample-icon { width:33px; height:33px; display:grid; place-items:center; flex:none; border-radius:8px; }
.sample-icon .icon { width:17px; height:17px; }
.sample-icon.blue { background:#edf3ff; color:#2858bd; }
.sample-icon.teal { background:#e8f7f1; color:#107353; }
.sample-icon.amber { background:#fff4e1; color:#98620e; }
.sample-icon.purple { background:#f1ecfc; color:#6b47ac; }
.sample-text { min-width:0; }
.sample-text strong, .sample-text small { display:block; overflow-wrap:anywhere; }
.sample-text strong { font-size:.875rem; line-height:1.2; font-weight:680; }
.sample-text small { color:var(--quiet); margin-top:3px; font-size:.78rem; line-height:1.2; }
.sample-note { display:flex; align-items:flex-start; gap:6px; margin-top:10px; color:var(--quiet); font-size:.78rem; }
.sample-note .icon { width:13px; height:13px; margin-top:3px; }

.trace-heading { border-bottom:1px solid var(--line); }
.stage-chip { align-items:center; display:inline-flex; gap:6px; color:#4d5e77; background:#f1f4f9; border:1px solid #e3e9f2; font-size:.82rem; font-weight:650; padding:4px 8px; border-radius:6px; white-space:nowrap; }
.stage-chip.running { background:#eff4ff; color:var(--blue-deep); border-color:#d9e5ff; }
.stage-list { list-style:none; padding:13px 20px 12px; margin:0; }
.stage { position:relative; display:grid; grid-template-columns:33px minmax(0,1fr) auto; gap:11px; align-items:center; padding:6px 2px; min-height:62px; }
.stage:not(:last-child)::after { position:absolute; display:block; content:""; top:calc(50% + 18px); height:calc(50% - 2px); left:18px; border-left:1px solid #dbe4f1; }
.stage-icon { display:grid; place-items:center; width:33px; height:33px; color:#687d9a; background:#f0f4fa; border:1px solid #e4ebf5; border-radius:9px; }
.stage-icon .icon { width:17px; height:17px; }
.stage-text strong, .stage-text small { display:block; overflow-wrap:anywhere; }
.stage-text strong { font-weight:670; font-size:.91rem; }
.stage-text small { color:var(--quiet); font-size:.82rem; line-height:1.35; margin-top:3px; }
.stage-meta { color:var(--quiet); font-size:.74rem; font-weight:650; }
.stage.done .stage-icon { color:#107653; background:#e9f9f1; border-color:#d3efe1; }
.stage.done .stage-meta { color:#1c704f; }
.stage.active .stage-icon { color:var(--blue-deep); background:#edf3ff; border-color:#cbdcff; box-shadow:0 0 0 3px #f0f5ff; }
.stage.warning .stage-icon { color:#945507; background:#fff4e4; border-color:#f6e4c9; }
.stage.warning .stage-meta { color:#88520a; }
.stage.failed .stage-icon { color:#a03a2f; background:#fff2ef; border-color:#f1d3cc; }
.stage.failed .stage-meta { color:#a03a2f; }
.stage.skipped { opacity:.7; }
.spinner { display:block; width:15px; height:15px; border:2px solid #d7e3fa; border-top-color:var(--blue); border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
.trace-footer { display:flex; justify-content:space-between; gap:8px; align-items:center; min-height:48px; padding:0 23px; border-top:1px solid var(--line); color:var(--quiet); background:#fbfcfe; font-size:.79rem; border-radius:0 0 var(--radius) var(--radius); }
.progress-track { width:89px; height:4px; border-radius:6px; background:#e4eaf4; overflow:hidden; }
.progress-track span { display:block; height:100%; background:#3b73e8; transition:width .2s ease; }
.recent, #run-result:not(:empty) { margin-top:20px; }

.empty { display:flex; align-items:center; gap:12px; min-height:84px; padding:14px 23px 17px; border-top:1px solid var(--line); }
.empty-icon { display:grid; place-items:center; background:#eff3f9; color:#6a7c96; width:39px; height:39px; border-radius:9px; flex:none; }
.empty strong { font-size:.91rem; font-weight:680; }
.empty p { font-size:.84rem; margin-top:3px; color:var(--quiet); }
.table-wrap, .evidence-wrap { overflow:auto; }
table { border-collapse:collapse; width:100%; text-align:left; }
thead { background:#f7f9fc; color:#4d5c74; }
th, td { padding:13px 14px; border-top:1px solid var(--line); font-size:.875rem; vertical-align:middle; }
th:first-child, td:first-child { padding-left:23px; }
th:last-child, td:last-child { padding-right:23px; }
th { white-space:nowrap; font-weight:660; }
td strong, td small { display:block; }
td strong { font-weight:665; }
td small { margin-top:4px; color:var(--quiet); font-size:.76rem; }
.amount, .time { white-space:nowrap; font-variant-numeric:tabular-nums; }
.row-link { color:var(--blue-deep); font-weight:680; white-space:nowrap; }
.badge { width:fit-content; background:#edf1f7; color:#495970; display:inline-flex; gap:5px; align-items:center; padding:4px 7px; border-radius:6px; font-size:.82rem; font-weight:700; white-space:nowrap; }
.badge .icon { width:13px; height:13px; stroke-width:2; }
.badge.approved { background:#e9f8ef; color:#146144; }
.badge.review { background:#fff3dd; color:#825105; }
.badge.duplicate { background:#f0ebfa; color:#624091; }
.badge.failed { background:#ffefeb; color:#943628; }

.metrics { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:20px; }
.metric { display:flex; align-items:center; gap:12px; padding:20px; }
.metric div { min-width:0; }
.metric div > span { display:block; color:var(--quiet); font-size:.88rem; }
.metric strong { display:block; margin-top:4px; font-size:1.55rem; font-variant-numeric:tabular-nums; }
.history-heading { align-items:center; }
.history-filters { display:flex; gap:8px; min-width:0; }
.search { display:flex; gap:6px; align-items:center; padding:0 9px; min-width:0; color:#62738d; }
.search input { width:155px; min-width:0; border:0; background:transparent; color:var(--ink); font-size:.875rem; }
.search .icon { width:16px; height:16px; }
.search, .status-filter select { min-height:38px; border:1px solid #d9e2ef; border-radius:8px; background-color:#fff; }
.status-filter select { appearance:none; padding:0 26px 0 9px; color:var(--ink); font-size:.875rem; }
.status-filter { position:relative; }
.status-filter::after { position:absolute; content:""; right:11px; top:14px; width:6px; height:6px; border:solid #536883; border-width:0 1.5px 1.5px 0; transform:rotate(45deg); pointer-events:none; }
.order-panel .panel-heading { align-items:center; }
.page-note, .import-message, .error-box { font-size:.875rem; }
.page-note { margin-top:12px; color:var(--quiet); }
.page-note .icon { width:15px; height:15px; margin-right:3px; }
.import-message { color:#185f47; padding:0 23px 13px; }
.import-error, .error-box { color:#973729; }
.error-box { padding:12px 15px; margin-bottom:14px; border:1px solid #efcec5; border-radius:8px; background:#fff1ec; }
.rules-panel article { display:flex; align-items:flex-start; gap:14px; padding:19px 22px; }
.rules-panel article + article { border-top:1px solid var(--line); }
.rules-panel h2 { font-size:1rem; margin-bottom:5px; }
.rules-panel p { color:var(--sub); }

.result { scroll-margin-top:77px; }
.result .panel-heading { align-items:center; }
.result-body { padding:0 23px 20px; }
.result-summary { background:#f5f8ff; border:1px solid #dde7fa; border-radius:11px; padding:15px; display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.result-summary.approved { background:#f1faf5; border-color:#cfebdc; }
.result-summary.review { background:#fffbef; border-color:#f2e4bf; }
.result-summary.duplicate { background:#f8f5ff; border-color:#eadff7; }
.result-summary.failed { background:#fff5f1; border-color:#f5dad0; }
.result-summary h3 { font-size:1.04rem; line-height:1.4; margin:8px 0 3px; overflow-wrap:anywhere; }
.result-summary p, .result-summary li { color:var(--sub); font-size:.91rem; }
.result-summary ul { padding-left:20px; margin-bottom:0; }
.decision-code { color:var(--quiet); text-align:right; font-size:.7rem; font-weight:700; letter-spacing:.07em; flex:none; max-width:35%; }
.result-section { margin-top:19px; }
.result-section h3 { font-size:1rem; margin-bottom:7px; }
.result-section > p { color:var(--quiet); font-size:.9rem; }
.reconcile { display:grid; grid-template-columns:repeat(auto-fit,minmax(115px,1fr)); gap:8px; margin:10px 0 0; }
.reconcile div { padding:9px; background:#f7f9fc; border:1px solid var(--line); border-radius:7px; }
.reconcile dt { color:var(--quiet); font-size:.79rem; }
.reconcile dd { margin:6px 0 0; font-weight:680; font-size:.93rem; overflow-wrap:anywhere; }
.evidence-wrap { border:1px solid var(--line); border-radius:8px; }
.evidence th, .evidence td { padding:8px 11px; overflow-wrap:anywhere; }
.evidence thead th { border-top:0; }
.evidence td:nth-child(2) { width:26%; min-width:94px; }
.source { display:block; color:var(--sub); font-size:.81rem; line-height:1.45; }
.source + .source { margin-top:3px; }
.source b { color:var(--blue-deep); font-size:.75rem; font-weight:700; }
.source-details { margin-top:13px; font-size:.875rem; border:1px solid var(--line); border-radius:8px; padding:10px; }
.source-details summary { cursor:pointer; font-weight:660; }
.source-details h4 { margin:11px 0 5px; }
.source-details pre { max-height:210px; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; margin:0; padding:9px; background:#f7f9fc; }
.run-meta { margin-top:12px; color:var(--quiet); font-size:.78rem; }

@media (max-width:1120px) {
  .sidebar { width:205px; }
  .workspace { margin-left:205px; }
  main, .topbar { padding-right:24px; padding-left:24px; }
  .run-grid, .detail-grid { gap:14px; }
  .panel-heading, .result-body { padding-left:17px; padding-right:17px; }
  #upload-content { padding-left:17px; padding-right:17px; }
  .stage-list { padding-left:14px; padding-right:14px; }
  .metrics { gap:10px; }
  .metric { padding:14px 10px; }
}
@media (max-width:900px) {
  .sidebar { width:174px; padding-left:10px; padding-right:10px; }
  .workspace { margin-left:174px; }
  main { padding:25px 18px 35px; }
  .topbar { padding:0 18px; }
  .run-grid, .detail-grid { grid-template-columns:1fr; }
  .metrics { grid-template-columns:1fr 1fr; }
  .history-heading { flex-wrap:wrap; }
}
@media (max-width:640px) {
  .sidebar { position:static; width:auto; padding:13px 12px 9px; }
  .brand { padding:0 2px; }
  .brand-icon { width:36px; height:36px; }
  .side-workspace { margin-top:11px; }
  .side-label, .workspace-storage, .side-bottom .icon { display:none; }
  .sidebar nav { grid-template-columns:repeat(3,minmax(0,1fr)); gap:4px; }
  .sidebar nav a { justify-content:center; gap:5px; padding:0 4px; font-size:.8rem; min-height:36px; }
  .sidebar nav .icon { width:14px; height:14px; }
  .side-bottom { display:block; margin-top:3px; }
  .side-link { display:inline-flex; min-height:31px; font-size:.78rem; padding:0 6px; }
  .workspace { margin:0; }
  .topbar { min-height:48px; padding:0 13px; }
  main { padding:20px 12px 30px; }
  .page-heading { display:block; margin-bottom:16px; }
  .page-heading > .btn { margin-top:12px; }
  .page-heading h1 { font-size:2rem; }
  .panel-heading { padding-top:16px; }
  .search input { width:115px; }
  .sample { gap:6px; padding-inline:6px; }
  .sample-icon { width:29px; height:29px; }
  .trace-footer { padding-inline:17px; }
  .decision-code { display:none; }
  .result .panel-heading { flex-wrap:wrap; }
}
@media (prefers-reduced-motion:reduce) {
  *, *::before, *::after { animation-duration:.001ms !important; transition-duration:.001ms !important; scroll-behavior:auto !important; }
}
