:root {
  --navy: #12334a;
  --navy-deep: #092538;
  --blue: #1e6fb8;
  --blue-soft: #e9f4fb;
  --teal: #087c72;
  --teal-soft: #e6f5f2;
  --amber: #f5b942;
  --amber-soft: #fff5d2;
  --ink: #17212b;
  --muted: #5d6c77;
  --line: #d6e1e8;
  --canvas: #eef4f7;
  --white: #fff;
  --danger: #b0322b;
  --shadow: 0 18px 50px rgba(16, 50, 73, .1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 16px; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button { cursor: pointer; }
.skip-link { position: fixed; z-index: 40; top: 10px; left: 10px; padding: 10px 14px; color: white; background: var(--navy-deep); border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.site-header { color: var(--navy); background: white; border-bottom: 1px solid rgba(18, 51, 74, .12); }
.header-inner { width: min(1380px, calc(100% - 32px)); min-height: 76px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: var(--navy); border-radius: 12px 12px 12px 4px; font-size: 14px; font-weight: 900; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: 12px; }
nav { display: flex; align-items: center; gap: 20px; }
nav a { color: var(--navy); font-size: 14px; font-weight: 800; }
.back-link { padding: 9px 13px; color: white; background: var(--blue); border-radius: 9px; text-decoration: none; }
main { width: min(1380px, calc(100% - 32px)); margin: 0 auto; padding: 38px 0 58px; }
.tool-intro { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 32px; align-items: end; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 12px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
h1 { max-width: 850px; margin: 0; color: var(--navy); font-size: clamp(40px, 5vw, 67px); line-height: 1.02; letter-spacing: -.04em; }
.tool-intro > div > p:last-child { max-width: 760px; margin: 15px 0 0; color: var(--muted); font-size: 18px; }
.demo-alert { display: flex; gap: 11px; padding: 17px; color: #563e00; background: var(--amber-soft); border: 1px solid #e5ca68; border-radius: 13px; }
.demo-alert > span { align-self: flex-start; padding: 4px 7px; color: white; background: #876300; border-radius: 6px; font-size: 11px; font-weight: 900; letter-spacing: .05em; }
.demo-alert p { margin: 0; font-size: 13px; }
.demo-alert strong { display: block; font-size: 14px; }
.session-strip { margin-top: 26px; display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 15px 18px; color: white; background: var(--navy); border-radius: 13px; }
.session-strip > div span, .session-strip > div strong { display: block; }
.session-strip > div span { color: #8bd6ff; font-size: 12px; font-weight: 850; text-transform: uppercase; }
.session-strip > div strong { margin-top: 2px; font-size: 14px; }
.session-strip dl { margin: 0; display: flex; gap: 8px; }
.session-strip dl > div { min-width: 112px; padding: 8px 11px; background: rgba(255,255,255,.1); border-radius: 8px; }
.session-strip dt { color: #cfe0e9; font-size: 11px; }
.session-strip dd { margin: 0; color: var(--amber); font-size: 22px; font-weight: 900; }
.workspace { margin-top: 18px; display: grid; grid-template-columns: minmax(500px, .88fr) minmax(570px, 1.12fr); gap: 18px; align-items: start; }
.editor { display: grid; gap: 13px; }
.form-section { padding: 24px; background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 9px 28px rgba(16,50,73,.06); }
.section-heading { margin-bottom: 20px; display: flex; align-items: flex-start; gap: 12px; }
.section-heading > span { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; color: var(--navy); background: var(--amber); border-radius: 9px; font-size: 12px; font-weight: 900; }
.section-heading h2 { margin: 0; color: var(--navy); font-size: 21px; line-height: 1.2; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.small-button { min-height: 36px; padding: 7px 10px; color: var(--blue); background: var(--blue-soft); border: 1px solid #9bc9e6; border-radius: 8px; font-size: 12px; font-weight: 850; }
.field-grid { display: grid; gap: 14px; }
.two-columns { grid-template-columns: 1fr 1fr; }
.field.full { grid-column: 1 / -1; }
.field { min-width: 0; }
.field label { margin-bottom: 6px; display: flex; justify-content: space-between; gap: 10px; color: var(--navy); font-size: 13px; font-weight: 800; }
.field label b { color: var(--danger); }
.field label span { color: var(--muted); font-size: 11px; font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 11px; color: var(--ink); background: white; border: 1px solid #aabdc8; border-radius: 8px; outline: none; }
.field input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button { margin: 0; -webkit-appearance: none; }
.field textarea { min-height: 78px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,111,184,.13); }
.field input:invalid:focus, .field textarea:invalid:focus { border-color: var(--danger); }
.field small { margin-top: 4px; display: block; color: var(--muted); font-size: 11px; }
.field-meta { display: flex; justify-content: space-between; gap: 15px; }
.input-suffix { display: flex; align-items: center; overflow: hidden; background: white; border: 1px solid #aabdc8; border-radius: 8px; }
.input-suffix:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,111,184,.13); }
.input-suffix input { min-width: 0; border: 0; border-radius: 0; box-shadow: none !important; }
.input-suffix span { padding: 0 11px; color: var(--muted); font-weight: 800; }
.line-items { display: grid; gap: 10px; }
.line-item { padding: 14px; overflow: hidden; background: #f3f8fa; border: 1px solid #d4e2e9; border-radius: 11px; }
.line-item-heading { margin: -14px -14px 14px; padding: 9px 14px; display: flex; align-items: center; background: var(--blue-soft); border-bottom: 1px solid #b9d7e8; }
.line-item-heading strong { color: var(--blue); font-size: 14px; font-weight: 900; }
.line-numbers { display: grid; grid-template-columns: .7fr .9fr 1fr; gap: 9px; }
.line-bottom { margin-top: 9px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.line-bottom > span { color: var(--navy); font-size: 15px; font-weight: 900; }
.line-actions { display: flex; align-items: center; gap: 8px; }
.line-actions [data-remove-line] { padding: 4px; color: var(--danger); background: none; border: 0; font-size: 12px; font-weight: 750; text-decoration: underline; }
.line-actions .small-button { min-height: 32px; padding: 6px 9px; text-decoration: none; }
.form-error { min-height: 19px; margin: 8px 0 0; color: var(--danger); font-size: 12px; font-weight: 750; }
.form-status { min-height: 19px; margin: -5px 0 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.totals-controls { margin-top: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.attachment-field { margin-top: 14px; }
.attachment-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: stretch; }
.attachment-field input[type="file"] { min-width: 0; min-height: 48px; padding: 6px; color: var(--muted); background: #f7fafc; }
.attachment-field input[type="file"]::file-selector-button { min-height: 34px; margin-right: 10px; padding: 6px 10px; color: var(--navy); background: var(--amber-soft); border: 1px solid #dec875; border-radius: 7px; font-weight: 850; }
.attachment-picker > button { min-width: 96px; padding: 8px 13px; color: white; background: var(--blue); border: 1px solid var(--blue); border-radius: 8px; font-weight: 850; }
.attached-files { margin-top: 9px; display: grid; gap: 7px; }
.attached-file { padding: 9px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--teal-soft); border: 1px solid #a3d6cd; border-radius: 8px; }
.attached-file strong, .attached-file span { display: block; overflow-wrap: anywhere; }
.attached-file strong { color: var(--navy); font-size: 12px; }
.attached-file span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.attached-file button { flex: 0 0 auto; padding: 5px; color: var(--danger); background: none; border: 0; font-size: 11px; font-weight: 800; text-decoration: underline; }
.privacy-note { display: flex; gap: 12px; padding: 17px; color: #24574e; background: var(--teal-soft); border: 1px solid #a3d6cd; border-radius: 12px; }
.privacy-note > span { width: 28px; height: 28px; flex: 0 0 auto; display: grid; place-items: center; color: white; background: var(--teal); border-radius: 8px; font-weight: 900; }
.privacy-note strong { display: block; }
.privacy-note p { margin: 2px 0 0; font-size: 13px; }
.editor-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 13px; border-radius: 9px; font-weight: 850; }
.button.primary { color: white; background: var(--blue); border: 1px solid var(--blue); }
.button.ghost { color: var(--navy); background: white; border: 1px solid #9db5c5; }
.button.email { color: white; background: #375a7f; border: 1px solid #375a7f; }
.button.whatsapp { color: white; background: #147c54; border: 1px solid #147c54; }
.attachment-help { margin: -3px 2px 0; color: var(--muted); font-size: 11px; }
.sent-row { display: flex; align-items: center; gap: 13px; }
.sent-row button { flex: 0 0 auto; padding: 8px 11px; color: var(--teal); background: white; border: 1px solid #7bbcaf; border-radius: 8px; font-size: 12px; font-weight: 850; }
.sent-row button[aria-pressed="true"] { color: white; background: var(--teal); }
.sent-row p { margin: 0; color: var(--muted); font-size: 12px; }
.sent-row p.error { color: var(--danger); font-weight: 750; }
.preview-panel { position: sticky; top: 12px; min-width: 0; }
.preview-toolbar { padding: 11px 14px; display: flex; align-items: center; justify-content: space-between; gap: 14px; color: white; background: var(--navy); border-radius: 13px 13px 0 0; }
.preview-toolbar span, .preview-toolbar strong { display: block; }
.preview-toolbar span { color: #8bd6ff; font-size: 11px; font-weight: 850; text-transform: uppercase; }
.preview-toolbar strong { font-size: 13px; }
.preview-toolbar-actions { display: flex; align-items: center; gap: 7px; }
.preview-toolbar button { padding: 7px 10px; color: var(--navy); background: var(--amber); border: 0; border-radius: 7px; font-size: 12px; font-weight: 900; }
.preview-toolbar button.secondary { color: white; background: transparent; border: 1px solid rgba(255,255,255,.55); }
.paper { min-height: 805px; padding: clamp(28px, 4vw, 48px); background: white; border: 1px solid #cbd8df; border-top: 0; border-radius: 0 0 13px 13px; box-shadow: var(--shadow); }
.paper-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 3px solid var(--navy); }
.paper-brand { display: flex; align-items: center; gap: 10px; }
.paper-brand > span { width: 38px; height: 38px; display: grid; place-items: center; color: white; background: var(--navy); border-radius: 10px 10px 10px 3px; font-size: 12px; font-weight: 900; }
.paper-brand strong, .paper-brand small { display: block; }
.paper-brand strong { color: var(--navy); font-size: 16px; }
.paper-brand small { color: var(--muted); font-size: 9px; }
.document-type { text-align: right; }
.document-type span { display: block; color: var(--blue); font-size: 10px; font-weight: 900; letter-spacing: .13em; }
.document-type strong { color: var(--navy); font-size: 18px; }
.party-grid { margin-top: 23px; display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.party-grid section { min-width: 0; padding: 14px; background: #f3f7f9; border-radius: 9px; }
.party-grid section > span, .paper-conditions span, .paper-attachments > span, .paper-acceptance span { display: block; color: var(--blue); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.party-grid strong { display: block; margin-top: 3px; color: var(--navy); font-size: 14px; }
.party-grid p { margin: 4px 0 0; color: var(--muted); font-size: 10px; white-space: pre-line; overflow-wrap: anywhere; }
.document-meta { margin-top: 14px; display: flex; gap: 28px; justify-content: flex-end; }
.document-meta p { margin: 0; }
.document-meta span, .document-meta strong { display: block; }
.document-meta span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.document-meta strong { color: var(--navy); font-size: 11px; }
.preview-table-wrap { margin-top: 19px; overflow-x: auto; }
.preview-table { width: 100%; border-collapse: collapse; }
.preview-table th, .preview-table td { padding: 8px 7px; text-align: right; vertical-align: top; border-bottom: 1px solid var(--line); font-size: 10px; }
.preview-table th { color: white; background: var(--navy); font-size: 9px; text-transform: uppercase; }
.preview-table th:first-child, .preview-table td:first-child { width: 7%; text-align: center; }
.preview-table th:nth-child(2), .preview-table td:nth-child(2) { width: 37%; text-align: left; }
.preview-table td:first-child { color: var(--blue); font-weight: 900; }
.preview-table td:nth-child(2) { color: var(--navy); font-weight: 700; white-space: pre-line; }
.paper-totals { margin: 18px 0 0 auto; width: min(310px, 70%); }
.paper-totals dl { margin: 0; }
.paper-totals dl > div { display: flex; justify-content: space-between; gap: 20px; padding: 5px 0; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 10px; }
.paper-totals dd { margin: 0; color: var(--navy); font-weight: 800; }
.paper-totals .grand-total { margin-top: 4px; padding: 10px 11px; color: white; background: var(--navy); border: 0; border-radius: 7px; font-size: 13px; font-weight: 900; }
.paper-totals .grand-total dd { color: var(--amber); font-size: 16px; }
.paper-conditions { margin-top: 23px; display: grid; gap: 11px; padding-top: 16px; border-top: 1px solid var(--line); }
.paper-conditions p { margin: 3px 0 0; color: #394d5a; font-size: 10px; white-space: pre-line; }
.paper-acceptance { margin-top: 18px; padding: 14px; display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: 16px; align-items: center; background: var(--blue-soft); border: 1px solid #bad8e9; border-radius: 9px; }
.paper-acceptance strong { display: block; margin-top: 3px; color: var(--navy); font-size: 13px; }
.paper-acceptance p { margin: 4px 0 6px; color: #394d5a; font-size: 9px; }
.paper-acceptance a { display: block; color: var(--blue); font-size: 9px; font-weight: 850; }
.acceptance-url { margin-top: 3px; display: block; color: #315a73; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 7px; line-height: 1.35; overflow-wrap: anywhere; }
.paper-acceptance small { margin-top: 5px; display: block; color: var(--muted); font-size: 8px; }
.paper-acceptance img { width: 112px; height: 112px; padding: 5px; background: white; border-radius: 6px; }
.paper-attachments { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.paper-attachments > p { margin: 4px 0 0; color: #394d5a; font-size: 10px; white-space: pre-line; }
.paper-attachments ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 9px; }
.preview-attachments-status { color: var(--danger) !important; font-weight: 750; }
.paper-attachment-images { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.paper-attachment-images figure { margin: 0; padding: 7px; border: 1px solid var(--line); border-radius: 7px; }
.paper-attachment-images img { width: 100%; max-height: 190px; display: block; object-fit: contain; }
.paper-attachment-images figcaption { margin-top: 5px; color: var(--muted); font-size: 8px; overflow-wrap: anywhere; }
.pdf-document { grid-column: 1 / -1; display: grid; gap: 10px; }
.pdf-document > strong { color: var(--navy); font-size: 10px; overflow-wrap: anywhere; }
.pdf-page { break-inside: avoid; }
.pdf-page canvas { width: 100%; height: auto; display: block; background: white; }
.pdf-render-status { margin: 0; padding: 9px; color: var(--muted); background: #f3f7f9; border-radius: 7px; font-size: 9px; }
.paper-footer { margin-top: 26px; padding-top: 11px; display: flex; justify-content: space-between; gap: 15px; color: var(--muted); border-top: 1px solid var(--line); font-size: 8px; }
.paper-footer p { max-width: 75%; margin: 0; }
.account-demo { margin-top: 54px; padding: clamp(26px, 4vw, 42px); color: white; background: var(--navy); border-radius: 22px; box-shadow: var(--shadow); }
.account-intro { max-width: 820px; }
.account-intro .eyebrow { color: #76ceff; }
.account-intro h2 { margin: 0; font-size: clamp(30px, 4vw, 47px); line-height: 1.07; }
.account-intro > p:last-child { margin: 12px 0 0; color: #cfe0e9; }
.account-stats { margin-top: 24px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.account-stats article { padding: 18px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.13); border-radius: 12px; }
.account-stats strong, .account-stats span { display: block; }
.account-stats strong { color: var(--amber); font-size: 34px; line-height: 1; }
.account-stats span { margin-top: 7px; color: #e5f0f5; font-size: 13px; }
.history-card { margin-top: 16px; overflow: hidden; color: var(--ink); background: white; border-radius: 14px; }
.history-head { padding: 15px 18px; display: flex; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.history-head strong, .history-head span { display: block; }
.history-head strong { color: var(--navy); }
.history-head span { color: var(--muted); font-size: 11px; }
.demo-chip { align-self: center; padding: 5px 8px; color: #755500 !important; background: var(--amber-soft); border-radius: 99px; font-weight: 900; }
.history-list { display: grid; }
.history-list article { padding: 14px 18px; display: grid; grid-template-columns: 1.2fr .8fr auto; gap: 18px; align-items: center; border-bottom: 1px solid var(--line); }
.history-list article:last-child { border-bottom: 0; }
.history-list strong, .history-list span { display: block; }
.history-list div:first-child strong { color: var(--navy); }
.history-list div:first-child span, .history-list small { color: var(--muted); font-size: 12px; }
.history-list div:nth-child(2) { text-align: right; }
.status { margin-top: 3px; font-size: 10px; font-weight: 850; }
.status.sent { color: var(--teal); }
.status.confirmed { color: var(--teal); }
.status.accepted { color: #18517b; }
.status.opened { color: var(--blue); }
.status.draft { color: #8a6400; }
.retention-rule { margin-top: 16px; display: flex; gap: 14px; align-items: center; }
.retention-rule > span { width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center; color: var(--navy); background: var(--amber); border-radius: 14px; font-size: 21px; font-weight: 900; }
.retention-rule strong { display: block; }
.retention-rule p { margin: 2px 0 0; color: #cfe0e9; font-size: 13px; }
.site-footer { margin: 0 auto 34px; width: min(1380px, calc(100% - 32px)); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 13px; }
.site-footer strong { color: var(--navy); }
.site-footer p { margin: 2px 0 0; }
.site-footer > div:last-child { display: flex; flex-wrap: wrap; gap: 18px; }
.site-footer a { color: var(--blue); }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .paper { min-height: 0; }
}

@media (max-width: 720px) {
  .tool-intro { grid-template-columns: 1fr; }
  .session-strip { align-items: flex-start; flex-direction: column; }
  .session-strip dl { width: 100%; }
  .session-strip dl > div { min-width: 0; flex: 1; }
  .history-list article { grid-template-columns: 1fr 1fr; }
  .history-list small { grid-column: 1 / -1; }
  .account-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
  .header-inner, main, .site-footer { width: min(100% - 20px, 1380px); }
  .brand small, nav > a:first-child { display: none; }
  main { padding-top: 27px; }
  h1 { font-size: 40px; }
  .tool-intro > div > p:last-child { font-size: 16px; }
  .session-strip dl { flex-direction: column; }
  .form-section { padding: 19px; }
  .two-columns, .line-numbers, .totals-controls, .editor-actions, .party-grid, .account-stats { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .attachment-picker { grid-template-columns: 1fr; }
  .attachment-picker > button { min-height: 42px; }
  .preview-toolbar { align-items: flex-start; border-radius: 11px 11px 0 0; }
  .preview-toolbar-actions { align-items: stretch; flex-direction: column; }
  .paper { padding: 20px 16px; }
  .paper-head { gap: 12px; }
  .paper-brand small { display: none; }
  .preview-table th:nth-child(4), .preview-table td:nth-child(4) { display: none; }
  .paper-totals { width: 78%; }
  .paper-acceptance { grid-template-columns: 1fr; }
  .paper-acceptance img { margin: 0 auto; }
  .paper-attachment-images { grid-template-columns: 1fr; }
  .history-list article { grid-template-columns: 1fr; gap: 7px; }
  .history-list div:nth-child(2) { text-align: left; }
  .history-list small { grid-column: auto; }
  .site-footer { align-items: flex-start; flex-direction: column; }
}

@media print {
  @page { size: A4; margin: 13mm; }
  body { background: white; }
  .site-header, .tool-intro, .session-strip, .editor, .preview-toolbar, .account-demo, .site-footer { display: none !important; }
  main { width: auto; margin: 0; padding: 0; }
  .workspace { display: block; margin: 0; }
  .preview-panel { position: static; }
  .paper { min-height: 0; padding: 0; border: 0; box-shadow: none; }
  .preview-table-wrap { overflow: visible; }
  .paper-attachments { break-before: page; }
  .paper-acceptance { break-inside: avoid; }
  .paper-attachment-images { display: block; }
  .paper-attachment-images figure { break-inside: avoid; }
  .paper-attachment-images img { max-height: 220mm; }
  .pdf-document { break-before: page; }
  .pdf-document > strong, .pdf-page figcaption { display: none; }
  .pdf-page { margin: 0; padding: 0 !important; border: 0 !important; }
  .pdf-page:not(:last-of-type) { break-after: page; }
  .pdf-page canvas { max-height: 265mm; object-fit: contain; }
  .pdf-render-status, .preview-attachments-status:empty { display: none; }
  .paper-footer { break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
