:root {
  color-scheme: light;
  --navy: #071a28;
  --navy-2: #0d2b40;
  --blue: #14557a;
  --gold: #c8954c;
  --gold-light: #e2bb79;
  --ink: #142330;
  --muted: #6b7883;
  --line: #dfe5e8;
  --paper: #f4f6f7;
  --white: #fff;
  --green: #16724d;
  --red: #a84040;
  --shadow: 0 22px 60px rgba(7, 26, 40, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; }
.topbar { height: 76px; padding: 0 clamp(22px, 5vw, 72px); display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: white; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: white; text-decoration: none; }
.sun-mark, .summary-mark { position: relative; display: block; width: 34px; height: 34px; border: 2px solid var(--gold); border-radius: 50%; overflow: hidden; }
.sun-mark::after, .summary-mark::after { content: ""; position: absolute; left: -5px; right: -5px; bottom: -1px; height: 14px; background: var(--navy); border-top: 2px solid var(--gold); transform: rotate(-8deg); }
.sun-mark i { position: absolute; width: 13px; height: 13px; left: 9px; top: 9px; border-radius: 50%; background: var(--gold); }
.brand-copy { display: grid; line-height: 1; }
.brand-copy strong { font-family: Georgia, serif; font-size: 1.1rem; letter-spacing: .17em; font-weight: 500; }
.brand-copy small { margin-top: 5px; font-size: .55rem; letter-spacing: .38em; color: var(--gold-light); }
.topbar-label { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: #b8c3ca; }

main { width: min(1220px, calc(100% - 40px)); margin: 0 auto; padding: 46px 0 80px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; font-size: .74rem; letter-spacing: .22em; font-weight: 700; color: var(--gold); }
.intro h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.15rem); line-height: 1.05; font-weight: 500; color: var(--navy); }
.intro p:not(.eyebrow) { margin: 12px 0 0; color: var(--muted); font-size: 1rem; }
.proposal-id { padding-left: 22px; border-left: 1px solid #cbd3d7; display: grid; min-width: 145px; }
.proposal-id span { font-size: .65rem; letter-spacing: .16em; color: var(--muted); }
.proposal-id strong { margin: 4px 0; color: var(--navy); }
.proposal-id small { color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 24px; align-items: start; }
.form-panel, .summary-card { background: var(--white); border: 1px solid rgba(7, 26, 40, .07); box-shadow: var(--shadow); }
.form-panel { border-radius: 8px; overflow: hidden; }
.form-section { padding: 30px clamp(22px, 4vw, 42px) 34px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.section-head { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.section-head > span { width: 35px; height: 35px; display: grid; place-items: center; flex: 0 0 35px; border-radius: 50%; background: var(--navy); color: var(--gold-light); font-size: .72rem; font-weight: 800; }
.section-head h2 { margin: 0; font-size: 1.05rem; color: var(--navy); }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field.full { grid-column: 1 / -1; }
.field { display: grid; gap: 8px; }
.field > span { font-size: .82rem; font-weight: 650; color: #394955; }
input, select, textarea { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid #cfd7dc; border-radius: 5px; outline: none; color: var(--ink); background: white; transition: border-color .18s, box-shadow .18s; }
textarea { min-height: 78px; padding-top: 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 85, 122, .11); }
input[readonly] { background: #f4f6f7; color: #50606b; }
input.invalid, select.invalid { border-color: var(--red); box-shadow: 0 0 0 3px rgba(168, 64, 64, .08); }
.money-input { display: flex; align-items: center; min-height: 48px; border: 1px solid #cfd7dc; border-radius: 5px; overflow: hidden; background: white; transition: border-color .18s, box-shadow .18s; }
.money-input:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(20, 85, 122, .11); }
.money-input b { align-self: stretch; display: grid; place-items: center; padding: 0 13px; background: #eef2f4; border-right: 1px solid #d8dfe3; color: #52616b; font-size: .78rem; }
.money-input input { min-height: 46px; border: 0; box-shadow: none !important; }
.total-field .money-input { border-color: var(--gold); }
.installment-card { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfb; }
.installment-title { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.installment-title span { font-size: .87rem; font-weight: 750; color: var(--navy); }
.installment-title small { color: var(--blue); font-weight: 650; }
.installment-grid { display: grid; grid-template-columns: 135px 1fr; gap: 14px; }
.lower-payments { margin-top: 18px; }

.summary-panel { position: sticky; top: 24px; }
.summary-card { border-radius: 8px; padding: 28px; border-top: 4px solid var(--gold); }
.summary-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.summary-head small, .client-preview small { letter-spacing: .13em; font-size: .64rem; font-weight: 800; color: var(--gold); }
.summary-head h2 { margin: 7px 0 0; font-family: Georgia, serif; font-size: 1.5rem; font-weight: 500; color: var(--navy); }
.summary-mark { width: 32px; height: 32px; border-color: var(--gold); }
.summary-mark::after { background: white; }
.client-preview { display: grid; padding: 21px 0; border-bottom: 1px solid var(--line); }
.client-preview strong { margin-top: 7px; font-size: .95rem; }
.client-preview span { margin-top: 4px; font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.payment-preview { margin: 0; padding: 12px 0; }
.payment-preview > div { display: flex; justify-content: space-between; gap: 18px; padding: 8px 0; font-size: .83rem; }
.payment-preview dt { color: var(--muted); }
.payment-preview dd { margin: 0; font-weight: 650; text-align: right; color: var(--navy); }
.payment-preview .total-line { margin-bottom: 6px; padding: 12px 0; border-bottom: 1px dashed #d7dde0; }
.payment-preview .total-line dt { color: var(--ink); font-weight: 700; }
.payment-preview .total-line dd { color: var(--blue); font-size: 1rem; }
.balance { min-height: 62px; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 5px; }
.balance > span { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 29px; border-radius: 50%; font-weight: 900; }
.balance div { display: grid; gap: 2px; }
.balance small { font-size: .58rem; letter-spacing: .13em; font-weight: 800; }
.balance strong { font-size: .78rem; }
.balance.neutral { background: #eef2f4; color: #62717a; }
.balance.neutral > span { background: #dfe5e8; }
.balance.ok { background: #e8f3ed; color: var(--green); }
.balance.ok > span { background: #cfe7da; }
.balance.error { background: #f7eaea; color: var(--red); }
.balance.error > span { background: #efd1d1; }
.primary-button, .secondary-button { min-height: 50px; border-radius: 5px; border: 0; font-weight: 750; }
.primary-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; padding: 0 20px; background: var(--navy); color: white; transition: transform .15s, background .15s; }
.primary-button:hover { background: var(--navy-2); }
.primary-button:active { transform: translateY(1px); }
.primary-button span { color: var(--gold-light); font-size: 1.25rem; }
.privacy-note { margin: 14px 0 0; font-size: .68rem; line-height: 1.45; text-align: center; color: #8a959c; }
.mobile-actions { display: none; }

dialog { width: 100%; max-width: 920px; max-height: 94vh; padding: 0; border: 0; border-radius: 9px; background: transparent; overflow: visible; }
dialog::backdrop { background: rgba(4, 17, 26, .78); backdrop-filter: blur(4px); }
.dialog-sheet { position: relative; max-height: 94vh; overflow: auto; padding: 22px; border-radius: 9px; background: #e9edef; }
.dialog-close { position: sticky; z-index: 4; float: right; top: 0; width: 37px; height: 37px; margin-bottom: -37px; border: 0; border-radius: 50%; background: var(--navy); color: white; font-size: 1.5rem; line-height: 1; }
.document { width: 100%; min-height: 920px; margin: 0 auto; padding: 52px 58px 34px; background: white; color: #16242d; box-shadow: 0 18px 45px rgba(7, 26, 40, .12); }
.document-head { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 28px; border-bottom: 2px solid var(--navy); }
.document-brand { display: flex; align-items: center; gap: 12px; }
.document-sun { width: 34px; height: 34px; border: 2px solid var(--gold); border-radius: 50%; background: linear-gradient(to top, white 0 27%, var(--gold) 28% 32%, transparent 33%), radial-gradient(circle at 50% 48%, var(--gold) 0 20%, transparent 21%); }
.document-brand div { display: grid; }
.document-brand strong { font-family: Georgia, serif; letter-spacing: .16em; }
.document-brand small { margin-top: 4px; color: var(--gold); font-size: .55rem; letter-spacing: .32em; }
.document-meta { display: grid; text-align: right; }
.document-meta span { font-size: .65rem; letter-spacing: .14em; color: var(--gold); }
.document-meta strong { margin: 4px 0; font-size: .85rem; }
.document-meta small { color: var(--muted); }
.document-title { padding: 34px 0 25px; }
.document-title small { color: var(--gold); font-size: .65rem; letter-spacing: .16em; font-weight: 800; }
.document-title h2 { margin: 7px 0 3px; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; color: var(--navy); }
.document-title p { margin: 0; color: var(--blue); font-weight: 700; }
.doc-section { margin-top: 12px; }
.doc-section h3 { margin: 0 0 13px; padding-bottom: 8px; border-bottom: 1px solid var(--line); color: var(--navy); font-size: .9rem; }
.doc-client { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px 30px; }
.doc-client p { display: grid; gap: 4px; margin: 0; }
.doc-client p:last-child { grid-column: 1 / -1; }
.doc-client span, .doc-table span { color: var(--muted); font-size: .7rem; }
.doc-client strong { font-size: .82rem; }
.doc-table { border: 1px solid var(--line); border-bottom: 0; }
.doc-row { display: grid; grid-template-columns: 1fr auto; gap: 20px; padding: 11px 13px; border-bottom: 1px solid var(--line); font-size: .8rem; }
.doc-row strong { color: var(--navy); }
.doc-total { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; background: var(--navy); color: white; }
.doc-total span { font-size: .7rem; letter-spacing: .1em; }
.doc-total strong { font-size: 1.1rem; color: var(--gold-light); }
.doc-trade p { margin: 0; padding: 12px 14px; border-left: 3px solid var(--gold); background: #f5f7f7; font-size: .78rem; line-height: 1.5; }
.doc-disclaimer { margin: 30px 0; color: #6f7b83; font-size: .65rem; line-height: 1.5; }
.signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 54px; margin: 70px 10px 48px; }
.signatures span { display: block; border-top: 1px solid #849099; }
.signatures p { margin: 7px 0 0; font-size: .7rem; text-align: center; color: var(--muted); }
.document-footer { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--line); color: #7b878f; font-size: .62rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr; gap: 10px; margin-top: 14px; }
.dialog-actions .primary-button { margin: 0; }
.secondary-button { padding: 0 16px; background: white; color: var(--navy); border: 1px solid #cbd3d8; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 25px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 4px; background: var(--navy); color: white; font-size: .8rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .summary-panel { position: static; order: -1; }
  .summary-card { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
  .summary-head, .balance, .desktop-submit, .privacy-note { grid-column: 1 / -1; }
  .client-preview { border-bottom: 0; }
  .payment-preview { border-left: 1px solid var(--line); padding-left: 24px; }
  .mobile-actions { display: block; padding: 0 22px 26px; }
  .desktop-submit { display: none; }
}

@media (max-width: 620px) {
  .topbar { height: 68px; padding: 0 18px; }
  .topbar-label { display: none; }
  main { width: min(100% - 24px, 1220px); padding: 28px 0 50px; }
  .intro { align-items: start; margin-bottom: 20px; }
  .intro p:not(.eyebrow) { font-size: .9rem; line-height: 1.5; }
  .proposal-id { display: none; }
  .summary-card { display: block; padding: 22px; }
  .client-preview { border-bottom: 1px solid var(--line); }
  .payment-preview { border-left: 0; padding-left: 0; }
  .form-section { padding: 25px 20px 28px; }
  .field-grid, .field-grid.two { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .installment-grid { grid-template-columns: 105px 1fr; }
  .installment-card { padding: 15px; }
  .installment-title { align-items: start; flex-direction: column; gap: 5px; }
  .dialog-sheet { padding: 8px; }
  .document { min-height: auto; padding: 32px 22px 25px; }
  .document-head { align-items: start; }
  .document-brand strong { font-size: .8rem; }
  .document-brand small { letter-spacing: .2em; }
  .document-sun { width: 28px; height: 28px; }
  .document-title h2 { font-size: 1.55rem; }
  .doc-client { grid-template-columns: 1fr; }
  .doc-client p:last-child { grid-column: auto; }
  .doc-total { align-items: start; flex-direction: column; gap: 6px; }
  .signatures { gap: 22px; margin-left: 0; margin-right: 0; }
  .dialog-actions { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4; margin: 0; }
  body { background: white; }
  body > .shell, .dialog-actions, .dialog-close, .toast { display: none !important; }
  dialog { position: static; display: block !important; width: 210mm; max-width: none; max-height: none; margin: 0; background: white; }
  dialog::backdrop { display: none; }
  .dialog-sheet { max-height: none; overflow: visible; padding: 0; background: white; }
  .document { width: 210mm; min-height: 297mm; padding: 17mm 16mm 12mm; box-shadow: none; }
}

