/* Rainways - appens utseende. Samma gröna som Streamlit-temat
   (.streamlit/config.toml): #375e43 i ljust läge, #6dbb85 i mörkt. */

:root {
  --bg: #ffffff;
  --bg-soft: #f0f2f6;
  --bg-sidebar: #f0f2f6;
  --surface: #ffffff;
  --text: #303a33;
  --text-muted: #6b7570;
  --border: #dde1e6;
  --accent: #375e43;
  --accent-text: #ffffff;
  --accent-soft: #e3ece5;
  --ok-bg: #e6f4ea; --ok-text: #1e5b33;
  --warn-bg: #fff4d6; --warn-text: #6b4e00;
  --error-bg: #fde8e7; --error-text: #8a1c14;
  --info-bg: #e7eefb; --info-text: #1d3f7a;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .05);
  --sheen: rgba(255, 255, 255, .6);
  --font: "Source Sans 3", "Source Sans Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --bg-soft: #161b22; --bg-sidebar: #161b22; --surface: #11161d;
    --text: #e6edf3; --text-muted: #9aa5b1; --border: #2a323c;
    --accent: #6dbb85; --accent-text: #0d1117; --accent-soft: #1d3125;
    --ok-bg: #12301c; --ok-text: #9ee2b3;
    --warn-bg: #3a2f0b; --warn-text: #f3d77d;
    --error-bg: #3b1513; --error-text: #f5a8a1;
    --info-bg: #13233f; --info-text: #a9c4f5;
    --shadow: none; --sheen: rgba(255, 255, 255, .05);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --bg-soft: #161b22; --bg-sidebar: #161b22; --surface: #11161d;
  --text: #e6edf3; --text-muted: #9aa5b1; --border: #2a323c;
  --accent: #6dbb85; --accent-text: #0d1117; --accent-soft: #1d3125;
  --ok-bg: #12301c; --ok-text: #9ee2b3;
  --warn-bg: #3a2f0b; --warn-text: #f3d77d;
  --error-bg: #3b1513; --error-text: #f5a8a1;
  --info-bg: #13233f; --info-text: #a9c4f5;
  --shadow: none; --sheen: rgba(255, 255, 255, .05);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.5;
}
a { color: var(--accent); }
h1 { font-size: 2.2rem; line-height: 1.15; margin: 0 0 1.25rem; }
h2 { font-size: 1.35rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .5rem; }
.icon { width: 1.15em; height: 1.15em; fill: currentColor; flex: none; vertical-align: -.2em; }

/* --- skal: sidopanel + innehåll -------------------------------------- */
/* Sidopanelens bakgrund som en kolumn hela vägen ner, även när innehållet
   är längre än skärmen (panelen själv är sticky och skärmhög). */
/* Med Rainways inställningar i menyn blir den bredare. */
.shell { --side-w: 260px; }
.shell:has(.side-settings), .shell:has(#rw-overview) { --side-w: 340px; }
.shell {
  display: flex; min-height: 100vh;
  background: linear-gradient(to right, var(--bg-sidebar) calc(var(--side-w) - 1px), var(--border) calc(var(--side-w) - 1px),
                              var(--border) var(--side-w), var(--bg) var(--side-w));
}
.sidebar {
  width: var(--side-w); flex: none; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 16px 18px; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo img { height: 64px; width: auto; display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo img { filter: invert(1) hue-rotate(180deg); } }
:root[data-theme="dark"] .logo img { filter: invert(1) hue-rotate(180deg); }
.nav { list-style: none; margin: 22px 0 0; padding: 0 0 16px; border-bottom: 1px solid var(--border); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: .95rem;
}
.nav a:hover { background: var(--accent-soft); }
.nav a[aria-current="page"] { font-weight: 600; position: relative; isolation: isolate; }
/* Markeringen för modulen man är i är ett eget element, så att den kan glida
   till nästa modul vid sidbytet (view-transition-name, se "Rörelse" nedan). */
.nav-pill { position: absolute; inset: 0; z-index: -1; border-radius: 6px; background: var(--accent-soft); view-transition-name: nav-pill; }
/* Tidigare körningar: en knapp som ser ut som modullänkarna och öppnar en
   panel över kartan bredvid menyn (_tidigare.html, static/tidigare.js). */
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--text); font: inherit; font-size: .95rem; text-align: left; cursor: pointer;
}
.nav-btn:hover, .nav-btn[aria-expanded="true"] { background: var(--accent-soft); }
.prev-panel {
  position: fixed; z-index: 12; top: 12px; bottom: 12px; left: calc(var(--side-w) + 12px);
  width: min(720px, calc(100vw - var(--side-w) - 24px)); overflow-y: auto; scrollbar-width: thin;
  padding: 14px 18px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(16, 24, 20, .18);
}
.prev-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.prev-head h2 { font-size: 1.05rem; margin: 0; }
.prev-head .btn { font-size: 1.2rem; line-height: 1; padding: 2px 9px; }
.prev-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font: inherit; font-size: .85rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.modules.prev-cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.prev-cards > .module[hidden] { display: none; }
.prev-cards .module { padding: 14px; }
.prev-cards .module .thumb { margin: -14px -14px 10px; }
.sidebar .spacer { flex: 1; }
/* Sidans eget innehåll i menyn - en behållare utan egen låda, så att
   inställningarnas flex och scroll gäller som förut. Översiktskartan byter
   innehållet när ett resultat öppnas på samma sida (static/oversikt.js). */
