/* Wilk Business Insurance Services — proposal generator UI
   Brand tokens: navy #10244E, gold #A69462. Typeface: brand font TBD (DECISIONS #13). */
:root {
  --navy: #10244E; --navy-700: #1A3468; --navy-900: #0A1733;
  --gold: #A69462; --gold-500: #B9A878; --gold-100: #F3EFE3;
  --ink: #1C2230; --ink-600: #4A5365; --ink-400: #7D8699;
  --line: #D9DCE3; --line-soft: #ECEEF2; --paper: #FFFFFF; --canvas: #F5F6F8;
  --ok: #1F7A4D; --warn: #9A6700; --danger: #B42318;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,36,78,.06), 0 6px 18px rgba(16,36,78,.06);
  --font: "Source Sans 3", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--navy); }
h1, h2, h3 { color: var(--navy); margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }

/* Shell */
.topbar { background: var(--navy); color: #fff; border-bottom: 3px solid var(--gold); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: .7rem 1.25rem; display: flex; align-items: center; gap: 1.5rem; }
.brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none; }
.brand-mark { height: 38px; width: auto; display: block; background: #fff; padding: 3px 8px; border-radius: 6px; }
.brand-app { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-500); font-weight: 600; }
.nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.nav a { color: #DCE3F0; text-decoration: none; padding: .45rem .8rem; border-radius: 6px; font-weight: 500; font-size: .95rem; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.nav .user { color: #AEB9CF; font-size: .85rem; padding: 0 .5rem; }
.nav .role { display: inline-block; background: var(--gold); color: var(--navy-900); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: .15rem .5rem; border-radius: 999px; margin-left: .35rem; }
.nav form { margin: 0; }
.nav button { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; padding: .4rem .8rem; border-radius: 6px; cursor: pointer; font: inherit; font-size: .9rem; }
.nav button:hover { background: rgba(255,255,255,.1); }
main { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head p { margin: .25rem 0 0; color: var(--ink-600); }
footer { max-width: 1240px; margin: 0 auto; padding: 1rem 1.25rem 2rem; color: var(--ink-400); font-size: .8rem; border-top: 1px solid var(--line-soft); }

/* Cards & grid */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.card + .card { margin-top: 1.25rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } .topbar-inner { flex-wrap: wrap; } }
.stat { padding: 1rem 1.1rem; }
.stat .label { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-400); font-weight: 600; }
.stat .value { font-size: 1.9rem; font-weight: 700; color: var(--navy); line-height: 1.1; margin-top: .25rem; }
.stat .sub { color: var(--ink-600); font-size: .85rem; margin-top: .25rem; }
.stat.gold { border-top: 3px solid var(--gold); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-400); font-weight: 600; padding: .55rem .6rem; border-bottom: 2px solid var(--line); }
td { padding: .6rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-400); }
.small { font-size: .85rem; }

/* Badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: .2rem .55rem; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge-draft { background: #EEF0F4; color: var(--ink-600); }
.badge-pending_review { background: #FFF4D6; color: var(--warn); }
.badge-approved, .badge-verified { background: #E3F4EA; color: var(--ok); }
.badge-sent { background: #E4ECFA; color: var(--navy); }
.badge-accepted { background: var(--gold-100); color: #6B5A27; }
.badge-declined, .badge-withdrawn, .badge-superseded, .badge-retired { background: #F3E6E4; color: var(--danger); }
.badge-fictional_test { background: #F3E6E4; color: var(--danger); border-color: #E7C2BD; }
.badge-pending { background: #FFF4D6; color: var(--warn); }
.badge-admitted { background: #E3F4EA; color: var(--ok); }
.badge-non_admitted { background: #FFF4D6; color: var(--warn); }
.badge-unknown { background: #EEF0F4; color: var(--ink-600); }

/* Notices */
.notice { border-radius: var(--radius); padding: .9rem 1.1rem; border: 1px solid; display: flex; gap: .75rem; align-items: flex-start; }
.notice-danger { background: #FBF0EF; border-color: #EFC9C4; color: #7A1C14; }
.notice-warn { background: #FFF8E6; border-color: #F0DFAF; color: #5E4300; }
.notice strong { display: block; }
.notice ul { margin: .25rem 0 0; padding-left: 1.1rem; }

/* Forms & buttons */
.btn { display: inline-block; background: var(--navy); color: #fff; border: 1px solid var(--navy); padding: .55rem 1rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--navy-700); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-500); }
.btn-outline { background: transparent; color: var(--navy); }
.btn-outline:hover { background: var(--gold-100); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: .85rem; color: var(--ink-600); margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-500); outline-offset: 1px; border-color: var(--gold); }
.field { margin-bottom: 1rem; }
.error { color: var(--danger); font-size: .85rem; margin-top: .3rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy-900), var(--navy) 60%, #243F7A); padding: 2rem 1rem; }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; }
.login-head { padding: 1.5rem 1.75rem 1rem; border-bottom: 3px solid var(--gold); text-align: center; }
.login-head img { height: 54px; width: auto; }
.login-head .brand-app { display: block; margin-top: .5rem; color: var(--gold); }
.login-body { padding: 1.5rem 1.75rem 1.75rem; }
.login-body .btn { width: 100%; margin-top: .25rem; }
.login-foot { padding: 0 1.75rem 1.5rem; color: var(--ink-400); font-size: .8rem; text-align: center; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink-600); }
.check input { width: auto; }

/* ===== Proposal editor (Milestone 2) ===== */
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.eyebrow { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-400); font-weight: 600; }
.notice-ok { background: #E8F5EE; border-color: #BFE3CE; color: #14532D; margin-bottom: 1rem; }
.prop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 2px solid var(--gold); }
.prop-head h1 { margin: .2rem 0 .35rem; font-size: 1.75rem; }
.prop-meta { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; color: var(--ink-600); font-size: .9rem; }
.prop-head-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.prop-head-actions form { margin: 0; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 1.25rem; align-items: start; }
.editor-main > .card + .card { margin-top: 1.25rem; }
.sticky { position: sticky; top: 1rem; }
.summary .label { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-400); font-weight: 600; }
.summary .value { font-size: 2rem; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.1; margin: .2rem 0; }
.summary .sub { color: var(--ink-600); font-size: .85rem; min-height: 1.2em; }
.summary hr { border: 0; border-top: 1px solid var(--line-soft); margin: .9rem 0; }
.save-state { margin-top: .6rem; color: var(--ok); text-align: center; }
.save-state.dirty { color: var(--warn); }
.save-state.saving { color: var(--ink-400); }
.save-state.error { color: var(--danger); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-opt { padding: .35rem .75rem; font-weight: 600; font-size: .85rem; cursor: pointer; margin: 0; color: var(--ink-600); }
.seg-opt:has(input:checked) { background: var(--navy); color: #fff; }
.seg-opt input { display: none; }
.typeahead { position: absolute; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: 300px; overflow: auto; }
.typeahead button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-soft); padding: .55rem .8rem; font: inherit; cursor: pointer; }
.typeahead button:hover, .typeahead button.active { background: var(--gold-100); }
.typeahead .sub { color: var(--ink-400); font-size: .8rem; }
.field { position: relative; }
.add-coverage { display: flex; gap: .5rem; align-items: center; }
.add-coverage select { width: auto; min-width: 220px; padding: .45rem .6rem; }
.cov-table-wrap { overflow-x: auto; margin: 0 -.25rem; }
.cov-table td { padding: .45rem .3rem; vertical-align: top; }
.cov-table th { padding: .45rem .3rem; }
.cov-table input, .cov-table select { padding: .45rem .4rem; font-size: .88rem; }
.cov-table .cov-type { font-size: .85rem; }
.cov-row.declined input:not(.cov-sym), .cov-row.not_offered input { color: var(--ink-400); }
.cov-row.declined .cov-premium-cell, .cov-row.not_offered .cov-premium-cell { opacity: .45; }
.cov-row.quoted_alternative .cov-premium-cell { opacity: .7; }
.cov-row.quoted_alternative td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.cov-method { margin-bottom: .3rem; font-size: .8rem !important; padding: .3rem .4rem !important; }
.cov-mode { display: flex; gap: .35rem; margin-bottom: .3rem; }
.chip { font-size: .72rem; font-weight: 600; color: var(--ink-600); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; cursor: pointer; margin: 0; }
.chip:has(input:checked) { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip input { display: none; }
.cov-flat, .cov-perunit { display: flex; align-items: center; gap: .3rem; }
.cov-perunit { display: none; flex-wrap: nowrap; }
.cov-perunit .cov-perunit-amt { width: 96px; }
.cov-flat .cov-annual { width: 120px; }
.cov-row[data-mode="per_unit"] .cov-flat { display: none; }
.cov-row[data-mode="per_unit"] .cov-perunit { display: flex; }
.cov-perunit .cov-units { width: 58px; }
.cov-perunit .eq { display: block; width: 100%; }
.cov-perunit { flex-wrap: wrap; }
.cov-perunit .eq { font-size: .85rem; color: var(--ink-600); white-space: nowrap; }
.prefix, .x { color: var(--ink-400); }
.money { text-align: right; font-variant-numeric: tabular-nums; }
.money.invalid { border-color: var(--danger); background: #FFF5F5; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--ink-400); width: 30px; height: 30px; border-radius: 6px; cursor: pointer; font-size: 1.1rem; line-height: 1; }
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }
.cov-row.hidden-field { display: none; }
.cov-type:disabled { background: var(--line-soft); }
@media (max-width: 1000px) { .editor { grid-template-columns: 1fr; } .sticky { position: static; } .grid-2 { grid-template-columns: 1fr; } }

/* ===== Preview sheet ===== */
.sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.25rem 2.5rem; max-width: 900px; margin: 0 auto; position: relative; overflow: hidden; }
.sheet.is-draft::before { content: "DRAFT"; position: absolute; left: 50%; top: 45%; transform: translate(-50%,-50%) rotate(-28deg); font-size: 9rem; font-weight: 800; color: rgba(16,36,78,.05); letter-spacing: .2em; pointer-events: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--navy); padding-bottom: 1rem; margin-bottom: 1.25rem; }
.sheet-head img { height: 56px; }
.sheet-agency { text-align: right; color: var(--ink-600); }
.sheet-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.sheet-title h2 { font-size: 1.5rem; margin: .1rem 0 0; }
.sheet-ref { text-align: right; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; font-size: .9rem; padding: 1rem; background: var(--canvas); border-radius: 8px; margin-bottom: 1.25rem; }
.sheet-table th { background: var(--navy); color: #fff; border: 0; }
.sheet-table th:first-child { border-radius: 6px 0 0 0; } .sheet-table th:last-child { border-radius: 0 6px 0 0; }
.sheet-table tr.declined td, .sheet-table tr.not_offered td { color: var(--ink-400); }
.sheet-table tr.quoted_alternative td { color: var(--ink-600); font-style: italic; }
.sheet-table tfoot td { border-top: 2px solid var(--gold); padding-top: .8rem; font-size: 1rem; }
.sheet-notes { margin-top: 1.25rem; padding: 1rem; border-left: 3px solid var(--gold); background: var(--gold-100); border-radius: 0 8px 8px 0; white-space: pre-line; }
.sheet-foot { margin-top: 1.75rem; padding-top: 1rem; border-top: 1px solid var(--line); }
@media (max-width: 800px) { .sheet { padding: 1.25rem; } .sheet-grid { grid-template-columns: 1fr 1fr; } .sheet.is-draft::before { font-size: 5rem; } }

/* ===== Milestone 3: financials ===== */
.fin { width: 100%; font-size: .9rem; }
.fin td { padding: .3rem 0; border-bottom: 1px solid var(--line-soft); }
.fin tr.total td { border-top: 2px solid var(--gold); border-bottom: 0; font-weight: 700; font-size: 1.05rem; color: var(--navy); padding-top: .5rem; }
.fin tr.bad td { color: var(--danger); }
.fin tr.warn td { color: var(--warn); }
.explain { border: 1px solid var(--line-soft); border-radius: 8px; padding: .4rem .6rem; margin: .35rem 0; background: #fff; }
.explain summary { cursor: pointer; display: flex; align-items: center; gap: .5rem; list-style: none; }
.explain summary::-webkit-details-marker { display: none; }
.explain summary::before { content: "▸"; color: var(--gold); font-size: .8rem; }
.explain[open] summary::before { content: "▾"; }
.explain .charge-label { flex: 1; }
.explain .charge-amt { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 90px; text-align: right; }
.explain-body { padding: .5rem 0 .2rem 1.1rem; color: var(--ink-600); border-top: 1px dashed var(--line-soft); margin-top: .35rem; }
.explain pre { white-space: pre-wrap; font-size: .78rem; margin: .4rem 0; background: var(--canvas); padding: .5rem; border-radius: 6px; }
.charges-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.charges-cols h3 { display: flex; justify-content: space-between; margin-bottom: .4rem; }
.subsection { margin-top: 1rem; border-top: 1px solid var(--line-soft); padding-top: .75rem; }
.subsection > summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.readiness { padding: .5rem .7rem; border-radius: 8px; font-size: .9rem; }
.readiness-ready { background: #E3F4EA; color: var(--ok); }
.readiness-blocked { background: #FBF0EF; color: var(--danger); }
.issues { margin: .5rem 0 0; padding-left: 1.1rem; max-height: 280px; overflow: auto; }
.issues li { margin: .25rem 0; }
.issue-blocker { color: var(--danger); }
.issue-warning { color: var(--warn); }
.issue-info { color: var(--ink-600); }
.pay-row { border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 8px; padding: .75rem .9rem; margin: .75rem 0; background: #fff; }
.pay-row-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.pay-row .field { margin-bottom: .5rem; }
.pay-row label { font-size: .78rem; }
.pay-result { border: 1px solid var(--line-soft); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; }
.pay-result-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .3rem; }
.pay-ok { border-color: #BFE3CE; } .pay-discrepancy { border-color: #EFC9C4; } .pay-incomplete { border-color: #F0DFAF; }
.summary .fin td:first-child { color: var(--ink-600); }
@media (max-width: 900px) { .charges-cols { grid-template-columns: 1fr; } }
.sheet-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.5rem; margin-top: 1.25rem; }
.sheet-cols h3 { font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-400); margin-bottom: .3rem; }
.sheet-mini td { padding: .3rem 0; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
.sheet-totals { width: 100%; background: var(--canvas); border-radius: 8px; }
.sheet-totals td { padding: .4rem .8rem; border-bottom: 1px solid var(--line-soft); font-size: .92rem; }
.sheet-totals tr.grand td { font-weight: 700; color: var(--navy); font-size: 1.05rem; border-top: 2px solid var(--gold); border-bottom: 0; }
@media (max-width: 800px) { .sheet-cols { grid-template-columns: 1fr; } }
.cov-parent { margin-top: .3rem; font-size: .78rem !important; padding: .25rem .4rem !important; color: var(--ink-600); }
.rule-date-extra input { font-size: .85rem; }
/* ===== Admin ===== */
.admin-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.admin-nav { display: flex; flex-direction: column; gap: .15rem; position: sticky; top: 1rem; }
.admin-nav a { padding: .45rem .7rem; border-radius: 6px; text-decoration: none; color: var(--ink-600); font-weight: 500; font-size: .92rem; }
.admin-nav a:hover { background: var(--gold-100); }
.admin-nav a.active { background: var(--navy); color: #fff; }
.checks { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.checks.states label { min-width: 48px; }
.basis-grid, .scope-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: .75rem; background: var(--canvas); border-radius: 8px; }
.scope-grid { grid-template-columns: repeat(4, 1fr); }
.scope-grid label, .basis-grid label { display: flex; margin: .15rem 0; font-weight: 400; }
.badge-superseded { background: #EEF0F4; color: var(--ink-400); }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } .admin-nav { flex-direction: row; flex-wrap: wrap; position: static; } .scope-grid { grid-template-columns: 1fr 1fr; } }
.checks-table td { padding: .5rem .4rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.checks-table .mark { width: 28px; font-weight: 700; font-size: 1.05rem; }
.checks-table tr.ok .mark { color: var(--ok); } .checks-table tr.fail .mark { color: var(--danger); }
.checks-table tr.fail td { background: #FDF6F5; }
.diff td { padding: .3rem .4rem; border-bottom: 1px solid var(--line-soft); }
.diff .from { color: var(--danger); text-decoration: line-through; } .diff .to { color: var(--ok); font-weight: 600; }
.sheet-sign { margin-top: 1.5rem; display: grid; grid-template-columns: 1fr; gap: .75rem; }
.sig-line { border-bottom: 1px solid var(--ink); padding-top: 1.6rem; max-width: 420px; }
.badge-demo { background: #FBF0EF; color: #9A2A1F; border-color: #EFC9C4; }
