/* Self-hosted (Latin subset only -- covers Swedish å/ä/ö), not loaded live
   from Google: that pattern has drawn real EU enforcement action for
   exposing visitor IPs to Google before any consent choice. */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/dm-mono-400.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/dm-mono-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/libre-franklin-variable.woff2') format('woff2');
}
@font-face {
  font-family: 'Libre Franklin';
  font-style: italic;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/libre-franklin-800italic.woff2') format('woff2');
}

:root {
  --ink: #182420;
  --paper: #faf8f2;
  --surface: #ffffff;
  --accent: #0f5646;
  --accent-dark: #0a4034;
  --accent-soft: #e6efe9;
  --line: #e2ded2;
  --muted: #6c6a5c;
  --red: #a5392a;
  --shadow-ink: 23, 32, 28;
  --shadow-accent: 15, 86, 70;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Libre Franklin", sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }

header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 4vw;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; font: 700 18px "Libre Franklin", sans-serif; letter-spacing: -.04em; white-space: nowrap; }
.brand span { display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 10px; border-radius: 8px; background: var(--accent); color: #fff; font: 700 12px "Libre Franklin"; }
.header-actions { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; justify-content: flex-end; font-size: 11px; color: var(--muted); }
.header-actions button { min-height: 44px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; font: 600 12px "Libre Franklin"; transition: border-color .15s ease, transform .1s ease; }
.header-actions button:hover { border-color: var(--accent); color: var(--accent); }
.header-actions button:active { transform: translateY(1px); }
.header-actions button[hidden] { display: none; }
#scan-status { display: inline-flex; align-items: center; gap: 6px; }
#scan-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.clock { color: var(--muted); font: 11px "DM Mono"; }

main { width: min(1600px, 94vw); margin: 0 auto; }

.login-panel { margin-top: 14px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 1px 2px rgba(var(--shadow-ink), .04); }
.login-panel[hidden] { display: none; }
.login-panel summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; }
.login-panel form { display: flex; gap: 12px; align-items: end; padding: 15px 0 0; }
.login-panel label { flex: 1; margin: 0; }
.login-panel button { min-height: 44px; padding: 9px 14px; border: 0; border-radius: var(--radius-sm); background: var(--accent); color: #fff; font: 600 13px "Libre Franklin"; cursor: pointer; }
.login-panel button:hover { background: var(--accent-dark); }
.login-panel p { margin: 8px 0 14px; }

.search-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 36px 0 26px; }
.search-heading p { margin: 0 0 8px; color: var(--muted); font-size: 13px; text-wrap: pretty; }
.journey { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 12px 0 6px; padding: 0; list-style: none; counter-reset: step; }
.journey li { counter-increment: step; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: 600 12px "Libre Franklin"; }
.journey li::before { content: counter(step); display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; }
.search-heading .journey-note { margin: 0 0 4px; font-size: 12px; }
.search-heading h1 { margin: 0; font-size: clamp(30px, 3.4vw, 46px); letter-spacing: -.045em; line-height: 1.05; font-weight: 800; }
.saved-tools { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 11px; }
.saved-tools button { min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font: 600 12px "Libre Franklin"; cursor: pointer; }
.saved-tools button:hover { border-color: var(--accent); background: var(--accent-soft); }

label { display: block; }
input, select, textarea {
  display: block; width: 100%; min-height: 44px; font: 14px "Libre Franklin"; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.catalog-controls {
  display: grid; grid-template-columns: minmax(200px, 2fr) minmax(150px, 1.3fr) minmax(150px, 1fr) minmax(140px, 1fr) auto auto;
  align-items: end; gap: 12px; padding: 20px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(var(--shadow-ink), .04), 0 16px 32px -18px rgba(var(--shadow-ink), .18);
}
.catalog-controls label { color: var(--ink); font: 600 12px "Libre Franklin"; margin: 0; }
.catalog-controls input, .catalog-controls select, .result-summary select { min-height: 46px; margin-top: 7px; }
.more-filters { position: relative; }
.more-filters summary, .clear-filters { display: grid; place-items: center; min-height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); cursor: pointer; font: 600 12px "Libre Franklin"; white-space: nowrap; transition: border-color .15s ease, color .15s ease; }
.more-filters summary { list-style: none; }
.more-filters summary::-webkit-details-marker { display: none; }
.more-filters[open] summary { border-color: var(--accent); color: var(--accent); }
.more-filter-fields { position: absolute; z-index: 1100; top: 54px; right: 0; width: min(340px, 90vw); padding: 16px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: 0 20px 40px -16px rgba(var(--shadow-ink), .28); }
.more-filter-fields label small { display: block; margin-top: 6px; color: var(--muted); font: 400 11px/1.45 "Libre Franklin"; }
.clear-filters:hover, .more-filters summary:hover { border-color: var(--accent); color: var(--accent); }