.sidebar-extra { display: contents; }
/* Rainways inställningar under modulerna: egen scroll, utloggningen kvar längst ner. */
.side-settings {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; margin: 0 -16px 12px; padding: 16px 16px 0;
  scrollbar-width: thin;
}
.side-settings ~ .spacer, .sidebar-extra:has(.side-settings) ~ .spacer { display: none; }
/* Senaste analyserna under inställningarna (_senaste.html): egen scroll. */
.side-recent {
  flex: 0 1 auto; min-height: 0; max-height: 32vh; overflow-y: auto; margin: 0 -16px 12px; padding: 12px 16px 0;
  border-top: 1px solid var(--border); scrollbar-width: thin;
}
.side-recent h2 { font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 .4rem; }
.side-recent ~ .spacer, .sidebar-extra:has(.side-recent) ~ .spacer { display: none; }
.sidebar-extra > .side-recent:first-child { flex-grow: 1; max-height: none; }
.side-settings[hidden] ~ .spacer, .sidebar-extra:has(> .side-settings[hidden]):not(:has(> .side-settings:not([hidden]))) ~ .spacer { display: block; }
/* Analysen som visas, överst i menyn på resultatsidorna (_korning_kort.html). */
.side-run { margin-top: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); flex: none; }
.side-run h2 { font-size: 1.1rem; margin-bottom: .5rem; }
.run-facts { margin: 0 0 12px; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
.run-facts div { display: contents; font-size: .9rem; }
.run-facts dt, .run-facts dd { font-size: .9rem; }
.run-facts dt { color: var(--text-muted); }
.run-facts dd { margin: 0; }
.run-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.run-actions .btn { font-size: .82rem; padding: 5px 10px; }
.rw-new-toggle { width: 100%; justify-content: center; }
.side-settings h2 { font-size: 1.1rem; margin-bottom: .25rem; }
.side-settings .rw-run { background: var(--bg-sidebar); bottom: 0; padding-bottom: 10px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 20px; min-height: 56px; }
.btn.menu-toggle { display: none; }
.backdrop { display: none; }
.user-badge {
  display: inline-flex; align-items: center; gap: 6px; max-width: min(24rem, 100%);
  padding: 4px 12px 4px 8px; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); text-decoration: none; font-size: .875rem; background: var(--surface);
}
.user-badge span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-badge:hover { border-color: var(--accent); }
.content { width: 100%; max-width: 1100px; margin: 0 auto; padding: 8px 40px 48px; }

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow);
    width: min(var(--side-w), 88vw);
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .35); }
  .shell { background: var(--bg); }
  .topbar { justify-content: space-between; padding: 8px 16px; }
  .btn.menu-toggle { display: inline-flex; }
  .user-badge span { display: none; }
  .user-badge { padding: 5px; }
  .content { padding: 4px 16px 40px; }
  h1 { font-size: 1.8rem; }
}

/* --- komponenter ------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; line-height: 1.3;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-text); }
.btn.icon-only { padding: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a {
  padding: 8px 0; color: var(--text); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent;
  font-size: .95rem;
}
.tabs a[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .tab-count {
  display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: 4px; border-radius: 999px; background: var(--accent);
  color: #fff; font-size: .72rem; font-weight: 600; line-height: 1.45; text-align: center; vertical-align: 1px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 20px; } }

.facts { margin: 0; }
.facts div { margin: 0 0 .35rem; }
.facts dt { display: inline; font-weight: 600; }
.facts dt::after { content: ": "; }
.facts dd { display: inline; margin: 0; }

.metric .label { font-size: .875rem; color: var(--text-muted); }
.metric .value { font-size: 2.1rem; line-height: 1.2; }
.caption { color: var(--text-muted); font-size: .875rem; }
ul.varningar { list-style: none; margin: 6px 0 0; padding: 0; font-size: .85rem; color: var(--warn-text); }
ul.varningar li { display: flex; gap: 6px; align-items: flex-start; margin: 3px 0; }
ul.varningar .icon { flex-shrink: 0; margin-top: .1em; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin: 8px 0; }
.alert .icon { margin-top: .15em; }
.alert.ok { background: var(--ok-bg); color: var(--ok-text); }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); }
.alert.error { background: var(--error-bg); color: var(--error-text); }
.alert.info { background: var(--info-bg); color: var(--info-text); }
.alert[hidden] { display: none; }

.card { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; background: var(--surface); margin: 0 0 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

label { display: block; font-size: .875rem; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=search], input[type=password], select {
  width: 100%; padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg-soft); color: var(--text); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: .95rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 8px 0; }
legend { font-size: .875rem; padding: 0; margin: 6px 0 2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; overflow-wrap: anywhere;
}

details.user { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 8px; background: var(--surface); }
details.user > summary {
  list-style: none; cursor: pointer; padding: 10px 14px; display: flex; align-items: center; gap: 10px;
}
details.user > summary::-webkit-details-marker { display: none; }
details.user > summary .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.user > summary .chev { transition: transform .15s; }
details.user[open] > summary .chev { transform: rotate(180deg); }
details.user .body { padding: 0 14px 14px; }
.tag { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--bg-soft); color: var(--text-muted); }
.tag.off { background: var(--error-bg); color: var(--error-text); }
.tag.ok { background: var(--accent-soft); color: var(--accent); margin-left: 4px; }

table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font-weight: 600; color: var(--text-muted); font-size: .82rem; }
.table-wrap { overflow-x: auto; }

.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.module {
  display: block; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; background: var(--surface);
}
.module:hover { border-color: var(--accent); }
.start-h { font-size: 1rem; margin: 28px 0 10px; color: var(--text-muted); font-weight: 600; }
.recent-cards .module h3 { gap: 6px; align-items: baseline; }
.recent-cards .module h3 .caption { font-weight: 400; font-size: .85rem; }
.module h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
/* Kartbilden överst på startsidans kort (rainways.thumbnails): grå medan
   den laddas, sedan tonar den in. */
.module .thumb {
  margin: -18px -18px 14px; aspect-ratio: 16 / 9; overflow: hidden; position: relative;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0; background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.module .thumb img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s; }
.module .thumb img.on { opacity: 1; }
/* Rainways-sidans körningar: rubrikens länk täcker hela kortet, knappen och
   frågetecknet ligger ovanpå den. */
.run-cards .module { position: relative; display: flex; flex-direction: column; }
.run-cards .module h3 { gap: 6px; align-items: baseline; flex-wrap: wrap; }
.run-cards .module h3 a { color: inherit; text-decoration: none; display: inline-block; }
.run-cards .module h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.run-cards .module h3 .caption { font-weight: 400; font-size: .85rem; }
.run-cards .rw-help, .run-cards .run-foot .btn { position: relative; z-index: 2; }
.run-foot .btn { white-space: nowrap; flex: none; }
.run-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.run-cards .module:focus-within { border-color: var(--accent); }

