:root {
  --navy: #13243a;
  --navy-2: #1c3555;
  --blue: #2867e8;
  --blue-dark: #1750c5;
  --ice: #eef5ff;
  --ink: #172235;
  --muted: #657287;
  --line: #dce3ec;
  --surface: #fff;
  --bg: #f4f7fb;
  --success: #1a9b68;
  --shadow: 0 12px 35px rgba(21, 42, 72, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
.auth-locked .app-shell { display: none !important; }
.auth-gate { display: none; min-height: 100vh; padding: 28px; place-items: center; background: radial-gradient(circle at 20% 10%, #284c78 0, #13243a 42%, #0d1929 100%); }
.auth-locked .auth-gate { display: grid; }
.auth-card { width: min(440px, 100%); padding: 34px; border-radius: 18px; background: white; box-shadow: 0 25px 80px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 30px; }
.deliestry-logo-image { display: block; width: min(100%, 330px); height: 112px; margin: -10px auto 13px; object-fit: contain; object-position: center; }
.login-product-title { margin: -2px 0 11px; color: var(--navy); font-size: 25px !important; font-weight: 850; letter-spacing: .015em; text-align: center; }
.auth-copy { margin: 10px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-fields { display: grid; gap: 15px; }
.auth-card .button-full { margin-top: 0; }
.gate-message { min-height: 18px; margin: 14px 0 0; color: #a12d2d; font-size: 12px; text-align: center; }
.login-legal { padding-top: 18px; margin-top: 18px; color: #728096; border-top: 1px solid var(--line); text-align: center; }
.login-legal p { margin: 0 0 7px; color: #46546a; font-size: 11px; font-weight: 750; }
.login-legal nav { display: flex; justify-content: center; gap: 6px; margin-bottom: 9px; font-size: 10px; }
.login-legal button { padding: 0; color: var(--blue); border: 0; background: none; font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
.login-legal small { display: block; font-size: 9px; line-height: 1.45; }
.legal-dialog[hidden] { display: none; }
.legal-dialog { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.legal-backdrop { position: absolute; inset: 0; background: rgba(8, 19, 33, .78); backdrop-filter: blur(5px); }
.legal-panel { position: relative; z-index: 1; width: min(650px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; padding: 34px; border-radius: 16px; background: white; box-shadow: 0 25px 80px rgba(0,0,0,.35); }
.legal-panel h2 { margin-bottom: 18px; font-size: 25px; }
.legal-panel h3 { margin: 22px 0 7px; font-size: 15px; }
.legal-panel p, .legal-panel li { color: #536177; font-size: 12px; line-height: 1.7; }
.legal-panel a { color: var(--blue); }
.legal-panel .legal-note { padding: 12px; border-radius: 8px; background: #fff8e7; color: #70571b; }
.legal-close { position: absolute; top: 12px; right: 14px; width: 34px; height: 34px; color: #526074; border: 0; border-radius: 50%; background: #f0f3f7; font-size: 22px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px; padding: 0 max(24px, calc((100vw - 1440px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  color: white; background: var(--navy);
}
.brand { display: flex; gap: 12px; align-items: center; color: white; text-decoration: none; font-size: 20px; font-weight: 800; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--blue); font-size: 11px; letter-spacing: -.5px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.language-picker { display: flex; align-items: center; gap: 8px; color: #c8d2df; font-size: 12px; }
.language-picker select { color: white; border: 1px solid #516176; background: var(--navy-2); }

.button { border: 0; border-radius: 9px; padding: 11px 16px; font-weight: 750; transition: .18s ease; }
.button-primary { color: white; background: var(--blue); box-shadow: 0 5px 12px rgba(40, 103, 232, .22); }
.button-primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.button-secondary { color: var(--ink); background: white; border: 1px solid var(--line); }
.topbar .button-secondary { color: white; background: transparent; border-color: #526177; }
.button-full { width: 100%; margin-top: 20px; }

.workspace { width: min(1440px, calc(100% - 48px)); margin: 34px auto 80px; }
.intro { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.eyebrow, .summary-label { margin: 0 0 8px; color: var(--blue); font-size: 11px; font-weight: 850; letter-spacing: .13em; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 40px); letter-spacing: -.035em; }
.intro p:not(.eyebrow) { margin: 9px 0 0; color: var(--muted); }
.status-pill { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border: 1px solid #d7e5dd; border-radius: 99px; color: #34755b; background: #f3fbf7; font-size: 12px; }
.status-pill span:first-child { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 24px; align-items: start; }
.editor { display: grid; gap: 20px; }
.card { padding: 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: center; gap: 13px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid #edf0f4; }
.step { display: grid; place-items: center; width: 33px; height: 33px; flex: 0 0 auto; color: var(--blue); border-radius: 9px; background: var(--ice); font-weight: 850; }
h2 { margin: 0; font-size: 18px; }
.card-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: grid; gap: 7px; color: #354258; font-size: 12px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 11px 12px; color: var(--ink); border: 1px solid #cfd8e4; border-radius: 8px; outline: none; background: white; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(40, 103, 232, .1); }
textarea { resize: vertical; }
.pdf-language-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 7px; }
.pdf-language-actions button { min-height: 34px; border: 1px solid #cad5e1; border-radius: 8px; color: #13243a; background: #f5f8fb; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; }
.pdf-language-actions button:hover { border-color: #1667b1; color: #1667b1; background: #edf6ff; }
.money-input { position: relative; }
.money-input input { padding-right: 40px; }
.money-input span { position: absolute; right: 13px; top: 50%; color: var(--muted); transform: translateY(-50%); }
.inline-control { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.three-actions { grid-template-columns: repeat(3, 1fr); }
.file-button { display: grid; place-items: center; text-align: center; }
.file-button input { display: none; }
.danger-button { color: #a72c2c; border-color: #edcaca; background: #fff8f8; }
.data-tools { padding-top: 18px; margin-top: 4px; border-top: 1px solid var(--line); }
.cloud-section { padding-top: 0; margin-top: 0; }
.cloud-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.cloud-state { padding: 10px 12px; color: #40526a; border-radius: 8px; background: #f1f5fa; font-size: 12px; }
.cloud-test-result { margin-top: 14px; padding: 12px; border-radius: 8px; background: #f4f7fb; font-size: 12px; line-height: 1.7; white-space: pre-line; }
.cloud-test-result.success { color: #176a49; background: #eef9f4; border: 1px solid #bfe5d3; }
.cloud-test-result.error { color: #942c2c; background: #fff3f3; border: 1px solid #efcaca; }
.field input:invalid:not(:placeholder-shown) { border-color: #c94141; }
.logo-preview { display: none; max-width: 220px; max-height: 90px; object-fit: contain; object-position: left center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.logo-preview[src] { display: block; }

.table-wrap { overflow-x: auto; }
.damage-table { width: 100%; border-collapse: collapse; }
.damage-table th { padding: 9px 8px; color: var(--muted); background: #f8fafc; font-size: 11px; text-align: center; }
.damage-table th:first-child { text-align: left; }
.damage-table td { padding: 8px; border-bottom: 1px solid #edf0f4; text-align: center; }
.damage-table td:first-child { color: #344157; text-align: left; font-size: 13px; font-weight: 700; white-space: nowrap; }
.damage-table input { width: 70px; padding: 8px; text-align: center; }
.damage-table select { min-width: 76px; padding: 8px; }
.calculation-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 0 18px; }
.hourly-setting { opacity: .45; }
body.hourly-mode .hourly-setting { opacity: 1; }
.row-total { min-width: 82px; color: var(--navy); font-size: 13px; font-weight: 800; }
.rate-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding-top: 20px; }

.summary-column { position: sticky; top: 20px; }
.summary-card { padding: 26px; color: white; border: 0; background: var(--navy); box-shadow: 0 20px 45px rgba(19, 36, 58, .2); }
.summary-card .summary-label { color: #8bb2ff; }
.summary-count { display: flex; align-items: baseline; gap: 10px; padding-bottom: 22px; margin-bottom: 18px; border-bottom: 1px solid #34465d; }
.summary-count strong { font-size: 35px; }
.summary-count span { color: #b8c4d4; font-size: 13px; }
.totals { margin: 0; }
.totals div { display: flex; justify-content: space-between; margin: 14px 0; color: #c9d2de; font-size: 13px; }
.totals dd { margin: 0; color: white; font-weight: 700; }
.grand-total { display: flex; justify-content: space-between; align-items: center; padding-top: 20px; margin-top: 20px; border-top: 1px solid #536176; }
.grand-total span { color: #c9d2de; font-size: 13px; }
.grand-total strong { font-size: 25px; }
.privacy-note { margin: 13px 0 0; color: #91a1b5; text-align: center; font-size: 10px; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 20; overflow-y: auto; padding: 30px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 19, 33, .76); backdrop-filter: blur(5px); }
.modal-panel { position: relative; width: min(900px, 100%); margin: auto; }
.compact-modal .modal-panel { width: min(720px, 100%); }
.archive-panel { width: min(820px, 100%) !important; }
.settings-panel .card, .archive-panel .card { max-height: calc(100vh - 110px); overflow-y: auto; }
.modal-toolbar { display: flex; justify-content: flex-end; gap: 10px; padding-bottom: 14px; }
.offer-sheet { min-height: 1120px; padding: 64px; color: #172235; background: white; box-shadow: 0 20px 70px rgba(0,0,0,.25); }
.offer-header { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 30px; border-bottom: 4px solid var(--navy); }
.offer-logo { color: var(--navy); font-size: 26px; font-weight: 900; }
.offer-logo span { color: var(--blue); }
.offer-meta { font-size: 12px; text-align: right; line-height: 1.65; }
.offer-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; margin: 45px 0; font-size: 13px; line-height: 1.65; }
.offer-section-label { margin-bottom: 7px; color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.offer-sheet h2 { margin: 0 0 8px; font-size: 25px; }
.offer-lead { color: #59677a; font-size: 13px; }
.offer-table { width: 100%; margin: 30px 0; border-collapse: collapse; font-size: 12px; }
.offer-table th { padding: 11px; color: white; background: var(--navy); text-align: left; }
.offer-table th:not(:first-child), .offer-table td:not(:first-child) { text-align: right; }
.offer-table td { padding: 11px; border-bottom: 1px solid #dfe5ec; }
.offer-totals { width: 340px; margin-left: auto; font-size: 12px; }
.offer-totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.offer-totals .offer-grand { padding-top: 13px; margin-top: 8px; border-top: 2px solid var(--navy); font-size: 18px; font-weight: 900; }
.offer-notes { margin-top: 50px; padding: 18px; border-radius: 8px; background: #f4f7fb; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.offer-footer { margin-top: 70px; padding-top: 20px; color: #667386; border-top: 1px solid #dfe5ec; font-size: 10px; line-height: 1.5; }
.offer-company-logo { display: block; max-width: 170px; max-height: 70px; margin-bottom: 8px; object-fit: contain; object-position: left center; }
.archive-list { display: grid; gap: 10px; }
.archive-empty { padding: 30px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.archive-item { display: grid; grid-template-columns: 1fr auto; gap: 15px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.archive-item strong, .archive-item span { display: block; }
.archive-item span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.status-badge { display: inline-block !important; width: fit-content; margin: 7px 0 0 !important; padding: 3px 7px; border-radius: 99px; color: #34526f !important; background: #edf4fa; font-size: 10px !important; font-weight: 800; text-transform: uppercase; }
.archive-actions { display: flex; gap: 7px; }
.archive-actions .button { padding: 8px 10px; font-size: 11px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .summary-column { position: static; grid-row: 1; }
  .summary-card { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 35px; }
  .summary-label, .summary-count, .grand-total, .button-full, .privacy-note { grid-column: 1 / -1; }
}
@media (max-width: 680px) {
  .topbar { height: auto; padding: 14px 16px; align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .language-picker span, #newQuote, #openArchive, #openSettings, #openCloud { display: none; }
  .workspace { width: min(100% - 24px, 1440px); margin-top: 22px; }
  .intro { align-items: flex-start; gap: 20px; }
  .status-pill { display: none; }
  .card { padding: 18px; }
  .form-grid, .rate-grid, .summary-card { grid-template-columns: 1fr; }
  .field-wide, .summary-label, .summary-count, .grand-total, .button-full, .privacy-note { grid-column: auto; }
  .offer-sheet { padding: 30px 22px; }
  .offer-addresses { grid-template-columns: 1fr; gap: 20px; }
  .inline-control, .three-actions, .archive-item { grid-template-columns: 1fr; }
  .calculation-toolbar { grid-template-columns: 1fr; }
  .deliestry-logo-image { width: min(100%, 285px); height: 96px; }
}

@media print {
  body * { visibility: hidden !important; }
  #offerSheet, #offerSheet * { visibility: visible !important; }
  #offerSheet { position: absolute; inset: 0; width: 100%; min-height: auto; padding: 14mm; box-shadow: none; }
  @page { size: A4; margin: 0; }
}
