:root {
  --bg: #f6f7f4; --card: #fff; --ink: #14202e; --muted: #556270; --line: #dde3ea; --soft: #ebf1ec;
  --accent: #1d6b4f; --accent-soft: #e2f2ea; --pop: #e4007c; --pop-ink: #fff; --pop-soft: #fde8f3;
  --bad: #a3271f; --warn: #8a5a00; --focus: #1d6b4f;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.pieni { font-size: .86rem; color: var(--muted); }

.yla { background: var(--card); border-bottom: 1px solid var(--line); }
.yla .wrap { display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.logo { font-weight: 800; text-decoration: none; color: var(--ink); font-size: 1.05rem; white-space: nowrap; }
.logo span { color: var(--accent); }
.yla nav { display: flex; gap: 0 14px; overflow-x: auto; white-space: nowrap; font-size: .92rem; scrollbar-width: none; max-width: 100%; }
.yla nav a { color: var(--muted); text-decoration: none; padding: 6px 0; display: inline-block; }
.yla nav a[aria-current] { color: var(--ink); font-weight: 650; }

.murupolku { font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.murupolku a { color: var(--muted); }
h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); line-height: 1.1; margin: 12px 0 10px; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 10px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.osio { margin: 34px 0; }
.osio p, .osio li { max-width: 72ch; }
.vastaus { font-size: 1.05rem; }

/* Laskuri */
.wizard { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 16px; min-height: 330px; }
.wz-top { display: flex; justify-content: space-between; align-items: center; min-height: 34px; font-size: .88rem; color: var(--muted); }
.wz-back { font: inherit; background: none; border: 0; color: var(--accent); padding: 6px 0; cursor: pointer; }
.wz-prog { height: 5px; background: var(--soft); border-radius: 3px; margin: 4px 0 12px; overflow: hidden; }
.wz-prog span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.wz-q { border: 0; margin: 0; padding: 0; min-width: 0; }
.wz-q + .wz-q { display: none; }
.wizard.js .wz-q + .wz-q { display: block; }
.wz-q legend { font-weight: 750; font-size: 1.15rem; margin-bottom: 10px; padding: 0; }
.wz-opts { display: grid; gap: 8px; }
.wz-opts button { font: inherit; font-weight: 600; text-align: left; padding: 13px 14px; min-height: 52px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); cursor: pointer; }
.wz-opts button:hover, .wz-opts button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.wz-tulos .t-pre { margin: 0; color: var(--muted); font-size: .9rem; }
.wz-tulos .t-ots { font-size: 1.45rem; margin: 2px 0 8px; }
.t-arvio { font-size: 2.2rem; font-weight: 820; line-height: 1.1; margin: 6px 0 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.t-arvio span { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.t-selite { font-size: .88rem; color: var(--muted); margin: 0 0 6px; }
.t-list { margin-top: 14px !important; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-list, .t-huom, .t-puute { padding-left: 1.15em; margin: 0 0 10px; }
.t-huom li { color: var(--warn); }
.t-puute li { color: var(--bad); font-weight: 600; }
.t-pikku { font-size: .86rem; color: var(--muted); margin: 6px 0 0; }
.t-linkit { font-size: .92rem; margin: 10px 0 4px; }
.wz-alusta { font: inherit; font-size: .9rem; background: none; border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; color: var(--ink); margin-top: 6px; }

.cta { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 10px 20px; border-radius: 999px; background: var(--pop); color: var(--pop-ink); font-weight: 750; text-decoration: none; margin-top: 6px; text-align: center; }
.cta:hover { filter: brightness(1.08); color: var(--pop-ink); }
.cta.pieni-cta { min-height: 40px; padding: 7px 14px; font-size: .9rem; margin: 0; }

/* POP-nosto */
.nosto { background: var(--card); border: 2px solid var(--pop); border-radius: 14px; padding: 16px; }
.nosto h2 { margin-bottom: 6px; }
.nosto ul { margin: 6px 0 12px; padding-left: 1.15em; }
.nosto .pieni { margin: 8px 0 0; }

/* Taulukot */
.taulukko { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { padding: 9px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { background: var(--soft); font-size: .82rem; color: var(--muted); white-space: nowrap; }
tbody th { min-width: 9em; }
tbody tr:last-child > * { border-bottom: 0; }
tr.pop-rivi { background: var(--pop-soft); }
td small, th small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.tyhja { color: var(--muted); }
.lahteet { font-size: .84rem; color: var(--muted); }
.lahteet a { color: var(--muted); }
.lista-muut { padding-left: 1.15em; }

/* Usein kysytyt */
.uk { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.uk details { border-top: 1px solid var(--line); padding: 10px 0; }
.uk details:first-of-type { border-top: 0; }
.uk summary { font-weight: 650; cursor: pointer; }
.uk details p { margin: 8px 0 0; }
.luemyos ul { padding-left: 1.15em; }

.ala { background: var(--card); border-top: 1px solid var(--line); margin-top: 44px; padding: 22px 0 90px; font-size: .88rem; color: var(--muted); }
.ala .sarakkeet { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ala ul { list-style: none; padding: 0; margin: 4px 0 0; }
.ala li { margin: 4px 0; }
.ala a { color: var(--muted); }
.ala b { color: var(--ink); }

.sticky-pop { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; display: none; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
@media (max-width: 760px) { .sticky-pop.nakyy { display: flex; } }
@media (min-width: 761px) { .wizard { max-width: 640px; } }


/* Kotivakuutusvalitsimen tulos */
.t-kaikki { margin: 12px 0 4px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.t-kaikki summary { cursor: pointer; font-weight: 650; font-size: .95rem; }
.t-kaikki table { margin-top: 8px; font-size: .9rem; }
.t-kaikki th { min-width: 7em; }
.t-pop { margin-top: 12px; padding: 12px; border: 2px solid var(--pop); border-radius: 12px; background: var(--card); }
.t-pop p { margin: 0 0 4px; font-size: .95rem; }
#ehdot tbody th { min-width: 8em; }

/* v2: matriisit, kortit, sisällys */
.matriisi { font-size: .88rem; }
.matriisi th[scope=row] { min-width: 10em; }
.matriisi th[scope=row] small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.matriisi td { min-width: 8.5em; vertical-align: top; }
.matriisi .pop-sarake { background: var(--accent-soft); }
.matriisi tr.ryhma th { background: var(--soft); text-align: left; font-size: .85rem; letter-spacing: .02em; }
.kapea { max-width: 640px; font-size: .92rem; }
.kapea th { width: 10em; }
.lahdelista { margin-top: 8px; font-size: .85rem; }
.lahdelista summary { cursor: pointer; }
.korttilista { list-style: none; padding: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .korttilista { grid-template-columns: repeat(3, 1fr); } }
.korttilista a { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-decoration: none; color: inherit; height: 100%; }
.korttilista a:hover { border-color: var(--accent); }
.korttilista b { display: block; color: var(--accent); margin-bottom: 4px; }
.korttilista span { font-size: .92rem; color: var(--muted); }
.sisallys ul { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; list-style: none; }
.yhtio h3 { margin-bottom: 6px; }
.pop-kortti { border-left: 4px solid var(--pop); padding-left: 12px; }
.matriisi .pop-sarake { background: var(--pop-soft); }

/* Tarvevalitsin (halytin.fi:n monivalintamalli) */
.tarve { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 8px 0 18px; }
.tv-prog { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.tv-bars { display: flex; gap: 4px; flex: 1; max-width: 220px; }
.tv-bars span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.tv-bars span.done { background: var(--accent); }
.tv-bars span.now { background: var(--accent); opacity: .55; }
.tv-q { font-size: 1.25rem; margin: 4px 0 10px; }
.tarve .opts { display: grid; gap: 8px; }
.tarve .opts.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tarve .opt { appearance: none; cursor: pointer; text-align: left; display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 3.2rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); font: inherit; }
.tarve .opts.grid .opt { align-items: flex-start; min-height: 4.4rem; }
.tarve .opt:hover { border-color: var(--accent); }
.tarve .opt-text { display: grid; gap: .15rem; flex: 1; min-width: 0; }
.tarve .opt-t { font-weight: 700; line-height: 1.2; font-size: .98rem; overflow-wrap: normal; hyphens: manual; }
.tarve .opt-s { font-size: .8rem; color: var(--muted); line-height: 1.3; }
.tarve .opt .mark { flex: none; width: 1.35rem; height: 1.35rem; border-radius: 50%; position: relative; border: 1.5px solid var(--line); background: var(--card); }
.tarve .opt.single .mark { display: none; }
.tarve .opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tarve .opt[aria-pressed="true"] .mark { background: var(--accent); border-color: var(--accent); }
.tarve .opt[aria-pressed="true"] .mark::after { content: ""; position: absolute; left: .42rem; top: .2rem; width: .3rem; height: .6rem; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.tv-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 12px; }
.tarve .primary { appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 1.08rem; background: var(--accent); color: #fff; border-radius: 12px; padding: .7rem 2rem; min-height: 3rem; }
.tarve .primary[disabled] { opacity: .4; cursor: default; }
.tarve .back { appearance: none; background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: .5rem 0; text-decoration: underline; }
.tv-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tv-chips span { font-size: .78rem; background: var(--soft); border-radius: 99px; padding: 2px 9px; }
.tv-tulos { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.tv-tulos li { display: grid; grid-template-columns: 7.5em 1fr; gap: 2px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: .93rem; }
.tv-tulos li.pop-rivi { border-color: var(--pop); background: var(--pop-soft); }
.tv-tulos small { grid-column: 2; color: var(--muted); font-size: .8rem; }
@media (max-width: 319px) { .tarve .opts.grid { grid-template-columns: 1fr; } }

.tarve, .tarve * { box-sizing: border-box; }
.tarve .opt { min-width: 0; }
.tarve .tv-nav:has(.primary) { position: sticky; bottom: 0; background: var(--card); padding: 8px 0; margin-bottom: -4px; border-top: 1px solid var(--line); }

/* v4: tiivis yläpalkki ja valitsin (yksi rivi ja yksi näkymä puhelimessa) */
.yla .wrap { flex-wrap: nowrap; justify-content: space-between; gap: 10px; padding-top: 6px; padding-bottom: 6px; }
.logo { font-size: .98rem; }
.yla nav { flex-wrap: nowrap; gap: 0 12px; font-size: .86rem; overflow: visible; }
.yla nav a { padding: 4px 0; }
h1 { font-size: clamp(1.35rem, 5vw, 2.2rem); margin: 10px 0 8px; }
.tarve { padding: 10px; margin: 4px 0 14px; }
.tv-prog { margin-bottom: 4px; }
.tv-q { font-size: 1.1rem; margin: 2px 0 8px; }
.tarve .opts { gap: 6px; }
.tarve .opts.grid .opt, .tarve .opt { min-height: 2.9rem; padding: .45rem .6rem; align-items: center; }
.tarve .opt-t { font-size: .93rem; }
.tarve .opt .mark { width: 1.15rem; height: 1.15rem; }
.tarve .opt[aria-pressed="true"] .mark::after { left: .34rem; top: .14rem; width: .26rem; height: .52rem; }
.tarve .tv-nav { margin-top: 8px; }
.tarve .primary { padding: .55rem 1.8rem; min-height: 2.7rem; font-size: 1rem; }
.tarve .pieni { margin: 6px 0 0; }
@media (max-width: 599px) { .tarve .opt-s { display: none; } }
@media (max-width: 340px) { .yla nav { font-size: .8rem; gap: 0 8px; } .logo { font-size: .9rem; } }
@media (max-width: 380px) { .yla nav { font-size: .82rem; gap: 0 9px; } .logo { font-size: .92rem; } .yla .wrap { gap: 8px; } }
.tarve .opt.lukittu { cursor: default; border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tarve .opt.lukittu:hover { border-color: var(--accent); }
.tarve .opt.lukittu .mark { background: var(--accent); border-color: var(--accent); }
.tarve .opt.lukittu .mark::after { content: ""; position: absolute; left: .34rem; top: .14rem; width: .26rem; height: .52rem; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.tarve .opt-lukko { font-size: .74rem; font-weight: 650; color: var(--accent); line-height: 1.1; }