.htmx-request .spinner, .spinner.htmx-request { display: inline-block; }
.spinner { display: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.centered { max-width: 560px; margin: 10vh auto; padding: 0 16px; }
/* Inloggningen (mapservice.login_page): ett smalt kort mitt på sidan. */
.login { max-width: 400px; }
.login .logo { height: 56px; }
.login form .btn.primary { width: 100%; justify-content: center; margin-top: 14px; }
.login .alt { margin-top: 18px; display: grid; gap: 8px; }
.login .alt .btn { justify-content: center; }
.login form .btn { width: 100%; justify-content: center; margin-top: 14px; }
.login .sso { margin: 18px 0 0; }
.login .sso form .btn { margin-top: 8px; }
.login .divider { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .85rem; margin: 22px 0 4px; }
.login .divider::before, .login .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.code-input { letter-spacing: .3em; font-variant-numeric: tabular-nums; font-size: 1.25rem; text-align: center; }
.qr { width: 200px; max-width: 100%; background: #fff; border-radius: var(--radius); padding: 6px; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { font-family: ui-monospace, monospace; letter-spacing: .08em; word-break: break-all; }
.recovery-codes { columns: 2; font-family: ui-monospace, monospace; font-size: 1.05rem; list-style: none; padding: 0; }
.recovery-codes li { padding: 3px 0; }
.method-list { list-style: none; padding: 0; margin: 8px 0; }
.method-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.method-list form { margin: 0; }

/* --- Rainways ----------------------------------------------------------- */
/* Rainways och resultatsidorna använder hela bredden bredvid menyn -
   kartan ska växa med skärmen, inte ligga i en fast spalt i mitten. */
.content:has(.rw-layout), .content:has(.rw-result) { max-width: none; padding-left: 28px; padding-right: 28px; }
.rw-main { max-width: 1100px; }
.rw-run { position: sticky; bottom: -18px; background: var(--surface); padding: 12px 0 4px; margin-top: 12px; }
.hit-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.hit {
  text-align: left; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .92rem;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
}
.hit:hover { background: var(--accent-soft); }
.hit.selected { background: var(--accent-soft); font-weight: 600; }
a.hit { display: block; text-decoration: none; }
/* Rainways inställningsgrupper (rainways/_grupp.html): en rubrik per grupp,
   hopfälld med en sammanfattning av valen. */
.rw-group-head, .rw-group > summary, .rw-group .g-row { font-size: .95rem; font-weight: 600; }
.rw-group-head { margin: 16px 0 2px; padding-top: 12px; border-top: 1px solid var(--border); }
.rw-group-head.first { margin-top: 10px; padding-top: 0; border-top: 0; }
.rw-group { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.rw-group > summary, .rw-group .g-row { list-style: none; display: flex; align-items: baseline; gap: 8px; }
.rw-group > summary { cursor: pointer; }
.rw-group > summary::-webkit-details-marker { display: none; }
.rw-group .g-title { flex: none; }
.rw-group .g-sum {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
  font-weight: 400; font-size: .85rem; color: var(--text-muted);
}
.rw-group[open] .g-sum { visibility: hidden; }
.rw-group .chev { align-self: center; transition: transform .15s; color: var(--text-muted); }
.rw-group[open] .chev { transform: rotate(180deg); }
.rw-group .g-body { padding: 2px 0 4px; }
.rw-group.fixed { opacity: .6; cursor: default; }
.rw-group.fixed .g-row { padding-right: calc(1.15em + 8px); }
details.advanced { margin: 12px 0 0; }
details.advanced > summary, details.card > summary, details.log > summary { cursor: pointer; font-size: .92rem; }
details.card > summary { font-weight: 600; }
.progress { height: 8px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin: 10px 0 6px; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s ease; }
details.log pre {
  max-height: 320px; overflow: auto; font-size: .78rem; background: var(--bg-soft); padding: 10px;
  border-radius: var(--radius); white-space: pre-wrap;
}
.map-frame { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
/* Lika hög som fönstret minus den övre raden (56 px) och lite luft:
   scrollar man ner till kartan fyller den skärmen, oavsett skärmstorlek. */
.map-frame { scroll-margin-top: 64px; }
.map-frame iframe { display: block; width: 100%; height: calc(100vh - 80px); min-height: 460px; border: 0; }
dl.notes { margin: 14px 0; }
dl.notes > div { margin: 0 0 6px; font-size: .92rem; }
dl.notes dt { display: inline; font-weight: 600; }
dl.notes dt::after { content: ": "; }
dl.notes dd { display: inline; margin: 0; color: var(--text-muted); }
ul.files { margin: 8px 0 0; padding-left: 18px; font-size: .88rem; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .bar, .swatch.bar { fill: #7aa7d9; background: #7aa7d9; }
svg.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.swatch { display: inline-block; width: 12px; height: 4px; vertical-align: middle; border-radius: 2px; }
.swatch.line { background: var(--accent); }
.swatch.sq { width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; }
.gr-sites tbody tr { cursor: pointer; }
.gr-sites tbody tr:hover, .gr-sites tbody tr:focus-visible { background: var(--accent-soft); }
svg.chart text { font-size: 10px; fill: var(--text-muted); }
/* transform i stället för margin-left: animeras av grafikkortet, utan ny layout varje bildruta. */
.progress .indeterminate { width: 40%; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
@media (max-width: 760px) {
  .content:has(.rw-layout), .content:has(.rw-result) { padding-left: 16px; padding-right: 16px; }
  .map-frame iframe { height: calc(100vh - 72px); min-height: 380px; }
}

/* --- Resultatsidor: kartan är hela sidan (2026-10-20) ------------------
   Sidan scrollar inte - det var lätt att råka scrolla sidan när man
   menade att zooma kartan. Nyckeltalen ligger i en halvgenomskinlig rad
   överst i kartan, detaljerna i en panel som skjuts ut från höger. */
body.map-page { overflow: hidden; }
body.map-page .main { height: 100vh; }
body.map-page .content { max-width: none; padding: 0; flex: 1; position: relative; min-height: 0; }
.map-stage { position: absolute; inset: 0; overflow: hidden; }
.map-full, .ov-map { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
/* Glasraden: över hela kartans bredd, halvgenomskinlig och suddig så att
   kartan anas under. Ortens namn och nyckeltalens siffror bär raden -
   etiketter och enheter är små och tunna. Kartans egna kontroller flyttas
   ner under raden (_drawer_js.html). */
.map-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px 32px; padding: 12px 28px 13px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .72), rgba(255, 255, 255, .52));
  backdrop-filter: blur(16px) saturate(170%); -webkit-backdrop-filter: blur(16px) saturate(170%);
  border-bottom: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 1px 0 rgba(20, 35, 28, .08), 0 8px 24px -12px rgba(20, 35, 28, .35);
  color: #17201b; line-height: 1.2;
}
.mh-id { min-width: 0; flex: 1 1 auto; }
.mh-eyebrow {
  display: flex; align-items: center; gap: 7px; font-size: .68rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: #2f6a45;
}
.mh-eyebrow a { color: inherit; text-decoration: none; opacity: .65; }
.mh-eyebrow a:hover { opacity: 1; }
.mh-eyebrow span { opacity: .45; }
.mh-place {
  margin: 2px 0 0; font-size: 1.65rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mh-kommun { margin-left: 10px; font-size: .95rem; font-weight: 400; letter-spacing: 0; color: #5d6862; }
.mh-sub {
  margin-top: 3px; font-size: .82rem; font-weight: 400; color: #47524c;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mh-metrics { display: flex; align-items: stretch; margin: 0; flex: 0 0 auto; }
.mh-metric { padding: 1px 22px; border-left: 1px solid rgba(23, 32, 27, .14); cursor: help; }
.mh-metric:first-child { border-left: 0; padding-left: 0; }
.mh-metric.is-link { cursor: pointer; border-radius: 8px; transition: background-color .15s; }
.mh-metric.is-link:first-child { padding-left: 12px; }
.mh-metric.is-link:hover, .mh-metric.is-link:focus-visible { background: rgba(55, 94, 67, .08); outline: none; }
.mh-metric.is-link:focus-visible { box-shadow: 0 0 0 2px #375e43; }
.mh-metric.is-link:hover dt, .mh-metric.is-link:focus-visible dt { color: #375e43; }
.mh-metric dd {
  margin: 0; font-size: 1.75rem; font-weight: 300; letter-spacing: -.02em; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mh-unit { margin-left: 4px; font-size: .9rem; font-weight: 500; letter-spacing: 0; color: #5d6862; }
.mh-metric dt {
  margin-top: 5px; font-size: .64rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: #5d6862; white-space: nowrap;
}
.mh-edit {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: #1f4a2e; text-decoration: none; white-space: nowrap;
  background: rgba(255, 255, 255, .55); border: 1px solid rgba(31, 74, 46, .25);
}
.mh-edit:hover { background: rgba(255, 255, 255, .9); border-color: rgba(31, 74, 46, .5); }
/* "Inställningar" i raden öppnar menyn - bara på mobil, där menyn är dold. */
.mh-edit { display: none; cursor: pointer; font: inherit; }
/* Svar från inställningarna på en resultatsida (t.ex. ett fel) ovanpå kartan. */
.rw-main-float { position: absolute; left: 12px; bottom: 64px; z-index: 8; width: min(420px, calc(100% - 24px)); }
.rw-main-float:empty { display: none; }
/* Ett resultat monterat ovanpå översiktskartan på samma sida (static/oversikt.js). */
.rw-mounted { position: absolute; inset: 0; z-index: 3; }
/* Översiktskartans uppmaning innan en ort valts (rainways/page.html). */
.ov-hint {
  position: absolute; left: 50%; top: 22px; transform: translateX(-50%); z-index: 4; margin: 0;
  padding: 8px 16px; border-radius: 999px; font-size: .9rem; font-weight: 600; color: #17201b;
  background: rgba(255, 255, 255, .72); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 6px 20px -10px rgba(20, 35, 28, .45); pointer-events: none;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .map-head { background: rgba(255, 255, 255, .92); }
}
.drawer-tab {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px 9px 10px; border: 0;
  border-radius: 8px 0 0 8px; background: #fff; color: #2b322e; font: inherit; font-size: .88rem;
  font-weight: 600; box-shadow: 0 1px 6px rgba(0, 0, 0, .3); cursor: pointer;
}
.drawer-tab:hover { background: #f2f5f3; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 7; width: min(460px, 94%);
  background: var(--bg); color: var(--text); border-left: 1px solid var(--border);
  box-shadow: -4px 0 18px rgba(0, 0, 0, .18); overflow-y: auto; padding: 14px 18px 24px;
  transform: translateX(105%); transition: transform .22s ease; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.drawer-head h2 { margin: 0; }
.drawer .card { margin-top: 14px; }
.drawer-sections .card:first-child { margin-top: 18px; }
/* Flikar i detaljpanelen: en sak i taget i stället för en lång kolumn. */
.drawer-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin: 4px 0 2px; }
.drawer-tabs button {
  border: 0; background: none; padding: 7px 0 8px; font: inherit; font-weight: 600; font-size: .92rem;
  color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
}
.drawer-tabs button:hover { color: var(--text); }
.drawer-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .drawer { transition: none; } }
/* Smalare fönster: nyckeltalen på en egen rad under namnet. */
@media (max-width: 1100px) {
  .map-head { flex-wrap: wrap; padding: 10px 18px 11px; }
  .mh-metrics { order: 3; flex-basis: 100%; }
  .mh-place { font-size: 1.4rem; }
  .mh-metric dd { font-size: 1.4rem; }
}
@media (max-width: 760px) {
  body.map-page .main { height: 100dvh; }
  .map-head { gap: 6px 12px; padding: 8px 12px 9px; }
  .mh-eyebrow { font-size: .6rem; }
  .mh-place { font-size: 1.15rem; }
  .mh-kommun, .mh-sub { display: none; }
  .mh-id { flex-basis: calc(100% - 120px); }
  .mh-edit { display: inline-flex; padding: 5px 12px; font-size: .72rem; }
  .mh-metric { padding: 0 12px; }
  .mh-metric dd { font-size: 1.1rem; }
  .mh-unit { font-size: .72rem; }
  .mh-metric dt { font-size: .56rem; letter-spacing: .08em; }
  .drawer-tab span { display: none; }
}

/* Förklaring bakom ett frågetecken (makrot help() i _grupp.html, static/help.js). */
.rw-help { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 17px; height: 17px;
  margin-left: 6px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface);
  color: var(--text-muted); font: 700 11px/1 var(--font); cursor: help; vertical-align: 1px; }
.rw-help:hover, .rw-help:focus-visible, .rw-help.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.rw-help:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check .rw-help { margin-left: 2px; }
.rw-help-pop { position: fixed; z-index: 10000; max-width: 300px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: .85rem; line-height: 1.45;
  box-shadow: 0 6px 24px rgba(16, 24, 20, .18); }
.rw-help-pop[hidden] { display: none; }
/* Startsidans tabell över de senaste analyserna. */
.btn.small { font-size: .8rem; padding: 3px 10px; }
/* Fastighetsanalysens sida (templates/fastighet/plats.html). */
.fs-title { margin: 4px 0 2px; }
.fs-map { display: block; width: 100%; height: clamp(440px, 48vh, 760px); margin: 14px 0 18px; border: 1px solid var(--border); border-radius: 10px; }
/* Spalter i stället för ett rutnät: korten är olika höga, och i ett rutnät
   lämnade ett kort stora luckor bredvid ett högre. */
/* Fastighetssidan fyller skärmen: korten i så många spalter som får plats
   (minst 420 px breda) och kartan högre på stora skärmar. */
.fs-page .rw-main { max-width: none; }
.fs-page > .rw-main > .caption, .fs-page .fs-all-row { max-width: 1100px; }
.fs-cards { columns: 420px; column-gap: 16px; }
.fs-card { margin: 0 0 16px; break-inside: avoid; }
.fs-card h2 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin-bottom: 10px; }
.fs-card h2 .icon { width: 1.2em; height: 1.2em; fill: var(--accent); }
.fs-big { font-size: 2rem; font-weight: 300; line-height: 1.1; font-variant-numeric: tabular-nums; }
/* Skyfallsscreeningen (rainways.skyfallsscreening): svaret, klimatreglaget och kurvan. */
.fs-screen { display: grid; gap: 6px; margin: 12px 0 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.fs-verdict { margin: 0; font-size: 0.98rem; }
.fs-verdict b { font-weight: 600; }
.fs-verdict.alt { color: var(--accent); }
.fs-climate { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-muted); }
.fs-climate input { flex: 0 0 140px; accent-color: var(--accent); }
.fs-mass { max-width: 1200px; }
.fs-mass textarea { width: 100%; box-sizing: border-box; font: inherit; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface, #fff); color: inherit; margin: 8px 0; resize: vertical; }
.fs-mass .table-wrap { overflow-x: auto; }
.fs-mass td.num, .fs-mass th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fs-big span { font-size: .95rem; font-weight: 500; color: var(--text-muted); }
.fs-gauges { margin: 6px 0 8px; }
.fs-gauges svg { display: block; max-width: 100%; height: auto; }
.fs-sub { margin: 14px 0 2px; font-size: .95rem; }
.fs-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 7px; vertical-align: -1px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 25%, transparent); }
.fs-grade { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: .78rem; white-space: nowrap; }
.fs-grade.bra { background: color-mix(in srgb, #16a34a 18%, transparent); }
.fs-grade.flackt { background: color-mix(in srgb, #eab308 24%, transparent); }
.fs-grade.mot { background: color-mix(in srgb, #dc2626 22%, transparent); }
.fs-grade.risk1 { background: color-mix(in srgb, #7f1d1d 30%, transparent); }
.fs-grade.risk2 { background: color-mix(in srgb, #dc2626 24%, transparent); }
.fs-grade.risk3 { background: color-mix(in srgb, #f97316 24%, transparent); }
.fs-grade.risk4 { background: color-mix(in srgb, #eab308 24%, transparent); }
.fs-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fs-months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; height: 64px; margin: 10px 0 4px; }
.fs-months div { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; }
.fs-months i { display: block; width: 100%; background: linear-gradient(#f59e0b, #fbbf24); border-radius: 3px 3px 0 0; min-height: 2px; }
.fs-months span { font-size: .68rem; color: var(--text-muted); line-height: 1; }
.fs-form fieldset { display: flex; gap: 16px; border: 0; padding: 0; margin: 0 0 8px; }
.fs-roof { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.fs-roof label { font-size: .85rem; }
.fs-roof[hidden] { display: none; }
.data.compact td, .data.compact th { padding: 4px 8px; font-size: .85rem; }
.fs-report-text { max-height: 13.5em; overflow-y: auto; margin: 0 0 12px; padding-right: 6px; font-size: .92rem; scrollbar-width: thin; }
.fs-report-list { max-height: 15em; overflow-y: auto; margin: 0 0 12px; padding: 0 6px 0 1.1em; font-size: .9rem; scrollbar-width: thin; }
.fs-report-list li { margin: 0 0 4px; }
/* "Kör alla analyser" (templates/fastighet/_alla.html). */
.fs-all { margin: 12px 0 0; }
.fs-all-row { display: flex; align-items: center; gap: 12px; }
.fs-all-row .progress { flex: 1; max-width: 420px; margin: 0; }
.fs-all-row .btn { white-space: nowrap; }
.fs-all-row .btn .icon { width: 1.1em; height: 1.1em; margin-right: 4px; vertical-align: -.2em; fill: currentColor; }

/* Skelettkort medan fastighetssidans analyser laddas: kortets form i grått
   i stället för en förloppsmätare, så att sidan inte hoppar när innehållet kommer. */
.skeleton .sk { display: block; height: 12px; width: 88%; margin: 0 0 12px; border-radius: 6px; background: var(--bg-soft); position: relative; overflow: hidden; }
.skeleton .sk-title { width: 42%; height: 18px; margin-bottom: 18px; }
.skeleton .sk-big { width: 28%; height: 32px; margin-bottom: 16px; }
.skeleton .sk.short { width: 58%; margin-bottom: 4px; }

/* Laddningslinjen överst vid sidbyten (motion.js). */
.nav-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10001; pointer-events: none;
  background: var(--accent); box-shadow: 0 0 10px var(--accent); transform-origin: 0 50%; transform: scaleX(0);
  animation: nav-progress 9s cubic-bezier(.08, .7, .2, 1) .12s forwards;
}
@keyframes nav-progress { 8% { transform: scaleX(.3); } 100% { transform: scaleX(.94); } }
@media (prefers-reduced-motion: reduce) { .nav-progress { animation: none; transform: scaleX(.6); } }

/* Aviseringar nere till höger: en analys längre ner på sidan blev klar (motion.js). */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 10000; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: .92rem;
  box-shadow: 0 8px 28px -8px rgba(16, 24, 20, .3);
}
.toast .icon { fill: var(--accent); }
.toast.out { opacity: 0; transform: translateX(16px); transition: opacity .25s, transform .25s; }

/* --- Rörelse ------------------------------------------------------------
   Sidbyten tonar över (view transitions mellan sidor), menyns markering
   glider till nästa modul, kort tonar in ett efter ett, nyckeltal räknas upp
   (motion.js) och ett kort lyser till när dess analys blir klar. Bara
   transform och opacitet animeras - det sköter grafikkortet utan ny layout,
   så bildfrekvensen håller. Med "minska rörelse" i systemet står allt still. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .sidebar { view-transition-name: sidebar; }
  ::view-transition-group(*) { animation-duration: .32s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
  ::view-transition-old(root) { animation: .16s ease-in both vt-out; }
  ::view-transition-new(root) { animation: .32s cubic-bezier(.2, .7, .2, 1) both vt-in; }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
  /* Byte mellan ljust och mörkt (motion.js): det nya temat tonar in över det gamla. */
  :root.theme-vt::view-transition-old(*) { animation: none; }
  :root.theme-vt::view-transition-new(*) { animation: .6s ease both vt-fade; }
  :root.theme-vt::view-transition-group(*) { animation: none; }
  @keyframes vt-fade { from { opacity: 0; } }

  /* Korten tonar in i tur och ordning (--i sätts av motion.js). */
  .modules > .module, .rise {
    animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(min(var(--i, 0), 12) * 45ms + 60ms);
  }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }

  /* Kort och knappar svarar på muspekaren. Skuggan ligger i ett eget lager
     som bara byter opacitet - en box-shadow som ändras ritas om varje ruta. */
  .module { position: relative; transition: transform .22s cubic-bezier(.2, .7, .2, 1), border-color .2s; }
  .module::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0;
    box-shadow: 0 10px 28px -10px rgba(20, 45, 30, .35); transition: opacity .22s;
  }
  .module:hover { transform: translateY(-3px); }
  .module:hover::after { opacity: 1; }
  .btn { transition: transform .12s, background-color .15s, border-color .15s; }
  .btn:active { transform: scale(.97); }

  /* Ett kort vars analys just blev klar lyser till en gång. */
  .just-done { animation: done-pop .5s cubic-bezier(.2, .7, .2, 1) both; position: relative; }
  .just-done::before {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
    box-shadow: 0 0 0 2px var(--accent), 0 0 24px 2px rgba(55, 94, 67, .35); animation: done-glow 1.8s ease-out both;
  }
  @keyframes done-pop { from { opacity: .4; transform: scale(.985); } }
  @keyframes done-glow { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

  /* Förloppsmätaren: ett ljusskimmer som löper över den fyllda delen. */
  .progress > div:not(.indeterminate) { position: relative; overflow: hidden; }
  .progress > div:not(.indeterminate)::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    animation: shimmer 1.6s ease-in-out infinite;
  }
  @keyframes shimmer { to { transform: translateX(100%); } }

  /* Glasraden glider ner när en resultatsida öppnas. */
  .map-head { animation: head-in .6s cubic-bezier(.2, .7, .2, 1) both; }
  .mh-metric dd, .metric .value { font-variant-numeric: tabular-nums; }
  .mh-metric { animation: rise .6s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms + 180ms); }
  @keyframes head-in { from { opacity: 0; transform: translateY(-100%); } }

  /* Laddningssidan för kartan andas. */
  .map-loading img { animation: breathe 2.4s ease-in-out infinite; }
  @keyframes breathe { 50% { transform: scale(1.05); opacity: .8; } }

  /* Skelettkorten skimrar, i takt med varandra. */
  .skeleton .sk::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, var(--sheen), transparent); animation: shimmer 1.5s ease-in-out infinite;
  }

  /* En utfällning (details) tonar fram sitt innehåll när den öppnas. */
  details[open] > :not(summary) { animation: unfold .28s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes unfold { from { opacity: 0; transform: translateY(-6px); } }

  /* Hjälprutan växer fram ur frågetecknet. */
  .rw-help-pop:not([hidden]) { animation: pop-in .16s cubic-bezier(.2, .7, .2, 1) both; transform-origin: 12px 0; }
  .rw-help-pop.above:not([hidden]) { transform-origin: 12px 100%; }
  @keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(-3px); } }

  /* Ljus som följer muspekaren över startsidans kort (--mx/--my från motion.js).
     Ett eget lager under texten; bara det lagret ritas om när musen rör sig. */
  .module { isolation: isolate; }
  .module::before {
    content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: 0;
    background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%);
    transition: opacity .3s;
  }
  .module:hover::before { opacity: 1; }
  /* Kartbilden: skimrar medan den laddas och zoomar lätt under muspekaren. */
  .module .thumb::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%); pointer-events: none;
    background: linear-gradient(90deg, transparent, var(--sheen), transparent); animation: shimmer 1.5s ease-in-out infinite;
  }
  .module .thumb:has(img.on)::after, .module .thumb.none::after { display: none; }
  .module .thumb img { transition: opacity .4s, transform .5s cubic-bezier(.2, .7, .2, 1); }
  .module:hover .thumb img { transform: scale(1.04); }

  .toast { animation: toast-in .4s cubic-bezier(.2, .7, .2, 1) both; }
  @keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
}

/* Grönanalysens planområden i den flytande panelen */
.gr-plan { max-height: calc(100vh - 240px); overflow-y: auto; }
.gr-plan .drawer-head { padding: 0; margin-bottom: 4px; }
.gr-plan input[type=number] { width: 64px; text-align: right; }
.gr-plan td + td { white-space: nowrap; }
.gr-effects { margin: 10px 0 6px; padding-left: 18px; font-size: .86rem; line-height: 1.45; }
.gr-effects li + li { margin-top: 4px; }
.gr-plans li { display: flex; flex-direction: column; }
.gr-weights { margin: 8px 0; }
.gr-weights label { display: grid; grid-template-columns: 1fr 120px 56px; align-items: center; gap: 8px; font-size: .86rem; }
.gr-weights output { color: var(--text-muted); font-size: .8rem; }
.gr-atgard-list { list-style: none; margin: 6px 0 10px; padding: 0; }
.gr-atgard-row { display: flex; gap: 10px; width: 100%; padding: 6px 4px; border: 0; border-top: 1px solid var(--border);
  background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: 4px; }
.gr-atgard-row:hover, .gr-atgard-row:focus-visible { background: rgba(168, 69, 6, .07); }
.gr-rank { flex: none; width: 22px; font-variant-numeric: tabular-nums; color: #a84506; font-weight: 600; }
.gr-what { display: flex; flex-direction: column; font-size: .88rem; }
.gr-what .caption { margin: 0; }
.et-row { display: grid; grid-template-columns: 1fr 90px; gap: 8px; }
#et-egen { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin: 8px 0; }
#et-egen legend { font-size: .85rem; padding: 0 4px; }
.et-sites { list-style: none; padding: 0; margin: 6px 0; }
.et-sites li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; margin-bottom: 4px; }
.et-sites .et-nr, .et-best .et-nr { color: #6a3d9a; font-weight: 600; font-variant-numeric: tabular-nums; }
.et-best { list-style: none; padding: 0; margin: 6px 0; }
.et-best button { display: flex; gap: 10px; width: 100%; border: 0; border-top: 1px solid var(--border); background: none;
  padding: 6px 4px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.et-best button:hover { background: var(--accent-soft); }
.et-results { list-style: none; padding: 0; margin: 8px 0; }
.et-results button { display: flex; gap: 10px; width: 100%; border: 0; border-top: 1px solid var(--border); background: none;
  padding: 7px 4px; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.et-results button:hover { background: var(--accent-soft); }
.et-results button > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.et-results .caption { margin: 0; }
.et-site-nr { color: #0f766e; }
.et-best button > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.et-best button > span:last-child { flex: 1; min-width: 0; }
.et-bar { display: block; width: 100%; height: 5px; margin-top: 4px; border-radius: 3px; background: var(--bg-soft); overflow: hidden; }
.et-bar i { display: block; height: 100%; border-radius: 3px; background: #6a3d9a; }
.et-chart, .rw-chart { margin: 8px 0 4px; }
.et-best .caption { margin: 0; }
/* "Detaljer" på kartsidorna och "Fråga" mäts båda från fönstret, så att de
   ligger under varandra även när kartytan börjar under sidhuvudet. */
.map-stage > .drawer-tab { position: fixed; top: 50%; }
.as-tab { position: fixed; top: calc(50% + 52px); }
.as-panel { position: fixed; display: flex; flex-direction: column; z-index: 9; }
.as-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; margin: 10px 0; }
.as-entry { display: flex; flex-direction: column; gap: 6px; }
.as-q { align-self: flex-end; max-width: 88%; background: var(--accent-soft); border-radius: 10px 10px 2px 10px;
  padding: 7px 10px; font-size: .92rem; display: flex; flex-direction: column; }
.as-q .caption { font-size: .72rem; margin: 0 0 2px; }
.as-a { max-width: 96%; background: var(--bg-soft); border-radius: 10px 10px 10px 2px; padding: 8px 11px; font-size: .92rem; }
.as-a p { margin: 0 0 6px; }
.as-a ul { margin: 0 0 6px; padding-left: 18px; }
.as-typing { display: inline-flex; align-self: flex-start; align-items: center; gap: 4px; padding: 11px 13px; }
.as-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); opacity: .35;
  animation: as-dot 1.2s ease-in-out infinite; }
.as-typing i:nth-child(2) { animation-delay: .15s; }
.as-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes as-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .as-typing i { animation: none; opacity: .6; } }
.as-chart { margin: 4px 0 8px; }
.as-chart figcaption { font-size: .8rem; color: var(--text-muted); margin-bottom: 2px; }
.as-chart svg { max-width: 100%; height: auto; display: block; }
.as-place { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; vertical-align: -2px; }
.as-a .caption { margin: 4px 0 0; font-size: .76rem; }
.as-warn { color: var(--warn-text); }
.as-form textarea { width: 100%; resize: vertical; font: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.as-nr { display: inline-block; min-width: 18px; height: 18px; border-radius: 9px; background: #c2255c; color: #fff;
  font-size: .72rem; font-weight: 600; line-height: 18px; text-align: center; margin-right: 3px; }
.as-rate { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 6px; }
.as-rate .caption { margin: 0; }
.as-thumb { padding: 2px 6px; color: var(--text-muted); }
.as-thumb:hover { color: var(--text); }
.as-rate-row { display: flex; gap: 6px; width: 100%; }
.as-rate-row input { flex: 1; min-width: 0; font: inherit; font-size: .82rem; }
.as-show { margin-top: 6px; font-size: .8rem; padding: 3px 10px; }
.as-entry.marked .as-a { box-shadow: inset 3px 0 0 #c2255c; }
/* Rita ett område och fråga om det. */
.as-area-chip { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; padding: 4px 4px 4px 10px; font-size: .82rem;
  border-radius: 8px; background: var(--accent-soft); }
.as-area-chip span { flex: 1; }
.as-area-chip[hidden] { display: none; }
.as-area-chip .btn { padding: 0 6px; }
.as-form .btn-row { display: flex; gap: 8px; }
#as-draw-btn.active { border-color: #1f6feb; color: #1f6feb; }
.as-draw-hint { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); padding: 6px 12px; border-radius: 8px;
  background: var(--bg); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.18); font-size: .85rem; pointer-events: none; }
/* Förslag på följdfrågor: bara under det senaste svaret. */
.as-next { display: flex; flex-wrap: wrap; gap: 6px; }
.as-entry:not(:last-child) .as-next { display: none; }
.as-chip { font: inherit; font-size: .8rem; text-align: left; padding: 4px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.as-chip:hover { border-color: var(--accent); color: var(--accent); }
details.gr-numbers { margin: 2px 0 6px; }
details.gr-numbers > summary { cursor: pointer; color: var(--text-muted); font-size: .85rem; }
.gr-bar { width: 90px; }
.gr-bar i { background: var(--accent); }
/* Delning med personer (rainways/_dela.html). */
.share-people { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.share-people li { display: flex; align-items: center; gap: 8px; }
.share-people li span { flex: 1 1 auto; min-width: 4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.share-people select, .share-add select { width: auto; flex: none; }
.share-people .btn, .share-add .btn { white-space: nowrap; flex: none; }
.share-add { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.share-add input { flex: 1 1 100%; min-width: 0; }

/* --- adminsidan (mapservice.admin_page) ------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 4px 0 16px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-soft);
}
.stat .label { font-size: .8rem; color: var(--text-muted); }
.stat .value { font-size: 1.6rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: .85rem; color: var(--text-muted); margin-left: 2px; }
.stat.bad { background: var(--error-bg); border-color: transparent; }
.stat.bad .value, .stat.bad .label, .stat.bad .caption { color: var(--error-text); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--text-muted); }
.dot.arbetar { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: puls 2s ease-in-out infinite; }
.dot.ledig { background: var(--accent); }
.dot.pausad { background: #c99a1e; }
.dot.borta { background: var(--error-text); }
@keyframes puls { 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .dot.arbetar { animation: none; } }
.nod-sum { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.nod-sum .who { white-space: nowrap; }
.nod-sum > .caption { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.nod .body .stats { margin-top: 4px; }
table.data.compact { font-size: .85rem; margin-bottom: 8px; }
table.data.compact th, table.data.compact td { padding: 4px 8px; }
.prog-cell { min-width: 140px; }
.prog { height: 8px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); overflow: hidden; }
.prog > span { display: block; height: 100%; background: var(--accent); transition: width .6s ease; }
figure.bars { margin: 0 0 16px; }
figure.bars svg { width: 100%; height: 120px; display: block; }
figure.bars rect { fill: var(--accent); opacity: .85; }
figure.bars g:hover rect { opacity: 1; }
figure.bars text { font-size: 10px; fill: var(--text-muted); }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .code { flex: 1; margin: 0; }
.copy-row .btn.done { color: var(--accent); border-color: var(--accent); }
details.log pre.code { white-space: pre-wrap; max-height: 320px; overflow: auto; }
.stat .value.small { font-size: 1.05rem; padding-top: 6px; }
.copy-row input { flex: 1; margin: 0; }
.nod-nyckel { margin-top: 14px; display: grid; gap: 8px; }
.nod-nyckel pre.code { white-space: pre; overflow: auto; }
.nod > .body > .copy-row { margin-bottom: 10px; }

/* Adminsidans karta över 5 km-rutorna (admin/_data.html, static/rutkarta.js). */
.rutkarta { margin: 18px 0; }
.rutkarta-huvud { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.rutkarta-huvud h3 { margin: 0; }
.rk-valen { display: flex; gap: 18px; flex-wrap: wrap; }
.rk-val { display: flex; align-items: center; gap: 8px; white-space: nowrap; color: var(--text-muted); }
.rutkarta-summa { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0; min-height: 1.4em; font-size: .92rem; }
.rk-post { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.rk-post b { color: var(--text); font-variant-numeric: tabular-nums; }
.rk-post i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.rk-tot { margin-left: auto; }
.rutkarta-yta { height: min(72vh, 820px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.rutkarta-info { margin: 10px 0 0; padding: 10px 12px; border-radius: var(--radius); background: var(--error-bg); color: var(--error-text); }
.rutkarta-info code { display: block; margin: 6px 0; white-space: pre-wrap; word-break: break-word; }
.rk-popup .maplibregl-popup-content { font: 13px/1.4 var(--font); padding: 8px 10px; color: #303a33; }
.rk-popup .rk-fel { color: #8a1c14; }
.rutkarta-fel { margin: 12px 0 0; }
.rutkarta-fel h4 { margin: 0 0 6px; font-size: .95rem; }
.rk-felrad { display: grid; grid-template-columns: 4.5em 1fr auto; gap: 12px; align-items: center; padding: 7px 0;
  border-top: 1px solid var(--border); }
.rk-felrad b { font-variant-numeric: tabular-nums; color: var(--error-text); text-align: right; }
.rk-felrad code { white-space: pre-wrap; word-break: break-word; font-size: .85rem; }
.rk-felrad .rk-knappar { display: flex; gap: 6px; white-space: nowrap; }
.rk-felrad.vald { background: var(--error-bg); }

/* Dagvattenanalys (templates/dagvatten) */
.dv-new-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.dv-facts { grid-template-columns: minmax(150px, max-content) 1fr; }
.dv-in input[type=number] { width: 9em; }
.dv-in td:nth-child(2) { color: var(--text-muted); }
.dv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 20px; margin: 14px 0 6px; }
.dv-grid label { display: block; }
.dv-grid select, .dv-grid input { width: 100%; }
.dv-kpis { display: flex; flex-wrap: wrap; gap: 12px; margin: 4px 0 10px; }
.dv-kpi { flex: 1 1 200px; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--bg-soft); display: flex; flex-direction: column; gap: 2px; }
.dv-kpi-v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dv-dim td { font-weight: 600; }
.dv-bars { width: 38%; min-width: 120px; }
.dv-bars i { display: block; height: 7px; border-radius: 3px; margin: 2px 0; }
.dv-b0 { background: #94a3b8; }
.dv-b1 { background: #2563eb; }
.dv-sw { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin: 0 5px 0 10px; vertical-align: 0; }
.dv-sw:first-child { margin-left: 0; }
