:root {
  --ink: #153c32;
  --paper: #f4f6ef;
  --card: #ffffff;
  --line: #7b907e;
  --muted: #4b5f50;
  --accent: #d6ed84;
  --accent-strong: #c6e26b;
  --danger: #873715;
  --success: #245c39;
  --small: .889rem;
  --radius: 16px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 112.5%;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
}
:root[data-text-size="xlarge"] { font-size: 137.5%; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 20px; }
body { margin: 0; min-width: 320px; min-height: 100vh; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button, select, label[role="button"], summary { cursor: pointer; }
button { appearance: none; border: 0; }
button, a, label[role="button"], summary { touch-action: manipulation; }
button:disabled, label:has(input:disabled) {
  cursor: not-allowed;
  color: #596257;
  background: #e8ebe4;
  border-color: #b6bfb1;
}
button, a, input, select, summary { outline-offset: 4px; }
:focus-visible { outline: 3px solid #236a4b; }
button:not(:disabled):active { transform: translateY(1px); }
.icon-definitions { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 24px; height: 24px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.flip, .flip-vertical { transform: rotate(180deg); }
.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; }
/* Consistent text sizes and explicit actions on every screen. */
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { font-size: 1.67rem; line-height: 1.35; margin: 0 0 8px; }
h2 { font-size: 1.44rem; line-height: 1.4; margin: 0; }
h3 { font-size: 1.22rem; line-height: 1.5; margin: 0; }
p { margin: 0; }
.button, .icon-button, .text-button {
  min-height: 56px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
}
.button-dark { background: var(--ink); color: white; }
.button-accent { background: var(--accent); color: #183724; }
.button-outline, .icon-button { border-color: var(--line); background: var(--card); }
.text-button { background: transparent; text-decoration: underline; text-underline-offset: 5px; }
.button-accent:not(:disabled):hover { background: var(--accent-strong); }
.button-outline:not(:disabled):hover, .icon-button:not(:disabled):hover { background: #eaf0df; }
/* Home: two obvious starting points, then the saved documents. */
.topbar { max-width: 1280px; margin: auto; padding: 20px 32px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #ced8c9; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-height: 56px; }
.brand strong { font-size: 1.33rem; letter-spacing: .05em; }
.brand-mark { display: grid; align-content: center; gap: 4px; width: 38px; height: 42px; padding: 10px; border-radius: 10px 10px 10px 2px; background: var(--ink); }
.brand-mark span { height: 3px; background: var(--accent); }
.brand-mark span:nth-child(2) { width: 75%; }
.brand-mark span:nth-child(3) { width: 50%; }
.text-size-control { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); background: white; border-radius: 12px; }
.text-size-control button { min-height: 56px; min-width: 56px; padding: 8px 12px; font-size: var(--small); border-radius: 9px; background: white; }
.text-size-control [aria-pressed="true"] { background: var(--ink); color: white; font-weight: 700; }
main { max-width: 1280px; padding: 28px 32px 130px; margin: auto; }
.ledger-hero { margin-bottom: 22px; }
.ledger-hero p { color: var(--muted); font-size: 1rem; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.quick-action { display: flex; align-items: center; gap: 16px; padding: 23px; min-height: 112px; text-align: left; border-radius: var(--radius); border: 2px solid var(--line); background: var(--card); }
.quick-action > .icon:first-child { width: 34px; height: 34px; }
.quick-action > span { flex: 1; min-width: 0; }
.quick-action strong { display: block; font-size: 1.33rem; margin-bottom: 3px; }
.quick-action small { display: block; font-size: var(--small); color: var(--muted); font-weight: 400; }
.quick-action-primary { background: var(--ink); color: white; border-color: var(--ink); }
.quick-action-primary small { color: #e5efd7; }
.quick-action-primary > .icon:first-child { color: var(--accent); }
.overview { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; padding: 2px 0 20px; font-size: var(--small); color: var(--muted); }
.overview strong { color: var(--ink); font-size: 1.11rem; font-variant-numeric: tabular-nums; }
.overview button { min-height: 56px; padding: 8px 10px; border-radius: 8px; background: #e7eddf; text-decoration: underline; text-underline-offset: 4px; }
#preferenceStatus { margin-bottom: 20px; padding: 12px; background: #fff0d7; color: #6b451c; font-size: var(--small); border-radius: 10px; }
.ledger-panel { min-width: 0; }
.ledger-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 18px; }
.ledger-heading > div:first-child { margin-right: auto; }
.view-switch { display: flex; padding: 4px; gap: 4px; border: 1px solid var(--line); border-radius: 12px; }
.view-switch button { min-height: 56px; padding: 10px 16px; border-radius: 8px; background: transparent; font-size: 1rem; }
.view-switch [aria-pressed="true"] { background: var(--ink); color: white; font-weight: 650; }
.ledger-toolbar { display: flex; align-items: center; gap: 12px; }
.search-box { display: flex; align-items: center; gap: 10px; padding: 0 15px; flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 12px; background: var(--card); }
.search-box:focus-within { outline: 3px solid #236a4b; outline-offset: 2px; }
.search-box input { width: 100%; min-width: 0; border: 0; background: transparent; outline: none; min-height: 58px; padding: 12px 0; font-size: 1rem; }
input::placeholder { color: var(--muted); opacity: 1; }
.customer-filter { min-width: 0; }
select { max-width: 100%; min-height: 62px; padding: 12px 32px 12px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); font-size: 1rem; }
.customer-filter select { max-width: 240px; }
.filter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; margin: 16px 0; gap: 8px; }
.filter-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-tabs button { min-height: 56px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.filter-tabs [aria-pressed="true"] { background: var(--ink); color: white; border-color: var(--ink); font-weight: 650; }
.sort-hint { font-size: var(--small); color: var(--muted); }
.records-scroll { border: 1px solid var(--line); background: var(--card); border-radius: 14px; overflow: auto; max-height: 65vh; }
.records-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 1rem; white-space: nowrap; }
.records-table th { position: sticky; top: 0; z-index: 1; background: #e6ecdf; color: var(--muted); font-weight: 650; padding: 16px; font-size: var(--small); }
.records-table th small { font-size: var(--small); }
.records-table td { padding: 10px 16px; border-bottom: 1px solid #cfd8c8; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.records-table tbody tr:last-child td { border: 0; }
.records-table tbody tr:hover { background: #f0f5e8; }
.record-open { min-height: 56px; background: transparent; padding: 12px 0; color: var(--ink); font-weight: 650; text-align: left; text-decoration: underline; text-underline-offset: 4px; }
.record-status { display: inline-flex; align-items: center; gap: 6px; color: var(--success); background: #e7f0e3; border: 1px solid #83a77a; padding: 5px 9px; border-radius: 7px; font-size: var(--small); white-space: nowrap; font-weight: 650; }
.record-status::before { content: "✓"; }
.record-status.is-warning { background: #fff0d7; border-color: #be8d47; color: #784912; }
.record-status.is-warning::before { content: "!"; font-weight: 800; }
.muted { color: var(--muted); font-size: var(--small); }
.record-cards { display: none; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.ledger-panel[data-view="cards"] .record-cards { display: grid; }
.ledger-panel[data-view="cards"] .records-scroll, .ledger-panel[data-view="cards"] #tableColumns { display: none; }
.record-card { width: 100%; text-align: left; display: block; padding: 22px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; min-width: 0; }
.record-card:hover { border-color: #356c45; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-number { color: var(--muted); font-size: var(--small); }
.card-batch { display: block; font-size: 1.33rem; line-height: 1.4; overflow-wrap: anywhere; margin: 8px 0; }
.card-customer { display: block; font-size: 1.11rem; overflow-wrap: anywhere; }
.card-details { display: flex; flex-wrap: wrap; gap: 16px 24px; border-top: 1px solid #d4ddce; padding-top: 16px; margin-top: 18px; }
.card-details > span { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 90px; }
.card-details small { font-size: var(--small); color: var(--muted); }
.card-details b { font-weight: 650; font-size: 1.11rem; overflow-wrap: anywhere; }
.card-footer { display: flex; flex-direction: column; align-items: stretch; gap: 14px; margin-top: 18px; font-size: var(--small); color: var(--muted); }
.card-open-label { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 12px 16px; background: #eaf0e2; border: 1px solid #9db68c; border-radius: 10px; font-size: 1rem; font-weight: 650; color: var(--ink); }
.ledger-empty { padding: 26px; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.ledger-panel:has(.ledger-empty:not([hidden])) .records-scroll { display: none; }
.ledger-empty p { font-size: 1rem; line-height: 1.8; color: var(--muted); margin: 12px 0 20px; }
.empty-illustration { display: none; }
.ledger-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; color: var(--muted); font-size: var(--small); }
.ledger-pagination > div { display: flex; gap: 12px; }
.ledger-pagination .icon { display: none; }
.ledger-footnote { font-size: var(--small); color: var(--muted); margin: 24px 0 0; text-align: center; }
.privacy-dot { display: none; }
.bottom-dock { position: fixed; z-index: 10; bottom: 16px; left: 50%; transform: translateX(-50%); width: 440px; max-width: calc(100% - 24px); display: flex; gap: 12px; padding: 8px 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 24px #183b3514; }
.dock-item { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 56px; gap: 8px; border-radius: 10px; background: white; font-size: 1rem; font-weight: 650; }
.dock-item.is-active { background: #e9efdf; }
/* Native modal sheets keep keyboard focus in the current task. */
dialog { color: var(--ink); border: 0; background: var(--paper); box-shadow: 0 24px 80px #122c3440; padding: 0; }
dialog::backdrop { background: #122c3466; }
body.editor-open, body.tools-open, body.success-open { overflow: hidden; }
.tools-dialog { width: 640px; max-width: calc(100% - 32px); max-height: 90dvh; border-radius: 20px; padding: 24px; overflow-y: auto; }
.sheet-handle { display: none; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.sheet-heading .icon { display: none; }
.tool-list { display: grid; gap: 16px; }
.tool-action { display: flex; align-items: center; gap: 16px; border: 1px solid var(--line); background: var(--card); padding: 18px; border-radius: 12px; text-align: left; }
.tool-icon { display: flex; align-items: center; justify-content: center; background: #eaf0dd; padding: 12px; border-radius: 10px; }
.tool-action > span:nth-child(2) { display: grid; gap: 8px; flex: 1; min-width: 0; }
.tool-action strong { font-size: 1.11rem; font-weight: 700; }
.tool-action small { font-size: var(--small); color: var(--muted); }
.tool-action > .icon { width: 20px; }
.storage-note { font-size: var(--small); line-height: 1.8; color: var(--muted); background: #e6ecdf; border-radius: 10px; margin: 22px 0 0; padding: 16px; }
.is-error { color: var(--danger); background: #fff0df; }
.editor-dialog { width: 1180px; max-width: calc(100vw - 48px); height: min(1000px, calc(100dvh - 48px)); max-height: calc(100dvh - 48px); border-radius: 20px; overflow: hidden; }
.editor-dialog[open] { display: flex; flex-direction: column; }
.editor-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 14px; gap: 14px; flex-shrink: 0; }
.editor-heading > div:first-child { min-width: 0; }
.editor-heading h2 { font-size: 1.44rem; margin: 0 0 5px; line-height: 1.4; }
.editor-heading p { font-size: var(--small); color: var(--muted); line-height: 1.6; }
.editor-heading-actions { flex-shrink: 0; }
.editor-heading-actions .icon { display: none; }
.editor-dirty { display: none; }
.steps { display: flex; gap: 12px; margin: 0 24px; padding-bottom: 12px; flex-shrink: 0; }
.step { display: flex; align-items: center; gap: 7px; flex: 1; color: var(--muted); border-bottom: 3px solid #c8d2bf; padding-bottom: 9px; font-size: var(--small); }
.step span { font-weight: 700; }
.step strong { font-weight: 500; }
.step.is-active { border-color: #315c36; color: var(--ink); }
.step.is-active strong { font-weight: 700; }
.recognition-status { padding: 12px 16px; margin: 0 24px 12px; border: 1px solid #a1b682; background: #edf2df; border-radius: 10px; flex-shrink: 0; }
.status-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: var(--small); }
.progress-track { height: 8px; background: #c8d4b4; margin-top: 8px; border-radius: 4px; overflow: hidden; }
.progress-track span { display: block; width: 0; height: 100%; background: #466b31; }
#cancelButton { margin-top: 6px; }
.editor-view-switch { display: none; }
.editor-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding-top: 20px; }
.workspace { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: start; padding: 10px 24px 24px; gap: 24px; }
.document-panel, .result-panel { min-width: 0; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.panel-heading h3 { font-size: 1.11rem; }
.image-meta, .result-count { font-size: var(--small); color: var(--muted); }
.result-count { background: #e1ead4; border-radius: 6px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.dropzone { border: 2px dashed #a1b386; border-radius: 16px; padding: 24px 20px; background: white; text-align: center; }
.dropzone.is-dragging { border-color: #365d1f; background: #f0f7d7; }
.dropzone h3 { font-size: 1.33rem; margin: 0 0 12px; }
.dropzone p { font-size: 1rem; color: var(--muted); margin-bottom: 24px; }
.scan-illustration { display: none; }
.upload-actions { display: flex; flex-direction: column; gap: 16px; margin: auto; }
.upload-actions .button { min-height: 64px; font-size: 1.11rem; }
.upload-hint { display: block; margin-top: 18px; font-size: var(--small); color: var(--muted); }
.upload-alternatives { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); margin-top: 20px; padding-top: 16px; }
.upload-alternatives .text-button { border: 1px solid var(--line); background: white; text-decoration: none; }
.empty-results { min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; gap: 16px; }
.empty-results > .icon { width: 36px; height: 36px; }
.empty-results p { font-size: 1rem; }
.preview-shell { background: var(--card); border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.preview-toolbar { display: flex; flex-wrap: wrap; align-items: center; padding: 12px; gap: 12px; }
.file-chip { min-width: 0; display: flex; align-items: center; gap: 8px; font-size: var(--small); width: 100%; }
.file-chip span { overflow-wrap: anywhere; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar-actions .icon { display: none; }
.canvas-frame { position: relative; overflow: auto; max-height: 560px; text-align: center; background: #e4e9dc; }
.canvas-frame canvas { display: block; max-width: 100%; height: auto; margin: auto; }
.field-overlays { position: absolute; pointer-events: none; }
.field-overlay { position: absolute; border: 1px solid #8e6c12; background: #efd76b17; }
.field-overlay.is-current { background: #ebc31a50; border: 2px solid #967300; }
.field-overlay.is-done { border-color: #4e7952; background: #5cbd8a0a; }
.preview-hint { padding: 16px; color: var(--muted); font-size: var(--small); }
.form-guidance { font-size: var(--small); color: var(--muted); margin-bottom: 16px; }
.result-form { display: grid; gap: 18px; }
.field-group { min-width: 0; background: white; border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.field-group summary { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 16px; min-height: 64px; list-style: none; font-size: 1.11rem; font-weight: 700; }
.field-group summary::-webkit-details-marker { display: none; }
.group-toggle { grid-column: 1; font-size: var(--small); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.group-count { grid-column: 2; grid-row: 1; font-size: var(--small); font-weight: 500; color: var(--muted); align-self: center; }
.field-group summary .icon { grid-column: 2; grid-row: 2; justify-self: end; width: 20px; height: 20px; }
.field-group[open] summary .icon { transform: rotate(90deg); }
.field-group[open] summary { border-bottom: 1px solid #cfd8c7; }
.field-group[open] .when-closed, .field-group:not([open]) .when-open { display: none; }
.field-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 24px; padding: 20px 16px; }
.field-control { min-width: 0; }
.field-label { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; margin-bottom: 9px; }
.field-label label { font-size: 1rem; font-weight: 650; }
.confidence { font-size: var(--small); color: var(--muted); }
.confidence.low { color: #834510; font-weight: 650; }
.input-row { display: flex; align-items: center; border: 2px solid var(--line); border-radius: 10px; background: #fff; min-height: 60px; }
.input-row:focus-within { outline: 3px solid #236a4b; outline-offset: 2px; }
.input-row input { border: 0; border-radius: 10px; background: transparent; padding: 14px 12px; width: 100%; min-width: 0; outline: none; font-size: 1.111rem; line-height: 1.4; }
.input-row input[readonly] { color: var(--muted); }
.is-warning .input-row { border-color: #ab7030; background: #fff6e4; }
.unit { padding-right: 10px; font-size: var(--small); color: var(--muted); max-width: 45%; overflow-wrap: anywhere; }
.remember-button { min-height: 56px; background: #e8efdf; font-size: var(--small); padding: 10px; flex-shrink: 0; border-radius: 0 8px 8px 0; }
.editor-error { font-size: var(--small); line-height: 1.7; padding: 12px; background: #fff0df; color: var(--danger); border: 1px solid #b5764e; border-radius: 10px; }
.editor-dialog > .editor-error { margin: 0 20px 10px; padding: 10px 12px; flex-shrink: 0; max-height: 100px; overflow: auto; }
.result-actions { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 24px; flex-shrink: 0; }
.result-actions:has(> [hidden]):has(.export-actions[hidden]) { display: none; }
.export-actions { margin-left: auto; }
.export-actions summary { min-height: 56px; padding: 12px 8px; text-decoration: underline; text-underline-offset: 5px; font-size: var(--small); }
.export-actions-body { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 10px; }
.export-actions .text-button { font-size: var(--small); }
.save-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; background: white; border-top: 1px solid var(--line); flex-shrink: 0; }
.save-bar > span { font-size: var(--small); line-height: 1.5; color: var(--muted); }
.save-actions { display: flex; gap: 12px; flex-shrink: 0; }
.save-actions .button { min-height: 60px; }
.success-dialog { width: 540px; max-width: calc(100% - 32px); max-height: 90dvh; overflow: hidden; padding: 0; border-radius: 20px; text-align: center; background: white; }
.success-dialog[open] { display: flex; flex-direction: column; }
.success-content { min-height: 0; overflow-y: auto; padding: 26px 24px 0; overscroll-behavior: contain; }
.success-mark { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 20px; background: #e1f0d4; color: #235c2c; }
.success-mark .icon { width: 40px; height: 40px; stroke-width: 2.5; }
.success-dialog h2 { font-size: 1.67rem; margin-bottom: 16px; }
.success-dialog p { font-size: 1rem; overflow-wrap: anywhere; }
.success-review { padding: 14px; margin-top: 16px; border: 1px solid #bd914a; border-radius: 10px; background: #fff3dc; color: #784912; }
.success-actions { display: grid; gap: 16px; padding: 20px 24px 24px; flex-shrink: 0; }
.success-actions .button { min-height: 60px; }
.toast { position: fixed; z-index: 100; bottom: 118px; left: 50%; transform: translateX(-50%); background: #193e35; color: white; padding: 16px 20px; border-radius: 12px; font-size: 1rem; line-height: 1.6; max-width: calc(100% - 32px); width: max-content; opacity: 0; pointer-events: none; }
.toast.is-visible { opacity: 1; }
.tools-dialog .toast { bottom: 24px; }
/* A single-column workflow on phones, with full-width form fields. */
@media (max-width: 767px) {
  .topbar { padding: 12px 16px; gap: 8px; }
  .brand { gap: 8px; }
  .brand strong { font-size: 1.22rem; }
  .brand-mark { width: 30px; height: 36px; padding: 8px; }
  .text-size-control button { padding: 8px 10px; }
  main { padding: 22px 16px 130px; }
  .ledger-hero { margin-bottom: 20px; }
  .quick-actions { grid-template-columns: 1fr; gap: 14px; }
  .quick-action { padding: 18px; gap: 12px; min-height: 104px; }
  .quick-action > .icon:first-child { width: 30px; height: 30px; }
  .quick-action > .icon:last-child { width: 18px; }
  .overview { gap: 4px 12px; padding-bottom: 22px; }
  .overview button { padding: 8px 6px; }
  .ledger-heading { margin-bottom: 18px; }
  .view-switch, .desktop-tools, #tableColumns { display: none; }
  .ledger-toolbar { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
  .search-box { padding: 0 12px; }
  .customer-filter select { max-width: none; width: 100%; }
  .filter-row { align-items: flex-start; }
  .filter-tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .filter-tabs button { padding: 12px 8px; justify-content: center; gap: 6px; }
  .sort-hint { display: none; }
  .ledger-panel .records-scroll { display: none; }
  .ledger-panel .record-cards { display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; }
  .record-card { padding: 18px; }
  .card-top { flex-wrap: wrap; gap: 8px; }
  .ledger-empty { padding: 24px 18px; }
  .ledger-pagination { flex-direction: column; align-items: stretch; }
  .ledger-pagination > div { display: grid; grid-template-columns: 1fr 1fr; }
  .bottom-dock { bottom: 0; width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-bottom: 0; gap: 8px; }
  .dock-item { gap: 6px; }
  .tools-dialog { width: 100%; max-width: 100%; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; padding: 22px 16px calc(24px + env(safe-area-inset-bottom)); }
  .tool-action { padding: 16px; gap: 10px; }
  .tool-icon { display: none; }
  .editor-dialog { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; padding-top: env(safe-area-inset-top); }
  .editor-heading { padding: 12px 16px; gap: 10px; align-items: flex-start; }
  .editor-heading h2 { font-size: 1.33rem; }
  .editor-heading p { display: none; }
  .editor-heading-actions .icon-button { padding: 10px 12px; font-size: var(--small); }
  .steps { margin: 0 16px; gap: 8px; padding-bottom: 10px; }
  .step { padding-bottom: 8px; gap: 5px; }
  .recognition-status { margin: 0 16px 10px; padding: 12px; }
  .editor-view-switch { display: flex; margin: 0 16px 12px; gap: 8px; flex-shrink: 0; }
  .editor-view-switch button { flex: 1; min-height: 56px; padding: 10px 8px; font-size: 1rem; border: 1px solid var(--line); border-radius: 10px; background: white; }
  .editor-view-switch [aria-pressed="true"] { background: var(--ink); color: white; font-weight: 700; border-color: var(--ink); }
  .workspace { display: block; padding: 4px 16px 24px; }
  .editor-dialog[data-editor-view="fields"] .document-panel { display: none; }
  .editor-dialog[data-editor-view="document"] .result-panel { display: none; }
  .dropzone { padding: 22px 16px; }
  .dropzone h3 { font-size: 1.22rem; }
  .field-grid { padding: 20px 14px; }
  .field-group summary { padding: 16px 14px; }
  .result-actions { padding: 0 16px; gap: 8px; }
  .save-bar { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: 8px; }
  .save-bar > span { text-align: center; }
  .save-actions .button-accent { flex: 1; }
  .save-actions .button-outline { display: none; }
  .save-actions .button-accent .icon { width: 24px; }
  .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
  .editor-dialog .toast { bottom: calc(155px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  .text-size-control button { padding: 8px; }
  .brand-mark { display: none; }
  .filter-tabs button { flex-wrap: wrap; }
  .dock-item .icon { display: none; }
}
/* On a short viewport the scrollable body must retain usable space. */
@media (max-height: 600px) {
  .success-mark { display: none; }
  .success-content { padding-top: 16px; }
  .success-actions { gap: 10px; padding-top: 14px; padding-bottom: 16px; }
  .editor-heading { padding-top: 8px; padding-bottom: 8px; align-items: center; }
  .editor-heading p, .steps, .save-bar > span { display: none; }
  .editor-heading h2 { font-size: 1.11rem; margin: 0; }
  .editor-view-switch { margin-bottom: 8px; }
  .editor-dialog .result-actions { padding-top: 0; }
  .editor-dialog .result-actions summary { min-height: 44px; padding: 6px; }
  .save-bar { padding-top: 8px; padding-bottom: 8px; }
  .editor-dialog > .editor-error { max-height: 70px; }
  .recognition-status { padding: 8px 12px; }
}
@media (max-height: 600px) and (min-width: 768px) {
  .editor-dialog { height: calc(100dvh - 24px); max-height: calc(100dvh - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Shared server data migration keeps the existing large-text controls. */
.migration-panel { margin: 0 0 24px; padding: 22px; border: 2px solid #315a47; border-radius: 18px; background: #eef5eb; color: #183e35; }
.migration-panel[hidden] { display: none; }
.migration-panel p { line-height: 1.6; overflow-wrap: anywhere; }
.migration-panel .button { min-height: 56px; white-space: normal; }
@media (max-width: 600px) { .migration-panel { padding: 18px; } .migration-panel .button { width: 100%; } }

.ledger-footnote.is-error { color: #9f2525; font-weight: 700; }
