:root {
  color-scheme: light;
  --page: #f5f8fb;
  --surface: #fff;
  --soft: #f8fafc;
  --ink: #0f1b2d;
  --text-secondary: #475467;
  --muted: #5b6676;
  --placeholder: #636e7d;
  --line: #e4e9f0;
  --control-line: #d6dde6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf1fe;
  --primary-line: #b7cef9;
  --success: #0b7a61;
  --success-soft: #e3f8f1;
  --warning: #92400e;
  --warning-soft: #fff4e5;
  --warning-line: #f4d8ad;
  --danger: #b42318;
  --danger-soft: #fff2f0;
  --danger-line: #f6cdc9;
  --danger-edge: #d92d20;
  --danger-hover: #fee4e2;
  --radius: 12px;
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
button, select, summary { cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
button:disabled { opacity: .57; cursor: wait; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

.layout { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); color: var(--ink); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; padding: 27px 16px 17px; }
.brand { display: flex; gap: 11px; align-items: center; margin: 0 9px; color: inherit; }
.brand-icon { width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-content: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary-hover); }
.brand-icon i { display: block; width: 15px; height: 18px; border: 2px solid currentColor; border-radius: 3px; position: relative; }
.brand-icon i::before, .brand-icon i::after { content: ''; position: absolute; left: 3px; right: 3px; height: 2px; background: currentColor; top: 4px; }
.brand-icon i::after { top: 9px; right: 5px; }
.brand strong { display: block; font-size: 17px; line-height: 1.4; letter-spacing: .035em; }
.brand small { color: var(--muted); font-size: 11px; }
.side-nav { display: grid; gap: 5px; margin-top: 42px; }
.side-nav a { color: var(--text-secondary); display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 8px; }
.side-nav a:hover { background: var(--primary-soft); color: var(--primary-hover); }
.side-nav a.active { background: var(--primary); color: var(--surface); font-weight: 650; }
.nav-icon { width: 15px; height: 15px; flex: 0 0 15px; display: inline-grid; place-items: center; color: currentColor; }
.nav-icon.list { border: 1.5px solid currentColor; border-radius: 3px; }
.nav-icon.list::after { content: ''; width: 7px; height: 1px; background: currentColor; box-shadow: 0 -3px currentColor, 0 3px currentColor; }
.nav-icon.plus { font-size: 20px; line-height: 1; }

.topbar { min-height: 65px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 34px; }
.breadcrumb { color: var(--muted); display: flex; align-items: center; gap: 9px; font-size: 13px; }
.breadcrumb b { font-weight: 650; color: var(--ink); }
.identity { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.avatar { display: grid; place-items: center; border-radius: 50%; width: 32px; height: 32px; background: var(--primary-soft); color: var(--primary-hover); font-size: 12px; font-weight: 700; }
.identity > div { display: grid; line-height: 1.3; }
.identity small { color: var(--muted); }
.link-button { border: 0; background: none; color: var(--primary); padding: 4px 0; font-weight: 650; white-space: nowrap; }
.identity .link-button { margin-left: 9px; color: var(--muted); font-size: 12px; }
.identity #return-workspace { min-height: 32px; padding: 5px 10px; font-size: 13px; color: var(--primary-hover); }
.stage { width: min(100%, 1460px); margin: 0 auto; padding: 28px 34px 40px; }
.page-top { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 22px; }
h1 { font-size: clamp(25px, 3vw, 33px); line-height: 1.28; font-weight: 720; letter-spacing: -.035em; overflow-wrap: anywhere; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 14px; }
.page-top p { margin-top: 6px; color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; min-height: 40px; border-radius: 7px; border: 1px solid transparent; font-weight: 650; line-height: 1.35; white-space: nowrap; }
.primary { background: var(--primary); color: white; border-color: var(--primary); }
.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.secondary { color: var(--ink); background: white; border-color: var(--control-line); }
.secondary:hover { background: var(--soft); border-color: var(--primary-line); }
.danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }
.danger:hover { background: var(--danger-hover); }
.subtle { color: var(--muted); background: transparent; }
.subtle:hover { background: var(--soft); }
.quiet, .muted { color: var(--muted); }
.quiet { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 21px; }
.stat { display: grid; position: relative; min-width: 0; min-height: 105px; padding: 13px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; color: var(--ink); }
.stat:hover, .stat.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.stat b { font-size: 33px; line-height: 1.1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stat .arrow { position: absolute; right: 15px; top: 16px; color: var(--muted); }
.badge { width: max-content; display: inline-flex; align-items: center; gap: 7px; padding: 4px 9px; border-radius: 5px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.badge::before, .event-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge::before { content: ''; }
.pending { background: var(--warning-soft); color: var(--warning); }
.returned { background: var(--danger-soft); color: var(--danger); }
.ordered { background: var(--success-soft); color: var(--success); }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel + .panel { margin-top: 16px; }
#recent-content:not(:empty) { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 17px 12px; }
.panel-head p { color: var(--muted); margin-top: 3px; font-size: 12px; }
.panel-body { padding: 0 17px 17px; }
.filters { display: grid; grid-template-columns: minmax(160px, 1.6fr) repeat(4, minmax(100px, 1fr)) auto; gap: 10px; align-items: end; padding: 1px 17px 16px; }
.filters.sales { grid-template-columns: minmax(160px, 1.5fr) repeat(3, minmax(100px, 1fr)) auto; }
.filter-actions { display: flex; gap: 2px; }
.filter-actions .button { padding-inline: 11px; }
.field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.field label, .field-label { color: var(--text-secondary); font-size: 13px; font-weight: 650; }
.field input, .field select, .field textarea, .dialog-body textarea { width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--control-line); background: white; color: var(--ink); }
:is(.field, .template-grid, .charge-mode, .file-plan-controls, .image-dock) :is(input, select, textarea):focus-visible, .dialog-body textarea:focus-visible { border-color: var(--primary); }
.field select, .field input[type=date] { padding-inline: 7px; }
.field input::placeholder, .field textarea::placeholder { color: var(--placeholder); }
.field textarea, .dialog-body textarea { resize: vertical; }
.field textarea { min-height: 67px; }
.field-error { color: var(--danger); font-size: 12px; }
.field [aria-invalid=true] { border-color: var(--danger-edge); }
.required { color: var(--danger); }

.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
.order-table { min-width: 820px; }
th { background: var(--soft); color: var(--text-secondary); font-weight: 650; text-align: left; white-space: nowrap; }
th, td { padding: 11px 11px; vertical-align: top; }
th:first-child, td:first-child { padding-left: 17px; }
th:last-child, td:last-child { padding-right: 17px; }
tbody tr { border-bottom: 1px solid var(--line); }
tbody tr:hover { background: var(--soft); }
td.item-customer { min-width: 108px; max-width: 205px; overflow-wrap: anywhere; }
td.item-product { min-width: 103px; max-width: 190px; overflow-wrap: anywhere; }
td.item-status { min-width: 103px; max-width: 190px; }
.order-link { color: var(--primary-hover); font-weight: 700; white-space: nowrap; }
.order-link:hover, .table-action:hover { text-decoration: underline; }
.table-action { font-weight: 650; white-space: nowrap; }
.reason-snippet { margin-top: 4px; color: var(--danger); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 17px; gap: 10px; color: var(--muted); font-size: 12px; }
.pagination .button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.empty { padding: 28px 17px; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: 3px; color: var(--ink); }
.recent-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-top: 1px solid var(--line); gap: 9px; padding: 10px 0; }
.recent-row:last-child { padding-bottom: 0; }
.recent-row p { margin-top: 2px; }

.back { display: inline-flex; margin-bottom: 12px; font-weight: 650; }
.detail-grid, .form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(275px, 34%); align-items: start; gap: 17px; }
.detail-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.identifier { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.callout { padding: 12px 13px; background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: 8px; color: var(--text-secondary); margin-bottom: 13px; overflow-wrap: anywhere; }
.callout.warning { background: var(--warning-soft); border-color: var(--warning-line); color: var(--warning); }
.callout.error, .form-error { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); }
.form-error { padding: 8px 11px; border-radius: 7px; margin-bottom: 10px; }
.callout p { margin-top: 4px; white-space: pre-wrap; }
.kv-group { padding: 13px 0; border-top: 1px solid var(--line); }
.kv-group:last-child { padding-bottom: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 15px; margin: 8px 0 0; }
.kv-grid dt { font-size: 12px; color: var(--muted); }
.kv-grid dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.span { grid-column: 1 / -1; }
.file-list { display: grid; gap: 7px; }
.file-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 7px; }
.file-thumb, .file-kind { width: 43px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); color: var(--primary-hover); font-size: 10px; font-weight: 700; }
.file-thumb img { width: 100%; height: 34px; object-fit: contain; }
.file-name { display: block; overflow-wrap: anywhere; }
.file-row .quiet { margin-top: 2px; }
.record { border-top: 1px solid var(--line); padding: 11px 0; }
.record:last-child { padding-bottom: 0; }
.record-head { display: flex; align-items: center; gap: 8px; }
.event-dot { display: inline-block; background-color: var(--primary); }
.event-dot.confirm { background-color: var(--success); }
.event-dot.return { background-color: var(--danger); }
.record .quiet { margin: 3px 0; }
details { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 9px; }
summary { color: var(--primary-hover); font-weight: 650; }
.compare { margin-top: 8px; font-size: 12px; table-layout: fixed; }
.compare td, .compare th { padding: 5px 4px; overflow-wrap: anywhere; white-space: pre-wrap; }
.compare td:first-child { width: 27%; }
.stack-actions { display: grid; gap: 8px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button-row > * { flex: 1; }
.form-panel { padding: 15px 17px 16px; }
.form-panel h2 { margin-bottom: 10px; }
.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px 13px; }
.form-panel .controls + .callout { margin-top: 12px; }
.form-aside { position: sticky; top: 15px; }
.form-aside dl { margin-bottom: 12px; }
.subtotal-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 11px; background: var(--primary-soft); border-radius: 7px; margin: 10px 0 13px; }
.subtotal-box output { font-weight: 750; font-size: 20px; overflow-wrap: anywhere; }
.upload-zone { margin-top: 10px; padding: 11px; border: 1px dashed var(--primary-line); border-radius: 7px; background: var(--surface); }
.upload-zone input { max-width: 100%; }
.upload-zone .quiet { margin-top: 5px; }
.file-list:not(:empty) { margin-top: 9px; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .85fr) minmax(420px, 1fr); }
.login-side { background: var(--surface); color: var(--ink); display: grid; align-content: center; padding: clamp(30px, 7vw, 105px); }
.login-side .brand { margin: 0 0 25px; }
.login-side h1 { font-size: clamp(32px, 4vw, 53px); }
.login-side p { margin-top: 13px; color: var(--muted); line-height: 1.8; max-width: 360px; }
.login-main { display: grid; place-items: center; padding: 24px; }
.login-card { padding: 28px; width: min(100%, 395px); }
.login-card h2 { font-size: 24px; }
.login-card form { display: grid; gap: 14px; margin-top: 17px; }
.login-card #login-error:empty { display: none; }
.login-card .quiet { margin-top: 6px; }
.boot { text-align: center; margin: 80px 20px; color: var(--muted); }

