:root {
  --forest: #1f3d2b;
  --forest-2: #2e5940;
  --forest-soft: #e6eee8;
  --accent: #8fc79b;
  --sky: #3a7ca5;
  --bg: #f7f6f2;
  --bg-alt: #eceae3;
  --card: #ffffff;
  --text: #1c1c1c;
  --muted: #55564f;
  --border: #ddd9cf;
  --danger: #b4432f;
  --sel: #f2c14e;
  --radius: 14px;
  --shadow: 0 18px 50px -12px rgba(18, 38, 26, 0.35), 0 2px 6px rgba(18, 38, 26, 0.08);
  --topbar-h: 91px;
  --panel-w: 430px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; color: var(--forest); }
h1 { font-size: 1.75rem; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
p { margin: 0 0 1em; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.app { position: fixed; inset: 0; }

/* ---------- Yläpalkki (sama kuin muilla sivuilla) ---------- */
.site-header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; padding-bottom: 16px; }
.logo { display: flex; align-items: center; }
.logo img { height: 58px; width: auto; display: block; }
.nav { display: flex; gap: 28px; align-items: center; }
.nav a { color: var(--text); font-weight: 500; text-decoration: none; }
.nav a:hover { color: var(--forest); }
.nav a.nav-cta { background: #054437; color: #fff; padding: 8px 18px; border-radius: 8px; font-weight: 600; }
.nav a.nav-cta:hover { color: #fff; opacity: .85; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-toggle span { width: 24px; height: 2px; background: var(--text); }

/* Vaiheet paneelin yläreunassa */
.panel-steps { flex: none; padding: 18px 26px 0; }
.panel-steps-text { font-size: .8rem; font-weight: 700; color: var(--forest); margin-bottom: 8px; letter-spacing: .02em; }
.panel-steps-text b { display: inline-grid; place-items: center; min-width: 32px; height: 22px; padding: 0 7px; margin-right: 8px; border-radius: 999px; background: var(--forest); color: #fff; font-size: .74rem; }
.seg { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.seg li { height: 4px; border-radius: 2px; background: var(--bg-alt); transition: background .35s; }
.seg li.is-done { background: var(--accent); cursor: pointer; }
.seg li.is-active { background: var(--forest); }
.eyebrow { display: none; }

/* ---------- Kartta ---------- */
.map { position: absolute; inset: 0; }
.maplibregl-ctrl-top-right { top: calc(var(--topbar-h) + 8px); }
.maplibregl-ctrl-group { border-radius: 10px !important; box-shadow: 0 4px 14px rgba(0,0,0,.15) !important; }

.map-ui {
  position: absolute; z-index: 10;
  top: calc(var(--topbar-h) + 16px);
  left: calc(var(--panel-w) + 32px); right: 60px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
  pointer-events: none;
}
.map-ui > * { pointer-events: auto; }

.layer-switch {
  display: flex; padding: 4px; gap: 2px;
  background: rgba(255,255,255,.95); border-radius: 999px; box-shadow: var(--shadow);
}
.layer-switch button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; color: var(--muted);
}
.layer-switch button.is-active { background: var(--forest); color: #fff; }

.map-clear {
  border: 0; background: #fff; color: #b3261e; font-weight: 700; font-size: .88rem;
  padding: 9px 16px; border-radius: 999px; box-shadow: var(--shadow); cursor: pointer;
}
.map-clear:hover { background: #fdecea; }
.maplibregl-ctrl-group button { width: 38px !important; height: 38px !important; }

.map-hint, .draw-bar {
  background: rgba(31, 61, 43, .94); color: #fff;
  padding: 9px 16px; border-radius: 999px; font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow);
}
.draw-bar { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 16px; }
.draw-bar .chip-btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }
.draw-bar .chip-btn--primary { background: var(--accent); color: var(--forest); }

.stand-tip {
  position: absolute; z-index: 15; pointer-events: none;
  background: #fff; border-radius: 12px; padding: 10px 12px; min-width: 190px;
  box-shadow: var(--shadow); font-size: .82rem; line-height: 1.4;
  transform: translate(14px, 14px);
}
.stand-tip strong { display: block; color: var(--forest); font-size: .92rem; margin-bottom: 4px; }
.stand-tip dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; }
.stand-tip dt { color: var(--muted); }
.stand-tip dd { margin: 0; font-weight: 600; }
.stand-tip .warn { margin-top: 6px; color: var(--danger); font-weight: 600; }

/* ---------- Paneeli ---------- */
.panel {
  position: absolute; z-index: 12;
  top: calc(var(--topbar-h) + 16px); left: 16px; bottom: 16px;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  overflow: hidden;
}
.sheet-handle { display: none; }
.panel-scroll { flex: 1; overflow-y: auto; padding: 18px 26px 12px; overscroll-behavior: contain; }

.view { display: none; }
.view.is-active { display: block; animation: viewIn .35s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--forest-2); margin-bottom: .6em; }
.lead { color: var(--muted); font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
h3.sub { font-size: .95rem; margin-top: 1.4em; color: var(--text); }

/* Kentät */
.field-label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.field-help { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--border); background: #fff; font: inherit; color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--forest-2); box-shadow: 0 0 0 4px rgba(46,89,64,.12); }
.input.is-invalid { border-color: var(--danger); }
textarea.input { resize: vertical; }
.search { position: relative; margin-top: 18px; }
.search-row { display: flex; gap: 8px; }
.search-row .input { flex: 1; min-width: 0; }

.suggest {
  list-style: none; margin: 4px 0 0; padding: 6px; position: absolute; left: 0; right: 0; z-index: 5;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto;
}
.suggest li { padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: .92rem; }
.suggest li:hover, .suggest li.is-hl { background: var(--forest-soft); }
.suggest small { display: block; color: var(--muted); font-size: .78rem; }

.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0 0; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.perks { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 8px; font-size: .9rem; color: var(--muted); }
.perk-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--forest-soft); color: var(--forest); font-size: .72rem; font-weight: 700; margin-right: 10px; }

/* Napit */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: 10px; border: 1.5px solid transparent;
  font-weight: 700; font-size: .95rem; text-decoration: none; white-space: nowrap;
  transition: background .2s, transform .1s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-2); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--forest); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-grow { flex: 1; }

