:root {
  color-scheme: light;
  --ink: #122b36;
  --ink-soft: #29434d;
  --paper: #fbfcfa;
  --canvas: #eaf0ef;
  --line: #b9c8c8;
  --line-dark: #8da3a5;
  --muted: #61757b;
  --teal: #087f73;
  --mint: #54c5a7;
  --mint-wash: #dcefe8;
  --amber: #c78316;
  --amber-wash: #f7ead1;
  --red: #a83f32;
  --red-wash: #f5e1dd;
  --shadow: 0 14px 34px rgb(18 43 54 / 8%);
  --sans: "Aptos", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", "Songti SC", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    linear-gradient(90deg, rgb(18 43 54 / 3%) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link {
  position: absolute;
  top: -80px;
  left: 16px;
  z-index: 20;
  padding: 10px 16px;
  background: var(--ink);
  color: white;
}
.skip-link:focus { top: 16px; }

.mode-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  border-bottom: 1px solid var(--amber);
  background: var(--amber-wash);
  color: #6f470d;
  padding: 10px 20px;
  text-align: center;
  font-size: 12px;
}
.mode-banner strong { font-size: 13px; }
.mode-banner-zh { color: #80500b; }
body[lang="en"] .mode-banner-zh { display: none; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line-dark);
  background: rgb(251 252 250 / 92%);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  background: var(--mint);
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.06em;
}
.brand-name { font-weight: 750; letter-spacing: 0.02em; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.language-switch {
  display: inline-flex;
  border: 1px solid var(--line-dark);
  background: var(--paper);
  padding: 3px;
}
.language-switch button {
  min-width: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 5px 10px;
}
.language-switch button[aria-pressed="true"] { background: var(--ink); color: white; }
.safety-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border: 1px solid var(--teal);
  background: var(--mint-wash);
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}
.safety-chip::before { content: ""; width: 7px; height: 7px; background: var(--teal); border-radius: 50%; }

main { width: min(1280px, calc(100% - 40px)); margin: 0 auto; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
  padding: clamp(46px, 7vw, 90px) 0 42px;
}
.kicker {
  margin: 0 0 16px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}
h1 {
  max-width: 760px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 5.4vw, 70px);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.045em;
}
.hero-en {
  max-width: 680px;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.4;
}
.hero-copy { max-width: 700px; margin: 20px 0 0; color: var(--muted); }
.hero-note {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line-dark);
  color: var(--muted);
  font-size: 13px;
}
.hero-note strong { color: var(--ink); }

