:root {
  --ink: #0a1633;
  --muted: #657086;
  --blue: #1698d4;
  --blue-dark: #0876b4;
  --orange: #f6a623;
  --surface: #f4f6f8;
  --paper: #ffffff;
  --line: #dfe4ea;
  --panel: #fbfcfd;
  --shadow: 0 24px 70px rgba(10, 22, 51, .16);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--surface); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  height: 76px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
}

.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.brand-lockup img { width: 44px; height: 44px; object-fit: contain; }
.brand-lockup div { display: grid; line-height: 1; }
.brand-lockup strong { font-size: 18px; letter-spacing: .13em; }
.brand-lockup span { margin-top: 6px; color: var(--muted); font-size: 12px; }

.header-actions { display: flex; align-items: center; gap: 9px; }
.draft-picker { display: grid; gap: 3px; margin-right: 8px; }
.draft-picker span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; }
.draft-picker select { width: 190px; height: 34px; }

.button, .icon-button {
  border: 0;
  border-radius: 9px;
  font-weight: 700;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.button { height: 40px; padding: 0 17px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--ink); box-shadow: 0 8px 22px rgba(10,22,51,.18); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: #dff3fc; color: #056a9e; }
.button.ghost { background: transparent; color: var(--ink); }

.workspace { display: grid; grid-template-columns: minmax(420px, 520px) minmax(720px, 1fr); min-height: calc(100vh - 76px); }
.editor { background: var(--paper); border-right: 1px solid var(--line); padding: 30px 34px 80px; }
.editor-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.eyebrow { margin: 0 0 6px; color: var(--blue-dark); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.editor-heading h1 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.save-state { font-size: 11px; color: #5f6e7b; padding: 6px 9px; border-radius: 99px; background: #edf1f4; }

.form-section { border-top: 1px solid var(--line); }
.form-section:last-child { border-bottom: 1px solid var(--line); }
.section-toggle { width: 100%; min-height: 55px; padding: 0; display: flex; align-items: center; justify-content: space-between; color: var(--ink); background: transparent; border: 0; text-align: left; font-weight: 750; }
.section-toggle span { display: flex; align-items: center; gap: 11px; }
.section-toggle b { color: var(--blue-dark); font-size: 10px; letter-spacing: .08em; }
.section-toggle i { color: var(--muted); font-style: normal; font-size: 18px; font-weight: 400; }
.section-body { display: none; padding: 1px 0 24px; animation: sectionIn .2s ease both; }
.form-section.open .section-body { display: block; }
@keyframes sectionIn { from { opacity: 0; transform: translateY(-4px); } }

.field-grid { display: grid; gap: 13px; grid-template-columns: 1fr; margin-bottom: 13px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 6px; color: #4d586c; font-size: 11px; font-weight: 700; letter-spacing: .015em; }
input, select, textarea {
  width: 100%;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid #d8dee6;
  border-radius: 8px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input, select { height: 40px; padding: 0 11px; }
textarea { padding: 10px 11px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); background: white; box-shadow: 0 0 0 3px rgba(22,152,212,.11); }
.field-help { margin: -4px 0 14px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.field-help.warning { color: #8a5800; background: #fff4dd; padding: 9px 11px; border-radius: 7px; margin: 2px 0 0; }
.travel-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.line-item { display: grid; grid-template-columns: minmax(150px, 1fr) 64px 105px 32px; gap: 8px; align-items: end; padding: 12px 0; border-top: 1px dashed var(--line); }
.line-item:first-child { margin-top: 10px; }
.remove-item { height: 40px; border: 0; background: #f5e8e8; color: #943a3a; border-radius: 7px; font-weight: 800; }
.text-button { border: 0; background: transparent; color: var(--blue-dark); font-weight: 750; padding: 7px 0; }

.preview-shell { position: relative; overflow: auto; padding: 25px 35px 90px; background: #e9edf1; }
.preview-toolbar { max-width: 850px; margin: 0 auto 15px; display: flex; align-items: center; justify-content: space-between; color: #596578; font-size: 12px; font-weight: 700; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; background: #20a46b; border-radius: 50%; box-shadow: 0 0 0 4px rgba(32,164,107,.11); }
.icon-button { height: 30px; min-width: 48px; padding: 0 8px; background: rgba(255,255,255,.72); color: var(--ink); }

.quote-document { width: 794px; min-height: 1123px; margin: 0 auto; background: white; box-shadow: var(--shadow); transform-origin: top center; transition: transform .25s ease; overflow: hidden; }
.document-hero { height: 258px; position: relative; overflow: hidden; color: white; }
.hero-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(.82) contrast(1.05); }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(4,13,35,.94) 0%, rgba(4,13,35,.68) 48%, rgba(4,13,35,.1) 100%); }
.document-brand { position: absolute; top: 27px; left: 44px; display: flex; align-items: center; gap: 10px; }
.document-brand img { width: 44px; height: 44px; background: rgba(255,255,255,.91); border-radius: 50%; object-fit: contain; }
.document-brand div { display: grid; }
.document-brand strong { font-size: 17px; letter-spacing: .16em; }
.document-brand span { margin-top: 3px; color: rgba(255,255,255,.72); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.document-title { position: absolute; left: 44px; bottom: 34px; max-width: 520px; }
.document-title p { margin: 0 0 10px; color: #69caf1; font-size: 10px; font-weight: 800; letter-spacing: .22em; }
.document-title h2 { margin: 0 0 7px; font-size: 31px; line-height: 1.08; letter-spacing: -.035em; }
.document-title span { color: rgba(255,255,255,.75); font-size: 13px; }

.document-content { padding: 30px 44px 28px; }
.document-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; padding-bottom: 20px; border-bottom: 1px solid #dfe5eb; }
.document-meta div { display: grid; gap: 4px; }
.document-meta span, .document-label, .offer-highlight span, .payment-info span { color: #778398; font-size: 8px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.document-meta strong { font-size: 11px; }
.address-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 38px; padding: 23px 0 19px; }
.address-grid h3 { margin: 7px 0 4px; font-size: 14px; }
.address-grid p:not(.document-label) { margin: 2px 0; color: #596477; font-size: 9px; line-height: 1.45; }
.address-grid p.seller-type { color: var(--ink); font-weight: 700; }
.document-intro { margin: 0 0 19px; color: #3e4a5d; font-size: 10px; line-height: 1.6; }

.offer-highlight { display: grid; grid-template-columns: 1.15fr .65fr 1fr; gap: 14px; padding: 14px 16px; color: white; background: var(--ink); border-left: 4px solid var(--orange); }
.offer-highlight div { display: grid; gap: 5px; }
.offer-highlight span { color: #91b4ca; }
.offer-highlight strong { font-size: 10px; }
.package-description { margin: 12px 2px 17px; color: #596477; font-size: 9px; line-height: 1.55; }

.price-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.price-table th { padding: 9px 8px; color: #6f7b8d; background: #f1f4f6; font-size: 8px; letter-spacing: .1em; text-transform: uppercase; text-align: right; }
.price-table th:first-child { width: 50%; text-align: left; }
.price-table th:nth-child(2) { width: 12%; }
.price-table td { padding: 11px 8px; border-bottom: 1px solid #e4e8ed; font-size: 9px; text-align: right; vertical-align: top; }
.price-table td:first-child { text-align: left; font-weight: 700; }
.price-table td small { display: block; margin-top: 3px; color: #7b8595; font-weight: 400; line-height: 1.4; }

.totals-wrap { display: grid; grid-template-columns: 1fr 250px; gap: 35px; padding: 17px 0; }
.payment-info { display: grid; align-content: start; gap: 5px; }
.payment-info strong { color: #3d485a; font-size: 9px; line-height: 1.45; }
.totals { display: grid; gap: 7px; }
.totals > div { display: flex; justify-content: space-between; gap: 15px; font-size: 9px; }
.totals > div span { color: #687487; }
.totals .grand-total { margin-top: 3px; padding-top: 10px; border-top: 2px solid var(--ink); align-items: baseline; }
.totals .grand-total span { color: var(--ink); font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.totals .grand-total strong { color: var(--blue-dark); font-size: 17px; }
.tax-status-note { margin: 1px 0 0; color: #697589; font-size: 8px; line-height: 1.4; text-align: right; }

.terms-block { padding: 14px 16px; background: #f4f6f8; border-radius: 4px; }
.terms-block .document-label { margin: 0 0 7px; }
.terms-block #outNotes { margin: 0; color: #596477; font-size: 8px; line-height: 1.55; white-space: pre-line; }
.document-footer { margin-top: 19px; padding-top: 14px; display: flex; align-items: flex-end; justify-content: space-between; border-top: 1px solid #dfe5eb; }
.document-footer div { display: grid; gap: 3px; }
.document-footer strong { color: var(--blue-dark); font-size: 11px; }
.document-footer span, .document-footer p { margin: 0; color: #7c8797; font-size: 8px; }
.document-footer p { max-width: 210px; text-align: right; font-style: italic; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; padding: 12px 16px; color: white; background: var(--ink); border-radius: 9px; box-shadow: 0 12px 35px rgba(0,0,0,.2); font-size: 13px; font-weight: 700; opacity: 0; transform: translateY(14px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 440px minmax(560px, 1fr); }
  .preview-shell { padding-left: 18px; padding-right: 18px; }
  .quote-document { transform: scale(.78); margin-bottom: -247px; }
  .preview-toolbar { max-width: 620px; }
}

@media (max-width: 900px) {
  .app-header { height: auto; min-height: 70px; padding: 12px 16px; }
  .draft-picker { display: none; }
  .button { padding: 0 12px; }
  .button.ghost { display: none; }
  .workspace { display: block; }
  .editor { border-right: 0; padding: 24px 20px 60px; }
  .preview-shell { padding: 22px 12px 70px; }
  .quote-document { transform: scale(.72); margin-bottom: -314px; }
  .preview-toolbar { max-width: 572px; }
}

@media (max-width: 600px) {
  .brand-lockup span { display: none; }
  .brand-lockup { min-width: 0; }
  .brand-lockup img { width: 36px; height: 36px; }
  .brand-lockup strong { font-size: 15px; }
  .header-actions { margin-left: auto; }
  .button.secondary { display: block; padding: 0 10px; }
  .button { height: 38px; font-size: 12px; }
  #newQuote { display: none; }
  .header-actions .button.primary { width: 62px; padding: 0; font-size: 0; }
  .header-actions .button.primary::after { content: "PDF"; font-size: 12px; }
  .editor-heading .save-state { display: none; }
  .field-grid.two, .travel-row { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr 64px 105px 32px; }
  .line-item label:first-child { grid-column: 1 / -1; }
  .quote-document { transform: scale(.45); margin-bottom: -618px; }
  .preview-toolbar { max-width: 358px; }
}

@page { size: A4; margin: 0; }
@media print {
  html, body { width: 210mm; height: auto; margin: 0; background: white; }
  .no-print { display: none !important; }
  .workspace, .preview-shell { display: block; margin: 0; padding: 0; min-height: 0; overflow: visible; background: white; }
  .quote-document { width: 210mm; min-height: 297mm; margin: 0; box-shadow: none; transform: none !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .document-hero { break-inside: avoid; }
  .price-table tr, .terms-block, .totals-wrap, .document-footer { break-inside: avoid; }
}
