:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-alt: #f8f9f7;
  --text: #161916;
  --muted: #676d67;
  --line: #d9ddd8;
  --line-strong: #bcc3bc;
  --accent: #1f5a45;
  --accent-dark: #164435;
  --accent-soft: #e7f0eb;
  --danger: #9f2d24;
  --danger-soft: #faece9;
  --warning: #8a5a00;
  --warning-soft: #fff3d6;
  --found: #94500b;
  --found-soft: #fff0df;
  --clear: #23623b;
  --clear-soft: #e8f4eb;
  --info: #375d8a;
  --info-soft: #eaf1f8;
  --shadow: 0 12px 32px rgba(30, 37, 31, 0.06);
  --radius: 14px;
  --radius-small: 9px;
}

* { box-sizing: border-box; }
html { color-scheme: light; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.topbar { background: #121713; color: #fff; border-bottom: 1px solid #252c26; }
.topbar__inner, .page-shell, .footer__inner { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.topbar__inner { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.45rem, 2vw, 1.9rem); letter-spacing: -0.02em; }
.topbar__actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.build-badge { min-height: 42px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 10px; border: 1px solid #4b554d; border-radius: 9px; background: #1a211b; color: #dfe6e0; }
.build-badge strong { font-size: 0.75rem; line-height: 1; }
.build-badge span { font-size: 0.63rem; color: #aeb8b0; white-space: nowrap; }
.build-badge.is-current { border-color: #50846b; background: #193427; }
.build-badge.is-current span { color: #b9dbc8; }
.build-badge.is-stale { border-color: #b9872d; background: #3a2b13; }
.build-badge.is-stale span { color: #f0cf94; }
.build-badge.is-error { border-color: #995a52; background: #38211f; }
.build-badge.is-error span { color: #e4b6b0; }
.eyebrow, .section-kicker { margin: 0; font-size: 0.72rem; line-height: 1; letter-spacing: 0.11em; font-weight: 700; }
.eyebrow { color: #9fb2a5; }
.section-kicker { color: var(--accent); margin-bottom: 7px; }
.page-shell { padding: 28px 0 56px; }

.notice { border-radius: var(--radius-small); padding: 12px 14px; margin-bottom: 18px; font-size: 0.9rem; line-height: 1.45; }
.notice--info { color: #29496b; background: var(--info-soft); border: 1px solid #c9daec; }
.notice--warning { color: #684400; background: var(--warning-soft); border: 1px solid #ead49c; }
.compact-notice { margin: 18px 0 0; font-size: 0.78rem; }

.stepper { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0 0 18px; }
.stepper__item { min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 11px 12px; display: flex; gap: 10px; align-items: center; text-align: left; cursor: pointer; transition: border-color 0.15s ease, background 0.15s ease; }
.stepper__item:disabled { cursor: default; opacity: 0.48; }
.stepper__item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.stepper__item.is-complete:not(.is-active) { border-color: #aec4b8; }
.stepper__number { width: 29px; height: 29px; border-radius: 50%; display: inline-grid; place-items: center; flex: 0 0 auto; background: #eef0ed; font-weight: 700; font-size: 0.82rem; }
.stepper__item.is-active .stepper__number, .stepper__item.is-complete .stepper__number { background: var(--accent); color: #fff; }
.stepper__item strong, .stepper__item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper__item strong { font-size: 0.87rem; }
.stepper__item small { margin-top: 2px; color: var(--muted); font-size: 0.72rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(20px, 3vw, 32px); }
.panel + .panel { margin-top: 18px; }
.panel__header { border-bottom: 1px solid var(--line); padding-bottom: 17px; margin-bottom: 23px; }
.panel__header--split { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.panel__header h2 { font-size: clamp(1.25rem, 2vw, 1.65rem); margin: 0; letter-spacing: -0.02em; }
.panel__header p:not(.section-kicker) { margin: 7px 0 0; color: var(--muted); line-height: 1.5; font-size: 0.92rem; }

.form-grid { display: grid; grid-template-columns: minmax(220px, 0.75fr) minmax(300px, 1.6fr); gap: 24px; align-items: start; }
.field { min-width: 0; }
.field > label:first-child, .upload-area > label { display: block; margin-bottom: 7px; font-size: 0.84rem; font-weight: 700; }
input[type="text"], input[type="search"], input[type="file"] { width: 100%; }
input[type="text"], input[type="search"] { min-height: 46px; border: 1px solid var(--line-strong); border-radius: 9px; padding: 10px 12px; background: #fff; color: var(--text); outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
input[type="text"]:focus, input[type="search"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 90, 69, 0.12); }
input:disabled { background: #eceeeb; color: #888d88; }
.check-row { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 0.82rem; cursor: pointer; }
.check-row input { width: 16px; height: 16px; accent-color: var(--accent); }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 0.76rem; line-height: 1.45; }
.field--autocomplete { position: relative; }
.input-with-status { position: relative; }
.input-with-status input { padding-right: 42px; }
.spinner { position: absolute; width: 17px; height: 17px; right: 13px; top: 50%; margin-top: -8.5px; border: 2px solid #d8ddd9; border-top-color: var(--accent); border-radius: 50%; opacity: 0; pointer-events: none; }
.spinner.is-active { opacity: 1; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.suggestions { position: absolute; z-index: 20; top: calc(100% - 27px); left: 0; right: 0; max-height: 290px; overflow-y: auto; background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: 0 14px 34px rgba(25, 32, 26, 0.14); }
.suggestion { width: 100%; border: 0; border-bottom: 1px solid #eceeeb; background: #fff; padding: 11px 12px; text-align: left; cursor: pointer; line-height: 1.35; }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion.is-highlighted { background: var(--accent-soft); }
.suggestion strong { display: block; font-size: 0.86rem; }
.suggestion small { display: block; color: var(--muted); margin-top: 2px; }
.inline-error { margin-top: 18px; border: 1px solid #e6bdb8; background: var(--danger-soft); color: #7e251e; border-radius: 9px; padding: 11px 13px; font-size: 0.84rem; line-height: 1.45; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; align-items: center; }
.actions--right { justify-content: flex-end; }
.actions--compact { margin-top: 12px; }
.button { min-height: 42px; border-radius: 9px; border: 1px solid transparent; padding: 9px 15px; font-weight: 700; font-size: 0.86rem; cursor: pointer; transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button--primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button--primary:hover:not(:disabled) { background: var(--accent-dark); }
.button--secondary { background: #fff; border-color: var(--line-strong); }
.button--secondary:hover:not(:disabled) { border-color: #848c85; }
.button--ghost { color: #dfe6e0; background: transparent; border-color: #4b554d; }
.button--ghost:hover { background: #202821; }
.button--small { min-height: 34px; padding: 6px 10px; font-size: 0.76rem; }
.link-button { display: inline-flex; align-items: center; text-decoration: none; }

.property-confirmation { max-width: 760px; }
.property-list { margin: 0; border-top: 1px solid var(--line); }
.property-list > div { display: grid; grid-template-columns: 130px 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.property-list dt { color: var(--muted); font-size: 0.8rem; }
.property-list dd { margin: 0; font-weight: 700; font-size: 0.92rem; }
.confirmation-question { margin: 22px 0 0; font-size: 0.92rem; }

.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.choice-card { min-height: 164px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-alt); padding: 18px; text-align: left; cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease; }
.choice-card:hover { border-color: var(--accent); box-shadow: 0 8px 22px rgba(31, 90, 69, 0.08); }
.choice-card:active { transform: translateY(1px); }
.choice-card--test { background: #fffaf0; }
.choice-card__icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; margin-bottom: 15px; }
.choice-card--test .choice-card__icon { background: var(--warning-soft); color: var(--warning); }
.choice-card strong, .choice-card small { display: block; }
.choice-card strong { margin-bottom: 7px; font-size: 0.9rem; }
.choice-card small { color: var(--muted); line-height: 1.45; }
.upload-area { margin-top: 18px; border: 1px dashed var(--line-strong); border-radius: 12px; padding: 18px; background: #fafbf9; }
input[type="file"] { border: 1px solid var(--line); border-radius: 9px; padding: 9px; background: #fff; }
.file-list { margin: 12px 0 0; padding: 0; list-style: none; }
.file-list li { padding: 8px 10px; margin-top: 6px; background: #fff; border: 1px solid var(--line); border-radius: 7px; font-size: 0.8rem; }

.status-pill, .status { display: inline-flex; align-items: center; white-space: nowrap; border-radius: 999px; font-weight: 700; }
.status-pill { padding: 6px 10px; font-size: 0.72rem; }
.status-pill--neutral { background: #eceeeb; color: #4f554f; }
.status { padding: 4px 8px; font-size: 0.68rem; }
.status--fixed { background: #e9ebea; color: #222722; }
.status--clear { background: var(--clear-soft); color: var(--clear); }
.status--found { background: var(--found-soft); color: var(--found); }
.status--info { background: var(--info-soft); color: var(--info); }
.status--manual { background: var(--warning-soft); color: var(--warning); }
.status--pending { background: #f0f1ef; color: #777d77; }
.status--running { background: var(--info-soft); color: var(--info); }

.case-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.case-summary > div { min-width: 0; padding: 13px 14px; background: #fafbf9; border-right: 1px solid var(--line); }
.case-summary > div:last-child { border-right: 0; }
.case-summary span, .case-summary strong { display: block; }
.case-summary span { color: var(--muted); font-size: 0.7rem; margin-bottom: 4px; }
.case-summary strong { font-size: 0.82rem; overflow-wrap: anywhere; }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.module-card { border: 1px solid var(--line); border-radius: 11px; padding: 15px; background: #fff; min-width: 0; }
.module-card--wide { grid-column: 1 / -1; }
.module-card--done { border-color: #b9c9c0; background: #fbfdfb; }
.module-card--future { background: #fafafa; }
.module-card__top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.module-card h3 { margin: 1px 0 0; font-size: 0.88rem; }
.module-card p { margin: 11px 0 0; font-size: 0.82rem; line-height: 1.45; }
.module-card small { display: block; color: var(--muted); margin-top: 7px; font-size: 0.72rem; line-height: 1.4; }

.geometry-preview { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.aerial-frame { position: relative; width: 100%; aspect-ratio: 960 / 520; overflow: hidden; border-radius: 9px; background: #eef1ed; border: 1px solid #dce1dc; }
.ortho-tiles, .matrikel-wms-layer, .aerial-frame svg, .aerial-fallback { position: absolute; inset: 0; width: 100%; height: 100%; }
.ortho-tiles { z-index: 0; overflow: hidden; background: #e9ece7; }
.matrikel-wms-layer { z-index: 1; object-fit: fill; background: #f5f6f3; }
.ortho-tile { position: absolute; display: block; max-width: none; max-height: none; object-fit: fill; }
.aerial-frame svg { z-index: 3; pointer-events: none; }
.aerial-fallback { z-index: 2; display: grid; place-items: center; padding: 20px; text-align: center; color: var(--muted); font-size: 0.78rem; line-height: 1.45; background: linear-gradient(135deg, rgba(239,242,238,0.94), rgba(248,249,247,0.94)); }
.geometry-preview > p { color: var(--muted); font-size: 0.7rem; margin: 7px 0 0; }

.plan-list { display: grid; gap: 9px; margin-top: 12px; }
.plan-card { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: #fafbf9; }
.plan-card__heading { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: space-between; align-items: baseline; }
.plan-card__heading strong { font-size: 0.82rem; }
.plan-card__heading small { margin: 0; }
.plan-card p { margin-top: 7px; }
.plan-card__metadata { padding-top: 6px; border-top: 1px solid #e7eae6; }
.plan-card__actions { margin-top: 9px; }

.technical-details { margin-top: 18px; border: 1px solid var(--line); border-radius: 10px; background: #fafbf9; }
.technical-details summary { padding: 12px 14px; cursor: pointer; font-weight: 700; font-size: 0.8rem; }
.technical-details__body { border-top: 1px solid var(--line); padding: 14px; }
.technical-details__body p { color: var(--muted); font-size: 0.76rem; margin: 0 0 10px; }
.copy-feedback { font-size: 0.75rem; color: var(--accent); font-weight: 700; }
pre { max-height: 440px; overflow: auto; padding: 12px; margin: 0; border-radius: 8px; background: #121713; color: #dfe6e0; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.footer { border-top: 1px solid var(--line); background: #eceeea; }
.footer__inner { padding: 18px 0 28px; color: #5c625c; font-size: 0.72rem; line-height: 1.45; }
.footer__inner p { margin: 4px 0; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .topbar__inner { align-items: flex-start; padding: 16px 0; }
  .topbar__actions { max-width: 62%; }
  .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .choice-grid, .case-summary, .dashboard-grid { grid-template-columns: 1fr; }
  .module-card--wide { grid-column: auto; }
  .case-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .case-summary > div:last-child { border-bottom: 0; }
  .choice-card { min-height: auto; }
}

@media (max-width: 540px) {
  .topbar__inner, .page-shell, .footer__inner { width: min(100% - 20px, 1120px); }
  .topbar__inner { min-height: 78px; flex-direction: column; }
  .topbar__actions { width: 100%; max-width: none; justify-content: flex-start; }
  .build-badge { flex: 1 1 100%; }
  .topbar__inner .button { align-self: center; }
  .stepper { grid-template-columns: 1fr; }
  .stepper__item:not(.is-active) { display: none; }
  .panel { padding: 18px 14px; }
  .panel__header--split, .module-card__top { flex-direction: column; }
  .property-list > div { grid-template-columns: 1fr; gap: 4px; }
  .actions .button { flex: 1 1 auto; }
}

/* v0.2.2 - kortvisning */
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; flex-wrap: wrap; }
.map-refresh-button { margin-left: auto; }
.map-toolbar__statuses { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.segmented-control { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: #fff; }
.segmented-control__button { min-height: 34px; border: 0; border-right: 1px solid var(--line-strong); padding: 6px 11px; background: #fff; color: var(--muted); font-size: 0.74rem; font-weight: 700; cursor: pointer; }
.segmented-control__button:last-child { border-right: 0; }
.segmented-control__button.is-active { color: #fff; background: var(--accent); }
.map-toolbar__status { color: var(--muted); font-size: 0.72rem; text-align: right; }
.aerial-frame.is-parcel-map { background: #f5f6f3; }
.aerial-frame.is-parcel-map .ortho-tiles { display: none; }
.aerial-frame.is-aerial .matrikel-wms-layer { display: none; }
.aerial-frame.is-parcel-map .aerial-fallback { background: #f5f6f3; color: transparent; }
.map-settings { margin: 0 0 9px; border: 1px solid var(--line); border-radius: 9px; background: #fafbf9; }
.map-settings summary { cursor: pointer; padding: 9px 11px; color: #374038; font-size: 0.74rem; }
.map-settings__body { padding: 0 11px 11px; border-top: 1px solid #e7eae6; }
.map-settings__body p { margin: 9px 0; color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.key-row { display: grid; grid-template-columns: minmax(140px, auto) minmax(240px, 1fr) auto auto; gap: 8px; align-items: center; }
.key-row label { font-size: 0.72rem; font-weight: 700; }
.key-row input { min-height: 36px; width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 9px; }
#orthoKeyState.is-ready { color: var(--clear); font-weight: 700; }
.map-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 0.7rem; }
.map-legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend-swatch { width: 18px; height: 10px; display: inline-block; border-radius: 2px; }
.legend-swatch--subject { border: 2px solid #0b5d46; background: rgba(31, 90, 69, 0.18); }
.legend-swatch--neighbor { border: 1px solid #6e746f; background: rgba(255, 255, 255, 0.28); }
.legend-line { width: 20px; height: 0; display: inline-block; border-top: 2px solid #9fa69f; }
.parcel-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fafbf9; color: var(--muted); font-size: 0.72rem; }
.parcel-meta strong { color: var(--text); }
.boundary-note { margin-top: 10px !important; padding: 8px 10px; border-radius: 8px; background: #f1f3f1; color: var(--muted); font-size: 0.74rem !important; }

@media (max-width: 620px) {
  .map-toolbar { align-items: stretch; flex-direction: column; }
  .map-toolbar__statuses { align-items: flex-start; }
  .segmented-control { width: 100%; }
  .segmented-control__button { flex: 1 1 50%; }
  .map-toolbar__status { text-align: left; }
  .key-row { grid-template-columns: 1fr; }
}
