:root {
  --walnut-950: #231a15;
  --walnut-900: #2e231c;
  --walnut-800: #4b3123;
  --copper: #c7793f;
  --copper-deep: #85421f;
  --gold: #d9a441;
  --cream: #f3e7d3;
  --warm-tan: #f0dfc6;
  --canvas: #f7f1e8;
  --panel: #fffdf9;
  --ink: #2a211b;
  --muted: #6f6258;
  --line: #e7dccd;
  --line-strong: #d8c8b3;
  --danger: #963b2c;
  --olive: #52622f;
  --amber-deep: #80500d;
  --shadow: 0 10px 28px rgba(42,33,27,.09);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { min-height: 100%; font-size: 16px; scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; min-width: 300px; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
#print-root { display: none; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .result-card strong { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
h1 { margin-bottom: 0; font-size: clamp(1.1rem, 2vw, 1.38rem); line-height: 1.2; }
h2 { margin-bottom: 0; font-size: 1.06rem; }
h3 { margin-bottom: 2px; font-size: .92rem; }

.app-header { position: relative; z-index: 10; color: var(--cream); background: linear-gradient(135deg, var(--walnut-950), var(--walnut-900)); border-bottom: 3px solid var(--copper); }
.header-inner { max-width: 1600px; min-height: 74px; margin: 0 auto; padding: 14px 22px; display: flex; align-items: center; gap: 20px; }
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.1); }
.brand-mark svg { width: 27px; fill: none; stroke: var(--cream); stroke-width: 2; }
.eyebrow, .section-kicker { margin: 0 0 3px; color: var(--copper-deep); font-size: .68rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.app-header .eyebrow, .section-kicker.light { color: #e7ad78; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }
.print-menu-wrap { position: relative; }
.print-menu { position: absolute; top: calc(100% + 7px); right: 0; z-index: 50; width: 205px; padding: 6px; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 14px 34px rgba(35,26,21,.24); }
.print-menu button { width: 100%; min-height: 39px; padding: 8px 10px; color: var(--ink); background: transparent; border: 0; border-radius: 7px; font-size: .77rem; font-weight: 720; text-align: left; }
.print-menu button:hover, .print-menu button:focus-visible { background: var(--warm-tan); }
.btn { min-height: 40px; padding: 8px 13px; border: 1px solid transparent; border-radius: 8px; font-size: .8rem; font-weight: 750; }
.btn { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease; }
.btn-secondary { color: var(--cream); background: rgba(255,253,249,.08); border-color: rgba(243,231,211,.3); }
.btn-secondary:hover { background: rgba(255,255,255,.14); }
.btn-install { color: var(--walnut-950); background: var(--cream); border-color: var(--cream); }
.btn-install:hover { background: #fffaf0; }
.btn:disabled { cursor: not-allowed; opacity: .45; }
.btn[aria-disabled="true"] { cursor: not-allowed; opacity: .45; }
.btn-ghost { color: var(--cream); background: transparent; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-primary { color: #fff; background: var(--copper-deep); }
.btn-primary:hover { background: #6f3519; }
.btn-quiet { color: var(--ink); background: var(--panel); border-color: var(--line-strong); }
.btn-danger { color: var(--danger); background: var(--panel); border-color: #d9a79c; }
.pwa-status-strip { max-width: 1600px; margin: -4px auto 0; padding: 0 22px 10px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; color: #eadfce; font-size: .7rem; }
.offline-ready-indicator { font-weight: 750; }
.offline-ready-indicator > span { margin-right: 4px; color: #aeca77; }
.pwa-update-action, .ios-install-help summary { padding: 0; color: #f0bd8f; background: transparent; border: 0; cursor: pointer; font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.ios-install-help { position: relative; }
.ios-install-help p { position: absolute; right: 0; z-index: 30; width: min(280px, calc(100vw - 28px)); margin: 8px 0 0; padding: 10px 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: .72rem; font-weight: 550; }

.app-shell { width: 100%; max-width: 1600px; margin: 0 auto; padding: 22px; display: grid; grid-template-columns: minmax(0, 1fr) clamp(360px, 32vw, 480px); align-items: start; gap: 20px; }
.workspace { min-width: 0; }
.app-shell, .workflow-section, .section-body, .paper-row, .paper-row > *, .field, input, select { min-width: 0; }
.workspace-intro { margin-bottom: 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.workspace-intro h2 { font-size: 1.3rem; }
.workspace-intro > p { max-width: 410px; margin-bottom: 1px; color: var(--muted); text-align: right; font-size: .82rem; }
.remembered-prices-notice { margin-bottom: 14px; padding: 11px 12px 11px 15px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: #58321d; background: #f5e2ca; border: 1px solid #d7ab7d; border-left: 4px solid var(--copper-deep); border-radius: 10px; box-shadow: 0 5px 14px rgba(88,50,29,.07); }
.remembered-prices-notice p { margin: 0; font-size: .76rem; }
.remembered-prices-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }
.remembered-prices-close { width: 30px; height: 30px; display: grid; place-items: center; color: #58321d; background: rgba(255,253,249,.55); border: 1px solid #d7ab7d; border-radius: 7px; font-size: 1.15rem; line-height: 1; }

.workflow-section { margin-bottom: 14px; overflow: visible; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-header { min-height: 64px; padding: 13px 18px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--line); }
.section-header > div { min-width: 0; }
.section-header p { margin: 2px 0 0; overflow: hidden; color: var(--muted); font-size: .73rem; text-overflow: ellipsis; white-space: nowrap; }
.section-number { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: var(--copper-deep); background: var(--warm-tan); border-radius: 9px; font-size: .72rem; font-weight: 850; }
.section-body { padding: 18px 20px 20px; }
.group-heading { margin-bottom: 13px; }
.group-heading p { margin-bottom: 0; color: var(--muted); font-size: .75rem; }
.split-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

.field-grid { display: grid; gap: 14px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.specification-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.production-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pricing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; color: #55483e; font-size: .77rem; font-weight: 730; }
.field input, .field select, .field textarea { width: 100%; min-height: 43px; padding: 8px 10px; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; outline: none; transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease; }
.field textarea { min-height: 68px; resize: vertical; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--copper-deep); box-shadow: 0 0 0 3px rgba(168,88,43,.16); }
.field input.is-restored, .field select.is-restored { box-shadow: inset 4px 0 0 var(--copper-deep); }
.field input.is-restored:focus, .field select.is-restored:focus { box-shadow: inset 4px 0 0 var(--copper-deep), 0 0 0 3px rgba(168,88,43,.16); }
.override-toggle input.is-restored { outline: 2px solid var(--copper-deep); outline-offset: 2px; }
.field input:disabled, .field select:disabled, .check-control:has(input:disabled) { color: #85786e; background: #eee6da; cursor: not-allowed; opacity: .78; }
.field input.invalid, .field select.invalid { border-color: var(--danger); background: #fff8f7; }
.field-note { min-height: 1em; color: var(--muted); font-size: .66rem; font-weight: 550; }
.field-error { color: var(--danger); font-size: .68rem; font-weight: 650; }
.money-input, .suffix-input { min-height: 43px; display: flex; align-items: center; overflow: hidden; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; transition: border-color 120ms ease, box-shadow 120ms ease; }
.money-input:focus-within, .suffix-input:focus-within { border-color: var(--copper-deep); box-shadow: 0 0 0 3px rgba(168,88,43,.16); }
.money-input:has(input:disabled), .suffix-input:has(input:disabled) { background: #eee6da; opacity: .78; }
.money-input > span { padding-left: 10px; color: var(--copper-deep); }
.suffix-input > span { padding-right: 10px; color: var(--muted); }
.money-input input, .suffix-input input { min-height: 41px; border: 0; border-radius: 0; box-shadow: none !important; }
.money-input:has(input.invalid), .suffix-input:has(input.invalid) { border-color: var(--danger); background: #fff8f7; }
.check-control { min-height: 43px; padding: 8px 10px; display: flex; align-items: center; gap: 9px; color: var(--ink); background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; font-weight: 600; }
.check-control input, .override-toggle input { width: 17px; height: 17px; margin: 0; accent-color: var(--copper-deep); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, .workspace:focus-visible, .results-panel:focus-visible { outline: 3px solid #a8582b; outline-offset: 2px; }

.takeup-bar { margin-top: 20px; padding-top: 18px; display: grid; grid-template-columns: minmax(170px, 1fr) minmax(170px, .8fr) minmax(150px, .7fr) auto; align-items: end; gap: 14px; border-top: 1px solid var(--line); }
.takeup-copy { align-self: center; display: grid; gap: 2px; }
.takeup-copy strong { font-size: .87rem; }
.takeup-copy span { color: var(--muted); font-size: .68rem; }
.rate-chip { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--warm-tan); text-align: right; }
.rate-chip span { display: block; color: #704523; font-size: .61rem; font-weight: 780; text-transform: uppercase; }
.rate-chip strong { color: var(--copper-deep); font-size: .86rem; }
.carton-dimensions-group { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.carton-dimensions-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.carton-dimensions-group > .field-note { display: block; margin-top: 9px; }

.paper-table-head, .paper-row { display: grid; grid-template-columns: minmax(105px, 1.05fr) minmax(125px, 1.25fr) minmax(72px, .55fr) minmax(96px, .75fr) minmax(88px, .7fr); align-items: center; gap: 12px; }
.paper-table-head { padding: 0 12px 8px; color: var(--muted); font-size: .64rem; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; }
.paper-row { min-height: 66px; padding: 10px 12px; border-top: 1px solid var(--line); }
.paper-row:last-child { border-bottom: 1px solid var(--line); }
.paper-layer-label { min-width: 0; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; column-gap: 8px; }
.layer-order { width: 28px; height: 28px; grid-row: span 2; display: grid; place-items: center; color: var(--copper-deep); background: var(--warm-tan); border-radius: 7px; font-size: .67rem; font-weight: 850; }
.paper-row.fluting .layer-order { color: #733a1f; background: #ecd0b5; }
.paper-layer-label strong { overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.paper-layer-label small { color: var(--muted); font-size: .65rem; }
.paper-name-cell > span, .paper-cell > span, .paper-cost-cell > span { display: none; }
.paper-name-cell input, .paper-cell input, .paper-cell .money-input { min-height: 39px; }
.paper-cell .money-input input { min-height: 37px; }
.paper-cost-cell { text-align: right; }
.paper-cost-cell strong { color: var(--copper-deep); font-size: .84rem; }
.media-gsm-options { display: flex; gap: 5px; }
.media-gsm-options button, .quick-options button, .inline-action { min-height: 27px; padding: 3px 8px; color: var(--copper-deep); background: var(--warm-tan); border: 1px solid var(--line-strong); border-radius: 6px; font-size: .68rem; font-weight: 800; transition: background-color 120ms ease, border-color 120ms ease; }
.media-gsm-options[hidden] { display: none; }

.production-groups { display: grid; gap: 22px; }
.production-group + .production-group { padding-top: 20px; border-top: 1px solid var(--line); }
.process-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.process-rate-card { min-width: 0; padding: 14px; display: grid; align-content: start; gap: 11px; border: 1px solid var(--line); border-radius: 12px; background: #fffaf3; }
.process-rate-card > div { display: grid; gap: 2px; }
.process-rate-card strong { font-size: .8rem; }
.process-rate-card small { color: var(--muted); font-size: .67rem; }
.process-rate-card.is-disabled { background: #eee6da; }
.process-rate-card.is-disabled > div { opacity: .65; }
.override-toggle { display: flex; align-items: center; gap: 6px; color: var(--copper-deep); font-size: .7rem; font-weight: 750; }
.override-toggle:has(input:disabled) { color: #8a9491; }
.inline-rate span { font-size: .67rem; }
.text-button { padding: 5px 0; color: var(--copper-deep); background: transparent; border: 0; font-size: .73rem; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.quick-options { display: flex; align-items: center; gap: 6px; }
.help-disclosure { margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); }
.help-disclosure summary { width: fit-content; color: var(--copper-deep); cursor: pointer; font-size: .74rem; font-weight: 800; }
.help-disclosure p { max-width: 750px; margin: 9px 0 0; color: var(--muted); font-size: .75rem; }

.results-panel { position: static; min-width: 0; color: var(--cream); background: linear-gradient(160deg, var(--walnut-950), var(--walnut-900)); border: 1px solid rgba(243,231,211,.1); border-radius: 18px; box-shadow: 0 14px 34px rgba(42,33,27,.18); }
.summary-header { padding: 19px 19px 13px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.summary-header h2 { font-size: 1.08rem; }
.summary-header > div > p:last-child { margin: 4px 0 0; color: #d3c4b3; font-size: .7rem; }
.status-pill { padding: 4px 8px; color: var(--cream); background: #635247; border: 1px solid rgba(243,231,211,.35); border-radius: 99px; font-size: .61rem; font-weight: 800; }
.status-pill[data-status="complete"] { background: var(--olive); border-color: #8da35a; }
.status-pill[data-status="partial"] { background: var(--amber-deep); border-color: #c58a33; }
.status-pill[data-status="error"] { background: var(--danger); border-color: #d17a68; }
.status-pill[data-status="waiting"] { background: #635247; }
.summary-warning { margin: 0 13px 11px; padding: 9px 10px; display: grid; gap: 2px; color: #f6ddca; background: rgba(150,59,44,.3); border: 1px solid rgba(209,122,104,.6); border-radius: 9px; font-size: .68rem; }
.result-card { margin: 0 13px 11px; padding: 15px 16px; color: var(--cream); border: 1px solid rgba(255,255,255,.13); border-radius: 14px; box-shadow: 0 8px 20px rgba(20,12,8,.13); }
.cost-result-card { background: linear-gradient(135deg, #85421f, #98491f); }
.selling-result-card { background: linear-gradient(135deg, #48572b, #665e28); }
.result-card span, .result-card small { display: block; }
.result-card span { font-size: .7rem; font-weight: 800; }
.result-card strong { display: block; margin: 3px 0; font-size: clamp(1.9rem, 2.2vw, 2.18rem); line-height: 1.08; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.result-card small { opacity: .88; font-size: .62rem; }
.summary-metrics { padding: 0 19px 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 11px 15px; }
.summary-metrics > div { min-width: 0; display: grid; gap: 2px; }
.summary-metrics .wide { grid-column: 1 / -1; padding-top: 9px; border-top: 1px solid rgba(255,255,255,.12); }
.summary-metrics span { color: #d3c4b3; font-size: .63rem; }
.summary-metrics strong { overflow-wrap: anywhere; font-size: .94rem; }
.summary-metrics .wide strong { color: #efb276; font-size: 1.15rem; }
.quantity-note { margin: 0; padding: 9px 19px; color: #c9b9a8; background: rgba(255,253,249,.045); font-size: .65rem; }
.summary-details { border-top: 1px solid rgba(255,255,255,.11); }
.summary-details > summary { padding: 12px 19px; cursor: pointer; color: #eadfce; font-size: .73rem; font-weight: 800; }
.details-content { padding: 0 19px 17px; }
.detail-section { padding-top: 15px; border-top: 1px solid rgba(255,255,255,.1); }
.detail-section + .detail-section { margin-top: 15px; }
.detail-section h3 { margin-bottom: 9px; color: var(--cream); font-size: .73rem; text-transform: uppercase; }
.detail-explainer { margin: -3px 0 10px; color: #c9b9a8; font-size: .64rem; }
.detail-list { margin: 0; display: grid; gap: 7px; }
.detail-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.detail-list dt { color: #c9b9a8; font-size: .66rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; font-size: .7rem; font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.cost-rounding-note { line-height: 1.45; }
.cost-build-up { display: grid; gap: 11px; }
.cost-block { --bd-accent: #e3b25d; --bd-tint: rgba(227,178,93,.12); position: relative; min-width: 0; padding: 12px 12px 12px 15px; overflow: hidden; background: var(--bd-tint); border: 1px solid rgba(243,231,211,.12); border-radius: 12px; }
.cost-block::before { position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--bd-accent); content: ""; }
.cost-block[data-block="direct"] { --bd-accent: #e3b25d; --bd-tint: rgba(227,178,93,.12); }
.cost-block[data-block="carton"] { --bd-accent: #7fb7a4; --bd-tint: rgba(127,183,164,.12); }
.cost-block[data-block="load"] { --bd-accent: #e58a5b; --bd-tint: rgba(229,138,91,.12); }
.cost-block[data-block="wastage"] { --bd-accent: #d98098; --bd-tint: rgba(217,128,152,.12); }
.cost-block[data-block="profit"] { --bd-accent: #9cc96b; --bd-tint: rgba(156,201,107,.12); }
.cost-block[data-block="final"] { --bd-accent: #f2e2c4; --bd-tint: rgba(242,226,196,.13); border-color: rgba(242,226,196,.48); box-shadow: 0 0 0 1px rgba(242,226,196,.09), 0 8px 24px rgba(0,0,0,.15); }
.cost-block > header { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cost-block > header h4 { min-width: 0; margin: 0; display: inline-flex; align-items: center; gap: 7px; color: var(--bd-accent); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: .68rem; letter-spacing: .035em; text-transform: uppercase; }
.cost-step { width: 21px; height: 21px; flex: 0 0 21px; display: inline-grid; place-items: center; color: var(--walnut-950); background: var(--bd-accent); border-radius: 99px; font-size: .62rem; font-weight: 900; }
.cost-chip { max-width: 55%; padding: 3px 7px; overflow-wrap: anywhere; color: var(--bd-accent); background: rgba(20,12,8,.3); border: 1px solid var(--bd-accent); border-radius: 99px; font-size: .58rem; font-weight: 800; text-align: right; }
.cost-block[data-entered="false"]::before, .cost-block[data-entered="false"] .cost-step, .cost-block[data-entered="false"] > header h4, .cost-block[data-entered="false"] .cost-chip, .cost-block[data-entered="false"] .cost-added { opacity: .55; }
.cost-block-list { margin: 0; display: grid; gap: 7px; }
.cost-block-list > div { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(84px, auto); align-items: baseline; gap: 10px; }
.cost-block-list dt { min-width: 0; color: #d3c4b3; font-size: .65rem; overflow-wrap: anywhere; }
.cost-block-list dd { min-width: 0; margin: 0; color: #fffaf2; font-size: .7rem; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.cost-block-list .cost-added dt, .cost-block-list .cost-added dd, .cost-block-list .cost-added dd strong { color: var(--bd-accent); }
.cost-block-list .cost-after { margin-top: 2px; padding-top: 7px; border-top: 1px dashed rgba(255,255,255,.14); }
.cost-block-list .cost-after dt, .cost-block-list .cost-after dd { color: #fffaf2; font-weight: 850; }
.cost-block-list .cost-operation dt, .cost-block-list .cost-operation dd { color: #c9b9a8; font-style: italic; }
.cost-row-with-note dd { display: grid; justify-items: end; gap: 2px; }
.cost-row-with-note dd small { color: #c9b9a8; font-size: .56rem; font-weight: 600; }
.cost-quoted dd { color: var(--bd-accent); font-size: .79rem; }
.cost-final .cost-block-list > .cost-quoted dd { font-size: 1.02rem; }
.area-cards { display: grid; gap: 8px; }
.area-cards > div { padding: 8px 9px; display: grid; grid-template-columns: 1fr auto; gap: 2px 9px; background: rgba(255,255,255,.055); border-radius: 7px; }
.area-cards span, .area-cards small { color: #c9b9a8; font-size: .61rem; }
.area-cards small { grid-column: 1 / -1; text-align: right; }
.area-cards strong { font-size: .71rem; }
.table-wrap { width: 100%; margin-top: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .64rem; }
th { padding: 7px 5px; color: #d3c4b3; background: rgba(255,253,249,.055); text-align: right; font-size: .55rem; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; }
td { padding: 8px 5px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: right; white-space: nowrap; }
.summary-footnote { margin: 0; padding: 10px 19px 13px; color: #b9a897; font-size: .57rem; text-align: center; }

.validation-message { margin-bottom: 12px; padding: 10px 12px; color: var(--danger); background: #fff4f2; border: 1px solid #ecc5bf; border-radius: 8px; font-size: .76rem; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; padding: 10px 14px; color: var(--cream); background: var(--walnut-900); border-radius: 10px; box-shadow: var(--shadow); font-size: .78rem; font-weight: 750; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity 120ms ease, transform 120ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-result-bar { display: none; }

.settings-dialog { width: min(730px, calc(100vw - 28px)); max-height: calc(100vh - 34px); padding: 0; color: var(--ink); background: var(--panel); border: 0; border-radius: 18px; box-shadow: 0 24px 70px rgba(42,33,27,.28); }
.settings-dialog::backdrop { background: rgba(35,26,21,.62); backdrop-filter: blur(2px); }
.dialog-shell { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dialog-header { padding: 18px 20px; display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); background: #f4eadc; border: 1px solid var(--line); border-radius: 8px; font-size: 1.35rem; }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog-body section + section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.remembered-prices-settings { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.remembered-prices-settings p { margin: 3px 0 0; color: var(--muted); font-size: .73rem; }
.remembered-prices-settings .btn { flex: 0 0 auto; }
.inline-action { width: fit-content; }
.dialog-footer { padding: 14px 20px; display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; border-top: 1px solid var(--line); background: #f7efe5; }
.document-dialog { width: min(900px, calc(100vw - 28px)); }
.compact-document-dialog { width: min(680px, calc(100vw - 28px)); }
.document-dialog-body { overscroll-behavior: contain; }
.dialog-details { border: 1px solid var(--line); border-radius: 11px; background: #fffaf3; }
.dialog-details > summary { padding: 13px 15px; color: var(--copper-deep); cursor: pointer; font-size: .84rem; font-weight: 850; }
.dialog-details-content { padding: 2px 15px 16px; }
.full-field { grid-column: 1 / -1; }
.logo-control { margin-top: 15px; padding-top: 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px; border-top: 1px solid var(--line); }
.logo-preview-wrap { min-width: 150px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.logo-preview-wrap img { width: auto; max-width: 120px; height: auto; max-height: 60px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.document-toggles { margin-top: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.document-reset-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.document-reset-row p { margin: 3px 0 0; color: var(--muted); font-size: .73rem; }
.document-dialog-footer { grid-template-columns: 1fr auto auto; }
.internal-dialog-warning { margin: 0 0 17px; padding: 12px 14px; display: grid; gap: 3px; color: #67261c; background: #fff2ef; border: 1px solid #e0b4aa; border-left: 4px solid var(--danger); border-radius: 9px; font-size: .74rem; }
.internal-dialog-warning strong { letter-spacing: .04em; }
.field-error[hidden] { display: none; }

@media (min-width: 981px) {
  html, body { height: 100%; overflow: hidden; }
  body { min-height: 0; display: flex; flex-direction: column; }
  .app-header { flex: none; }
  .app-shell { flex: 1 1 auto; min-height: 0; overflow: hidden; align-items: stretch; }
  .workspace, .results-panel { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: #b88963 rgba(255,253,249,.1); }
  .workspace::-webkit-scrollbar, .results-panel::-webkit-scrollbar { width: 9px; }
  .workspace::-webkit-scrollbar-track { background: #eee2d3; border-radius: 99px; }
  .results-panel::-webkit-scrollbar-track { background: rgba(255,253,249,.08); border-radius: 99px; }
  .workspace::-webkit-scrollbar-thumb, .results-panel::-webkit-scrollbar-thumb { background: #b88963; border: 2px solid transparent; border-radius: 99px; background-clip: padding-box; }
}

@supports (height: 100dvh) {
  @media (min-width: 981px) { body { height: 100dvh; } }
}

@media (max-width: 1024px) {
  .app-shell { padding: 18px; gap: 16px; }
  .specification-grid, .carton-dimensions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .takeup-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-chip { text-align: left; }
  .paper-table-head, .paper-row { grid-template-columns: minmax(95px, 1fr) minmax(115px, 1.15fr) minmax(68px, .55fr) minmax(88px, .72fr) minmax(82px, .68fr); gap: 9px; }
  .production-grid, .process-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; align-items: start; overflow: visible; }
  .workspace, .results-panel { height: auto; overflow: visible; }
}

@media (max-width: 768px) {
  .header-inner { padding: 13px 16px; flex-wrap: wrap; }
  .header-actions { width: 100%; margin-left: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
  .print-menu-wrap, .print-menu-wrap #print-summary { width: 100%; }
  .pwa-status-strip { padding: 0 16px 10px; justify-content: flex-start; flex-wrap: wrap; }
  .app-shell { padding: 16px 16px 88px; grid-template-columns: 1fr; }
  .workspace-intro { align-items: flex-start; flex-direction: column; gap: 4px; }
  .workspace-intro > p { text-align: left; }
  .section-body { padding: 16px; }
  .paper-table-head { display: none; }
  .paper-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 0; gap: 10px 12px; }
  .paper-layer-label, .paper-name-cell { grid-column: 1 / -1; }
  .paper-name-cell > span, .paper-cell > span, .paper-cost-cell > span { display: block; color: var(--muted); font-size: .62rem; }
  .paper-cost-cell { grid-column: 1 / -1; align-self: end; display: flex; align-items: center; justify-content: space-between; }
  .mobile-result-bar { position: fixed; right: 12px; bottom: 12px; left: 12px; z-index: 20; padding: 10px 11px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--cream); background: linear-gradient(135deg, var(--walnut-950), var(--walnut-900)); border: 1px solid rgba(243,231,211,.16); border-radius: 14px; box-shadow: 0 14px 36px rgba(42,33,27,.3); transition: opacity 120ms ease, transform 120ms ease; }
  .mobile-result-pair { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mobile-result-pair > div { min-width: 0; display: grid; }
  .mobile-result-bar span { color: #d3c4b3; font-size: .61rem; }
  .mobile-result-bar strong { font-size: .96rem; }
  .mobile-result-pair > div:last-child strong { color: #bad889; }
  .mobile-result-bar button { min-height: 38px; padding: 7px 12px; color: #fff; background: var(--copper-deep); border: 1px solid #b86b3c; border-radius: 8px; font-size: .71rem; font-weight: 800; }
  body:has(.workspace input:focus) .mobile-result-bar,
  body:has(.workspace select:focus) .mobile-result-bar { opacity: 0; pointer-events: none; transform: translateY(120%); }
}

@media (max-width: 560px) {
  .header-inner { padding: 12px 14px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .header-actions { grid-template-columns: 1fr 1fr; }
  .pwa-status-strip { padding-right: 14px; padding-left: 14px; }
  .app-shell { padding: 14px 14px 86px; }
  .remembered-prices-notice, .remembered-prices-settings { align-items: flex-start; flex-direction: column; }
  .remembered-prices-actions { width: 100%; justify-content: space-between; }
  .section-header { padding: 12px 14px; }
  .section-body { padding: 14px; }
  .specification-grid, .production-grid, .pricing-grid, .two-col, .carton-dimensions-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .takeup-bar { grid-template-columns: 1fr 1fr; }
  .takeup-copy, .rate-chip { grid-column: 1 / -1; }
  .split-heading { align-items: flex-start; flex-direction: column; }
  .process-grid { grid-template-columns: 1fr; }
  .paper-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .paper-layer-label, .paper-name-cell { grid-column: 1 / -1; }
  .paper-cell { grid-column: auto; }
  .paper-cost-cell { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
  .dialog-footer { grid-template-columns: 1fr 1fr; }
  .dialog-footer span { display: none; }
  .dialog-footer .btn-danger { grid-column: 1 / -1; }
  .logo-control, .document-toggles { grid-template-columns: 1fr; }
  .logo-preview-wrap { justify-content: flex-start; }
  .document-reset-row { align-items: flex-start; flex-direction: column; }
  .document-dialog-footer { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 390px) {
  .header-actions .btn { padding: 7px 8px; font-size: .7rem; }
  .specification-grid, .production-grid, .pricing-grid, .two-col, .takeup-bar, .carton-dimensions-grid { grid-template-columns: 1fr; }
  .takeup-copy, .rate-chip { grid-column: auto; }
  .paper-row { grid-template-columns: 1fr 1fr; }
  .paper-name-cell, .paper-layer-label, .paper-cost-cell { grid-column: 1 / -1; }
  .summary-metrics { grid-template-columns: 1fr; }
  .summary-metrics .wide { grid-column: auto; }
  .details-content { padding-right: 13px; padding-left: 13px; }
  .cost-block { padding-right: 9px; padding-left: 9px; }
  .cost-block-list > div { grid-template-columns: minmax(0, 1fr) minmax(78px, auto); gap: 8px; }
  .cost-chip { max-width: 50%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  @page { size: A4 portrait; margin: 14mm; }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body > * { display: none !important; }
  body > #print-root { display: block !important; }
  #print-root { width: 100%; color: #111; background: #fff; font-family: Arial, Helvetica, sans-serif; font-size: 8.6pt; line-height: 1.32; }
  .print-document, .print-document * { box-sizing: border-box; }
  .print-document h1, .print-document h2, .print-document h3, .print-document p { margin-top: 0; }
  .print-document table { width: 100%; border-collapse: collapse; color: #111; font-size: 7.5pt; }
  .print-document th, .print-document td { padding: 5px 6px; border: 1px solid #777; vertical-align: top; }
  .print-document th { color: #111; background: #f4f4f4; font-weight: 750; }
  .pre-line { white-space: pre-line; }
  .quotation-letterhead { padding-bottom: 8px; display: grid; grid-template-columns: minmax(0, 1fr) 58mm; gap: 12mm; border-bottom: 1.5px solid #8A4B1F; break-inside: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .quotation-company { display: flex; align-items: flex-start; gap: 9px; }
  .quotation-logo { max-width: 38mm; max-height: 20mm; object-fit: contain; }
  .quotation-company h1 { margin-bottom: 3px; font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-size: 17pt; line-height: 1.05; }
  .quotation-company p { margin: 0 0 1px; color: #333; font-size: 7.2pt; }
  .quotation-meta { text-align: right; }
  .quotation-meta h2 { margin-bottom: 5px; color: #8A4B1F; font-family: Arial, Helvetica, sans-serif; font-size: 16pt; letter-spacing: .08em; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .quotation-meta dl { margin: 0; }
  .quotation-meta dl > div { display: grid; grid-template-columns: 1fr 1.35fr; gap: 5px; }
  .quotation-meta dt { color: #555; }
  .quotation-meta dd { margin: 0; font-weight: 700; }
  .quotation-to { margin: 11px 0 7px; break-inside: avoid; }
  .quotation-to h3, .quotation-terms h3 { margin-bottom: 4px; color: #8A4B1F; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; letter-spacing: .06em; text-transform: uppercase; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .quotation-to > strong { display: block; margin-bottom: 2px; font-size: 9.3pt; }
  .quotation-to p { margin: 0 0 1px; }
  .quotation-subject { margin: 6px 0 8px; padding: 5px 0; border-top: 1px solid #bbb; border-bottom: 1px solid #bbb; break-inside: avoid; }
  .quotation-items { margin-top: 8px; table-layout: fixed; break-inside: avoid; }
  .quotation-items th:nth-child(1) { width: 7mm; }
  .quotation-items th:nth-child(3) { width: 15mm; }
  .quotation-items th:nth-child(4) { width: 16mm; }
  .quotation-items th:nth-child(5), .quotation-items th:nth-child(6) { width: 25mm; }
  .quotation-items td:nth-child(1), .quotation-items td:nth-child(n+3), .quotation-items th:nth-child(1), .quotation-items th:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }
  .quotation-items td:nth-child(2) strong { display: block; margin-bottom: 3px; font-size: 8.4pt; }
  .quotation-items td:nth-child(2) span { display: block; margin-top: 1px; color: #333; }
  .quotation-items tfoot th { text-align: right; }
  .quotation-items tfoot td { text-align: right; font-variant-numeric: tabular-nums; }
  .quotation-items .quotation-grand-total th, .quotation-items .quotation-grand-total td { border-top: 1.5px solid #111; font-size: 8.3pt; }
  .quotation-words { margin: 7px 0 10px; padding: 5px 7px; border-left: 2px solid #8A4B1F; background: #fafafa; break-inside: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .quotation-terms { margin-top: 9px; break-inside: avoid; }
  .quotation-terms ol { margin: 0; padding-left: 18px; }
  .quotation-terms li { margin: 0 0 3px; }
  .quotation-signature { margin-top: 16px; display: flex; justify-content: flex-end; break-inside: avoid; }
  .quotation-signature > div { width: 55mm; display: grid; gap: 2px; }
  .signature-line { height: 16mm; border-bottom: 1px solid #555; }
  .quotation-signature small { color: #444; }
  .quotation-footer { margin-top: 11px; padding-top: 5px; border-top: 1px solid #aaa; color: #555; font-size: 6.7pt; text-align: center; break-inside: avoid; }
  .costing-sheet-document { width: 100%; display: table; }
  .costing-sheet-content { display: table-row-group; }
  .costing-sheet-header { padding-bottom: 8px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(48mm, .65fr); gap: 12px; border-bottom: 1.5px solid #111; break-inside: avoid; }
  .costing-sheet-header h1 { margin: 4px 0 2px; font-family: Arial, Helvetica, sans-serif; font-size: 15pt; letter-spacing: .04em; }
  .costing-sheet-header p { margin-bottom: 0; color: #444; }
  .internal-ribbon { width: fit-content; padding: 3px 7px; color: #111 !important; border: 1.5px solid #111; font-size: 7.5pt; font-weight: 850; letter-spacing: .08em; }
  .costing-sheet-header dl { margin: 0; }
  .costing-sheet-header dl > div { margin-bottom: 3px; display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px; }
  .costing-sheet-header dt { color: #555; }
  .costing-sheet-header dd { margin: 0; font-weight: 700; text-align: right; }
  .print-sheet-section { margin-top: 10px; }
  .print-sheet-section > h2 { margin-bottom: 5px; padding-left: 6px; border-left: 3px solid #8A4B1F; font-family: Arial, Helvetica, sans-serif; font-size: 9.2pt; letter-spacing: .04em; text-transform: uppercase; break-after: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-spec-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid #888; }
  .print-spec-grid > div { min-width: 0; padding: 4px 6px; display: grid; grid-template-columns: 1fr 1.25fr; gap: 5px; border-bottom: 1px solid #ccc; break-inside: avoid; }
  .print-spec-grid > div:nth-child(odd) { border-right: 1px solid #ccc; }
  .print-spec-grid dt { color: #555; }
  .print-spec-grid dd { margin: 0; overflow-wrap: anywhere; font-weight: 700; text-align: right; }
  .internal-table { table-layout: fixed; }
  .internal-table tr, .internal-table tfoot { break-inside: avoid; }
  .internal-table th:not(:first-child), .internal-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
  .internal-table th:nth-child(1), .internal-table th:nth-child(2) { text-align: left; }
  .process-table th:nth-child(2), .process-table td:nth-child(2) { text-align: left; }
  .print-cost-build-up { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .print-cost-block { position: relative; padding: 7px 8px 7px 10px; border: 1px solid #999; border-left: 3px solid #8A4B1F; break-inside: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-cost-block h3 { margin-bottom: 5px; font-family: Arial, Helvetica, sans-serif; font-size: 8pt; text-transform: uppercase; }
  .print-cost-block h3 span { margin-right: 5px; }
  .print-cost-block dl { margin: 0; }
  .print-cost-block dl > div { padding: 2px 0; display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted #ccc; }
  .print-cost-block dt { color: #444; }
  .print-cost-block dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
  .print-cost-block .print-total { margin-top: 2px; padding-top: 4px; border-top: 1px solid #333; border-bottom: 0; font-weight: 800; }
  .print-final-block { border-color: #333; }
  .print-summary-box, .planned-production { break-inside: avoid; }
  .internal-page-footer { display: table-footer-group; }
  .internal-page-footer span { padding-top: 3px; display: table-cell; border-top: 1px solid #777; color: #555; font-size: 6.7pt; text-align: center; }
}
