:root {
  --ink: #202c3c;
  --muted: #718096;
  --line: #d9e0e8;
  --line-dark: #aeb9c7;
  --paper-line: #777c83;
  --cream: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --navy: #17324d;
  --navy-2: #244968;
  --red: #c95740;
  --red-dark: #a53e2c;
  --green: #24875e;
  --shadow: 0 18px 45px rgba(28, 47, 66, .09);
  --radius: 16px;
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--cream);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--cream); }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: radial-gradient(circle at 80% -10%, #fff 0, var(--cream) 38rem); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, .button-link { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }

.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; }
.topbar { height: 74px; display: flex; align-items: center; gap: 40px; padding: 0 4.2vw; border-bottom: 1px solid rgba(29, 52, 72, .08); background: rgba(255,255,255,.74); backdrop-filter: blur(16px); }
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 190px; color: var(--navy); }
.brand strong { display: block; font-size: 15px; letter-spacing: .08em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 9px; background: var(--navy); color: white; font-family: "Songti SC", serif; font-size: 18px; box-shadow: 4px 4px 0 #e7cfc6; }
.topnav { display: flex; align-items: center; gap: 25px; flex: 1; }
.topnav a { color: #526477; font-size: 13px; transition: color .2s ease; }
.topnav a:hover, .quiet-link:hover { color: var(--red); }
.user-menu { display: flex; align-items: center; gap: 15px; white-space: nowrap; }
.user-chip { color: var(--navy); font-size: 13px; }
.user-chip em { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 20px; color: var(--red-dark); background: #f8e7e1; font-size: 10px; font-style: normal; }
.quiet-link { color: var(--muted); font-size: 12px; }
.page-shell { width: min(1440px, 92vw); margin: 0 auto; padding: 48px 0 72px; }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.workspace-head h1 { margin: 4px 0 7px; color: var(--navy); font-family: "Songti SC", "STSong", serif; font-size: clamp(29px, 4vw, 44px); font-weight: 600; letter-spacing: .035em; }
.workspace-head p { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .24em; }
.head-actions { display: flex; align-items: center; gap: 10px; }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; font-weight: 650; transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.primary-button { background: var(--navy); color: #fff; box-shadow: 0 6px 14px rgba(23, 50, 77, .16); }
.primary-button:hover { background: var(--navy-2); transform: translateY(-1px); }
.secondary-button { border-color: var(--line); background: #fff; color: #4d6377; }
.secondary-button:hover { border-color: #b9c5d2; color: var(--navy); background: var(--surface-soft); }
.danger-button { border-color: #f1c8c1; background: #fff8f6; color: var(--red-dark); }
.danger-button:hover { background: #fbe8e3; }
.button-link { text-decoration: none; }
.full-button { width: 100%; }
.flash-stack { margin-bottom: 20px; }
.flash, .form-error { padding: 12px 14px; border: 1px solid #efc4bc; border-radius: 10px; background: #fff4f1; color: #9e3d2d; font-size: 13px; }

/* Login */
.login-layout { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; min-height: calc(100vh - 220px); max-width: 520px; margin: 0 auto; }
.login-copy { width: 100%; max-width: 390px; padding: 0; }
.login-copy p { max-width: none; margin: 0; color: #697b8c; font-size: 14px; line-height: 1.9; }
.login-note { display: flex; align-items: center; gap: 8px; margin-top: 22px; color: #718091; font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #45ae78; box-shadow: 0 0 0 4px #e0f2e8; }
.login-card { width: 100%; max-width: 390px; padding: 35px; border: 1px solid rgba(26, 56, 79, .1); border-radius: 20px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); }
.card-kicker { color: var(--red); font-size: 10px; font-weight: 700; letter-spacing: .2em; }
.login-card h2 { margin: 9px 0 23px; color: var(--navy); font-family: "Songti SC", "STSong", serif; font-size: 28px; }
.login-card .form-error { margin-bottom: 15px; }
.login-help { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

/* Editor */
.type-switcher { display: inline-flex; gap: 4px; margin-bottom: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.65); }
.type-tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 15px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.type-tab span { color: #acb5c0; font-size: 11px; }
.type-tab:hover { color: var(--navy); }
.type-tab.active { background: var(--navy); color: #fff; box-shadow: 0 4px 10px rgba(23,50,77,.16); }
.type-tab.active span { color: #d1e2ef; }
.editor-grid { display: grid; grid-template-columns: minmax(500px, 1.07fr) minmax(450px, .93fr); gap: 22px; align-items: start; }
.editor-panel, .preview-panel, .filter-card, .history-card { min-width: 0; border: 1px solid rgba(36, 61, 82, .1); border-radius: var(--radius); background: rgba(255,255,255,.86); box-shadow: 0 8px 28px rgba(34, 52, 68, .045); }
.editor-panel { padding: 25px 25px 21px; }
.panel-heading, .history-card-head, .preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.panel-heading > div, .history-card-head > div, .preview-toolbar > div { display: flex; align-items: center; gap: 10px; }
.panel-heading h2, .history-card h2, .preview-toolbar h2 { margin: 0; color: var(--navy); font-size: 16px; letter-spacing: .03em; }
.section-index { color: var(--red); font-size: 10px; font-weight: 750; letter-spacing: .13em; }
.auto-badge, .preview-status { padding: 5px 8px; border-radius: 20px; color: #5a9677; background: #eaf6ef; font-size: 10px; }
.field-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 13px; margin: 21px 0 12px; }
.field-grid.three-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-fields { margin-top: 12px; }
.field { display: block; }
.field > span, .filter-group label { display: block; margin-bottom: 7px; color: #748292; font-size: 11px; }
.field input, .field select, .filter-group input, .filter-group select { width: 100%; height: 39px; padding: 0 11px; border: 1px solid #dbe2e9; border-radius: 8px; outline: none; color: var(--ink); background: #fbfcfd; font-size: 13px; transition: border-color .2s ease, box-shadow .2s ease; }
.field input:focus, .field select:focus, .filter-group input:focus, .filter-group select:focus, .item-editor-table input:focus { border-color: #819bb2; box-shadow: 0 0 0 3px rgba(83, 125, 155, .1); background: #fff; }
.field > span i { color: var(--red); font-style: normal; }
.store-recovery-fields { margin-top: 12px; margin-bottom: 0; }
.store-recovery-fields select:disabled { color: #aeb8c1; background: #f5f7f8; cursor: not-allowed; }
.creator-line { display: flex; align-items: center; gap: 7px; margin: 17px 0 26px; color: #667a8d; font-size: 11px; }
.creator-line strong { color: var(--navy); font-weight: 650; }
.line-hint { margin-left: auto; color: #a1acb8; }
.payment-fields { grid-template-columns: minmax(180px, .7fr) minmax(280px, 1.3fr); margin-top: 12px; margin-bottom: 0; }
.payment-fields select:disabled, .payment-fields input:disabled { color: #aeb8c1; background: #f5f7f8; cursor: not-allowed; }
.replacement-option { display: inline-flex; align-items: center; gap: 7px; margin: 1px 0 4px; color: var(--navy); font-size: 12px; cursor: pointer; }
.replacement-option input { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); }
.replacement-option small { color: #8c9aa6; font-size: 10px; }
.item-heading { margin-bottom: 14px; }
.row-counter { color: #8996a3; font-size: 11px; }
.pricing-mode-panel { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin: -2px 0 13px; padding: 11px 13px; border: 1px solid #e2e8ed; border-radius: 9px; background: #f9fbfc; }
.pricing-mode-copy { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.pricing-mode-copy strong { color: var(--navy); font-size: 12px; white-space: nowrap; }
.pricing-mode-copy span { color: #8996a3; font-size: 10px; }
.pricing-mode-options { display: flex; flex-wrap: wrap; gap: 7px; }
.pricing-mode-option { display: inline-flex; align-items: center; gap: 5px; padding: 6px 8px; border: 1px solid #dce4ea; border-radius: 7px; color: #5d7182; background: #fff; font-size: 10px; cursor: pointer; white-space: nowrap; }
.pricing-mode-option:has(input:checked) { border-color: #93acbf; color: var(--navy); background: #eef5f9; }
.pricing-mode-option input { margin: 0; accent-color: var(--navy); }
.item-editor-wrap { overflow: visible; border: 1px solid #e1e6eb; border-radius: 10px; }
.item-editor-table { width: 100%; min-width: 660px; border-collapse: collapse; table-layout: fixed; }
.item-editor-table th { height: 39px; padding: 0 7px; border-bottom: 1px solid #dbe2e9; color: #6e7c8c; background: #f7f9fb; font-size: 11px; font-weight: 650; text-align: left; white-space: nowrap; }
.item-editor-table th i { color: var(--red); font-style: normal; }
.item-editor-table td { height: 48px; padding: 5px 5px; border-bottom: 1px solid #edf0f3; }
.item-editor-table tr:last-child td { border-bottom: 0; }
.item-editor-table th:nth-child(1), .item-editor-table td:nth-child(1) { width: 32px; text-align: center; }
.item-editor-table th:nth-child(2), .item-editor-table td:nth-child(2) { width: 25%; }
.item-editor-table th:nth-child(3), .item-editor-table td:nth-child(3) { width: 17%; }
.item-editor-table th:nth-child(4), .item-editor-table td:nth-child(4) { width: 13%; }
.item-editor-table th:nth-child(5), .item-editor-table td:nth-child(5) { width: 20%; }
.item-editor-table th:nth-child(6), .item-editor-table td:nth-child(6) { width: 12%; }
.item-editor-table th:nth-child(7), .item-editor-table td:nth-child(7) { width: 28px; }
.item-editor-table td.line-no { color: #a5afba; font-size: 11px; }
.item-editor-table input { width: 100%; min-width: 0; height: 33px; padding: 0 7px; border: 1px solid transparent; border-radius: 6px; outline: none; color: var(--ink); background: transparent; font-size: 12px; }
.item-editor-table input:hover { border-color: #e1e7ec; background: #fbfcfd; }
.item-editor-table input:disabled { color: #aeb8c1; background: #f5f7f8; cursor: not-allowed; }
.item-editor-table input::placeholder { color: #b6bec7; }
.calculated-cell { color: var(--navy); font-size: 12px; white-space: nowrap; }
.delete-row { width: 24px; height: 24px; border: 0; border-radius: 50%; color: #9aa7b2; background: transparent; font-size: 18px; line-height: 1; }
.delete-row:hover { color: var(--red); background: #fff1ed; }
.model-picker { position: relative; }
.suggestions { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; display: none; max-height: 260px; overflow-x: hidden; overflow-y: auto; border: 1px solid #d7e0e9; border-radius: 9px; background: #fff; box-shadow: 0 12px 25px rgba(32, 50, 69, .16); }
.suggestions.open { display: block; }
.suggestion { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 9px 10px; border: 0; border-bottom: 1px solid #eef2f5; color: var(--ink); background: #fff; text-align: left; }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover { background: #f5f8fb; }
.suggestion strong { font-size: 12px; font-weight: 650; }
.suggestion small { color: #a0abb6; font-size: 9px; }
.suggestion-empty { padding: 12px; color: #8a97a4; font-size: 11px; }
.editor-bottom { display: flex; align-items: center; gap: 12px; margin: 12px 2px 18px; color: #9aa5b0; font-size: 11px; }
.add-row-button { padding: 0; border: 0; color: var(--red); background: transparent; font-size: 12px; font-weight: 650; }
.add-row-button:hover { color: var(--red-dark); }
.manual-total-field { display: grid; grid-template-columns: auto minmax(180px, 260px) 1fr; align-items: center; gap: 10px; margin: -3px 0 17px; color: #748292; font-size: 11px; }
.manual-total-field > span { white-space: nowrap; }
.manual-total-input { display: flex; align-items: center; height: 39px; padding-left: 11px; border: 1px solid #dbe2e9; border-radius: 8px; background: #fbfcfd; }
.manual-total-input:focus-within { border-color: #819bb2; box-shadow: 0 0 0 3px rgba(83, 125, 155, .1); background: #fff; }
.manual-total-input b { color: var(--navy); font-size: 14px; font-weight: 500; }
.manual-total-input input { width: 100%; height: 37px; padding: 0 10px 0 5px; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.manual-total-field small { color: #9aa5b0; font-size: 10px; }
.submit-bar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-top: 17px; border-top: 1px solid #e9edf0; }
.total-caption { display: block; margin-bottom: 3px; color: #8995a1; font-size: 10px; }
.submit-bar strong { color: var(--navy); font-size: 22px; letter-spacing: .02em; }
.submit-bar .primary-button span { margin-left: 11px; font-size: 18px; line-height: 0; }
.client-error { min-height: 18px; margin-top: 11px; color: var(--red-dark); font-size: 12px; }

/* Preview paper */
.preview-panel { min-width: 0; overflow: hidden; }
.preview-toolbar { padding: 18px 20px; border-bottom: 1px solid #e8ecef; }
.preview-scroll { overflow: auto; padding: 22px; background: #eef1f3; }
.paper-mount { width: 100%; max-width: 930px; margin: 0 auto; }
.paper { position: relative; width: 100%; min-height: 650px; padding: 10px; background: #fff; box-shadow: 0 9px 25px rgba(29,44,57,.17); color: #25282d; }
.paper-inner { position: relative; min-height: 630px; height: 100%; padding: 27px 30px 23px; border: 1px solid #8c8e91; font-family: "Songti SC", "STSong", "SimSun", serif; }
.paper-title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; position: relative; min-height: 42px; column-gap: 12px; }
.paper-title-row h2 { min-width: 0; margin: 0; color: #252525; font-family: "Songti SC", "STSong", serif; font-size: clamp(16px, 1.7vw, 30px); font-weight: 700; letter-spacing: .11em; text-align: center; white-space: nowrap; }
.paper-no { position: static; justify-self: end; color: #333; font-family: Arial, sans-serif; font-size: 15px; white-space: nowrap; }
.paper-no strong { margin-left: 4px; color: #c64e32; font-size: 25px; font-weight: 500; letter-spacing: .03em; }
.paper-party { display: flex; align-items: baseline; gap: 5px; min-height: 34px; margin-top: 5px; font-size: 15px; }
.paper-party b { display: inline-block; min-width: 180px; border-bottom: 1px solid #555; font-weight: 400; }
.paper-party.inbound-party { gap: 3px; font-size: 11px; white-space: nowrap; }
.paper-party.inbound-party b { min-width: 72px; }
.paper-date { position: absolute; right: 30px; top: 83px; color: #333; font-size: 15px; letter-spacing: .08em; }
.paper-table { width: 100%; margin-top: 5px; border-collapse: collapse; table-layout: fixed; font-size: 13px; }
.paper-table th, .paper-table td { height: 42px; padding: 4px 5px; border: 1px solid var(--paper-line); vertical-align: middle; }
.paper-table thead th { height: 42px; background: #fff; font-size: 15px; font-weight: 700; text-align: center; }
.paper-table th:nth-child(1), .paper-table td:nth-child(1) { width: 27%; }
.paper-table th:nth-child(2), .paper-table td:nth-child(2) { width: 20%; }
.paper-table th:nth-child(3), .paper-table td:nth-child(3) { width: 14%; }
.paper-table th:nth-child(4), .paper-table td:nth-child(4) { width: 19%; }
.paper-table th:nth-child(5), .paper-table td:nth-child(5) { width: 20%; }
.paper-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-table .model-cell, .paper-table .serial-cell, .paper-table .remark-cell { text-align: left; }
.paper-table .price-cell { text-align: right; font-family: Arial, sans-serif; }
.paper-table .amount-grid-cell { padding: 0; overflow: visible; text-align: center; white-space: normal; }
.amount-grid-heading { padding: 0 !important; vertical-align: top !important; }
.amount-grid-title { display: block; height: 18px; line-height: 18px; }
.amount-grid-units, .amount-grid-values { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); width: 100%; }
.amount-grid-units { height: 23px; border-top: 1px solid var(--paper-line); }
.amount-grid-units span, .amount-grid-values span { display: flex; align-items: center; justify-content: center; min-width: 0; border-left: 1px solid var(--paper-line); font-family: Arial, "Microsoft YaHei", sans-serif; font-size: 10px; }
.amount-grid-units span:first-child, .amount-grid-values span:first-child { border-left: 0; }
.amount-grid-values { min-height: 41px; height: 100%; }
.amount-grid-values span { font-size: 12px; }
.paper-table tfoot th { height: 44px; font-size: 18px; text-align: center; }
.paper-total { display: grid; grid-template-columns: 22% minmax(0, 1fr); min-height: 45px; padding: 0; border: 1px solid var(--paper-line); border-top: 0; overflow: hidden; }
.paper-total-label { display: flex; align-items: center; min-width: 0; padding: 8px 9px; font-size: 16px; font-weight: 700; white-space: nowrap; }
.paper-total-upper { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); align-items: stretch; min-width: 0; margin: 0; padding: 6px 4px; overflow: hidden; }
.paper-total-slot { position: relative; min-width: 0; min-height: 2em; white-space: nowrap; }
.paper-total-digit, .paper-total-unit { position: absolute; top: 50%; display: block; font-size: 20px; line-height: 1; transform: translateY(-50%); }
.paper-total-digit { right: calc(50% + .9em); width: 1em; font-weight: 400; text-align: center; }
.paper-total-unit { left: 50%; font-weight: 400; transform: translate(-50%, -50%); }
.paper-legal { min-height: 43px; padding: 7px 9px; border: 1px solid var(--paper-line); border-top: 0; color: #333; font-size: 10px; line-height: 1.55; }
.paper-legal.inbound-legal { font-size: 9px; line-height: 1.45; }
.paper-signatures { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 13px; font-size: 14px; }
.paper-signatures span { white-space: nowrap; }
.paper-signatures b { font-weight: 400; }
.stamp-blank { display: inline-block; width: 52px; height: 30px; vertical-align: middle; border: 1px dashed #c6c9cc; border-radius: 50%; }
.paper-address { margin-top: 9px; color: #333; font-family: Arial, "Microsoft YaHei", sans-serif; font-size: 11px; line-height: 1.55; }
.paper-signature-confirm { margin-top: 12px; font-size: 15px; font-weight: 700; text-align: center; }
.paper-signature-confirm span { display: inline-flex; align-items: flex-start; justify-content: center; width: 45%; height: 28px; padding: 0 4px 6px; vertical-align: middle; border-bottom: 1px solid #555; line-height: 1.15; }
.paper-inbound .paper-signature-confirm { position: relative; left: 8%; }
.paper-creator { position: absolute; right: 30px; bottom: 13px; color: #9a9da1; font-family: Arial, "Microsoft YaHei", sans-serif; font-size: 9px; }
.paper-inbound .paper-date { position: static; height: 18px; margin: 0; text-align: right; line-height: 18px; }
.inbound-signatures { margin-top: 17px; }
.saved-papers { display: grid; gap: 26px; }
.saved-paper-mount { max-width: 1120px; }
.saved-payment { margin: 0 0 21px; padding: 17px 20px; border: 1px solid #dfe7ec; border-radius: 12px; background: rgba(255,255,255,.82); }
.saved-payment-heading { display: flex; align-items: center; gap: 10px; }
.saved-payment-heading h2 { margin: 0; color: var(--navy); font-size: 15px; }
.saved-payment-heading > span:last-child { margin-left: auto; color: #8b9aa7; font-size: 10px; }
.saved-payment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; margin-top: 14px; }
.saved-payment-grid > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.saved-payment-grid span { color: #8997a4; font-size: 11px; }
.saved-payment-grid strong { overflow-wrap: anywhere; color: var(--navy); font-size: 14px; font-weight: 600; }
.attachment-ready { color: #2f8d68 !important; }
.attachment-pending { color: #b44d3b !important; }
.void-editor { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; width: 100%; margin-top: 10px; }
.void-editor[hidden] { display: none; }
.void-editor label { display: flex; flex: 1 1 280px; flex-direction: column; gap: 5px; color: #71808d; font-size: 11px; }
.void-editor input { width: 100%; min-height: 39px; padding: 0 11px; border: 1px solid #e0b3aa; border-radius: 8px; background: #fff; color: #29343d; font: inherit; outline: none; }
.void-editor input:focus { border-color: #c64e32; box-shadow: 0 0 0 3px rgba(198,78,50,.12); }
.void-editor-actions { display: flex; gap: 8px; }
.void-editor-actions button { min-height: 39px; }
.void-error { flex-basis: 100%; min-height: 17px; margin: 0; color: #a84535; font-size: 11px; }
.heading-number { color: var(--red); font-family: Arial, sans-serif; font-size: .52em; font-weight: 500; letter-spacing: .03em; }
.saved-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: -8px 0 21px; }
.api-hint { color: #8997a4; font-size: 11px; }
.api-hint code { color: #596d80; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.void-banner { margin-bottom: 19px; padding: 12px 15px; border: 1px solid #f0c9c0; border-radius: 9px; background: #fff4f1; color: #a84535; font-size: 13px; }
.modal-open { overflow: hidden; }
.submit-confirm-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.submit-confirm-modal[hidden] { display: none; }
.submit-confirm-backdrop { position: absolute; inset: 0; background: rgba(23, 50, 77, .42); backdrop-filter: blur(4px); }
.submit-confirm-dialog { position: relative; width: min(100%, 470px); padding: 28px; border: 1px solid rgba(23, 50, 77, .12); border-radius: 18px; background: #fff; box-shadow: 0 24px 70px rgba(20, 39, 56, .24); }
.submit-confirm-close { position: absolute; top: 10px; right: 13px; width: 30px; height: 30px; border: 0; border-radius: 50%; color: #8492a0; background: transparent; font-size: 24px; line-height: 1; }
.submit-confirm-close:hover { color: var(--navy); background: #f3f6f8; }
.submit-confirm-dialog h2 { margin: 8px 0 5px; color: var(--navy); font-family: "Songti SC", "STSong", serif; font-size: 25px; }
.submit-confirm-type { margin: 0 0 20px; color: #718395; font-size: 12px; }
.submit-confirm-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 14px; border: 1px solid #e2e9ee; border-radius: 11px; background: #f8fafb; }
.submit-confirm-summary > div { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.submit-confirm-summary span { color: #8997a4; font-size: 10px; }
.submit-confirm-summary strong { overflow-wrap: anywhere; color: var(--navy); font-size: 13px; font-weight: 650; }
.submit-confirm-summary .submit-confirm-total { color: var(--red-dark); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 17px; }
.submit-confirm-uppercase { grid-column: 1 / -1; padding-top: 10px; border-top: 1px solid #e3e9ed; }
.submit-modal-error { min-height: 18px; margin: 11px 0 0; color: var(--red-dark); font-size: 12px; }
.submit-confirm-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 10px; }
.submit-confirm-actions .primary-button span { margin-left: 8px; font-size: 17px; line-height: 0; }

/* History */
.filter-card { display: grid; grid-template-columns: minmax(190px, 1.7fr) repeat(5, minmax(115px, 1fr)) auto; gap: 12px; align-items: end; padding: 17px; margin-bottom: 20px; }
.filter-group label { margin-bottom: 5px; }
.filter-submit { height: 39px; min-height: 39px; padding: 0 15px; }
.history-card { overflow: hidden; }
.history-card-head { padding: 19px 21px; border-bottom: 1px solid #e8edf0; }
.muted-text { color: #9aa6b1; font-size: 11px; }
.history-table-wrap { overflow-x: auto; }
.history-table { width: 100%; min-width: 900px; border-collapse: collapse; }
.history-table th { padding: 11px 14px; color: #7b8997; background: #f8fafb; font-size: 11px; font-weight: 650; text-align: left; white-space: nowrap; }
.history-table td { padding: 14px; border-top: 1px solid #edf1f3; color: #536678; font-size: 12px; white-space: nowrap; }
.history-table tbody tr:hover { background: #fcfdfd; }
.bill-link { display: block; color: var(--navy); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 650; }
.part-label { display: block; margin-top: 4px; color: #a1acb5; font-size: 10px; }
.type-pill, .status-pill { display: inline-flex; align-items: center; padding: 4px 7px; border-radius: 20px; font-size: 10px; }
.type-sale { color: #9c5d32; background: #fff0df; }
.type-outbound { color: #346f9a; background: #e8f3fb; }
.type-inbound { color: #48785a; background: #eaf7ee; }
.status-submitted { color: #33805d; background: #eaf7ef; }
.status-voided { color: #a34838; background: #ffede9; }
.money-cell { color: var(--navy) !important; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px 11px; min-width: 150px; }
.row-actions a { color: var(--red); font-size: 11px; }
.row-actions a:hover { text-decoration: underline; }
.replacement-pill { display: inline-flex; margin-left: 5px; padding: 3px 6px; border-radius: 20px; color: #96612d; background: #fff1dc; font-size: 9px; }
.empty-state { padding: 68px 20px 78px; text-align: center; }
.empty-icon { color: #b7c2cb; font-size: 40px; }
.empty-state h3 { margin: 11px 0 7px; color: var(--navy); font-family: "Songti SC", serif; font-size: 20px; }
.empty-state p { margin: 0 0 19px; color: #8997a4; font-size: 12px; }
.paper-uploads { margin-top: 26px; padding: 19px 21px; border: 1px solid rgba(36, 61, 82, .1); border-radius: var(--radius); background: rgba(255,255,255,.86); box-shadow: 0 8px 28px rgba(34, 52, 68, .045); }
.paper-uploads-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.paper-uploads-heading > div { display: flex; align-items: center; gap: 10px; }
.paper-uploads-heading h2 { margin: 0; color: var(--navy); font-size: 16px; }
.paper-uploads-heading > span { color: #8997a4; font-size: 10px; }
.paper-upload-form { display: flex; align-items: center; gap: 10px; margin-top: 15px; }
.paper-upload-form input[type="file"] { min-width: 0; flex: 1; color: #637588; font-size: 12px; }
.paper-upload-name { max-width: 220px; overflow: hidden; color: #8997a4; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.paper-upload-error { min-height: 17px; margin: 9px 0 0; color: var(--red-dark); font-size: 11px; }
.paper-upload-empty { margin: 11px 0 0; color: #9aa6b1; font-size: 11px; }
.paper-upload-list { display: grid; gap: 8px; margin-top: 10px; }
.paper-upload-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid #e5ebef; border-radius: 9px; background: #fbfcfd; }
.paper-upload-item > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.paper-upload-item strong { color: var(--navy); font-size: 12px; }
.paper-upload-item span { overflow: hidden; color: #8997a4; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.paper-upload-item .secondary-button { min-height: 32px; padding: 0 12px; font-size: 11px; }
.machine-photo-uploads { border-color: rgba(47, 137, 104, .2); }
.machine-photo-uploads .section-index { color: #2f8968; }

@media (max-width: 1120px) {
  .editor-grid { grid-template-columns: 1fr; }
  .preview-panel { order: 2; }
  .preview-scroll { padding: 16px; }
  .filter-card { grid-template-columns: repeat(3, 1fr); }
  .search-filter { grid-column: span 2; }
  .filter-submit { width: 100%; }
}
@media (max-width: 720px) {
  .topbar { height: 64px; padding: 0 18px; gap: 15px; }
  .brand { min-width: auto; }
  .brand small, .topnav { display: none; }
  .user-menu { margin-left: auto; gap: 8px; }
  .user-chip { max-width: 82px; overflow: hidden; text-overflow: ellipsis; }
  .page-shell { width: min(100% - 28px, 600px); padding: 27px 0 45px; }
  .workspace-head { align-items: flex-start; flex-direction: column; gap: 15px; margin-bottom: 18px; }
  .workspace-head h1 { font-size: 31px; }
  .head-actions { width: 100%; }
  .head-actions .secondary-button, .head-actions .primary-button { flex: 1; }
  .type-switcher { display: flex; width: 100%; }
  .type-tab { flex: 1; justify-content: center; padding: 9px 5px; font-size: 12px; }
  .editor-panel { padding: 18px 13px 16px; border-radius: 13px; }
  .panel-heading h2 { font-size: 15px; }
  .field-grid.three-fields { grid-template-columns: 1fr; gap: 10px; }
  .compact-fields { display: grid; grid-template-columns: repeat(3, 1fr) !important; gap: 7px !important; }
  .compact-fields .field > span { white-space: nowrap; font-size: 10px; }
  .payment-fields { grid-template-columns: 1fr; gap: 10px; }
  .line-hint { display: none; }
  .pricing-mode-panel { align-items: stretch; flex-direction: column; gap: 8px; margin-top: -1px; }
  .pricing-mode-copy { align-items: flex-start; flex-direction: column; gap: 3px; }
  .pricing-mode-options { width: 100%; }
  .pricing-mode-option { flex: 1; justify-content: center; }
  .item-editor-wrap { overflow: visible; }
  .item-editor-table { min-width: 0; width: 100%; }
  .item-editor-table th:nth-child(1), .item-editor-table td:nth-child(1) { width: 4%; }
  .item-editor-table th:nth-child(2), .item-editor-table td:nth-child(2) { width: 25%; }
  .item-editor-table th:nth-child(3), .item-editor-table td:nth-child(3) { width: 18%; }
  .item-editor-table th:nth-child(4), .item-editor-table td:nth-child(4) { width: 14%; }
  .item-editor-table th:nth-child(5), .item-editor-table td:nth-child(5) { width: 23%; }
  .item-editor-table th:nth-child(6), .item-editor-table td:nth-child(6) { width: 13%; }
  .item-editor-table th:nth-child(7), .item-editor-table td:nth-child(7) { width: 3%; }
  .item-editor-table th { padding: 0 2px; font-size: 9px; }
  .item-editor-table td { padding: 3px 1px; }
  .item-editor-table input { padding: 0 3px; font-size: 9px; }
  .calculated-cell { font-size: 9px; }
  .manual-total-field { grid-template-columns: 1fr; gap: 5px; margin-top: -3px; }
  .manual-total-input { width: 100%; }
  .delete-row { width: 19px; height: 19px; font-size: 14px; }
  .suggestions { right: auto; width: min(300px, calc(100vw - 42px)); max-height: 230px; }
  .suggestion { padding: 8px 9px; }
  .suggestion strong { font-size: 11px; }
  .submit-bar { align-items: stretch; flex-direction: column; }
  .submit-bar .primary-button { width: 100%; }
  .preview-toolbar { padding: 15px; }
  .preview-scroll { padding: 10px 4px; }
  .paper { min-height: 490px; padding: 5px; }
  .paper-inner { min-height: 480px; padding: 17px 12px 16px; }
  .paper-title-row h2 { font-size: 16px; letter-spacing: .11em; }
  .paper-no { top: -1px; font-size: 9px; }
  .paper-no strong { font-size: 13px; }
  .paper-date { right: 12px; top: 55px; font-size: 9px; }
  .paper-inbound .paper-date { right: auto; top: auto; height: 14px; line-height: 14px; font-size: 9px; }
  .paper-party { min-height: 27px; font-size: 9px; }
  .paper-party b { min-width: 90px; }
  .paper-party.inbound-party { gap: 1px; font-size: 6px; }
  .paper-party.inbound-party b { min-width: 35px; }
  .paper-table { margin-top: 2px; font-size: 8px; }
  .paper-table th, .paper-table td { height: 31px; padding: 2px; }
  .paper-table thead th { height: 31px; font-size: 9px; }
  .paper-table tfoot th { height: 32px; font-size: 10px; }
  .amount-grid-title { height: 12px; line-height: 12px; }
  .amount-grid-units { height: 17px; }
  .amount-grid-units span, .amount-grid-values span { font-size: 6px; }
  .amount-grid-values { min-height: 29px; }
  .paper-total { min-height: 31px; }
  .paper-total-label { padding: 4px; font-size: 9px; }
  .paper-total-upper { padding: 4px 2px; }
  .paper-total-slot { min-height: 2em; }
  .paper-total-digit, .paper-total-unit { font-size: 10px; }
  .paper-total-digit { right: calc(50% + .9em); }
  .paper-legal { min-height: 34px; padding: 4px; font-size: 6px; }
  .paper-legal.inbound-legal { font-size: 5px; }
  .paper-signatures { gap: 4px; margin-top: 7px; font-size: 7px; }
  .stamp-blank { width: 23px; height: 15px; }
  .paper-address { margin-top: 4px; font-size: 6px; }
  .paper-signature-confirm { margin-top: 6px; font-size: 8px; }
  .paper-signature-confirm span { height: 15px; padding: 0 1px 3px; }
  .paper-inbound .paper-signature-confirm { left: 8%; }
  .paper-creator { right: 12px; bottom: 6px; font-size: 5px; }
  .filter-card { grid-template-columns: repeat(2, 1fr); padding: 13px; }
  .search-filter { grid-column: span 2; }
  .filter-submit { grid-column: span 2; }
  .history-card-head { padding: 16px; }
  .saved-actions { align-items: flex-start; flex-direction: column; gap: 10px; }
  .saved-payment { padding: 15px; }
  .saved-payment-heading { align-items: flex-start; flex-wrap: wrap; }
  .saved-payment-heading > span:last-child { width: 100%; margin-left: 0; }
  .saved-payment-grid { grid-template-columns: 1fr; gap: 10px; }
  .paper-uploads { padding: 15px; }
  .paper-uploads-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .paper-upload-form { align-items: stretch; flex-direction: column; }
  .paper-upload-form .primary-button { width: 100%; }
  .paper-upload-name { max-width: none; }
  .paper-upload-item { align-items: stretch; flex-direction: column; }
  .paper-upload-item .secondary-button { width: 100%; }
  .void-editor { align-items: stretch; flex-direction: column; gap: 8px; }
  .void-editor-actions { width: 100%; }
  .void-editor-actions button { flex: 1; }
  .api-hint { overflow-wrap: anywhere; }
  .submit-confirm-dialog { padding: 24px 18px 18px; border-radius: 15px; }
  .submit-confirm-actions { flex-direction: column-reverse; }
  .submit-confirm-actions button { width: 100%; }
}

@media print {
  @page { size: A4 landscape; margin: 0; }
  html, body { width: 100%; min-height: 100%; background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { color: #000; }
  .no-print, .topbar, .page-shell > .workspace-head, .saved-actions, .void-banner { display: none !important; }
  .page-shell { width: 100%; margin: 0; padding: 0; }
  .editor-grid { display: block; }
  .editor-panel { display: none !important; }
  .preview-panel, .saved-papers { display: block; border: 0; box-shadow: none; background: #fff; }
  .preview-panel { width: 100%; }
  .preview-scroll { overflow: visible; padding: 0; background: #fff; }
  .paper-mount, .saved-paper-mount { width: 100%; max-width: none; margin: 0; }
  .paper { width: 100%; height: 100vh; min-height: 0; padding: 8mm; box-shadow: none; page-break-after: always; }
  .paper:last-child { page-break-after: auto; }
  .paper-inner { min-height: calc(100vh - 16mm); padding: 7mm 8mm 6mm; }
  .paper-title-row h2 { font-size: 24px; }
  .paper-no { font-size: 14px; }
  .paper-no strong { font-size: 24px; }
  .paper-party { font-size: 13px; }
  .paper-date { top: 21mm; right: 8mm; font-size: 13px; }
  .paper-table { margin-top: 2mm; font-size: 12px; }
  .paper-table th, .paper-table td { height: 12mm; }
  .paper-table thead th { height: 12mm; font-size: 13px; }
  .paper-table tfoot th { height: 12mm; font-size: 15px; }
  .amount-grid-title { height: 5mm; line-height: 5mm; }
  .amount-grid-units { height: 7mm; }
  .amount-grid-units span, .amount-grid-values span { font-size: 9px; }
  .amount-grid-values { min-height: 11mm; }
  .paper-total { min-height: 12mm; }
  .paper-total-label { padding: 2mm; font-size: 14px; }
  .paper-total-upper { padding: 1.5mm 1mm; }
  .paper-total-slot { min-height: 7mm; }
  .paper-total-digit, .paper-total-unit { font-size: 15px; }
  .paper-total-digit { right: calc(50% + .9em); }
  .paper-legal { min-height: 12mm; font-size: 9px; }
  .paper-legal.inbound-legal { font-size: 8px; }
  .paper-signatures { margin-top: 4mm; font-size: 12px; }
  .paper-address { font-size: 10px; }
  .paper-inbound .paper-date { right: auto; top: auto; height: 6mm; line-height: 6mm; text-align: right; font-size: 13px; }
  .paper-signature-confirm { margin-top: 4mm; font-size: 13px; }
  .paper-signature-confirm span { height: 8mm; padding: 0 1mm 2mm; }
  .paper-inbound .paper-signature-confirm { left: 8%; }
}
