/* Proposta Pronta — estilos */
:root {
  --ink: #16211c;
  --ink-2: #2b3832;
  --muted: #5d6a63;
  --paper: #f5f2ea;
  --card: #fffdf8;
  --line: #e1dccf;
  --line-2: #cfc8b8;
  --green: #1d5c4a;
  --green-2: #174a3c;
  --green-soft: #e3eee8;
  --amber: #e2a23b;
  --amber-soft: #fbefd9;
  --red: #b3412f;
  --wa: #1fa855;
  --r: 12px;
  --shadow: 0 1px 2px rgba(22, 33, 28, .06), 0 8px 24px -12px rgba(22, 33, 28, .18);
  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.5; }
img { max-width: 100%; display: block; }
a { color: var(--green); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 10px; border: 1.5px solid transparent; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; transition: background .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); }
.btn-amber { background: var(--amber); color: var(--ink); }
.btn-amber:hover { background: #d4952f; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: #ece7db; }
.btn-wa { background: var(--wa); color: #fff; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon { width: 20px; height: 20px; flex: none; }

/* ======================================================
   APP
   ====================================================== */
.app-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: var(--ink); color: #fff; }
.brand { white-space: nowrap; display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; color: inherit; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--amber); display: grid; place-items: center; color: var(--ink); }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.12); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green-2); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.top-actions .btn-ghost { color: #fff; border-color: rgba(255,255,255,.25); }
.top-actions .btn-ghost:hover { background: rgba(255,255,255,.08); }

.tabs { position: sticky; top: 52px; z-index: 20; display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 13px 4px; border: 0; background: none; font-weight: 700; font-size: 14px; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--green); }

.layout { max-width: 1320px; margin: 0 auto; }
.pane { padding: 16px 14px 120px; }
.pane[hidden] { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card > h2 { font-size: 17px; margin: 0 0 4px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card > h2 .step { width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; display: grid; place-items: center; }
.card > .hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid2 .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: 9px; background: #fff; font-size: 16px; }
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-soft); }
.field .err { color: var(--red); font-size: 13px; min-height: 0; }
.field.invalid input { border-color: var(--red); }