.bridge-board {
  position: relative;
  padding: 26px;
  border: 1px solid var(--line-dark);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.bridge-board::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.board-title {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.board-title span:last-child { color: var(--teal); font-family: var(--mono); letter-spacing: 0; }
.flow { position: relative; display: grid; gap: 12px; }
.flow-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.flow-node {
  position: relative;
  min-height: 72px;
  padding: 13px 14px;
  border: 1px solid var(--line-dark);
  background: var(--canvas);
}
.flow-node b { display: block; font-size: 13px; }
.flow-node small { color: var(--muted); font-size: 11px; }
.flow-node.core {
  border-color: var(--teal);
  background: var(--mint-wash);
  text-align: center;
}
.flow-node.core b { color: var(--teal); }
.flow-node.output { border-left: 4px solid var(--amber); }
.flow-arrow { height: 18px; text-align: center; color: var(--teal); font-family: var(--mono); }
.board-foot {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-dark);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
}

.workspace {
  margin-bottom: 72px;
  border: 1px solid var(--line-dark);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.workspace-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line-dark);
}
h2 { margin: 0; font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -0.02em; }
.section-copy { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.connection-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: #f2f6f5;
}
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 750; }
.field input, .field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-dark);
  border-radius: 0;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
}
.field input:focus, .field select:focus { border-color: var(--teal); }
.connection-actions { display: flex; gap: 9px; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: white;
  padding: 9px 16px;
  font-weight: 750;
  text-decoration: none;
}
.button:hover { background: var(--ink-soft); }
.button.secondary { background: transparent; color: var(--ink); }
.button.secondary:hover { background: var(--canvas); }
.button.accent { border-color: var(--teal); background: var(--teal); }
.button.accent:hover { background: #06675e; }
.button:disabled { cursor: not-allowed; opacity: 0.48; }
.button.small { min-height: 34px; padding: 5px 11px; font-size: 12px; }
.status-line {
  grid-column: 1 / -1;
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.status-line.ok { color: var(--teal); }
.status-line.error { color: var(--red); }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 26px 28px; }
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px dashed var(--line-dark);
  background: #f7f9f8;
  padding: 24px;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
}
.dropzone.dragging { border-color: var(--teal); background: var(--mint-wash); }
.dropzone.has-file { border-style: solid; border-color: var(--teal); background: var(--mint-wash); }
.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.drop-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border: 1px solid var(--line-dark);
  background: white;
  font-family: var(--serif);
  font-size: 22px;
}
.drop-title { margin: 0; font-weight: 750; }
.drop-help { margin: 5px 0 12px; color: var(--muted); font-size: 12px; }
.file-name { margin: 10px 0 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.file-meta { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.run-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line-dark);
}
.mode-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.mode-toggle input { width: 18px; height: 18px; accent-color: var(--teal); }
.mode-toggle strong { display: block; font-size: 13px; }
.mode-toggle small { display: block; color: var(--muted); font-size: 11px; }
.request-id { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.results { padding: 26px 28px 30px; }
.results-empty {
  padding: 34px 20px;
  border: 1px dashed var(--line-dark);
  color: var(--muted);
  text-align: center;
}
.run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}
.run-meta span { overflow-wrap: anywhere; }
.replay-badge {
  border: 1px solid var(--amber);
  background: var(--amber-wash);
  color: #80500b;
  padding: 2px 7px;
  font-family: var(--sans);
  font-weight: 750;
}
.ledger-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin: 0 0 26px;
  border: 1px solid var(--line-dark);
}
.metric { padding: 15px 16px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric dt { color: var(--muted); font-size: 11px; font-weight: 700; }
.metric dd { margin: 3px 0 0; font-family: var(--serif); font-size: clamp(23px, 2.4vw, 34px); line-height: 1.1; }
.metric.safe dd { color: var(--teal); }
.metric.warn dd { color: var(--amber); }
.metric.danger dd { color: var(--red); }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-dark); overflow-x: auto; }
.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 11px 17px 9px;
  white-space: nowrap;
  font-weight: 750;
}
.tab[aria-selected="true"] { border-bottom-color: var(--teal); color: var(--ink); }
.tab-panel { padding-top: 20px; }
.panel-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 14px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters .field { min-width: 170px; }
.filters input, .filters select { min-height: 36px; padding: 6px 9px; font-size: 13px; }
.export-actions { display: flex; gap: 8px; }
.table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: var(--ink); color: white; font-size: 11px; font-weight: 750; }
tbody tr:nth-child(even) { background: #f2f6f5; }
tbody tr:hover { background: var(--mint-wash); }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.code { font-family: var(--mono); font-size: 11px; }
.severity, .match-status {
  display: inline-block;
  border: 1px solid currentColor;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.severity.error, .match-status.amount_mismatch, .match-status.currency_mismatch { color: var(--red); background: var(--red-wash); }
.severity.warning, .match-status.unpaid { color: #80500b; background: var(--amber-wash); }
.match-status.matched { color: var(--teal); background: var(--mint-wash); }
.message-en { display: block; }
.message-zh { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
body[lang="en"] .message-zh { display: none; }
body[lang="zh-CN"] .message-en { display: none; }
.empty-row { padding: 28px; color: var(--muted); text-align: center; }
.report-pre {
  max-height: 620px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: #f5f7f5;
  padding: 22px;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}
.audit-list { display: grid; gap: 10px; }
.audit-item { display: grid; grid-template-columns: 150px 1fr auto; gap: 14px; padding: 13px 15px; border: 1px solid var(--line); }
.audit-item time { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.audit-item code { font-size: 11px; overflow-wrap: anywhere; }
.audit-outcome { align-self: start; border: 1px solid var(--teal); color: var(--teal); padding: 2px 7px; font-size: 10px; font-weight: 800; }
.audit-outcome.replayed { border-color: var(--amber); color: #80500b; }

.history { margin-bottom: 56px; }
.history-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.history-list { border: 1px solid var(--line-dark); background: var(--paper); }
.history-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(160px, 1.4fr) repeat(3, minmax(80px, 0.5fr)) auto;
  gap: 16px;
  align-items: center;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 14px 18px;
  text-align: left;
}
.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: var(--mint-wash); }
.history-row code { font-size: 11px; overflow-wrap: anywhere; }
.history-row .history-number { font-family: var(--serif); font-size: 20px; }
.history-empty { padding: 24px; color: var(--muted); }
.footer {
  border-top: 1px solid var(--line-dark);
  background: var(--ink);
  color: #d9e4e3;
  padding: 28px clamp(20px, 4vw, 64px);
}
.footer-inner { width: min(1280px, 100%); margin: 0 auto; display: flex; justify-content: space-between; gap: 24px; font-size: 12px; }
.footer strong { color: var(--mint); }
.footer p { margin: 0; max-width: 760px; }
.footer code { color: white; font-size: 11px; }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .bridge-board { max-width: 620px; }
  .ledger-strip { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .history-row { grid-template-columns: 1fr 1fr auto; }
  .history-row .history-hash { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 700px) {
  main { width: min(100% - 24px, 1280px); }
  .masthead { align-items: flex-start; padding: 14px 16px; }
  .brand-sub, .safety-chip { display: none; }
  .hero { padding-top: 36px; }
  h1 { font-size: clamp(36px, 10vw, 52px); }
  .bridge-board { padding: 20px; }
  .workspace-head, .connection-panel, .upload-grid, .run-bar, .results { padding: 20px 18px; }
  .connection-panel, .upload-grid { grid-template-columns: 1fr; }
  .connection-actions { flex-wrap: wrap; }
  .run-bar { align-items: stretch; flex-direction: column; }
  .run-bar .button { width: 100%; }
  .ledger-strip { grid-template-columns: repeat(2, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:nth-last-child(-n+2) { border-bottom: 0; }
  .panel-tools { align-items: stretch; flex-direction: column; }
  .filters { display: grid; grid-template-columns: 1fr; }
  .export-actions { flex-wrap: wrap; }
  .audit-item { grid-template-columns: 1fr auto; }
  .audit-item code { grid-column: 1 / -1; grid-row: 2; }
  .history-row { grid-template-columns: 1fr auto; gap: 8px 14px; }
  .history-row .history-hash, .history-row .history-stat { grid-column: 1 / -1; }
  .footer-inner { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
