:root {
  color-scheme: light;
  --paper: #f1f4f2;
  --ink: #20372e;
  --muted: #4f655e;
  --line: #cad8d1;
  --green: #176546;
  --dark: #17382d;
  --orange: #815315;
  font: 15px/1.55 "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
h1 { font-size: clamp(25px, 4vw, 36px); line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; }
p { color: var(--muted); }
button, input, select, textarea { font: inherit; }
button { min-height: 40px; border: 1px solid transparent; border-radius: 5px; background: var(--green); color: #fff; font-weight: 650; padding: 7px 13px; cursor: pointer; }
button:hover:not(:disabled) { background: #11543a; }
button:disabled { opacity: .55; cursor: default; }
button.secondary { color: var(--ink); background: #fff; border-color: #adc3b8; }
button.secondary:hover:not(:disabled) { background: #edf6f0; }
:focus-visible { outline: 3px solid #ad7523; outline-offset: 2px; }
.shell { width: calc(100% - 28px); margin-inline: auto; }
.masthead { background: var(--dark); color: #fff; }
.masthead-content { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding-block: 24px; }
.masthead p { color: #c7e1d5; margin-top: 5px; }
.masthead-link { color: #e5f8ef; text-underline-offset: 4px; flex-shrink: 0; }
main.shell { padding-block: 20px 50px; }
.workspace-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.workspace-nav button[aria-current="page"] { color: white; background: var(--green); border-color: var(--green); }
.workspace-link { display: inline-flex; align-items: center; min-height: 40px; padding: 7px 13px; border: 1px solid #adc3b8; border-radius: 5px; color: var(--ink); background: white; font-weight: 650; text-decoration: none; }
.workspace-link:hover { background: #edf6f0; }
.view-heading { margin: 0 0 14px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); border-block: 1px solid #a6bfb2; background: #fbfdfb; margin-bottom: 16px; }
.summary:empty { display: none; }
.summary dl { margin: 0; padding: 11px 16px; border-inline-start: 1px solid var(--line); }
.summary dt { color: var(--muted); font-size: 13px; }
.summary dd { margin: 2px 0 0; font-size: 24px; font-weight: 680; font-variant-numeric: tabular-nums; }
.intake-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 14px; }
.ledger { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 17px 20px; margin-bottom: 14px; min-width: 0; }
.ledger > h2 + p, .section-bar h2 + p { margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 11px 14px; margin-top: 12px; }
.wide { grid-column: 1 / -1; }
label { display: grid; gap: 5px; color: #304a40; font-weight: 600; min-width: 0; }
input, select, textarea { min-width: 0; min-height: 40px; width: 100%; border: 1px solid #adc3b8; border-radius: 4px; padding: 7px 9px; background: #fff; color: var(--ink); font-weight: 450; }
input[type="checkbox"] { width: 18px; min-height: 18px; accent-color: var(--green); }
textarea { resize: vertical; }
input[type="file"] { overflow: hidden; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.allocation-line { display: grid; grid-template-columns: minmax(0, 3fr) minmax(120px, 1fr) auto; gap: 8px; margin-block: 8px; }
.help { font-size: 13px; color: var(--muted); }
#import-state { margin-top: 10px; }
.manual-entry { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px; }
summary { color: var(--green); font-weight: 640; cursor: pointer; }
.section-bar { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(140px, .7fr) auto; align-items: end; gap: 12px; margin-bottom: 12px; }
.feedback { padding: 9px 12px; margin: 10px 0; background: #e9f4ed; color: #274d39; border-left: 3px solid #3d835b; border-radius: 3px; overflow-wrap: anywhere; }
.feedback.error { background: #fff0ef; color: #832f30; border-left-color: #a64a42; }
.feedback.warning { background: #fff5df; color: var(--orange); border-left-color: #a77225; }
#page-feedback { margin-top: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 4px; }
#preview-table { margin-top: 10px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
th, td { padding: 4px 6px; vertical-align: middle; border-bottom: 1px solid #dae4df; line-height: 1.3; }
th { background: #e9f2ed; color: #36584a; font-size: 13px; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f9fcfa; }
tbody tr:last-child td { border-bottom: none; }
.number { white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; align-items: start; gap: 6px; flex-wrap: wrap; min-width: 160px; }
.row-actions button { min-height: 32px; font-size: 13px; padding: 4px 8px; }
.chip { display: inline-block; border-radius: 3px; padding: 2px 7px; font-size: 13px; font-weight: 650; white-space: nowrap; background: #edf1ef; color: #3c5d50; }
.chip.good { background: #dcefe2; color: #245b36; }
.chip.warn { background: #fff1d7; color: #795118; }
.chip.bad { background: #fae9e8; color: #873d3b; }
.empty { padding: 9px 0; }
.ocr-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; margin-bottom: 8px; }
#ocr-queue, #settlement-preview { margin-top: 10px; }
.order-grid-controls { display: grid; grid-template-columns: minmax(0, 2fr) minmax(145px, 1fr); gap: 12px; }
.order-grid-actions, .order-grid-pagination { margin-block: 10px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; }
.order-sheet { max-height: min(68vh, 680px); margin-top: 10px; position: relative; }
.order-sheet table { width: 100%; min-width: 0; table-layout: fixed; font-size: 12px; }
.order-sheet th, .order-sheet td { border-right: 1px solid #dae4df; }
.order-sheet th { position: sticky; top: 0; z-index: 2; height: 38px; white-space: normal; }
.order-sheet .row-number { position: sticky; left: 0; z-index: 1; width: 48px; min-width: 0; background: #f4f8f5; }
.order-sheet th.row-number { z-index: 3; background: #e9f2ed; }
.sheet-row-control { display: flex; align-items: center; gap: 3px; white-space: nowrap; font-size: 11px; }
.order-sheet input[type="checkbox"] { width: 16px; height: 16px; min-height: 16px; padding: 0; margin: 0; }
.sheet-column-letter { display: block; font-size: 12px; color: #496458; }
.sheet-column-header { display: block; font-weight: 650; }
.order-sheet :is(th,td):not(.row-number) { min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; }
.order-sheet td { height: 27px; white-space: nowrap; padding: 3px 4px; }
.order-sheet :is(th,td).empty-column { width: 16px; padding-inline: 1px; }
.order-sheet :is(th,td):last-child { width: 17%; }
.order-sheet :is(th,td):nth-child(4) { width: 6.3%; }
.order-sheet :is(th,td):is(:nth-child(7),:nth-child(8),:nth-child(21),:nth-child(24)) { width: 5.5%; }
.order-sheet :is(th,td):is(:nth-child(3),:nth-child(6)) { width: 2%; }
.order-sheet .row-number .chip { display: block; margin-top: 4px; }
.order-sheet td.overlay-cell { background: #edf6ee; }
.order-sheet tr.sheet-selected td { background: #e1f1e6; }
.order-sheet .sheet-cell-copy { min-height: 19px; margin: 0 0 0 3px; padding: 0 3px; font-size: 10px; display: none; }
.order-sheet td:hover .sheet-cell-copy, .order-sheet td:focus-within .sheet-cell-copy { display: inline-block; }
.order-sheet td[title] { cursor: default; }
@media (max-width: 860px) { .order-sheet table { min-width: 1300px; } }
#order-paste-panel > p, #order-paste-preview { margin-top: 9px; }
.settlement-detail-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; }
.settlement-detail-meta p { overflow-wrap: anywhere; }
.settlement-form { border-top: 1px solid var(--line); padding-top: 12px; }
.settlement-form h3, #settlement-detail h3 { margin: 0 0 6px; font-size: 16px; }
#settlement-event-history { margin-top: 8px; }
dialog { color: var(--ink); width: min(760px, calc(100% - 28px)); max-height: 92vh; overflow: auto; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; }
dialog::backdrop { background: #15392db0; }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 10px; }
#copy-content-label { margin: 12px 0; }
#copy-content { white-space: pre; overflow: auto; font: 13px/1.5 ui-monospace, monospace; }
.clipboard-staging { position: fixed; top: 0; left: -10000px; width: 1px; height: 1px; min-height: 1px; padding: 0; opacity: 0; pointer-events: none; }
@media (max-width: 860px) {
  .intake-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .filter-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filter-bar > .actions { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .shell { width: calc(100% - 22px); }
  .masthead-content { flex-direction: column; align-items: start; padding-block: 17px; }
  .ledger, dialog { padding: 13px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .ocr-controls, .settlement-detail-meta { grid-template-columns: minmax(0, 1fr); }
  .order-grid-controls { grid-template-columns: minmax(0, 1fr); }
  .allocation-line { grid-template-columns: minmax(0, 1fr); }
  th, td { padding-inline: 7px; }
}

.icp-footer { text-align:center; padding:12px; font-size:12px; color:#667085; }
.icp-footer a { color:inherit; }
