:root {
  --ink: #20252d;
  --muted: #67717e;
  --line: #e5e9ee;
  --paper: #ffffff;
  --wash: #ffffff;
  --soft-blue: #eaf3ff;
  --blue: #246bdf;
  --blue-dark: #1755b7;
  --danger: #c13a46;
  --radius: 18px;
  --shadow: 0 18px 44px rgba(31, 49, 71, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--wash); }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--wash); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

.skip-link { position: fixed; z-index: 50; top: -80px; left: 16px; padding: 12px 16px; border-radius: 10px; color: #fff; background: var(--ink); transition: top .18s; }
.skip-link:focus { top: 16px; }

.application { min-height: 100svh; display: flex; flex-direction: column; }
.topbar { width: min(100% - 32px, 980px); min-height: 82px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: #155a99; background: #dcefff; font-size: 19px; letter-spacing: normal; }
.brand-logo { display: block; width: 56px; height: auto; }
.topbar-action { min-height: 42px; padding: 0 14px; border: 0; border-radius: 12px; color: var(--ink); background: transparent; font-size: .92rem; font-weight: 700; }
.topbar-action:hover { background: #eef4fa; }

.workspace { width: min(100% - 32px, 760px); flex: 1 0 auto; margin: 0 auto; padding: clamp(44px, 8vh, 86px) 0 44px; }
.workspace.is-short { display: flex; align-items: center; min-height: calc(100svh - 118px); padding-top: 20px; padding-bottom: 20px; }
.flow { width: 100%; }
.progress { display: flex; align-items: center; gap: 8px; margin: 0 0 32px; color: #8a939e; font-size: .79rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.progress-step { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.progress-number { display: grid; place-items: center; width: 23px; height: 23px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); font-size: .72rem; }
.progress-step.is-current { color: var(--ink); }
.progress-step.is-current .progress-number { border-color: var(--blue); color: #fff; background: var(--blue); }
.progress-line { flex: 1; height: 1px; min-width: 10px; background: var(--line); }

.page-title { max-width: 650px; margin: 0; font-size: clamp(2rem, 5vw, 3.55rem); line-height: 1.04; letter-spacing: -.065em; font-weight: 780; }
.page-lead { max-width: 600px; margin: 14px 0 0; color: var(--muted); font-size: clamp(1rem, 2vw, 1.15rem); line-height: 1.58; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.intro-logo { display: flex; align-items: center; justify-content: center; margin: 0 0 clamp(38px, 8vh, 72px); }
.intro-logo .brand-logo { width: clamp(128px, 24vw, 192px); }

.brief-form { margin-top: 32px; }
.brief-form-minimal { margin-top: 0; }
.field-label { display: block; margin: 0 0 10px; color: var(--ink); font-size: 1rem; font-weight: 720; }
.text-field, .input-field, .select-field { width: 100%; border: 1px solid var(--line); outline: 0; border-radius: 14px; color: var(--ink); background: var(--paper); box-shadow: none; transition: border-color .16s, box-shadow .16s; }
.text-field { min-height: 210px; padding: 20px; resize: vertical; font-size: 1.12rem; line-height: 1.52; }
.input-field, .select-field { min-height: 56px; padding: 0 16px; font-size: 1rem; }
.text-field::placeholder, .input-field::placeholder { color: #98a2ad; opacity: 1; }
.text-field:focus, .input-field:focus, .select-field:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36, 107, 223, .12); }
.field-help { margin: 9px 0 0; color: var(--muted); font-size: .91rem; line-height: 1.45; }
.form-status { min-height: 24px; margin: 14px 0 0; color: var(--danger); font-weight: 650; }

.button-row { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.button-row.spread { justify-content: space-between; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 54px; border: 1px solid transparent; border-radius: 14px; padding: 0 22px; text-decoration: none; font-size: 1rem; font-weight: 740; transition: transform .16s, background .16s, border-color .16s, box-shadow .16s; }
.button:not(:disabled):hover { transform: translateY(-1px); }
.button.primary { color: #fff; background: var(--blue); box-shadow: 0 7px 16px rgba(36, 107, 223, .2); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: var(--ink); border-color: var(--line); background: var(--paper); }
.button.secondary:hover { border-color: #b8c8d9; background: #f9fbfd; }
.button.quiet { color: var(--ink); background: transparent; padding-inline: 8px; }
.button.danger { color: var(--danger); background: transparent; padding-inline: 8px; }
.button.full { width: 100%; }
.button.small { min-height: 44px; padding: 0 14px; border-radius: 12px; font-size: .92rem; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 24px; }
.quick-action { min-height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--paper); font-size: .86rem; font-weight: 720; }
.quick-action:hover { border-color: #b8c8d9; background: #fafdff; }
.quick-icon { font-size: 19px; line-height: 1; }

.form-grid { display: grid; gap: 18px; margin-top: 30px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-divider { height: 1px; margin: 32px 0; background: var(--line); }
.section-title { margin: 0; font-size: 1.22rem; letter-spacing: -.035em; }
.section-copy { margin: 7px 0 0; color: var(--muted); line-height: 1.5; }

.question-list { margin-top: 28px; border-top: 1px solid var(--line); }
.question { padding: 22px 0; border-bottom: 1px solid var(--line); }
.question legend, .question-label { display: block; width: 100%; margin: 0 0 13px; padding: 0; color: var(--ink); font-size: 1.04rem; font-weight: 720; line-height: 1.4; }
fieldset.question { min-width: 0; border-right: 0; border-left: 0; }
.measure { display: flex; max-width: 260px; gap: 8px; }
.measure .input-field { min-width: 0; }
.measure-unit { display: grid; place-items: center; min-width: 58px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: var(--paper); font-weight: 700; }
.choice-list { display: flex; flex-wrap: wrap; gap: 9px; }
.choice { position: relative; display: inline-flex; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: inline-flex; align-items: center; min-height: 46px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; color: var(--ink); background: var(--paper); font-weight: 650; }
.choice input:checked + span { border-color: var(--blue); color: var(--blue-dark); background: var(--soft-blue); }

.offer-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-top: 24px; }
.offer-title { margin: 0; font-size: clamp(1.45rem, 4vw, 2.25rem); letter-spacing: -.055em; line-height: 1.12; }
.offer-summary { max-width: 680px; margin: 10px 0 0; color: var(--muted); line-height: 1.55; }
.offer-list { margin-top: 28px; border-top: 1px solid var(--line); }
.offer-line { display: grid; grid-template-columns: minmax(0, 1fr) 92px 76px 112px 42px; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.offer-line input { min-width: 0; min-height: 46px; border: 1px solid transparent; border-radius: 10px; padding: 0 10px; color: var(--ink); background: transparent; }
.offer-line input:hover { border-color: var(--line); background: var(--paper); }
.offer-line input:focus { outline: 0; border-color: var(--blue); background: var(--paper); box-shadow: 0 0 0 3px rgba(36, 107, 223, .1); }
.delete-line { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; color: #8b96a3; background: transparent; font-size: 20px; }
.delete-line:hover { color: var(--danger); background: #fff4f4; }
.offer-total { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 24px 0; font-size: 1.04rem; font-weight: 760; }
.offer-total strong { font-size: 1.75rem; letter-spacing: -.045em; }
.add-item { margin-top: 14px; }

.template-choice { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
.template-option { position: relative; border: 1px solid var(--line); border-radius: var(--radius); padding: 19px; background: var(--paper); text-align: left; }
.template-option input { position: absolute; opacity: 0; }
.template-option:has(input:checked) { border-color: var(--blue); background: #f8fbff; box-shadow: 0 0 0 3px rgba(36, 107, 223, .09); }
.template-option strong { display: block; font-size: 1.06rem; }
.template-option span { display: block; margin-top: 5px; color: var(--muted); font-size: .91rem; line-height: 1.4; }
.template-option b { display: block; margin-top: 14px; color: var(--blue-dark); font-size: .9rem; }

.send-intro { display: flex; align-items: center; gap: 12px; margin: 30px 0 0; padding: 14px 16px; border-radius: 14px; background: var(--soft-blue); color: #214d87; line-height: 1.45; }
.send-intro span { font-size: 20px; }
.upload-label { display: inline-flex; align-items: center; min-height: 50px; border: 1px solid var(--line); border-radius: 13px; padding: 0 15px; color: var(--ink); background: var(--paper); font-weight: 650; cursor: pointer; }
.upload-label input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-name { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }

.dialog-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: end center; padding: 16px; background: rgba(20, 30, 41, .34); }
.dialog { width: min(100%, 520px); max-height: min(86svh, 680px); overflow: auto; border-radius: 22px; padding: 24px; background: var(--paper); box-shadow: var(--shadow); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.045em; }
.dialog p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.dialog-close { display: grid; place-items: center; flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 10px; color: var(--ink); background: #f4f7f9; font-size: 22px; }
.dialog .template-choice { grid-template-columns: 1fr; }
.dialog .button-row { margin-top: 24px; }

.toast { position: fixed; z-index: 30; right: 20px; bottom: 20px; max-width: min(420px, calc(100% - 40px)); border-radius: 14px; padding: 14px 17px; color: #fff; background: var(--ink); box-shadow: var(--shadow); font-weight: 650; }
.toast.error { background: #a92f39; }
.loading { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: rgba(255,255,255,.82); backdrop-filter: blur(4px); }
.loading-box { display: grid; justify-items: center; gap: 15px; min-width: 240px; padding: 28px; border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); font-weight: 730; }
.loader { width: 34px; height: 34px; border: 3px solid #dce8f6; border-top-color: var(--blue); border-radius: 50%; animation: spin .78s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.footer { width: min(100% - 32px, 980px); margin: auto auto 0; padding: 25px 0 calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); text-align: center; font-size: .9rem; line-height: 1.65; }
.footer a { color: inherit; }

.legal-workspace { max-width: 760px; }
.legal-back { display: inline-flex; align-items: center; min-height: 42px; margin: -10px 0 28px; color: var(--ink); font-weight: 700; text-decoration: none; }
.legal-back:hover { color: var(--blue-dark); }
.legal-content { margin-top: 38px; border-top: 1px solid var(--line); }
.legal-content section { padding: 25px 0; border-bottom: 1px solid var(--line); }
.legal-content h2 { margin: 0; color: var(--ink); font-size: 1.17rem; letter-spacing: -.03em; }
.legal-content p { margin: 9px 0 0; color: var(--muted); line-height: 1.62; }
.legal-content a { color: var(--blue-dark); }

@media (max-width: 640px) {
  .topbar { width: min(100% - 24px, 980px); min-height: 70px; }
  .brand-logo { width: 48px; }
  .topbar-action { min-height: 40px; padding: 0 8px; font-size: .85rem; }
  .workspace { width: min(100% - 32px, 760px); padding-top: 36px; }
  .workspace.is-short { min-height: calc(100svh - 116px); }
  .progress { gap: 5px; margin-bottom: 28px; font-size: .67rem; }
  .progress-step { gap: 4px; }
  .progress-number { width: 20px; height: 20px; font-size: .64rem; }
  .page-title { font-size: 2rem; }
  .intro-logo { margin-bottom: 40px; font-size: 1.7rem; }
  .text-field { min-height: 190px; padding: 17px; font-size: 1.05rem; }
  .button-row { align-items: stretch; flex-direction: column-reverse; }
  .button-row.spread { flex-direction: column-reverse; }
  .button { width: 100%; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .quick-action { min-height: 66px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .offer-heading { align-items: flex-start; flex-direction: column; }
  .offer-line { grid-template-columns: 1fr 70px 68px 38px; gap: 7px; }
  .offer-line .item-price { grid-column: 1 / span 3; }
  .offer-line .delete-line { grid-column: 4; grid-row: 1 / span 2; align-self: center; }
  .template-choice { grid-template-columns: 1fr; }
  .legal-back { margin-bottom: 24px; }
  .footer { width: min(100% - 32px, 980px); }
}

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