.active-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 14px; }
.active-filters > strong { color: var(--muted); font-size: 12px; }
#filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#filter-chips button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%; padding: 8px 12px; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font: 600 12px "Libre Franklin"; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
#filter-chips button:hover { background: var(--surface); }
#filter-chips svg { width: 14px; height: 14px; flex: none; }
.guest-saved-note { margin: 12px 2px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.guest-saved-note button { border: 0; padding: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

.result-summary { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding: 22px 2px 14px; border-bottom: 1px solid var(--line); font-family: "Libre Franklin", sans-serif; }
.result-summary strong { font-size: 18px; }
.result-summary span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.result-actions { display: flex; align-items: end; gap: 12px; }
.result-actions label { margin: 0; color: var(--muted); font: 600 12px "Libre Franklin", sans-serif; }
.check-inline { display: flex; align-items: center; gap: 6px; min-height: 44px; font: 600 12px "Libre Franklin", sans-serif; }
.check-inline input { width: auto; min-height: 0; margin: 0; }
.result-summary select { min-height: 44px; margin-top: 3px; }
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.view-switch button { min-width: 58px; min-height: 44px; border: 0; border-radius: 6px; padding: 8px 12px; background: transparent; color: var(--muted); cursor: pointer; font: 600 12px "Libre Franklin"; transition: background .15s ease, color .15s ease; }
.view-switch button[aria-pressed="true"] { background: var(--accent); color: #fff; }
#filter-status { min-height: 15px; margin: 8px 0; color: var(--muted); font-size: 12px; }

.results-layout { display: grid; grid-template-columns: minmax(400px, 47%) minmax(0, 1fr); gap: 18px; align-items: start; }
.results-layout.list-active { grid-template-columns: minmax(0, 1fr); }
.results-layout.list-active #map-panel { display: none; }
.listings { display: flex; flex-direction: column; gap: 14px; padding: 0 0 80px; }
.load-more { align-self: center; min-height: 44px; margin: 12px 0; padding: 0 22px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font: 600 13px "Libre Franklin"; cursor: pointer; transition: background .15s ease, color .15s ease, transform .1s ease; }
.load-more:hover { background: var(--accent); color: #fff; }
.load-more:active { transform: translateY(1px); }

.card {
  display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 186px; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: 0 1px 2px rgba(var(--shadow-ink), .03), 0 10px 24px -16px rgba(var(--shadow-ink), .14);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); border-color: #cfe4da; box-shadow: 0 4px 10px rgba(var(--shadow-ink), .05), 0 22px 34px -18px rgba(var(--shadow-accent), .28); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--shadow-accent), .22); }
.listing-image { display: block; width: 190px; height: 100%; min-height: 186px; overflow: hidden; background: var(--accent-soft); }
.image-fallback { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.kind-apartment { --pin-color: #285a91; }
.kind-house { --pin-color: #934638; }
.kind-country { --pin-color: #2d704b; }
.kind-plot { --pin-color: #78528c; }
.kind-other { --pin-color: #4c5c67; }
.kind-mixed { --pin-color: #0f5646; }
.home-pin, .map-group { display: grid; place-items: center; background: var(--pin-color); border: 2px solid #fff; border-radius: 50%; box-shadow: 0 2px 8px #122a2466; color: #fff; }
.home-pin svg { width: 19px; height: 19px; }
.home-pin.is-approximate { border-style: dashed; opacity: .75; }
.home-pin.is-selected { outline: 3px solid #ecb651; outline-offset: 2px; z-index: 1; }
.map-group { width: 48px; height: 48px; border-width: 3px; grid-template-rows: 20px 14px; align-content: center; font-weight: 700; font-size: 12px; line-height: 1; }
.map-group.kind-mixed { grid-template-rows: auto; }
.map-group svg { width: 15px; height: 15px; }
.listing-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.listing-image:hover img { transform: scale(1.03); }
.card-content { min-width: 0; padding: 16px 18px; }
.card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.source { background: none; color: var(--accent); padding: 0; font-weight: 700; }
.upcoming { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 4px; background: #f2e5c6; color: #614a18; font-size: 11px; }
.card h2 { margin: 9px 0 4px; font-size: 19px; line-height: 1.2; letter-spacing: -.03em; font-weight: 700; }
.card-title { display: inline-block; margin: -13px 0; padding: 13px 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.card-title:hover { color: var(--accent); text-decoration: underline; }
.card .area { margin: 0; font-size: 12px; color: var(--muted); }
.card .price { margin: 10px 0; font: 700 18px "Libre Franklin"; }
.price-drop { display: inline-block; margin-left: 8px; padding: 3px 7px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-dark); font: 700 11px "Libre Franklin"; vertical-align: middle; }
.facts { display: flex; gap: 8px; flex-wrap: wrap; }
.fact { border: 0; padding: 0; color: var(--muted); font: 12px "Libre Franklin"; }
.fact:not(:last-child)::after { content: " ·"; }
.commutes { display: flex; gap: 8px; margin-top: 10px; }
.commute { padding: 5px 8px; border-radius: 5px; background: var(--accent-soft); color: var(--muted); font: 12px "Libre Franklin"; }
.commute strong { display: inline; margin-left: 4px; color: var(--ink); font: 700 12px "Libre Franklin"; }
.commute.bad { background: #fbe8e4; }
.commutes button { min-height: 44px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--accent); font: 600 11px "Libre Franklin"; cursor: pointer; }
.commute-error { margin: 8px 0 0; color: var(--red); font: 12px/1.4 "Libre Franklin"; }
.commutes { flex-wrap: wrap; }
.destinations-list { display: grid; gap: 16px; }
.destination-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label label" "field remove" "status status"; align-items: start; gap: 6px 8px; }
.destination-row > label { grid-area: label; font-weight: 600; }
.destination-field { grid-area: field; position: relative; min-width: 0; }
.destination-field input { width: 100%; }
.destination-remove { grid-area: remove; }
.destination-remove, .add-destination { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.destination-remove:disabled { opacity: .45; cursor: not-allowed; }
.destination-status { grid-area: status; min-height: 1.3em; color: var(--muted); }
.destination-status[data-state="picked"] { color: var(--accent-dark); font-weight: 600; }
.destination-status[data-state="error"], .destination-status[data-state="empty"] { color: #8a2b1d; }
.destination-results { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 16rem; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 24px rgba(24, 36, 32, .16); }
.destination-results li { min-height: 44px; display: flex; align-items: center; padding: 8px 12px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.destination-results li:hover, .destination-results li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-dark); }
.add-destination { margin: 12px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions a, .actions button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: 0; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 8px 12px; color: var(--ink); font: 600 12px "Libre Franklin"; text-decoration: none; cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.actions a:hover, .actions button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.actions button[data-dismiss-id] { color: var(--muted); }
.actions button[data-dismiss-id]:hover { border-color: var(--red); color: var(--red); background: #fbe8e4; }

.leaflet-container { background: var(--accent-soft); }
#map-panel { position: sticky; top: 16px; height: calc(100vh - 32px); min-height: 500px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--accent-soft); box-shadow: 0 1px 2px rgba(var(--shadow-ink), .03), 0 16px 32px -20px rgba(var(--shadow-ink), .18); }
#map { width: 100%; height: 100%; }
.map-legend { position: absolute; z-index: 500; top: 12px; right: 12px; margin: 0; padding: 9px 11px; background: #fffffff2; border-radius: var(--radius-sm); box-shadow: 0 6px 16px rgba(var(--shadow-ink), .18); color: var(--ink); font-size: 11px; }
.map-legend summary { cursor: pointer; font-weight: 700; }
.map-legend-items { display: grid; gap: 5px; margin-top: 8px; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend b { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--pin-color); color: #fff; font-size: 15px; line-height: 1; }
.map-legend b svg { width: 13px; height: 13px; }
.map-legend small { color: var(--muted); }
#map-status { position: absolute; z-index: 500; left: 12px; bottom: 30px; max-width: calc(100% - 24px); margin: 0; padding: 8px 10px; border-radius: var(--radius-sm); background: #fffffff2; color: var(--ink); font-size: 11px; box-shadow: 0 6px 16px rgba(var(--shadow-ink), .18); }
.map-popup strong { display: block; font-size: 14px; }
.map-popup span { display: block; margin: 4px 0; }
.map-popup a { color: var(--accent); }
.map-popup .approx-note { color: #8a6415; font-size: 11px; }
.location-note { color: #8a6415; font-size: 12px; margin: 2px 0 0; }
.leaflet-control-zoom { border: none !important; border-radius: var(--radius-sm) !important; overflow: hidden; box-shadow: 0 4px 14px rgba(var(--shadow-ink), .18) !important; }
.leaflet-control-zoom a { color: var(--ink) !important; }

.empty { border: 1px dashed var(--line); border-radius: var(--radius-md); padding: 30px; background: var(--surface); text-align: center; color: var(--muted); }
.empty button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin-top: 14px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font: 600 13px "Libre Franklin"; cursor: pointer; }
.empty button:hover { background: var(--accent-soft); }

dialog { background: var(--surface); color: var(--ink); border: 0; border-radius: var(--radius-lg); box-shadow: 0 30px 60px -20px rgba(var(--shadow-ink), .35); }
#settings-dialog { max-height: 88dvh; overflow-y: auto; }
dialog::backdrop { background: rgba(24, 36, 32, .45); }
form { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; }
.dialog-head small { font: 11px "DM Mono"; letter-spacing: .1em; color: var(--muted); }
.dialog-head h2 { font-size: 30px; margin: 6px 0 22px; letter-spacing: -.03em; }
.dialog-head button { width: 44px; height: 44px; border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.dialog-head button:hover { color: var(--ink); }
form label { font: 12px "DM Mono"; margin-bottom: 14px; }
dialog input, dialog select, dialog textarea { background: var(--surface); border-color: var(--line); color: var(--ink); }
.lede { max-width: 65ch; color: var(--muted); }
.error { color: var(--red); font: 12px "DM Mono"; min-height: 14px; }

#detail-dialog { padding: 28px; width: min(760px, 92vw); max-height: 88vh; overflow: auto; }
.detail-body { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 22px; margin-top: 6px; }
.detail-image { display: block; min-height: 200px; border-radius: var(--radius-md); overflow: hidden; background: var(--accent-soft); }
.detail-image[hidden] { display: none; }
.detail-image img { display: block; width: 100%; height: 100%; object-fit: cover; }
.detail-info { min-width: 0; }
.detail-info .area { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.detail-info .price { margin: 10px 0; font: 700 22px "Libre Franklin"; }
.detail-info .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
.detail-info .commutes { display: flex; gap: 8px; margin: 10px 0 0; }
.detail-info .actions { margin-top: 18px; }
@media (max-width: 640px) {
  .detail-body { grid-template-columns: 1fr; }
  .detail-image { max-height: 220px; }
}

.primary { border: 0; background: var(--accent); color: #fff; padding: 14px 19px; border-radius: var(--radius-sm); font: 600 13px "Libre Franklin"; cursor: pointer; transition: background .15s ease, transform .1s ease; }
.primary:hover { background: var(--accent-dark); }
.primary:active { transform: translateY(1px) scale(.99); }

.account-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 16px 28px 24px; border-top: 1px solid var(--line); }
.account-controls button { min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); padding: 9px 14px; font: 600 12px "Libre Franklin", sans-serif; cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.account-controls button:hover { border-color: var(--accent); color: var(--accent); }
.account-controls button.danger { border-color: var(--red); color: var(--red); }
.account-controls button.danger:hover { background: var(--red); color: #fff; }
.account-controls #account-status { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .catalog-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .more-filters, .clear-filters { grid-column: auto; }
  .results-layout { grid-template-columns: minmax(360px, 52%) minmax(0, 1fr); }
  .card { grid-template-columns: 135px minmax(0, 1fr); }
  .listing-image { width: 135px; }
}
@media (max-width: 750px) {
  header { height:auto; min-height:64px; padding:10px 4vw; flex-wrap:wrap; gap:8px; }
  .header-actions { width:100%; justify-content:space-between; gap:6px; }
  .header-actions button { flex:1; min-width:0; padding-inline:8px; }
  .header-actions #scan-status, .clock { display: none; }
  .search-heading { align-items: start; flex-direction: column; gap: 12px; padding: 26px 0 20px; }
  .saved-tools #forward-address { display: none; }
  .catalog-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 14px; }
  .more-filters[open] { grid-column: 1 / -1; }
  .more-filters[open] .more-filter-fields { position: static; width: 100%; max-height: min(55dvh, 480px); overflow-y: auto; margin-top: 8px; box-shadow: none; }
  .catalog-controls label:first-child { grid-column: 1 / -1; }
  .result-summary { align-items: center; }
  .result-actions { flex-wrap: wrap; justify-content: end; }
  .results-layout { display: block; }
  #map-panel { display: none; position: relative; top: auto; height: calc(100dvh - 190px); min-height: 400px; }
  .results-layout.map-active .listings { display: none; }
  .results-layout.map-active #map-panel { display: block; }
  .login-panel form { display: block; }
  .login-panel button { margin-top: 10px; }
}
@media (max-width: 480px) {
  .saved-tools { width: 100%; }
  .saved-tools button { width: 100%; }
  .catalog-controls { grid-template-columns: 1fr 1fr; }
  .catalog-controls label:nth-child(2), .catalog-controls label:nth-child(3), .catalog-controls label:nth-child(4) { grid-column: 1 / -1; }
  .more-filters, .clear-filters { grid-column: span 1; }
  .result-summary { align-items: start; flex-direction: column; gap: 14px; }
  .result-actions { width: 100%; justify-content: space-between; }
  .result-actions #saved-only-wrap { flex-basis: 100%; min-height: 44px; }
  .result-actions label:not(#saved-only-wrap) { flex: 1; }
  .result-actions select { width: 100%; font-size: 16px; }
  .catalog-controls input, .catalog-controls select, .login-panel input, dialog input, dialog select, dialog textarea { font-size: 16px; }
  .card { grid-template-columns: 110px minmax(0, 1fr); min-height: 150px; }
  .listing-image { width: 110px; min-height: 150px; }
  .card-content { padding: 12px; }
  .card h2 { font-size: 16px; }
  .card .price { font-size: 15px; }
  .card .top { font-size: 11px; }
  .actions { gap: 7px; }
  .actions a, .actions button { font-size: 11px; padding: 8px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

#tools-dialog { width: min(640px, 94vw); max-height: 88dvh; overflow-y: auto; padding: 28px; }
.tool-form { display: grid; gap: 4px; padding: 16px 0 0; border-top: 1px solid var(--line); margin-top: 16px; }
.tool-form h3 { margin: 0 0 8px; font-size: 16px; }
.tool-form .primary { justify-self: start; }
.tool-result { font-size: 14px; min-height: 0; }
.tool-result dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; margin: 12px 0; }
.tool-result dd { margin: 0; text-align: right; font-weight: 600; }
.tool-result ul { margin: 6px 0; padding-left: 18px; color: var(--muted); font-size: 12px; }
.tool-result .warn { color: var(--red); }
.cost-table-wrap { overflow-x: auto; max-width: 100%; }
.cost-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cost-table th, .cost-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.cost-table th:first-child { text-align: left; }
.cost-table-hint { color: var(--muted); font-size: 12px; }
@media (max-width:700px) {
  .cost-table-wrap { overflow:visible; }
  .cost-table, .cost-table tbody, .cost-table tr, .cost-table th, .cost-table td { display:block; width:100%; }
  .cost-table thead { position:absolute; width:1px; height:1px; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
  .cost-table tr { margin:10px 0; padding:10px; border:1px solid var(--line); border-radius:var(--radius-sm); }
  .cost-table th, .cost-table td { padding:5px 0; text-align:left; white-space:normal; overflow-wrap:anywhere; }
  .cost-table td::before { content:attr(data-label); display:block; color:var(--muted); font-size:11px; font-weight:600; }
}
#purchase-form details { margin: 8px 0; }
#purchase-form details label { display: block; }
#purchase-form > .tool-result, #purchase-form > details { min-width: 0; }
#purchase-form .tool-result dt { overflow-wrap: anywhere; }
.bid-plan { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.bid-plan summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
#bid-plan-form { padding: 0; display: grid; gap: 4px; }
#bid-plan-form fieldset { border: 0; padding: 0; margin: 8px 0; }
#bid-plan-form .check-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
#bid-plan-form .check-row input[type=date] { width: auto; }
#bid-plan-form .private-note { color: var(--muted); font-size: 12px; }
#bid-plan-form .log-rows { margin: 4px 0; padding-left: 18px; font-size: 13px; }
#bid-plan-form fieldset { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
#bid-plan-form legend { font-weight: 600; }
#bid-plan-form .check-row input[type=time], #bid-plan-form .check-row input[type=number], #bid-plan-form .check-row select { width: auto; max-width: 110px; }
#bid-plan-form .check-row input:not([type]), #bid-plan-form .check-row input[id=cond-text] { flex: 1 1 140px; min-width: 0; }
#bid-plan-form .link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 4px; min-height: 32px; }
.reminders { list-style: none; padding: 0 !important; color: inherit !important; font-size: 13px !important; }
.reminders li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.reminders .overdue { color: var(--red); }
.purchase-journey { min-width: 0; }
.purchase-journey h4 { margin: 18px 0 8px; }
.purchase-row, .purchase-task { display: grid; gap: 7px; border-bottom: 1px solid var(--line); padding: 10px 0; min-width: 0; }
.purchase-row label { display: grid; gap: 7px; min-width: 0; }
.purchase-row input, .purchase-row select, .purchase-task input:not([type=checkbox]), .purchase-add input { min-width: 0; width: 100%; box-sizing: border-box; }
.purchase-task { grid-template-columns: minmax(0, 2fr) minmax(130px, 1fr); align-items: center; }
.purchase-task label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.purchase-task label input[type=checkbox] { flex: 0 0 auto; width: auto; }
.purchase-task input[name$="-note"] { grid-column: 1 / -1; }
.purchase-add { display: flex; gap: 8px; flex-wrap: wrap; }
.purchase-add input { flex: 1 1 180px; }
@media (max-width: 500px) { .purchase-task { grid-template-columns: 1fr; } .purchase-task input[name$="-note"] { grid-column: auto; } }

.brf-analysis { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.brf-analysis summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
#brf-analysis-body { display: grid; gap: 6px; min-width: 0; }
#brf-analysis-body h4 { margin: 12px 0 2px; }
#brf-analysis-body .private-note, #brf-analysis-body .uncertainty, #brf-analysis-body .cite { color: var(--muted); font-size: 12px; display: block; overflow-wrap: anywhere; }
.brf-check { border-left: 4px solid var(--line); padding: 4px 8px; }
.brf-check.mismatch { border-left-color: #b3261e; }
.brf-check.match { border-left-color: #2e7d32; }
.brf-check p { margin: 2px 0; }
.brf-analysis .table-scroll { overflow-x: auto; }
.brf-analysis .table-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.brf-table { border-collapse: collapse; font-size: 13px; width: 100%; }
.brf-table th, .brf-table td { text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.brf-analysis .table-scroll[aria-label="Lånelista ur årsredovisningen"] table { min-width: 640px; }
.site-footer { padding: 1rem 1.5rem; text-align: center; font-size: .875rem; }
.site-footer a { display: inline-block; padding: .65rem .35rem; }  /* 44px touch target */
.leaflet-control-zoom a { width: 40px !important; height: 40px !important; line-height: 40px !important; }
.site-footer a, .private-note a, .account-controls a { color: inherit; text-decoration: underline; text-underline-offset: .15em; }

#map-status[data-loading]::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--accent); animation: map-pulse 1s ease-in-out infinite; }
@keyframes map-pulse { 50% { opacity: .25; } }
@media (max-width: 750px) {
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] { overflow: visible; }
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] table,
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] tbody { display: block; }
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] thead { display: none; }
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] tr { display: grid; grid-template-columns: minmax(0, 1fr); padding: 8px 0; border-bottom: 1px solid var(--line); }
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] th,
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] td { border: 0; padding: 2px 4px; min-width: 0; overflow-wrap: anywhere; }
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] td:nth-child(3)::before { content: "Säkerhet: "; }
  .brf-analysis .table-scroll[aria-label="Nyckeltal ur årsredovisningen"] td:nth-child(4) { grid-column: 1 / -1; }
  /* In map view the list/map switch floats so the way back to the list is always reachable. */
  body:has(.results-layout.map-active) .site-footer { padding-bottom: 84px; }
  main:has(.results-layout.map-active) .view-switch { position: fixed; z-index: 1200; right: 14px; bottom: 14px; box-shadow: 0 8px 24px rgba(var(--shadow-ink), .28); }
}
@media (pointer: coarse) { .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; } }
.check-inline input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
#bid-plan-form .check-row input[type=number] { max-width: 130px; }
#bid-add, #cond-add { min-height: 44px; padding: 8px 14px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font: 600 12px "Libre Franklin", sans-serif; cursor: pointer; }
#bid-add:hover, #cond-add:hover { background: var(--accent-soft); }
#bid-plan-form .link { min-height: 44px; }
#brf-upload-form { padding: 0; }
#brf-delete { min-height: 44px; margin-left: 8px; padding: 8px 14px; border: 1px solid var(--red); border-radius: var(--radius-sm); background: var(--surface); color: var(--red); font: 600 12px "Libre Franklin", sans-serif; cursor: pointer; }
#brf-delete:hover { background: #fbe8e4; }
.brf-analysis form { padding: 0; }
.brf-analysis button { min-height: 44px; margin: 8px 8px 8px 0; padding: 8px 14px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--surface); color: var(--accent); font: 600 12px "Libre Franklin", sans-serif; cursor: pointer; }
.brf-analysis button:hover { background: var(--accent-soft); }
.brf-analysis button[type=submit], .brf-analysis button.primary { background: var(--accent); color: #fff; }
.brf-analysis button[type=submit]:hover, .brf-analysis button.primary:hover { background: var(--accent-dark); }
.brf-analysis #brf-delete { border-color: var(--red); color: var(--red); background: var(--surface); }
p.map-tile-error{margin:.4rem 0;padding:.5rem .75rem;border-left:3px solid #b7412c;background:#fff4f0;color:#5a1f12;font-size:.9rem}
#brf-analysis-body .badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border: 1px solid var(--accent); border-radius: 999px; font: 700 11px "Libre Franklin", sans-serif; vertical-align: middle; }
#brf-ai-form .check-inline { align-items: flex-start; font-weight: 500; }

.ai-contract { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line, #ccc); border-radius: 8px; }
.ai-contract label { display: block; margin: 8px 0; }
.ai-contract-result { margin-top: 12px; padding: 10px 12px; border-left: 3px solid #7a5af8; }
.ai-contract-result blockquote { margin: 4px 0; padding-left: 8px; border-left: 2px solid #bbb; overflow-wrap: anywhere; }
.ai-contract-result li { margin: 8px 0; overflow-wrap: anywhere; }

.auto-run { margin: 0 0 12px; display: grid; gap: 6px; }
.auto-run .primary { justify-self: start; }
.auto-run .primary:disabled, #brf-auto:disabled, #comps-auto:disabled { opacity: .6; cursor: progress; }
#auto-run-status:empty { display: none; }
#brf-auto + small, #comps-auto + small { display: block; margin-top: 6px; color: var(--muted); }
#auto-run-status { font-size: .9rem; color: var(--muted); margin: 0; }
