* { box-sizing: border-box; }
body { margin: 0; background: var(--color-canvas); color: var(--color-text); font-size: 14px; line-height: 1.6; }
button, a, input, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.page-shell { width: min(1480px, 100%); margin: 0 auto; padding: 28px 40px 56px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; gap: 10px; align-items: center; font-size: 17px; font-weight: 750; text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.back-link { padding: 8px 0 8px 10px; color: var(--color-text-muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--color-text); text-decoration: underline; }
.intro { margin: 46px 0 30px; }
.eyebrow { margin: 0 0 10px; font-size: var(--type-meta); letter-spacing: .16em; font-weight: 700; color: var(--color-text-muted); }
h1 { margin: 0; font-size: clamp(32px, 4vw, 48px); line-height: 1.2; letter-spacing: -.05em; font-weight: var(--weight-heading); }
.intro > p:last-child { margin: 14px 0 0; font-size: 15px; color: var(--color-text-muted); }
.workspace { border: 1px solid var(--color-border); border-radius: 12px; background: var(--color-surface); overflow: hidden; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 24px; border-bottom: 1px solid var(--color-border); }
.document-state { display: flex; flex-direction: column; gap: 4px; }
.document-state strong { font-size: 16px; }
#save-status { color: var(--color-text-muted); font-size: 12px; }
#save-status[data-error="true"] { color: var(--color-danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button, .row-controls button { border: 1px solid var(--color-border); border-radius: 6px; background: var(--color-control); color: var(--color-text); padding: 9px 14px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.actions button:hover, .row-controls button:hover { border-color: var(--color-text-muted); background: var(--color-accent-soft); }
.actions .primary { background: var(--color-text); color: var(--color-canvas); border-color: var(--color-text); }
.actions .primary:hover { background: var(--color-text-strong); color: var(--color-canvas); }
.actions button[aria-pressed="true"] { background: var(--color-accent-soft); border-color: var(--color-accent); }
.editor-note, .workspace-footnote { margin: 0; padding: 14px 24px; font-size: 12px; color: var(--color-text-muted); }
.workspace-footnote { border-top: 1px solid var(--color-border); }
.error-message { margin: 0 24px 14px; padding: 10px 14px; background: var(--color-danger-soft); border-left: 3px solid var(--color-danger); color: var(--color-danger); }
.paper-scroll { max-width: 100%; overflow: auto; padding: 8px 24px 24px; }
.quotation-paper { min-width: 1040px; padding: 32px 28px 28px; background: var(--color-paper); color: var(--color-text); box-shadow: 0 2px 12px var(--color-shadow); }
.document-heading { text-align: center; margin-bottom: 16px; }
.company-title { max-width: 760px; margin: 0 auto; font-size: 23px; font-weight: 700; }
.company-title textarea { text-align: center; }
.document-heading h2 { font-size: 26px; font-weight: 650; letter-spacing: .24em; margin: 12px 0 0; }
.parties { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--color-text-muted); border-bottom: 0; }
.party { padding: 10px 12px; }
.party + .party { border-left: 1px solid var(--color-text-muted); }
.detail-field { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 4px; }
.party .detail-field { grid-template-columns: 4em minmax(0, 1fr); }
.detail-field > label { padding-top: 7px; white-space: nowrap; }
.document-meta input { max-width: 210px; }
.document-meta { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 8px 12px; border: 1px solid var(--color-text-muted); border-bottom: 0; }
.editable { min-width: 0; }
.editable input, .editable textarea { display: block; width: 100%; min-width: 0; border: 1px solid transparent; border-bottom-color: var(--color-border); border-radius: 3px; padding: 6px 5px; background: transparent; color: inherit; line-height: 1.6; font-size: inherit; font-weight: inherit; }
.editable textarea { resize: none; overflow: hidden; min-height: 35px; }
.editable input { height: 35px; }
.editable input::placeholder, .editable textarea::placeholder { font-size: 12px; font-weight: 400; color: var(--color-text-muted); }
.party .editable input::placeholder, .party .editable textarea::placeholder { font-size: inherit; }
.editable input:hover, .editable textarea:hover { background: var(--color-surface); border-color: var(--color-border); }
.editable input:focus, .editable textarea:focus { outline: 2px solid var(--color-accent); outline-offset: 0; background: var(--color-control); border-color: transparent; }
.editable input[aria-invalid="true"] { border-color: var(--color-danger); background: var(--color-danger-soft); }
.field-text { display: none; overflow-wrap: anywhere; white-space: pre-wrap; min-height: 1.6em; padding: 6px 5px; }
.items-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 12px; }
.items-table th, .items-table td { border: 1px solid var(--color-text-muted); padding: 5px 3px; vertical-align: top; }
.items-table th { text-align: center; vertical-align: middle; font-weight: 650; background: var(--color-surface); }
.items-table tbody td { padding-top: 10px; padding-bottom: 10px; vertical-align: middle; text-align: center; }
.items-table .editable input, .items-table .editable textarea { text-align: center; }
.items-table td:nth-child(4), .items-table td:nth-child(4) textarea { text-align: left; }
.items-table .editable input, .items-table .editable textarea, .items-table .field-text { padding: 5px 3px; }
.col-index { width: 4%; }.col-code { width: 12%; }.col-name { width: 10%; }.col-spec { width: 20%; }.col-material { width: 13%; }.col-color { width: 8%; }.col-unit { width: 8%; }.col-price { width: 11%; }.col-remark { width: 14%; }
.row-number { display: block; text-align: center; padding: 5px 0 12px; }
.delete-item { display: block; margin: 0 auto; border: 0; color: var(--color-danger); background: transparent; padding: 6px 0; font-size: 11px; }
.delete-item:disabled { opacity: .4; cursor: default; }
.row-controls { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; }
.row-controls span { color: var(--color-text-muted); font-size: 12px; }
.terms { display: grid; grid-template-columns: 64px 1fr; border: 1px solid var(--color-text-muted); }
.terms h3 { display: flex; align-items: center; justify-content: center; font-size: 14px; writing-mode: vertical-rl; letter-spacing: .5em; margin: 0; border-right: 1px solid var(--color-text-muted); }
.terms .detail-field { padding: 3px 10px; }
.terms .detail-field + .detail-field { border-top: 1px solid var(--color-border); }
.signatures { display: grid; grid-template-columns: 1fr 1fr; min-height: 130px; }
.signature-party { display: flex; flex-direction: column; padding: 12px; }
.signature-party p { margin: 0 0 12px; }
.signature-party > div { margin-top: auto; max-width: 290px; }
.signature-party .detail-field { grid-template-columns: 4em minmax(0, 1fr); }
.is-preview .editable input, .is-preview .editable textarea, .is-preview .row-controls, .is-preview .delete-item { display: none; }
.is-preview .field-text { display: block; }
.is-preview .terms { border-top: 0; }
.print-validation-error { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
button:focus-visible, a:focus-visible, .paper-scroll:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
@media (max-width: 760px) {
  .page-shell { padding: 20px 16px 32px; }
  .topbar { gap: 10px; }.topbar-actions { gap: 6px; }.brand { font-size: 15px; }.back-link { font-size: 12px; }
  .intro { margin-top: 32px; }
  .toolbar { align-items: stretch; flex-direction: column; padding: 16px; gap: 14px; }
  .actions { display: grid; grid-template-columns: 1fr 1fr; }
  .actions button { padding: 10px 8px; }
  .editor-note, .workspace-footnote { padding: 12px 16px; }
  .paper-scroll { padding: 4px 12px 16px; }
}
/* Zero page margins suppress Chrome's automatic date/title/URL/page-number header and footer.
   Keep the visual page inset in the fragmented document box instead. */
@page { size: A4 landscape; margin: 0; }
@media print {
  .has-print-error .page-shell { display: none !important; }
  .has-print-error .print-validation-error { display: block; margin: 10mm; font-size: 14px; }
  :root, html[data-theme="dark"] { color-scheme: light; --color-paper: #fff; --color-text: #111; --color-text-muted: #444; --color-border: #bbb; --color-surface: #fff; }
  html, body { display: block; background: white; color: black; margin: 0; min-height: 0; font-size: 10px; line-height: 1.35; }
  .page-shell { width: 100%; max-width: none; margin: 0; padding: 0; }
  .topbar, .intro, .toolbar, .editor-note, .workspace-footnote, .site-footer, .error-message, .row-controls, .delete-item, noscript { display: none !important; }
  .workspace { border: 0; border-radius: 0; background: white; overflow: visible; }
  .paper-scroll { padding: 0; overflow: visible; }
  .quotation-paper {
    min-width: 0; width: 100%; padding: 10mm; box-shadow: none;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
  }
  .editable input, .editable textarea { display: none !important; }
  .field-text { display: block; padding: 2px 3px; }
  .document-heading { margin-bottom: 10px; }
  .company-title { font-size: 20px; }.document-heading h2 { font-size: 23px; margin-top: 4px; }
  .party { padding: 4px 8px; }.detail-field > label { padding-top: 3px; }
  .document-meta { padding: 5px 8px; gap: 5px; }
  .items-table { font-size: 10px; }
  .items-table th, .items-table td { padding: 4px 2px; }
  .items-table tbody td { padding-top: 6px; padding-bottom: 6px; }
  .items-table .field-text { padding: 3px 1px; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .row-number { padding: 3px 0; }
  .terms { border-top: 0; grid-template-columns: 45px 1fr; }
  .terms h3 { font-size: 11px; }.terms .detail-field { padding: 1px 8px; }
  .signatures { min-height: 70px; break-inside: avoid; }.signature-party { padding: 8px; }.signature-party p { margin-bottom: 8px; }
  a { text-decoration: none; }
}
