:root {
  --paper: #f2f5f7;
  --surface: #ffffff;
  --ink: #1c2b39;
  --muted: #5d6f80;
  --line: #d8e0e7;
  --primary: #0f5c8c;
  --primary-dark: #0a4468;
  --accent: #1e8f6b;
  --warn: #b45309;
  --danger: #b42318;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
code { background: #e7edf2; padding: .1em .35em; border-radius: 4px; font-size: .9em; }
:focus-visible { outline: 3px solid #7fb4d6; outline-offset: 2px; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.main { padding: 24px 0 40px; min-height: 70vh; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--muted); text-decoration: none; font-size: .95rem; padding: 6px 0; }
.nav a:hover { color: var(--primary); }
.is-admin .topbar { border-top: 4px solid var(--primary); }
.foot { padding: 18px 0 30px; color: var(--muted); font-size: .85rem; }

/* ---------- hero, cards ---------- */
.hero { padding: 28px 0 22px; max-width: 720px; }
.hero.left { padding-top: 8px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.section-title { margin: 28px 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink); transition: border-color .15s; }
.card:hover { border-color: var(--primary); color: var(--ink); }
.card h2, .card h3 { margin: 4px 0 0; }
.card p { color: var(--muted); margin: 0; flex: 1; }
.card-meta { margin-top: 8px; color: var(--primary); font-weight: 600; font-size: .95rem; }
.badge { align-self: flex-start; font-size: .78rem; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #e4eef7; color: var(--primary); }
.badge.non_life { background: #e2f3ec; color: #17694f; }
.badge.both { background: #eee9f7; color: #5b3e96; }
.empty { padding: 26px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted); }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 4px 10px; min-height: 32px; font-size: .88rem; }
form.inline { display: inline; }
.stack > * + * { margin-top: 14px; }
.grid2, .grid3, .grid4 { display: grid; gap: 12px; }
.grid2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid3 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid4 { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.f, .bf { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; }
.f > span, .bf > span { color: var(--ink); }
.bf small, .sub-h small, .bsec h3 small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=number], input[type=email], input[type=password], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #b9c6d2; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; font-weight: 400; min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 3px solid #cfe3f1; outline-offset: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--paper) 30%); padding: 18px 0 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }
.copy-block { position: relative; }
.copy-block pre { margin: 8px 0 0; background: #14222f; color: #e6eef5; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: .82rem; line-height: 1.5; }
.copy-block .btn { position: absolute; right: 8px; top: 16px; }
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }

/* ---------- notices, panels, tables ---------- */
.notice { padding: 11px 14px; border-radius: 8px; margin-bottom: 12px; background: #e2f3ec; color: #14573f; border: 1px solid #b9dfce; }
.notice.err { background: #fdeceb; color: #8a1a11; border-color: #f3c3bf; }
.notice.warn { background: #fdf3e3; color: #7a4308; border-color: #f0d6a8; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.panel.narrow { max-width: 460px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1, .page-head h2 { margin: 0; }
.page-head.tight { margin-bottom: 4px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.pill { font-size: .78rem; padding: 2px 9px; border-radius: 99px; font-weight: 600; }
.pill.ok { background: #e2f3ec; color: #17694f; }
.pill.off { background: #eceff2; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); text-decoration: none; font-size: .9rem; background: #fff; }
.chip:hover { border-color: var(--primary); }
.login { max-width: 380px; margin: 40px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }

/* ---------- calculator ---------- */
.calc { display: grid; gap: 20px; align-items: start; }
@media (min-width: 880px) { .calc { grid-template-columns: minmax(0, 1fr) 380px; } .quote { position: sticky; top: 16px; } }
.calc-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 18px; }
.field label { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 5px; }
.field .range-hint, .field .help { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit .unit { color: var(--muted); white-space: nowrap; }
.field input.bad, .field select.bad { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: .85rem; margin-top: 4px; min-height: 0; }
.field-checkbox { margin: 0; }
.field .addon { display: flex; align-items: flex-start; gap: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; cursor: pointer; margin: 0; font-weight: 500; }
.field .addon:hover { border-color: var(--primary); }
.field .addon input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex: none; }
.addon-text { display: flex; flex-direction: column; }
.addon-text small { color: var(--muted); font-size: .82rem; }

/* the quote slip: the one distinctive element */
.quote {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 22px 18px;
  position: relative; box-shadow: 0 1px 0 var(--line);
  border-top: 5px solid var(--accent);
}
.quote-title { font-size: 1rem; color: var(--muted); font-family: var(--sans); font-weight: 600; margin-bottom: 6px; }
.quote-msg { color: var(--muted); }
.quote-amount { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 2px dashed var(--line); margin-bottom: 12px; }
.quote-amount .amt { font-family: var(--serif); font-size: clamp(2.2rem, 7vw, 2.9rem); font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.quote-amount .per { color: var(--muted); }
.quote-sub { margin: -6px 0 12px; color: var(--muted); font-size: .92rem; }
.breakdown table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .92rem; }
.breakdown td { padding: 5px 0; vertical-align: top; }
.breakdown td.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.breakdown small { color: var(--muted); }
.breakdown tr.k-discount td.r { color: var(--accent); }
.breakdown tr.total td { border-top: 1px solid var(--ink); font-weight: 700; padding-top: 8px; }
.quote-h3 { font-family: var(--sans); font-size: .95rem; margin: 16px 0 6px; }
.benefits { list-style: none; margin: 0; padding: 0; }
.benefits li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.benefits small { flex-basis: 100%; color: var(--muted); }
.fine { color: var(--muted); font-size: .8rem; margin: 14px 0 0; }

/* ---------- admin builder ---------- */
.builder { display: grid; gap: 18px; }
.bsec h3 { font-size: 1.05rem; margin-bottom: 10px; }
.bcard { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 12px; display: grid; gap: 12px; background: #fbfcfd; }
.bcard-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.tag { font-size: .75rem; background: #e4eef7; color: var(--primary); border-radius: 99px; padding: 2px 8px; font-weight: 600; }
.sub { border-top: 1px dashed var(--line); padding-top: 10px; display: grid; gap: 6px; }
.sub-h { font-weight: 600; font-size: .9rem; }
.row4, .row5 { display: grid; gap: 6px; align-items: center; }
.row4 { grid-template-columns: 1fr 1fr 1fr 36px; }
.row5 { grid-template-columns: 1fr 1.4fr .8fr .8fr 36px; }
.row4.head, .row5.head { font-size: .78rem; color: var(--muted); font-weight: 600; }
.row4 input, .row5 input { min-height: 36px; padding: 6px 8px; min-width: 0; }
@media (max-width: 560px) { .row5 { grid-template-columns: 1fr 1fr; } .row5.head { display: none; } .row5 .btn { grid-column: span 2; } }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.freqs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.freq { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 6px; }
.raw textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; margin: 8px 0; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
