/* Kundkarta — Havslugn-tema (ljus default + mörk), mobilanpassat kart-UI. */
:root {
  --bg: #ecedea;
  --bg-elev: #f3f4f0;
  --bg-card: #fbfcf8;
  --border: #c8ccc4;
  --border-strong: #abb0a6;
  --fg: #1c2535;
  --fg-muted: #525d6f;
  --fg-dim: #828d9c;
  --accent: #4a6c8c;
  --accent-strong: #2f4e6e;
  --accent-soft: rgba(74, 108, 140, 0.12);
  --on-accent: #fbfcf8;
  --warn: #a86436;
  --warn-soft: rgba(168, 100, 54, 0.14);
  --shadow: 0 2px 12px rgba(28, 37, 53, 0.08);
  --shadow-lg: 0 8px 32px rgba(28, 37, 53, 0.18);

  /* status­färger (även till kartpins) */
  --st-utfört: #5c7a52;   /* grön */
  --st-bokat: #4a6c8c;    /* blå */
  --st-offert: #b3700a;   /* bärnsten */
  --st-arkiv: #98a0a8;    /* grå */

  --sans: -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  --serif: "Iowan Old Style", "Charter", Georgia, serif;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="ljus"]) {
    --bg: #182030;
    --bg-elev: #1f293a;
    --bg-card: #283449;
    --border: #2e3a52;
    --border-strong: #43526c;
    --fg: #e6ebee;
    --fg-muted: #9aa5b3;
    --fg-dim: #6a7585;
    --accent: #80a3c2;
    --accent-strong: #9cbcd8;
    --accent-soft: rgba(128, 163, 194, 0.18);
    --on-accent: #182030;
    --warn: #c98756;
    --warn-soft: rgba(201, 135, 86, 0.16);
    --shadow: 0 2px 14px rgba(0, 5, 15, 0.4);
    --shadow-lg: 0 10px 36px rgba(0, 5, 15, 0.6);
    --st-utfört: #8aa67e;
    --st-bokat: #80a3c2;
    --st-offert: #d59a3f;
    --st-arkiv: #6a7585;
  }
}
[data-theme="mörk"] {
  --bg: #182030; --bg-elev: #1f293a; --bg-card: #283449;
  --border: #2e3a52; --border-strong: #43526c;
  --fg: #e6ebee; --fg-muted: #9aa5b3; --fg-dim: #6a7585;
  --accent: #80a3c2; --accent-strong: #9cbcd8; --accent-soft: rgba(128, 163, 194, 0.18);
  --on-accent: #182030; --warn: #c98756; --warn-soft: rgba(201, 135, 86, 0.16);
  --shadow: 0 2px 14px rgba(0, 5, 15, 0.4); --shadow-lg: 0 10px 36px rgba(0, 5, 15, 0.6);
  --st-utfört: #8aa67e; --st-bokat: #80a3c2; --st-offert: #d59a3f; --st-arkiv: #6a7585;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- karta ---------- */
#map { position: fixed; inset: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* topp-pellet (status nu) */
.toast {
  position: fixed; top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%) translateY(-200%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 60;
  transition: transform .28s cubic-bezier(.2,.8,.2,1); max-width: 90vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 16px; bottom: calc(var(--safe-b) + 76px); z-index: 40;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--on-accent); font-size: 30px; line-height: 1;
  box-shadow: var(--shadow-lg); display: grid; place-items: center; cursor: pointer;
}
.fab:active { transform: scale(.94); }

/* "Nära mig"-knapp uppe till höger */
.map-btn {
  position: fixed; right: 16px; z-index: 40; background: var(--bg-card); color: var(--fg);
  border: 1px solid var(--border); border-radius: 999px; padding: 9px 14px; font-size: 14px;
  font-weight: 600; box-shadow: var(--shadow); display: flex; gap: 6px; align-items: center; cursor: pointer;
}
.map-btn.locate { top: calc(var(--safe-t) + 12px); }
.map-btn.route  { top: calc(var(--safe-t) + 58px); }

/* ---------- bottom nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  background: none; border: none; color: var(--fg-dim); font-family: var(--sans);
  font-size: 11px; font-weight: 600; padding: 8px 2px 6px; display: grid; gap: 2px; justify-items: center; cursor: pointer;
}
.tabbar button .ico { font-size: 20px; line-height: 1; }
.tabbar button[aria-current="true"] { color: var(--accent); }
.tabbar button .badge {
  position: absolute; transform: translate(14px, -4px); background: var(--warn); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; border-radius: 999px; padding: 0 4px;
  display: grid; place-items: center;
}

/* ---------- bottom sheet ---------- */
.sheet-scrim {
  position: fixed; inset: 0; z-index: 49; background: rgba(10, 14, 22, 0.4);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg-elev); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(101%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
  max-height: 86vh; display: flex; flex-direction: column;
  padding-bottom: var(--safe-b);
}
.sheet.show { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 10px auto 4px; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 4px 18px 10px; }
.sheet-head h2 { font-size: 18px; margin: 0; flex: 1; }
/* nedre padding så att innehållet inte göms bakom den flytande tabbaren */
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 18px calc(72px + var(--safe-b)); }
.x-btn { background: none; border: none; color: var(--fg-dim); font-size: 26px; line-height: 1; cursor: pointer; padding: 4px; }

