:root {
  color-scheme: light;
  --canvas: #f3f6f7;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --surface-green: #eef7f5;
  --line: #d8e0e3;
  --line-strong: #bdc9cd;
  --text: #172426;
  --muted: #647376;
  --muted-light: #8a979a;
  --nav: #173b3a;
  --nav-deep: #102e2d;
  --teal: #087d73;
  --teal-dark: #07675f;
  --teal-light: #d8eeea;
  --blue: #376783;
  --amber: #9b5c08;
  --amber-bg: #fff5dc;
  --red: #b13a2f;
  --green: #15734a;
  --shadow: 0 1px 2px rgba(21, 43, 45, .05), 0 10px 30px rgba(21, 43, 45, .04);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
svg { display: block; }
.hidden { display: none !important; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  color: #f6fbfa;
  background: var(--nav);
  border-right: 1px solid rgba(255, 255, 255, .05);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: #0b887c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
}
.brand-mark svg { width: 23px; height: 23px; fill: currentColor; }
.brand-copy { min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.25; letter-spacing: 0; white-space: nowrap; }
.brand p { margin: 5px 0 0; color: #a9c0be; font-size: 12px; }

.nav-label {
  margin: 48px 8px 15px;
  color: #809d9a;
  font-size: 11px;
  font-weight: 700;
}
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.steps li {
  position: relative;
  min-height: 64px;
  padding: 10px 10px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  color: #88a29f;
  border-radius: 7px;
}
.steps li > span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid #52706d;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.steps strong, .steps small { display: block; }
.steps strong { color: #bad0ce; font-size: 14px; font-weight: 700; }
.steps small { margin-top: 4px; color: inherit; font-size: 11px; }
.steps li.active { color: #bad0ce; background: rgba(255, 255, 255, .07); }
.steps li.active::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 2px 2px 0; background: #4cc0b2; }
.steps li.active > span { color: #fff; border-color: #0f9386; background: #0f9386; }
.steps li.active strong { color: #fff; }
.steps li.done > span { color: #72cec3; border-color: #4c8d87; }
.steps li.done strong { color: #d8e8e6; }

.sidebar-footer { margin-top: auto; padding-top: 20px; }
.privacy-state {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 7px;
  background: rgba(4, 25, 24, .16);
}
.privacy-state > span { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 5px; border-radius: 50%; background: #7d918f; }
.privacy-state > span.local { background: #59d39b; box-shadow: 0 0 0 3px rgba(89, 211, 155, .1); }
.privacy-state > span.cloud { background: #efb44f; box-shadow: 0 0 0 3px rgba(239, 180, 79, .1); }
.privacy-state strong, .privacy-state small { display: block; }
.privacy-state strong { color: #eaf3f2; font-size: 12px; }
.privacy-state small { margin-top: 4px; color: #89a5a2; font-size: 10px; }
.product-version { margin-top: 12px; color: #718c89; font-size: 10px; text-align: center; }

.main { min-width: 0; min-height: 100vh; padding: 0 34px 38px; }
.topbar {
  min-height: 104px;
  margin: 0 -34px 28px;
  padding: 22px 34px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(255, 255, 255, .84);
  border-bottom: 1px solid var(--line);
}
.topbar-copy { min-width: 0; }
.eyebrow { display: block; margin-bottom: 4px; color: var(--teal); font-size: 10px; font-weight: 800; }
.topbar h2 { margin: 0; font-size: 23px; line-height: 1.3; letter-spacing: 0; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  color: #526164;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.icon-button:hover { color: var(--teal); border-color: #9bbdb8; background: var(--surface-green); }
.icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.step-view { display: none; }
.step-view.active { display: block; }

.upload-layout { width: min(100%, 1240px); margin: 0 auto; }
.upload-heading { margin-bottom: 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.upload-heading h3 { margin: 0; font-size: 16px; }
.upload-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.local-badge { height: 26px; padding: 0 9px; display: inline-flex; align-items: center; gap: 7px; color: var(--green); background: #e9f6ef; border: 1px solid #c9e8d7; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.local-badge i { width: 6px; height: 6px; border-radius: 50%; background: #28a169; }

.file-grid { display: grid; grid-template-columns: minmax(300px, .84fr) minmax(380px, 1.16fr); gap: 16px; }
.file-drop {
  position: relative;
  min-height: 312px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.file-drop::after { content: ""; position: absolute; inset: 8px; pointer-events: none; border: 1px dashed #c3ced1; border-radius: 5px; }
.file-drop:hover { transform: translateY(-1px); border-color: #8cb6b0; box-shadow: 0 12px 34px rgba(21, 63, 61, .08); }
.file-drop:hover::after { border-color: #89aaa6; }
.file-drop:focus-within { outline: 3px solid rgba(8, 125, 115, .14); outline-offset: 2px; }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-card-top { position: absolute; z-index: 1; top: 21px; left: 22px; right: 22px; display: flex; align-items: center; justify-content: space-between; }
.file-index { color: var(--teal); font-size: 11px; font-weight: 800; }
.file-kind { color: var(--muted-light); font-size: 10px; font-weight: 700; }
.drop-icon { z-index: 1; width: 62px; height: 62px; margin-bottom: 16px; display: grid; place-items: center; border-radius: 8px; }
.drop-icon svg { width: 31px; height: 31px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.excel-icon { color: #19734d; background: #e9f5ee; }
.receipt-icon { color: var(--blue); background: #eaf1f5; }
.file-drop > strong { z-index: 1; font-size: 16px; }
.file-drop > span[id] { z-index: 1; min-height: 20px; max-width: 90%; margin-top: 7px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.choose-file { z-index: 1; min-height: 34px; margin-top: 18px; padding: 0 14px; display: inline-flex; align-items: center; color: #334346; background: #fff; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 12px; font-weight: 700; }
.file-drop:hover .choose-file { color: var(--teal); border-color: #8fb7b2; }
.file-drop.has-file { border-color: #79a9a2; background: #fbfefd; }
.file-drop.has-file::after { border-style: solid; border-color: #b5d5d0; }
.file-drop.has-file .choose-file { color: var(--teal); background: var(--surface-green); border-color: #add1cc; }
.file-drop.has-file .choose-file::before { content: "✓"; margin-right: 6px; color: var(--green); }

.selected-files { margin-top: 10px; padding: 9px 10px; display: flex; flex-wrap: wrap; gap: 6px; background: rgba(255, 255, 255, .56); border: 1px solid var(--line); border-radius: 6px; }
.selected-files span { max-width: 240px; flex: 0 0 auto; padding: 5px 8px; overflow: hidden; color: #506063; background: #fff; border: 1px solid var(--line); border-radius: 4px; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }

.command-bar {
  min-height: 84px;
  margin-top: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.mode-control { display: flex; align-items: center; gap: 18px; min-width: 0; }
.mode-title strong, .mode-title span { display: block; }
.mode-title strong { font-size: 13px; }
.mode-title span { margin-top: 4px; color: var(--muted-light); font-size: 10px; white-space: nowrap; }
.segmented { display: flex; min-width: 0; padding: 3px; background: #edf2f3; border: 1px solid #e0e7e9; border-radius: 6px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { min-height: 34px; padding: 0 13px; display: grid; place-items: center; color: var(--muted); border-radius: 4px; cursor: pointer; font-size: 11px; font-weight: 700; white-space: nowrap; }
.segmented input:checked + label { color: #fff; background: var(--nav); box-shadow: 0 1px 3px rgba(16, 46, 45, .18); }

.button { min-height: 40px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: #354447; background: #fff; border: 1px solid transparent; border-radius: 6px; font-weight: 700; font-size: 13px; text-decoration: none; }
.button.primary { color: #fff; background: var(--teal); border-color: var(--teal); box-shadow: 0 4px 10px rgba(8, 125, 115, .13); }
.button.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.button.secondary { border-color: var(--line-strong); }
.button.secondary:hover { color: var(--teal); border-color: #8db4af; background: var(--surface-green); }
.button:focus-visible, .icon-button:focus-visible, .segmented label:focus-visible { outline: 3px solid rgba(8, 125, 115, .17); outline-offset: 2px; }
.action-button { min-width: 152px; min-height: 46px; flex: 0 0 auto; }
.action-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.review-toolbar { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.summary-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-strip > span { min-width: 104px; height: 58px; padding: 8px 11px; display: grid; grid-template-columns: auto auto; align-content: center; justify-content: start; column-gap: 4px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 1px 2px rgba(21, 43, 45, .03); }
.summary-strip small { grid-column: 1 / -1; margin-bottom: 2px; color: var(--muted-light); font-size: 9px; font-weight: 700; }
.summary-strip strong { color: var(--text); font-size: 17px; line-height: 1.1; }
.summary-strip em { align-self: end; color: var(--muted); font-size: 10px; font-style: normal; }
.summary-strip .warning-summary { background: #fffaf0; border-color: #ead9ae; }
.summary-strip .warning-summary strong { color: var(--amber); }
.sheet-picker { min-width: min(330px, 100%); padding: 8px 10px; display: flex; align-items: center; gap: 9px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-size: 11px; }
.sheet-picker span { white-space: nowrap; }
.sheet-picker select { flex: 1; min-width: 0; }

select, input[type="text"], input[type="url"], input[type="password"], input[type="number"] { min-height: 34px; padding: 6px 8px; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; }
select:focus, input:focus { outline: 2px solid rgba(8, 125, 115, .12); border-color: #6ca69f; }

.review-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 14px; align-items: start; }
.receipt-rail, .review-main { min-width: 0; }
.receipt-rail { position: sticky; top: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.panel-heading { min-height: 30px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-heading strong, .panel-heading span { display: block; }
.panel-heading strong { font-size: 13px; }
.panel-heading span { margin-top: 3px; color: var(--muted-light); font-size: 9px; }
.receipt-tabs { max-height: 208px; margin: 6px 0 10px; display: grid; gap: 5px; overflow: auto; }
.receipt-tab { width: 100%; min-height: 48px; padding: 7px 8px; display: grid; grid-template-columns: 27px minmax(0, 1fr); gap: 8px; align-items: center; color: var(--muted); text-align: left; background: var(--surface-soft); border: 1px solid transparent; border-radius: 5px; }
.receipt-tab > span { width: 25px; height: 25px; display: grid; place-items: center; color: #506063; background: #e5ebed; border-radius: 4px; font-size: 10px; font-weight: 800; }
.receipt-tab strong, .receipt-tab small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-tab strong { color: var(--text); font-size: 11px; }
.receipt-tab small { margin-top: 3px; font-size: 9px; }
.receipt-tab:hover { border-color: var(--line-strong); }
.receipt-tab.active { color: var(--teal); background: var(--surface-green); border-color: #99c4be; }
.receipt-tab.active > span { color: #fff; background: var(--teal); }
.receipt-preview { min-height: 310px; max-height: 480px; display: grid; place-items: center; overflow: auto; background: #e9edef; border: 1px solid #cbd4d7; border-radius: 5px; }
.receipt-preview img { width: 100%; height: auto; display: block; }

.review-main { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.table-heading { margin-bottom: 8px; align-items: center; }
.table-heading > div strong, .table-heading > div span { display: inline-block; }
.table-heading > div span { margin: 0 0 0 8px; }
.table-heading .autosave-state { margin: 0; padding-left: 12px; color: var(--green); position: relative; }
.table-heading .autosave-state::before { content: ""; position: absolute; left: 0; top: 3px; width: 6px; height: 6px; border-radius: 50%; background: #3aab74; }
.warning-panel { margin-bottom: 8px; padding: 9px 11px; display: grid; gap: 4px; color: #71460c; background: var(--amber-bg); border: 1px solid #eddcae; border-left: 3px solid #cc8b2b; border-radius: 4px; font-size: 11px; }
.table-wrap { max-height: clamp(360px, calc(100vh - 500px), 570px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; }
.review-table { width: 100%; min-width: 1240px; table-layout: fixed; border-collapse: collapse; }
.review-table th { position: sticky; top: 0; z-index: 2; height: 38px; padding: 8px; color: #4d5c5f; background: #edf2f3; border-bottom: 1px solid #ccd6d9; font-size: 10px; font-weight: 800; text-align: left; }
.review-table td { height: 39px; padding: 3px; border-bottom: 1px solid #e7ecee; }
.review-table tbody tr:nth-child(even):not(.needs-review) td { background: #fbfcfc; }
.review-table tbody tr:hover td { background: #f2f8f7; }
.review-table th:nth-child(1) { width: 176px; }
.review-table th:nth-child(2) { width: 112px; }
.review-table th:nth-child(3) { width: 220px; }
.review-table th:nth-child(4) { width: 180px; }
.review-table th:nth-child(5) { width: 130px; }
.review-table th:nth-child(6) { width: 62px; }
.review-table th:nth-child(7), .review-table th:nth-child(8), .review-table th:nth-child(9) { width: 78px; }
.review-table th:nth-child(10) { width: 72px; }
.review-table input { width: 100%; min-width: 0; min-height: 30px; padding: 4px 5px; color: var(--text); background: transparent; border: 1px solid transparent; border-radius: 3px; font-size: 11px; }
.review-table input:hover { border-color: #d0dcde; background: rgba(255, 255, 255, .8); }
.review-table input:focus { outline: 2px solid rgba(8, 125, 115, .1); border-color: var(--teal); background: #fff; }
.review-table tr.needs-review td { background: var(--amber-bg); }
.review-table tr.selected-receipt td { box-shadow: inset 0 1px rgba(8, 125, 115, .16), inset 0 -1px rgba(8, 125, 115, .16); }
.target-cell { padding: 5px 7px !important; }
.target-cell strong, .target-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target-cell strong { color: var(--text); font-size: 10px; }
.target-cell small { margin-top: 3px; color: var(--teal); font-size: 9px; }
.status-cell { text-align: center; }
.status { display: inline-flex; min-height: 22px; padding: 0 6px; align-items: center; border-radius: 4px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.status.ok { color: var(--green); background: #e6f5ed; }
.status.warning { color: var(--amber); background: #ffe7ad; }
.mapping-panel { margin-top: 9px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 5px; }
.mapping-panel summary { padding: 10px 11px; cursor: pointer; font-size: 11px; font-weight: 700; }
.mapping-panel summary span, .mapping-panel summary small { display: inline-block; }
.mapping-panel summary small { margin-left: 8px; color: var(--muted-light); font-weight: 400; }
.mapping-grid { padding: 0 11px 11px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mapping-grid label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.mapping-empty { grid-column: 1 / -1; margin: 0; padding: 8px 0; color: var(--muted); font-size: 11px; }
.review-actions { margin-top: 12px; padding-top: 12px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); }

.completion-panel { min-height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.completion-mark { width: 62px; height: 62px; display: grid; place-items: center; color: var(--green); background: #e8f6ef; border: 1px solid #c8e7d6; border-radius: 50%; }
.completion-mark svg { width: 31px; height: 31px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.completion-kicker { margin-top: 18px; color: var(--green); font-size: 10px; font-weight: 800; }
.completion-panel h3 { margin: 5px 0 8px; font-size: 21px; }
.completion-panel p { max-width: 620px; margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.completion-actions { display: flex; gap: 8px; }
.completion-actions .button { min-width: 156px; }

dialog { width: min(520px, calc(100vw - 28px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 60px rgba(20, 38, 40, .22); }
dialog::backdrop { background: rgba(13, 31, 32, .48); }
.settings-form { padding: 20px; display: grid; gap: 13px; }
.dialog-header { padding-bottom: 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-header span { color: var(--teal); font-size: 9px; font-weight: 800; }
.dialog-header h3 { margin: 3px 0 0; font-size: 18px; }
.dialog-header .icon-button { border: 0; font-size: 24px; }
.settings-form > label:not(.toggle-row) { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.toggle-row { padding: 11px; display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.toggle-row strong, .toggle-row small { display: block; }
.toggle-row strong { font-size: 12px; }
.toggle-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.toggle-row input { width: 18px; height: 18px; accent-color: var(--teal); }
.settings-note { color: var(--muted); font-size: 10px; }
.dialog-actions { padding-top: 3px; display: flex; justify-content: flex-end; }

.busy-overlay { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: rgba(244, 247, 248, .92); }
.busy-overlay strong { font-size: 14px; }
.busy-overlay span { color: var(--muted); font-size: 10px; }
.spinner { width: 38px; height: 38px; margin-bottom: 5px; border: 3px solid #ccd8da; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 110; max-width: min(420px, calc(100vw - 40px)); padding: 11px 14px; color: #fff; background: var(--nav-deep); border: 1px solid rgba(255, 255, 255, .09); border-radius: 6px; box-shadow: 0 12px 32px rgba(9, 28, 27, .2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 218px minmax(0, 1fr); }
  .sidebar { padding-left: 15px; padding-right: 15px; }
  .main { padding-left: 22px; padding-right: 22px; }
  .topbar { margin-left: -22px; margin-right: -22px; padding-left: 22px; padding-right: 22px; }
  .file-grid { grid-template-columns: 1fr 1fr; }
  .mode-control { gap: 10px; }
  .mode-title span { display: none; }
  .segmented label { padding: 0 9px; }
  .review-layout { grid-template-columns: 228px minmax(0, 1fr); }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { min-height: auto; height: 68px; padding: 10px 16px; position: sticky; top: 0; flex-direction: row; align-items: center; gap: 18px; }
  .brand-mark { width: 36px; height: 36px; flex-basis: 36px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .brand h1 { font-size: 15px; }
  .brand p, .nav-label, .sidebar-footer { display: none; }
  .steps { margin-left: auto; display: flex; gap: 7px; }
  .steps li { min-height: 38px; padding: 4px; grid-template-columns: 28px; }
  .steps li::before, .steps li div { display: none; }
  .steps li > span { width: 28px; height: 28px; }
  .main { min-height: calc(100vh - 68px); padding: 0 18px 28px; }
  .topbar { min-height: 88px; margin: 0 -18px 20px; padding: 16px 18px; }
  .receipt-rail { position: static; }
  .review-layout { grid-template-columns: 1fr; }
  .receipt-rail { display: grid; grid-template-columns: 190px minmax(0, 1fr); grid-template-rows: auto auto; gap: 8px 10px; }
  .receipt-rail .panel-heading { grid-column: 1 / -1; }
  .receipt-tabs { max-height: 300px; margin: 0; }
  .receipt-preview { min-height: 260px; max-height: 340px; }
}

@media (max-width: 680px) {
  .sidebar { height: 60px; padding: 9px 12px; }
  .brand-copy p { display: none; }
  .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .steps { gap: 2px; }
  .steps li { grid-template-columns: 26px; padding: 2px; }
  .steps li > span { width: 26px; height: 26px; font-size: 10px; }
  .main { min-height: calc(100vh - 60px); padding: 0 12px 22px; }
  .topbar { min-height: 82px; margin: 0 -12px 16px; padding: 13px 12px; }
  .topbar h2 { font-size: 20px; }
  .topbar p { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .upload-heading { align-items: center; }
  .upload-heading p { display: none; }
  .local-badge { font-size: 9px; }
  .file-grid { grid-template-columns: 1fr; gap: 10px; }
  .file-drop { min-height: 220px; padding: 19px; }
  .file-card-top { top: 17px; left: 18px; right: 18px; }
  .drop-icon { width: 50px; height: 50px; margin-bottom: 11px; }
  .drop-icon svg { width: 26px; height: 26px; }
  .file-drop > strong { font-size: 14px; }
  .choose-file { min-height: 31px; margin-top: 11px; }
  .command-bar { padding: 12px; align-items: stretch; flex-direction: column; gap: 12px; }
  .selected-files { flex-wrap: nowrap; overflow-x: auto; }
  .mode-control { align-items: stretch; flex-direction: column; gap: 8px; }
  .mode-title span { display: block; }
  .segmented { width: 100%; }
  .segmented label { flex: 1; padding: 0 6px; font-size: 10px; text-align: center; }
  .action-button { width: 100%; }
  .review-toolbar { align-items: stretch; flex-direction: column; }
  .summary-strip { display: grid; grid-template-columns: repeat(2, 1fr); }
  .summary-strip > span { min-width: 0; }
  .sheet-picker { min-width: 0; }
  .receipt-rail { display: block; }
  .receipt-tabs { margin: 6px 0 8px; display: flex; max-height: none; overflow-x: auto; }
  .receipt-tab { min-width: 145px; }
  .receipt-preview { min-height: 260px; max-height: 380px; }
  .review-main { padding: 9px; }
  .table-wrap { max-height: 480px; }
  .table-heading .autosave-state { display: none; }
  .mapping-grid { grid-template-columns: repeat(2, 1fr); }
  .review-actions { gap: 8px; }
  .review-actions .button { flex: 1; padding-left: 9px; padding-right: 9px; font-size: 11px; }
  .completion-panel { min-height: 470px; }
  .completion-actions { width: 100%; max-width: 340px; flex-direction: column; }
  .completion-actions .button { width: 100%; }
}

/* ── 自动补全下拉（需求2）────────────────────────────────── */
.autocomplete-dropdown {
  position: fixed;
  z-index: 10000;
  background: #fff;
  border: 1px solid #b5c9c5;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 10px 32px rgba(21, 43, 45, 0.14);
  max-height: 240px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  font-size: 12px;
}
.autocomplete-dropdown li {
  padding: 7px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: var(--text);
  transition: background 0.1s;
}
.autocomplete-dropdown li:hover,
.autocomplete-dropdown li.selected {
  background: #e8f5f4;
  color: #0d514b;
}
.ac-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-count {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--muted-light);
}

/* ── 自动修正单元格指示（需求5: 蓝底提示）─────────────── */
.review-table td.auto-corrected {
  background: #e5f0fd !important;
  border-left: 2px solid #5b9bd5;
}
.review-table td.auto-corrected input {
  color: #1a4a7a;
}
.review-table td.auto-corrected::after {
  content: "↻";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 11px;
  color: #5b9bd5;
  pointer-events: none;
}
.review-table td {
  position: relative;
}

/* ── 匹配度标签（需求5: 匹配度可视化）─────────────────── */
.match-score {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 6px;
  color: #fff;
  background: #28a169;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
}

/* ── 纠错管理面板（需求5）────────────────────────────── */
#correctionsDialog {
  width: min(680px, calc(100vw - 28px));
  max-height: 80vh;
  overflow-y: auto;
}
.corrections-toolbar {
  padding: 16px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.corrections-toolbar span {
  color: var(--muted);
  font-size: 12px;
}
.corrections-table-wrap {
  max-height: 460px;
  overflow-y: auto;
  margin: 8px 20px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.corrections-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.corrections-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 10px;
  background: #edf2f3;
  border-bottom: 1px solid #ccd6d9;
  font-size: 10px;
  font-weight: 800;
  text-align: left;
  color: #4d5c5f;
}
.corrections-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e7ecee;
  vertical-align: middle;
}
.corrections-table tbody tr:hover td {
  background: #f8fafa;
}
.corrections-table th:nth-child(1) { width: 64px; }
.corrections-table th:nth-child(2) { width: auto; }
.corrections-table th:nth-child(3) { width: auto; }
.corrections-table th:nth-child(4) { width: 56px; text-align: center; }
.corrections-table th:nth-child(5) { width: 44px; text-align: center; }
.corr-from {
  color: var(--amber);
  text-decoration: line-through;
  text-decoration-color: #d4a843;
}
.corr-to {
  color: var(--green);
}
.loading-hint {
  padding: 32px 16px !important;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}
.link-button {
  padding: 2px 6px;
  color: var(--muted-light);
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.link-button:hover {
  color: var(--red);
  border-color: #e0c8c5;
  background: #fef5f5;
}
.danger-button {
  color: var(--red) !important;
  border-color: #e0c8c5 !important;
}
.danger-button:hover {
  background: #fef5f5 !important;
}

@media (max-width: 390px) {
  .brand h1 { font-size: 13px; }
  .brand { gap: 8px; }
  .steps li > span { width: 24px; height: 24px; }
  .steps li { grid-template-columns: 24px; }
  .topbar p { max-width: 220px; }
  .local-badge { padding: 0 6px; }
  .segmented label { font-size: 9px; }
}