.logo-up { display: flex; gap: 12px; align-items: center; }
.logo-prev { width: 64px; height: 64px; border: 1.5px dashed var(--line-2); border-radius: 10px; display: grid; place-items: center; overflow: hidden; background: #fff; font-size: 12px; color: var(--muted); text-align: center; }
.logo-prev img { width: 100%; height: 100%; object-fit: contain; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches label { position: relative; }
.swatches input { position: absolute; opacity: 0; inset: 0; }
.swatches span { display: block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--line-2); cursor: pointer; }
.swatches input:checked + span { box-shadow: 0 0 0 2.5px var(--ink); }
.swatches input:focus-visible + span { outline: 3px solid var(--amber); }

.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.presets button { flex: none; padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 600; font-size: 14px; cursor: pointer; }
.presets button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.items { display: flex; flex-direction: column; gap: 10px; }
.item { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
.item .field.d { grid-column: 1 / -1; }
.item .field input { min-height: 42px; }
.item .rm { width: 42px; height: 42px; border-radius: 9px; border: 1.5px solid var(--line-2); background: #fff; cursor: pointer; display: grid; place-items: center; color: var(--red); }
.item-total { grid-column: 1 / -1; text-align: right; font-size: 13px; color: var(--muted); }
.totals-box { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--green-soft); display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.totals-box b { font-size: 22px; color: var(--green-2); }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1.5px solid var(--line-2); border-radius: 99px; background: #fff; font-size: 14px; font-weight: 600; cursor: pointer; }
.checks input { accent-color: var(--green); width: 18px; height: 18px; }
.seg { display: inline-flex; border: 1.5px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 0 12px; min-height: 42px; font-weight: 700; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.row-inline { display: flex; gap: 8px; align-items: flex-end; }
.row-inline .field { flex: 1; }

/* prévia */
.preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.preview-tools { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.doc-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.doc-tabs button { padding: 7px 12px; border-radius: 99px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 700; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.doc-tabs button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.doc-tabs .lock { font-size: 11px; }
.sheet-frame { width: 100%; overflow: hidden; }
.sheet-scale { transform-origin: top left; width: 794px; }
.sheet { position: relative; background: #fff; box-shadow: var(--shadow); border-radius: 2px; overflow: hidden; }
.sheet .pb { position: absolute; left: 0; right: 0; border-top: 2px dashed #c9c2b2; pointer-events: none; }
.sheet .pb::after { content: attr(data-label); position: absolute; right: 8px; top: -11px; background: #fff; color: #9a9384; font: 600 11px var(--font); padding: 0 6px; }
.watermark { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.watermark div { position: absolute; left: -20%; width: 140%; transform: rotate(-28deg); text-align: center; font: 800 46px var(--font); color: rgba(29, 92, 74, .10); letter-spacing: .06em; white-space: nowrap; }

.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,253,248,.96); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.bottom-bar .btn { flex: 1; padding: 0 10px; font-size: 15px; }

.locked-box { border: 1.5px dashed var(--line-2); border-radius: var(--r); padding: 18px; background: var(--card); text-align: center; }
.locked-box h3 { margin: 6px 0; }
.locked-box p { color: var(--muted); margin: 0 0 14px; }

/* mensagens */
.msg-cat { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.msg { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.msg h4 { margin: 0 0 4px; font-size: 15px; }
.msg .when { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.msg pre { margin: 0 0 10px; white-space: pre-wrap; font: 15px/1.5 var(--font); background: #eef5f0; border-radius: 10px 10px 10px 2px; padding: 10px 12px; }
.msg .acts { display: flex; gap: 8px; }
.blur { filter: blur(5px); user-select: none; pointer-events: none; }

/* histórico */
.hist-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; margin-bottom: 8px; }
.hist-item b { display: block; }
.hist-item small { color: var(--muted); }
.hist-acts { display: flex; gap: 6px; flex: none; }

/* modal / checkout */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(22,33,28,.55); }
.modal[hidden] { display: none; }
.modal-box { width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .4; } }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.x { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #ece7db; cursor: pointer; font-size: 20px; flex: none; }
.co-main { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 10px; background: #fff; border: 1.5px solid var(--green); margin-bottom: 10px; }
.co-main b { font-size: 15px; }
.co-main small { display: block; color: var(--muted); }
.bump { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 2px dashed var(--amber); background: var(--amber-soft); margin-bottom: 10px; cursor: pointer; }
.bump input { width: 22px; height: 22px; accent-color: var(--green); flex: none; margin-top: 2px; }
.bump b { display: block; font-size: 15px; }
.bump small { color: var(--ink-2); font-size: 13px; }
.bump .price { font-weight: 800; white-space: nowrap; }
.co-total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 2px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; }
.co-total b { font-size: 24px; }
.co-fields { display: grid; gap: 10px; margin: 6px 0 14px; }
.fine { font-size: 12.5px; color: var(--muted); text-align: center; margin: 10px 0 0; }
.pix-qr { display: grid; place-items: center; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; }
.pix-qr img, .pix-qr canvas, .pix-qr svg { width: 220px; height: 220px; image-rendering: pixelated; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; min-height: 46px; padding: 0 10px; border: 1.5px solid var(--line-2); border-radius: 9px; font-size: 13px; background: #fff; }
.wait { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 14px 0 4px; font-weight: 600; color: var(--ink-2); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--green); animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.steps-pix { margin: 10px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.ok-icon { width: 60px; height: 60px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; margin: 4px auto 10px; }
.center { text-align: center; }
.code-box { font: 700 15px ui-monospace, Menlo, monospace; background: #fff; border: 1px dashed var(--line-2); border-radius: 8px; padding: 8px; text-align: center; margin: 8px 0; }
.demo-flag { background: var(--amber-soft); border: 1px solid var(--amber); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 80; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: 90vw; }
.toast[hidden] { display: none; }

.busy { position: fixed; inset: 0; z-index: 90; background: rgba(245,242,234,.85); display: grid; place-items: center; text-align: center; font-weight: 700; }
.busy[hidden] { display: none; }
.busy .spin { width: 34px; height: 34px; margin: 0 auto 10px; }

#render-root { position: fixed; left: -10000px; top: 0; width: 794px; }
#print-root { display: none; }
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .doc { width: 210mm; min-height: auto; padding: 14mm 15mm; }
  #print-root .blk { break-inside: avoid; }
  #print-root .d-table thead { display: table-header-group; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (min-width: 980px) {
  .tabs { display: none; }
  .layout { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(0, 1.1fr); gap: 24px; padding: 20px; }
  .pane { padding: 0 0 40px; }
  .pane[hidden] { display: block !important; }
  #pane-form { grid-column: 1; grid-row: 1; }
  #pane-extra { grid-column: 1; grid-row: 2; }
  #bb-preview { display: none; }
  #pane-preview { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 90px); overflow-y: auto; padding-bottom: 20px; }
  .pane-extra { grid-column: 1 / 2; }
  .bottom-bar { left: auto; right: 24px; bottom: 20px; width: min(520px, 46vw); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 10px; }
  #pane-preview { padding-bottom: 90px; }
  .modal { align-items: center; }
  .modal-box { border-radius: 18px; }
}
@media (max-width: 360px) {
  .grid2 { grid-template-columns: 1fr; }
  .item { grid-template-columns: 1fr 1fr; }
}

/* ======================================================
   DOCUMENTO (A4 = 794 x 1123 px a 96 dpi)
   ====================================================== */
.doc { --accent: #1d5c4a; width: 794px; min-height: 1123px; padding: 52px 56px 60px; background: #fff; color: #1d2421; font: 12.5px/1.5 var(--font); }
.doc * { box-sizing: border-box; }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 18px; border-bottom: 3px solid var(--accent); }
.d-brand { display: flex; gap: 14px; align-items: center; }
.d-logo { width: 72px; height: 72px; object-fit: contain; flex: none; }
.d-logo--txt { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 24px; border-radius: 10px; }
.d-company { font-size: 18px; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; margin-bottom: 2px; }
.d-muted { color: #66706b; font-size: 11.5px; display: block; }
.d-docid { text-align: right; flex: none; }
.d-doclabel { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #66706b; font-weight: 700; }
.d-number { font-size: 22px; font-weight: 800; color: var(--accent); }
.d-meta { display: flex; justify-content: space-between; gap: 24px; padding: 18px 0; }
.d-meta > div { display: flex; flex-direction: column; }
.d-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: #66706b; font-weight: 700; }
.d-v { font-size: 14px; font-weight: 700; }
.d-dates { flex-direction: row !important; gap: 24px; text-align: right; }
.d-dates > div { display: flex; flex-direction: column; }
.d-title { font-size: 20px; margin: 4px 0 6px; letter-spacing: -.01em; }
.d-scope { margin: 0 0 16px; color: #3a4440; }
.d-table { width: 100%; border-collapse: collapse; margin-bottom: 6px; }
.d-table th { background: var(--accent); color: #fff; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding: 8px; text-align: left; }
.d-table td { padding: 9px 8px; border-bottom: 1px solid #e6e3dc; vertical-align: top; }
.d-table tbody tr:nth-child(even) td { background: #faf8f4; }
.c-n { width: 28px; color: #8a918d; }
.c-q { width: 80px; white-space: nowrap; }
.c-p, .c-t { width: 104px; text-align: right !important; white-space: nowrap; }
.c-t { font-weight: 700; }
.d-empty { text-align: center; color: #9aa09d; padding: 20px !important; }
.d-sum { margin-left: auto; width: 290px; padding-top: 6px; }
.d-sumrow { display: flex; justify-content: space-between; padding: 5px 8px; }
.d-disc { color: #b3412f; }
.d-total { margin-top: 4px; background: var(--accent); color: #fff; border-radius: 6px; padding: 10px 12px; font-size: 17px; font-weight: 800; }
.d-pay { margin-top: 18px; padding: 14px 16px; border: 1.5px solid #e6e3dc; border-left: 4px solid var(--accent); border-radius: 6px; }
.d-paytitle { font-weight: 800; margin-bottom: 4px; }
.d-terms { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.d-term { padding: 10px 12px; background: #faf8f4; border-radius: 6px; display: flex; flex-direction: column; }
.d-term b { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #66706b; }
.d-notes { margin-top: 12px; }
.d-notes p { margin: 2px 0 0; color: #3a4440; }
.d-accept { margin-top: 26px; }
.d-accept p { color: #66706b; margin: 0 0 30px; }
.d-signs { display: flex; gap: 40px; }
.d-sign { flex: 1; text-align: center; font-size: 11.5px; color: #3a4440; }
.d-sign span { display: block; border-top: 1px solid #1d2421; margin-bottom: 6px; }
.d-sign small { color: #66706b; }
.d-signs--wit { margin-top: 36px; }
.d-signs--one { justify-content: center; margin-top: 40px; }
.d-signs--one .d-sign { max-width: 320px; }

.k-title { text-align: center; font-size: 18px; text-transform: uppercase; letter-spacing: .06em; margin: 22px 0 14px; }
.k-parts p, .k-cl p { margin: 0 0 8px; text-align: justify; }
.k-cl h3 { font-size: 12.5px; margin: 12px 0 4px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.k-cl ul { margin: 0 0 8px; padding-left: 20px; }
.k-end { margin-top: 22px; }
.k-end > p { margin-bottom: 40px; }

.r-box { margin-top: 30px; border: 1.5px solid #e6e3dc; border-radius: 8px; padding: 26px 28px; font-size: 13.5px; }
.r-box p { margin: 0 0 12px; text-align: justify; }
.r-value { display: flex; justify-content: space-between; align-items: baseline; background: #faf8f4; border-radius: 6px; padding: 12px 16px; margin-bottom: 18px; }
.r-value span { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: #66706b; font-weight: 700; }
.r-value b { font-size: 24px; color: var(--accent); }

@media (max-width: 480px) {
  .app-top { padding: 8px 12px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand-mark { width: 26px; height: 26px; }
  .badge { font-size: 11px; padding: 3px 8px; }
  .top-actions .btn-sm { padding: 0 10px; min-height: 34px; font-size: 13px; }
  .lbl-long { display: none; }
  .doc-tabs { gap: 4px; flex-wrap: nowrap; }
  .doc-tabs button { padding: 6px 10px; font-size: 12px; }
  .tabs { top: 50px; }
}
@media (min-width: 481px) { .lbl-short { display: none; } }