/* ---------- generella ---------- */
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-dim); margin: 18px 0 8px; }
.muted { color: var(--fg-muted); }
.dim { color: var(--fg-dim); }
.empty { text-align: center; color: var(--fg-dim); padding: 32px 16px; }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-size: 15px; font-weight: 600; text-decoration: none;
  padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border-strong);
  background: var(--bg-card); color: var(--fg); cursor: pointer;
}
button.btn.primary, a.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
button.btn.ghost { background: none; border-color: transparent; color: var(--accent-strong); }
button.btn.block, a.btn.block { width: 100%; }
button.btn:active, a.btn:active { transform: scale(.98); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btn-row .btn { flex: 1; }

/* form */
label.field { display: block; margin: 12px 0; }
label.field .lab { font-size: 13px; color: var(--fg-muted); margin-bottom: 5px; display: block; }
input, select, textarea {
  width: 100%; font-family: var(--sans); font-size: 16px; color: var(--fg);
  background: var(--bg-card); border: 1px solid var(--border-strong); border-radius: 10px; padding: 11px 12px;
}
textarea { min-height: 64px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* status-väljare (segment) */
.segs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segs label { position: relative; }
.segs input { position: absolute; opacity: 0; }
.segs span {
  display: block; text-align: center; padding: 9px 4px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border-strong); color: var(--fg-muted); cursor: pointer;
}
.segs input:checked + span { border-color: currentColor; }
.segs .s-utfört input:checked + span { color: var(--st-utfört); background: color-mix(in srgb, var(--st-utfört) 14%, transparent); }
.segs .s-bokat  input:checked + span { color: var(--st-bokat);  background: color-mix(in srgb, var(--st-bokat) 14%, transparent); }
.segs .s-offert input:checked + span { color: var(--st-offert); background: color-mix(in srgb, var(--st-offert) 14%, transparent); }

/* kund-/förslagskort i listor */
.card {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer; font-family: var(--sans); color: var(--fg);
}
.card:active { background: var(--bg-elev); }
.dot { flex: none; width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; }
.dot.utfört { background: var(--st-utfört); } .dot.bokat { background: var(--st-bokat); }
.dot.offert { background: var(--st-offert); } .dot.arkiv { background: var(--st-arkiv); }
.card .main { flex: 1; min-width: 0; }
.card .name { font-weight: 700; font-size: 16px; }
.card .sub { font-size: 13px; color: var(--fg-muted); margin-top: 2px; }
.card .meta { font-size: 13px; color: var(--fg-dim); white-space: nowrap; }
.pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong);
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }

/* säsongstips / nudge-ruta */
.nudge {
  background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--fg); border-radius: 12px; padding: 11px 13px; font-size: 14px; margin: 10px 0;
  display: flex; gap: 9px;
}
.nudge .ico { flex: none; }

/* kundkortets stjärnor */
.stars { font-size: 18px; letter-spacing: 2px; }
.star-pick button { background: none; border: none; font-size: 28px; cursor: pointer; padding: 2px; color: var(--border-strong); }
.star-pick button.on { color: var(--st-offert); }

/* sök */
.searchbar { position: sticky; top: 0; background: var(--bg-elev); padding: 4px 0 10px; z-index: 1; }
.filterchips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { font-size: 13px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: none; color: var(--fg-muted); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* jobbhistorik */
.job { border-left: 3px solid var(--border-strong); padding: 4px 0 10px 12px; margin-left: 4px; }
.job .jt { font-weight: 600; }
.job .jm { font-size: 13px; color: var(--fg-dim); }

hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* adress-autocomplete */
.ac-list { margin: -6px 0 6px; display: flex; flex-direction: column; gap: 5px; }
.ac-item { text-align: left; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; color: var(--fg); cursor: pointer; font-family: var(--sans); }
.ac-item:active { background: var(--bg-elev); }
.ac-loading { font-size: 13px; padding: 6px 2px; }

/* MapLibre-pin (HTML-markör) */
.pin { width: 26px; height: 26px; cursor: pointer; transform: translateY(-4px); }
.pin svg { display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.35)); }
.pin .ring {
  position: absolute; inset: -5px; border-radius: 50%; border: 2.5px solid var(--warn);
  animation: pulse 2s infinite; pointer-events: none;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--warn-soft);} 70%{box-shadow:0 0 0 8px transparent;} 100%{box-shadow:0 0 0 0 transparent;} }
.you {
  width: 18px; height: 18px; border-radius: 50%; background: #2f7df6; border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(47,125,246,.3);
}