.chip-btn {
  border: 1.5px solid var(--border); background: #fff; color: var(--forest);
  padding: 7px 12px; border-radius: 999px; font-size: .84rem; font-weight: 600;
}
.chip-btn:hover { background: var(--bg); }
.chip-btn:disabled { opacity: .45; cursor: not-allowed; }
.chip-btn--primary { background: var(--forest); color: #fff; border-color: var(--forest); }
.chip-btn--primary:hover { background: var(--forest-2); }
.link-btn { border: 0; background: none; color: var(--sky); font-weight: 700; font-size: .88rem; padding: 4px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }

/* Vaihe 2 */
.parcel-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--forest-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px;
}
.parcel-card strong { display: block; color: var(--forest); font-size: 1.05rem; }
.parcel-card-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--forest-2); font-weight: 700; }
.parcel-card-meta { font-size: .82rem; color: var(--muted); }

.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: var(--bg-alt); border-radius: 12px; margin: 8px 0 12px; }
.segmented button { border: 0; background: transparent; padding: 9px; border-radius: 9px; font-weight: 700; font-size: .88rem; color: var(--muted); }
.segmented button.is-active { background: #fff; color: var(--forest); box-shadow: 0 2px 6px rgba(0,0,0,.08); }

.stand-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.stand-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 10px; font-size: .9rem;
  cursor: pointer; transition: border-color .2s, background .2s;
}
.stand-list li:hover { border-color: var(--forest-2); }
.stand-list li.is-sel { border-color: var(--forest); background: var(--forest-soft); }
.stand-no { width: 32px; height: 32px; flex: none; border-radius: 8px; display: grid; place-items: center; background: var(--bg-alt); font-weight: 700; color: var(--forest); font-size: .85rem; }
.is-sel .stand-no { background: var(--forest); color: #fff; }
.stand-info { flex: 1; min-width: 0; line-height: 1.3; }
.stand-info small { display: block; color: var(--muted); font-size: .78rem; }
.stand-ha { font-weight: 700; white-space: nowrap; }
.stand-warn { color: var(--danger); }
.stand-list .rm { border: 0; background: none; color: var(--muted); font-size: 1.1rem; padding: 0 4px; }

/* Vaihe 3 */
.product-list { display: grid; gap: 10px; margin-top: 10px; }
.product {
  position: relative; text-align: left; width: 100%;
  padding: 14px 16px 14px 52px; border-radius: 12px; border: 1.5px solid var(--border); background: #fff;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.product::before {
  content: ""; position: absolute; left: 16px; top: 17px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: #fff; transition: all .2s;
}
.product.is-sel { border-color: var(--forest); background: var(--forest-soft); box-shadow: 0 0 0 3px rgba(31,61,43,.08); }
.product.is-sel::before { border-color: var(--forest); background: var(--forest); box-shadow: inset 0 0 0 4px #fff; }
.product-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.product-name { font-weight: 700; color: var(--forest); }
.product-price { font-weight: 700; white-space: nowrap; font-size: .9rem; text-align: right; }
.product-price small { display: block; font-size: .74rem; font-weight: 600; opacity: .75; }
.product-desc { display: block; color: var(--muted); font-size: .84rem; margin-top: 3px; }
.product--only { padding-left: 16px; cursor: default; }
.product--only::before { display: none; }
.product-tag { display: inline-block; margin-top: 6px; font-size: .74rem; font-weight: 700; color: var(--forest-2); }

.pill-group { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { border: 1.5px solid var(--border); background: #fff; padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .88rem; color: var(--text); }
.pill:only-child { cursor: default; }
.pill.is-sel { background: var(--forest); color: #fff; border-color: var(--forest); }

.option-list { display: grid; gap: 8px; }
.option { text-align: left; padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: #fff; display: flex; justify-content: space-between; gap: 10px; }
.option small { display: block; color: var(--muted); font-size: .8rem; }
.option b { color: var(--forest); }
.option.is-sel { border-color: var(--forest); background: var(--forest-soft); }

/* Vaihe 4 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.fld { display: grid; gap: 5px; font-size: .86rem; font-weight: 700; }
.fld--wide { grid-column: 1 / -1; }

/* Vaihe 5 */
.review-map { margin: 10px 0 14px; border-radius: 12px; overflow: hidden; background: var(--bg-alt); aspect-ratio: 16/10; }
.review-map img { width: 100%; height: 100%; object-fit: cover; display: block; }
.review { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .9rem; }
.review dt { color: var(--muted); }
.review dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .86rem; color: var(--muted); padding: 12px; background: var(--bg); border-radius: 10px; cursor: pointer; }
.check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--forest); flex: none; }
.report-check { margin-top: 8px; }
.report-check[hidden] { display: none; }
.report-check b { color: var(--forest); }

.done-badge { width: 64px; height: 64px; border-radius: 50%; background: var(--forest); color: #fff; display: grid; place-items: center; font-size: 2rem; margin: 10px 0 18px; animation: pop .5s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Hinta + napit ---------- */
.panel-foot { border-top: 1px solid var(--border); padding: 14px 20px 16px; background: #fff; }
.price { background: var(--forest); color: #fff; border-radius: 14px; padding: 14px 16px 10px; margin-bottom: 12px; }
.price-main { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.price-label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; opacity: .7; font-weight: 700; }
.price-area { font-size: 1.1rem; font-weight: 700; }
.price-total-wrap { text-align: right; }
.price-total { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.price-vat { display: block; font-size: .78rem; font-weight: 600; letter-spacing: 0; opacity: .8; }
.price-vat[hidden] { display: none; }
.price-toggle { border: 0; background: none; color: var(--accent); font-size: .8rem; font-weight: 700; padding: 6px 0 2px; }
.price-toggle::after { content: " ▾"; }
.price-toggle[aria-expanded="true"]::after { content: " ▴"; }
.price-rows { margin: 6px 0 4px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: .84rem; }
.price-rows dt { opacity: .8; }
.price-rows dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.price-rows .sep { grid-column: 1/-1; height: 1px; background: rgba(255,255,255,.18); margin: 4px 0; }
.price-rows .metka { color: var(--accent); }

.nav-btns { display: flex; gap: 8px; }
.panel-msg { margin: 8px 0 0; font-size: .84rem; color: var(--danger); min-height: 0; }
.panel-msg:empty { display: none; }

/* Latausilmoitus */
.loader {
  position: absolute; z-index: 30; left: 50%; top: calc(var(--topbar-h) + 20px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: #fff; padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 600; font-size: .9rem;
}
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--forest-soft); border-top-color: var(--forest); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobiili: alapaneeli ---------- */
@media (max-width: 760px) {
  :root { --topbar-h: 67px; }
  .header-inner { padding-top: 10px; padding-bottom: 10px; }
  .logo img { height: 46px; }
  .nav { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); flex-direction: column; align-items: flex-start; padding: 16px 24px; display: none; gap: 18px; }
  .nav.open { display: flex; }
  .nav-toggle { display: flex; }
  .panel-steps { padding: 0 18px 4px; touch-action: none; cursor: grab; }
  .panel-steps-text { margin-bottom: 6px; }
  html, body { height: 100dvh; }

  /* Yläpalkki: logo + "2/5 · Alue" + ohut palkki */
  .map-ui { left: 12px; right: 12px; top: calc(var(--topbar-h) + 10px); }
  .maplibregl-ctrl-top-right { top: calc(var(--topbar-h) + 62px); }
  .map-clear { font-size: .82rem; padding: 7px 13px; }
  .layer-switch button { padding: 6px 11px; font-size: .8rem; }
  .map-hint, .draw-bar { font-size: .82rem; }
  .draw-bar { width: 100%; justify-content: space-between; border-radius: 14px; }

  /* Paneeli = alapaneeli */
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    border-radius: 20px 20px 0 0;
    height: var(--sheet-h, 55dvh);
    max-height: calc(100dvh - var(--topbar-h));
    transition: height .32s cubic-bezier(.2,.8,.2,1), border-radius .3s;
    box-shadow: 0 -10px 40px -10px rgba(18,38,26,.35);
  }
  .panel[data-sheet="full"] { border-radius: 0; }
  .panel.is-dragging { transition: none; }
  .panel[data-sheet="peek"] .panel-scroll { overflow: hidden; }
  .sheet-handle {
    display: block; flex: none; border: 0; background: transparent;
    padding: 12px 0 8px; touch-action: none; cursor: grab;
  }
  .sheet-handle span { display: block; margin: 0 auto; width: 40px; height: 5px; border-radius: 3px; background: #cfcabd; }
  .panel-scroll { padding: 4px 18px 16px; }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.2rem; }
  .eyebrow { display: none; }
  .lead { font-size: .95rem; }
  .perks { display: none; }

  /* Vaihe 2 tiiviiksi: tila + valintatapa näkyvät heti */
  .parcel-card { padding: 8px 12px; margin-bottom: 10px; }
  .parcel-card strong { display: inline; font-size: .95rem; }
  .parcel-card-label { display: none; }
  .parcel-card-meta { display: block; }
  .view[data-view="2"] h2 { display: none; }
  .segmented { margin-top: 0; }

  /* Alapalkki yhdelle riville */
  .panel-foot {
    display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .price { margin: 0; padding: 8px 12px; border-radius: 12px; cursor: pointer; min-width: 0; }
  .price-main { align-items: center; }
  .price-label { display: none; }
  .price-area { font-size: .85rem; opacity: .85; font-weight: 600; }
  .price-total { font-size: 1.3rem; }
  .price-toggle { display: none; }
  .price-rows { font-size: .8rem; }
  .nav-btns { gap: 6px; }
  .nav-btns .btn { padding: 13px 16px; }
  #backBtn { padding: 13px 14px; font-size: 0; }
  #backBtn::before { content: "←"; font-size: 1.1rem; }
  .panel-msg { grid-column: 1 / -1; margin: 0; }
  .panel-foot:has(#priceBox[hidden]) { grid-template-columns: 1fr; }
  .panel-foot:has(#priceBox[hidden]) .nav-btns { justify-content: stretch; }
  .panel-foot:has(#priceBox[hidden]) .btn-grow { flex: 1; }

  .form-grid { grid-template-columns: 1fr; }
  .loader { top: calc(var(--topbar-h) + 56px); white-space: nowrap; }

  /* Kuviokortti napautuksesta */
  .stand-tip {
    position: fixed; left: 12px !important; right: 12px; top: auto !important;
    bottom: calc(var(--sheet-px, 200px) + 10px);
    transform: none; min-width: 0;
    transition: bottom .32s cubic-bezier(.2,.8,.2,1);
  }
  .stand-tip dl { grid-template-columns: auto 1fr auto 1fr; }
  .stand-tip .state { float: right; font-weight: 700; font-size: .8rem; color: var(--forest-2); }
}

/* Palvelut-alavalikko (sama kuin style.css) */
.nav-drop { position: relative; }
.nav-drop summary { display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer; font-weight: 500; color: var(--text); }
.nav-drop summary::-webkit-details-marker { display: none; }
.nav-drop summary::after { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.nav-drop[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.nav-drop summary:hover { color: var(--forest); }
.nav-menu { position: absolute; top: calc(100% + 14px); left: -16px; z-index: 1000; display: flex; flex-direction: column; min-width: 220px; padding: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.nav-menu a { padding: 8px 12px; border-radius: 6px; }
.nav-menu a:hover { background: var(--bg); }
@media (max-width: 760px) {
  .nav-menu { position: static; min-width: 0; padding: 8px 0 0 12px; background: none; border: none; box-shadow: none; }
}

/* Upotettuna boorilannoitussivulle: ei omaa yläpalkkia */
html.upotus .site-header { display: none; }