dialog { width: min(580px, calc(100% - 28px)); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); box-shadow: 0 20px 70px #10182837; }
dialog::backdrop { background: #10182880; }
.dialog-head { padding: 15px 17px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.dialog-close { color: var(--muted); background: transparent; border: 0; font-size: 22px; line-height: 1; }
.dialog-body { padding: 16px 17px; }
.dialog-body > p + p, .dialog-body > * + .field, .dialog-body > textarea { margin-top: 9px; }
.dialog-actions { display: flex; justify-content: end; gap: 8px; border-top: 1px solid var(--line); padding: 12px 17px; }
#toast { position: fixed; bottom: 18px; right: 18px; z-index: 5; max-width: min(430px, calc(100% - 36px)); color: white; background: var(--ink); border-radius: 8px; box-shadow: 0 6px 26px #10182830; padding: 9px 14px; }
#toast:empty { display: none; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: 190px minmax(0, 1fr); }
  .stage, .topbar { padding-inline: 21px; }
  .filters, .filters.sales { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; gap: 13px; flex-wrap: wrap; align-items: center; padding: 12px; position: static; height: auto; }
  .side-nav { display: flex; margin: 0; }
  .topbar { min-height: 56px; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .form-aside { position: static; }
  .login-shell { grid-template-columns: 1fr; }
  .login-side { padding: 23px; }
  .login-side .brand { margin-bottom: 12px; }
  .login-main { align-items: start; }
}
@media (max-width: 510px) {
  .stage, .topbar { padding-inline: 12px; }
  .stage { padding-top: 20px; }
  .filters, .filters.sales { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { gap: 7px; }
  .stat { padding-inline: 9px; min-height: 84px; }
  .stat b { font-size: 28px; }
  .stat .arrow { display: none; }
  .controls { grid-template-columns: 1fr; }
  .page-top { align-items: start; }
  .login-card { padding: 19px; }
}

.screen-reader { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.order-workspace { min-width: 0; }
.official-paper-stage { overflow-x: auto; padding: 8px 0 18px; }
sales-order-paper { display: block; font: 14px/1.5 "Microsoft YaHei","PingFang SC",Arial,sans-serif; }
.paper-supplement { max-width: 1040px; margin-inline: auto; }
.paper-extra { margin: 0 0 16px; display: grid; gap: 7px; }
.paper-extra > div { display: grid; grid-template-columns: 6em 1fr; gap: 8px; }
.paper-extra dt { color: var(--muted); }
.paper-extra dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-supplement h3 { margin-bottom: 10px; }
.order-workspace .page-top { align-items: center; margin-bottom: 16px; }
.order-workspace .copy-hint { align-self: end; }
.template-bar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface); margin-bottom: 12px;
}
.template-label { margin-right: 4px; color: var(--text-secondary); font-weight: 700; font-size: 13px; }
.template-option {
  min-height: 32px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 6px;
  background: white; color: var(--text-secondary); font-size: 13px; font-weight: 650;
}
.template-option:hover { background: var(--soft); border-color: var(--primary-line); }
.template-option[aria-pressed=true] { background: var(--primary); color: var(--surface); border-color: var(--primary); }
.charge-mode { display: flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 13px; }
.charge-mode select {
  min-height: 32px; padding: 4px 8px; border: 1px solid var(--control-line); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.sheet-paper {
  min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  border-top: 4px solid var(--primary); box-shadow: 0 1px 2px #1018280b; padding: 18px 19px 20px;
}
.sheet-header { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.sheet-header h2 { font-size: 25px; color: var(--ink); letter-spacing: .045em; }
.sheet-doc-id { color: var(--muted); background: var(--soft); border-radius: 6px; padding: 6px 9px; font-size: 12px; }
.sheet-doc-id strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.sheet-meta {
  display: grid; grid-template-columns: minmax(145px, 1.25fr) minmax(115px, 1fr) minmax(92px, .68fr) minmax(95px, .66fr);
  gap: 1px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--line); margin-bottom: 13px;
}
.sheet-meta > .sheet-field { background: var(--surface); padding: 8px 10px; }
.sheet-meta > .sheet-field:last-child { grid-column: 1 / -1; }
.sheet-field { min-width: 0; }
.sheet-field > :first-child { display: block; margin-bottom: 3px; color: var(--text-secondary); font-size: 12px; line-height: 1.35; font-weight: 650; }
.sheet-field > div { min-height: 25px; }
.sheet-meta .cell-copy { font-weight: 620; }
.sheet-meta .cell-copy, .sheet-meta .sheet-empty { padding: 2px 0; }
.sheet-paper input:not([type=checkbox]):not([type=file]), .sheet-paper textarea {
  display: block; width: 100%; min-width: 0; min-height: 35px; padding: 6px 7px;
  color: var(--ink); border: 1px solid var(--control-line); border-radius: 5px; background: var(--surface);
}
.sheet-paper input::placeholder, .sheet-paper textarea::placeholder { color: var(--placeholder); }
.sheet-paper textarea { resize: vertical; field-sizing: content; max-height: 17rem; }
.sheet-paper :is(input, textarea):focus { border-color: var(--primary); outline: 2px solid var(--primary); outline-offset: 0; }
.sheet-paper :is(input, textarea)[aria-invalid=true] { border-color: var(--danger-edge); background: var(--danger-soft); }
.sheet-error { display: block; margin: 3px 0 0; color: var(--danger); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.sheet-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 7px; }
.sheet-grid { table-layout: fixed; min-width: 690px; font-size: 13px; }
.editing .sheet-grid { min-width: 860px; }
.sheet-grid th, .sheet-grid td { padding: 9px 8px; border-right: 1px solid var(--line); }
.sheet-grid td:last-child, .sheet-grid th:last-child { border-right: 0; }
.sheet-grid th { background: var(--primary-soft); color: var(--text-secondary); white-space: normal; }
.sheet-grid td { overflow-wrap: anywhere; }
.sheet-grid tr:last-child { border-bottom: 0; }
.sheet-grid tr:hover { background: var(--surface); }
.sheet-grid .col-name { width: 16%; }
.sheet-grid .col-spec { width: 27%; }
.sheet-grid .col-unit { width: 7%; }
.sheet-grid .col-qty { width: 11%; }
.sheet-grid .col-price { width: 10%; }
.sheet-grid .col-amount { width: 11%; }
.sheet-grid .col-action { width: 36px; }
.sheet-grid td:nth-child(4), .sheet-grid td:nth-child(5), .sheet-grid td:nth-child(6), .sheet-totals dd { font-variant-numeric: tabular-nums; }
.sheet-grid .kit-row { background: var(--primary-soft); }
.sheet-grid .kit-row:hover { background: var(--primary-soft); }
.sheet-grid .component-row td:first-child { border-left: 3px solid var(--primary-line); }
.row-kind, .row-quantity-label { display: block; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.row-kind.kit-label { color: var(--primary-hover); font-weight: 750; }
.editing .row-kind { margin: 4px 0 0; }
.return-paste { margin-top: 12px; padding: 12px; border: 1px dashed var(--control-line); border-radius: 6px; }
.return-paste:focus-visible { outline: 2px solid var(--primary); }
.return-paste p { margin: 4px 0; }
.return-notice { margin-bottom: 14px; }
.return-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.return-thumbs:not(:empty) { margin-top: 8px; }
.return-thumb { display: grid; gap: 4px; justify-items: center; padding: 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); font: inherit; font-size: 12px; }
button.return-thumb { cursor: zoom-in; }
.return-thumb img { width: 96px; height: 68px; display: block; object-fit: contain; }
.cell-copy { display: inline-block; user-select: all; white-space: pre-wrap; overflow-wrap: anywhere; }
.sheet-empty { color: var(--muted); }
.editing .sheet-grid .row-amount { padding-top: 15px; }
.spec-suggest { display: block; margin-top: 4px; max-width: 100%; border: 0; padding: 1px 3px; background: transparent; color: var(--primary-hover); font-size: 11px; }
.sheet-grid .row-action { padding-inline: 3px; text-align: center; }
.remove-line { border: 0; border-radius: 5px; background: transparent; color: var(--danger); padding: 2px 6px; font-size: 19px; line-height: 1.25; }
.remove-line:hover { background: var(--danger-hover); }
.sheet-add { margin-top: 9px; }
.sheet-add .button { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.sheet-footer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 33%); gap: 16px; margin-top: 14px; }
.sheet-notes { border: 1px solid var(--line); border-radius: 7px; background: var(--surface); min-width: 0; padding: 9px 10px; }
.sheet-notes textarea { min-height: 62px; }
.sheet-totals { display: grid; align-content: start; margin: 0; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.sheet-totals > div { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(74px, 1fr); align-items: center; gap: 6px; padding: 7px 9px; }
.sheet-totals dt { color: var(--text-secondary); font-size: 12px; font-weight: 650; }
.sheet-totals dd { margin: 0; text-align: right; overflow-wrap: anywhere; font-weight: 680; }
.sheet-totals dd input { text-align: right; }
.sheet-totals .final-money { color: var(--primary-hover); background: var(--primary-soft); padding-block: 9px; }
.final-money dd { font-size: 17px; font-weight: 780; }
.sheet-legacy-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 8px; }
.sheet-source { margin: 0 0 10px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.sheet-source a { font-weight: 700; text-decoration: underline; }
.sheet-attachments { margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); }
.sheet-attachments h3 { font-size: 15px; margin-bottom: 7px; }
.sheet-attachments .file-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 295px), 1fr)); gap: 9px; }
.file-buttons { display: flex; gap: 8px; align-items: center; color: var(--primary); white-space: nowrap; }
.file-buttons a { font-weight: 650; }
.sheet-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 11px; background: var(--soft); border: 1px dashed var(--primary-line); border-radius: 7px; color: var(--text-secondary); }
.sheet-drop.drag-over, .sheet-drop:has(input:focus-visible) { border-color: var(--primary); outline: 2px solid var(--primary); background: var(--primary-soft); }
.sheet-drop label { cursor: pointer; min-height: 32px; padding-block: 5px; }
.file-limits { margin-top: 5px; }
.reuse-files, .existing-files { margin-bottom: 10px; }
.reuse-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); margin-top: 7px; }
.reuse-grid > div { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
.reuse-grid label { display: flex; align-items: center; min-width: 0; gap: 5px; overflow-wrap: anywhere; }
.history-panel { background: var(--soft); border: 1px solid var(--primary-line); border-radius: 7px; padding: 9px 11px; margin-bottom: 12px; }
.history-panel h3 { color: var(--primary-hover); margin-bottom: 4px; }
.history-list { display: grid; margin: 0; padding: 0; max-height: 290px; overflow: auto; }
.history-list li { display: flex; justify-content: space-between; gap: 9px; align-items: center; padding: 7px 0; border-top: 1px solid var(--primary-line); }
.history-list p { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.history-list .button { padding: 5px 8px; min-height: 29px; font-size: 12px; }
.draft-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.wide-dialog { width: min(1100px, calc(100% - 28px)); }
.wide-dialog .dialog-body { background: var(--page); }
.receipt-layout { display: grid; grid-template-columns: minmax(0, 1fr) 245px; align-items: start; gap: 13px; }
.receipt-layout > aside { min-width: 0; }
.receipt-main > .panel { margin-top: 13px; }
.receipt-main { min-width: 0; }
.receipt-main .official-paper-stage { container-type: inline-size; }
@container (max-width: 899px) { .receipt-main sales-order-paper { zoom: .83; } }
@container (max-width: 756px) { .receipt-main sales-order-paper { zoom: .75; } }
.template-fields { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.template-grid { width: 100%; border-collapse: collapse; margin: 10px 0; }
.template-grid th, .template-grid td { padding: 7px; border-bottom: 1px solid var(--line); text-align: left; }
.template-grid th:nth-child(2) { width: 46%; }
.template-grid th:nth-child(3) { width: 12%; }
.template-grid input, .template-grid textarea { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 5px; }
.receipt-main details > .sheet-paper { margin-top: 8px; }
.receipt-layout .callout { font-size: 13px; }
.receipt-layout .callout > p:first-child { margin-top: 0; }
@media (min-width: 1091px) {
  .layout:has(.order-workspace) { grid-template-columns: 184px minmax(0, 1fr); }
  .stage:has(.order-workspace) { padding-inline: 25px; }
}
@media (max-width: 1210px) {
  .receipt-layout { grid-template-columns: minmax(0, 1fr); }
  .receipt-layout > aside { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; grid-row: 1; }
  .receipt-layout > aside .panel { margin: 0; }
}
@media (max-width: 640px) {
  .sheet-paper { padding: 12px; }
  .sheet-meta, .receipt-layout > aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .receipt-layout > aside { grid-template-columns: minmax(0, 1fr); }
  .sheet-footer { grid-template-columns: minmax(0, 1fr); }
  .history-list li { align-items: flex-start; flex-direction: column; }
  .preview-top { flex-wrap: wrap; }
  .sheet-header h2 { font-size: 21px; }
}

.receipt-compare { grid-template-columns: minmax(0, 1fr) minmax(238px, 25%); }
.receipt-aside { scrollbar-width: thin; }
.receipt-files-link { margin: 0 0 8px; }
.receipt-files-link .link-button { font-size: 12px; }
.source-badge { display: inline-block; border-radius: 4px; background: var(--primary-soft); color: var(--primary-hover); font-weight: 740; padding: 1px 6px; margin-right: 4px; }
.image-dock select {
  width: 100%; padding: 5px 6px; border: 1px solid var(--control-line); color: var(--ink);
  border-radius: 6px; background: var(--surface); font-size: 12px;
}
.dock-figure {
  display: grid; place-items: center; width: 100%; height: clamp(123px, 19vh, 193px); margin-top: 8px;
  padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--soft); cursor: zoom-in; overflow: hidden;
}
.dock-figure img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.dock-name { display: block; overflow-wrap: anywhere; margin-top: 6px; font-size: 12px; }
.dock-actions { display: flex; justify-content: space-between; align-items: center; gap: 7px; }
.dock-actions .link-button { font-size: 12px; }
.supplier-files, .other-order-files { padding: 8px 10px 10px; border-radius: 7px; background: var(--soft); border: 1px solid var(--primary-line); scroll-margin-top: 12px; }
.other-order-files { background: var(--surface); border-color: var(--line); margin-top: 8px; }
.supplier-files h4, .other-order-files h4 { margin: 0 0 5px; color: var(--primary-hover); font-size: 13px; }
.file-count { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 1px 6px; background: var(--primary-soft); color: var(--primary-hover); font: 650 11px/1.5 system-ui, sans-serif; }
.file-row { background: var(--surface); }
.file-row .file-thumb { padding: 0; cursor: zoom-in; overflow: hidden; }
.file-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; font-size: 11px; }
.file-labels b { color: var(--text-secondary); }
.file-origin { border-radius: 4px; background: var(--soft); color: var(--text-secondary); padding: 1px 4px; }
.file-origin.reused { background: var(--primary-soft); color: var(--primary-hover); }
.archive-files { background: var(--soft); border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; margin-top: 8px; }
.archive-files summary { color: var(--muted); font-size: 12px; }
.archive-files .quiet { margin-top: 4px; }
.editor-file { margin-top: 8px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.editor-file .file-list { grid-template-columns: 1fr; margin: 0; }
.editor-file .file-row { margin: 0; padding: 0; border: 0; background: transparent; }
.file-plan-controls { display: flex; flex-wrap: wrap; gap: 7px 12px; align-items: center; margin-top: 8px; }
.file-plan-controls label { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; color: var(--text-secondary); }
.file-plan-controls label select, .sheet-paper .file-plan-controls input:not([type=checkbox]) { min-height: 28px; width: auto; padding: 3px 6px; font-size: 12px; border: 1px solid var(--control-line); border-radius: 5px; color: var(--ink); background: var(--surface); }
.file-plan-controls label input:not([type=checkbox]) { max-width: 135px; }
.file-plan-controls button { margin-left: auto; }
.archive-toggle { white-space: nowrap; }
#image-viewer { width: min(960px, calc(100vw - 28px)); }
#image-viewer h2 { overflow-wrap: anywhere; }
.viewer-viewport { background: var(--soft); overflow: auto; padding: 8px; max-height: min(67vh, 650px); }
.viewer-viewport img { display: block; margin: 0 auto; max-width: 100%; max-height: min(63vh, 625px); object-fit: contain; }
#image-viewer.actual-size .viewer-viewport img { max-width: none; max-height: none; }
.viewer-error { padding: 10px 14px; }
@media (min-width: 1121px) {
  .receipt-compare > .receipt-aside { grid-row: auto; display: block; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
  .receipt-compare > .receipt-aside .panel + .panel { margin-top: 13px; }
  .receipt-compare .sheet-grid { min-width: 652px; }
}
@media (max-width: 1120px) {
  .receipt-compare { grid-template-columns: minmax(0, 1fr); }
  .receipt-compare > .receipt-aside { grid-row: auto; }
}
