/* Watt-Wo – Version 4 (0.1.4): Installationskarte mittig (Safari-Leiste), kein
   Leerband auf Seiten ohne Filterleiste. Version 3 (0.1.3): Installationskarte. Version 2 (0.1.2): Helles Design als Alternative, Umschalter im
   Profil (Hell, Dunkel, System). Version 1 (0.1.0): Grundgerüst. Dunkle Oberfläche für den
   Einsatz im Fahrzeug, Preise in Space Grotesk, Fließtext im Systemfont.
   Struktur wie Merchbutler: fixer Header, Hauptbereich, untere Navigation,
   auf Desktop wandert die Navigation nach oben rechts. */

:root {
  --bg: #0E1224;
  --surface: #171C33;
  --surface-2: #202747;
  --line: #2A3157;
  --text: #EEF0FA;
  --muted: #8A90B8;
  --cyan: #2EF2E6;
  --violet: #7B4DFF;
  --good: #3DDC84;
  --mid: #FFB020;
  --bad: #FF5A5F;
  --header-h: 56px;
  --filter-h: 48px;
  --nav-h: 64px;
  --radius: 14px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: dark; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overscroll-behavior: none;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; background: none; color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
input { font-family: inherit; }
[hidden] { display: none !important; }

/* Header */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: rgba(14, 18, 36, .92);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { width: 30px; height: 30px; border-radius: 8px; }
.brand-word { font-family: var(--font-display); font-size: 20px; letter-spacing: -.01em; }
.brand-word b { color: var(--cyan); font-weight: 700; }
.brand-word i { color: var(--violet); font-style: normal; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 8px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 18px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; white-space: nowrap; max-width: 46vw;
}
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip-vehicle svg { color: var(--cyan); flex: none; }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line);
}
.icon-btn.active { border-color: var(--cyan); color: var(--cyan); }
.badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--cyan); color: var(--bg); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.filter-bar {
  height: var(--filter-h);
  display: flex; gap: 8px; align-items: center;
  padding: 0 12px; overflow-x: auto; scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s;
}
.fchip.on { background: rgba(46, 242, 230, .14); border-color: var(--cyan); color: var(--cyan); }

/* Main */
.main {
  padding-top: calc(var(--header-h) + var(--filter-h) + env(safe-area-inset-top));
}
/* Version 4: ohne Filterleiste (alle Seiten außer Karte) kein Leerband unter dem Kopf */
body:has(#filterBar[style*="none"]) .main { padding-top: calc(var(--header-h) + env(safe-area-inset-top)); }
.main {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.page { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.container { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.h1 { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 6px; }
.h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 28px 0 8px; }
.lead { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.note {
  background: rgba(123, 77, 255, .14); border: 1px solid rgba(123, 77, 255, .45);
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px;
}

/* Karte */
.page-map { position: relative; height: calc(100vh - var(--header-h) - var(--filter-h) - var(--nav-h) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.map { position: absolute; inset: 0; background: var(--surface); }
.search-wrap {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; gap: 8px;
}
.search {
  flex: 1; height: 46px; padding: 0 16px; border-radius: 23px;
  border: 1px solid var(--line); background: rgba(23, 28, 51, .96); color: var(--text);
  font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.search::placeholder { color: var(--muted); }
.locate-btn {
  width: 46px; height: 46px; border-radius: 23px; flex: none;
  background: rgba(23, 28, 51, .96); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: var(--cyan);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.map-status {
  position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); z-index: 5;
  background: rgba(23, 28, 51, .96); border: 1px solid var(--line);
  border-radius: 20px; padding: 6px 14px; font-size: 13px; color: var(--muted); white-space: nowrap;
  transition: opacity .3s;
}
.map-status.off { opacity: 0; pointer-events: none; }
.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  display: flex; gap: 12px; font-size: 12px; color: var(--muted);
  background: rgba(23, 28, 51, .92); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px;
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-good { background: var(--good); } .dot-mid { background: var(--mid); } .dot-bad { background: var(--bad); } .dot-none { background: var(--muted); }

/* Listen und Karten */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-compact { max-height: 46vh; overflow-y: auto; margin-top: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; align-items: center; gap: 12px;
}
.card.active { border-color: var(--cyan); background: rgba(46, 242, 230, .06); }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { color: var(--muted); font-size: 13px; }
.card-actions { display: flex; gap: 6px; flex: none; }
.btn {
  height: 42px; padding: 0 16px; border-radius: 12px; background: var(--cyan); color: var(--bg);
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.btn-small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-danger { background: rgba(255, 90, 95, .15); color: var(--bad); border: 1px solid rgba(255, 90, 95, .4); }
.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 15px;
}
.input-small { width: 74px; text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.row-range { flex-wrap: wrap; }
.row-range label { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips .chip { max-width: none; }
.chips .chip button { color: var(--muted); font-size: 16px; line-height: 1; padding-left: 4px; }
.empty { color: var(--muted); font-size: 14px; padding: 18px 0; }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 1500; background: rgba(0, 0, 0, .35); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1600;
  background: var(--surface); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  max-height: 82vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .5);
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { flex: none; height: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sheet-grip::before { content: ''; width: 40px; height: 4px; border-radius: 2px; background: var(--line); }
.sheet-body { overflow-y: auto; padding: 0 16px 20px; }
.st-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.st-name { font-family: var(--font-display); font-size: 19px; font-weight: 700; line-height: 1.2; }
.st-addr { color: var(--muted); font-size: 13px; }
.st-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.tag { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.tag.dc { color: var(--cyan); border-color: rgba(46, 242, 230, .4); }
.tag.free { color: var(--good); border-color: rgba(61, 220, 132, .4); }
.st-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.st-actions .btn { flex: 1; text-align: center; display: flex; align-items: center; justify-content: center; }
.offers-title { font-size: 13px; color: var(--muted); margin: 6px 0 8px; display: flex; justify-content: space-between; }
.offer {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 8px;
}
.offer.mine { border-color: var(--cyan); background: rgba(46, 242, 230, .07); }
.offer.best { border-color: var(--good); }
.offer-prov { font-weight: 600; font-size: 14px; }
.offer-tariff { color: var(--muted); font-size: 12px; grid-column: 1; }
.offer-price { font-family: var(--font-display); font-size: 20px; font-weight: 700; text-align: right; grid-row: 1 / span 2; }
.offer-price small { display: block; font-size: 11px; color: var(--muted); font-family: var(--font-body); font-weight: 400; }
.offer-flags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.flag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.flag.ok { color: var(--good); }
.flag.mine { color: var(--cyan); border-color: rgba(46, 242, 230, .5); }
.flag.warn { color: var(--mid); }
.loading-inline { color: var(--muted); font-size: 14px; padding: 14px 0; display: flex; gap: 10px; align-items: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Navigation */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(14, 18, 36, .96); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--cyan); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 2000; background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
  padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); max-width: 90vw;
}

/* Version 2: helles Design, per data-theme="light" am html-Element */
html[data-theme="light"] {
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #EEF1F8;
  --line: #D9DEEB;
  --text: #141A33;
  --muted: #5E6689;
  --cyan: #0A9E95;
  --violet: #6A3FE6;
  --good: #1FA75E;
  --mid: #D98A00;
  --bad: #D9383D;
  color-scheme: light;
}
html[data-theme="light"] .header { background: rgba(244, 246, 251, .92); }
html[data-theme="light"] .nav { background: rgba(244, 246, 251, .96); }
html[data-theme="light"] .search, html[data-theme="light"] .locate-btn, html[data-theme="light"] .map-status, html[data-theme="light"] .legend { background: rgba(255, 255, 255, .96); box-shadow: 0 6px 20px rgba(20, 26, 51, .12); }
html[data-theme="light"] .map { background: #E8ECF5; }
html[data-theme="light"] .btn { color: #FFFFFF; }
html[data-theme="light"] .badge { color: #FFFFFF; }
html[data-theme="light"] .fchip.on { background: rgba(10, 158, 149, .12); }
html[data-theme="light"] .card.active { background: rgba(10, 158, 149, .06); }
html[data-theme="light"] .offer.mine { background: rgba(10, 158, 149, .07); }
html[data-theme="light"] .sheet { box-shadow: 0 -12px 40px rgba(20, 26, 51, .18); }
html[data-theme="light"] .toast { box-shadow: 0 8px 24px rgba(20, 26, 51, .18); }
html[data-theme="light"] .note { background: rgba(106, 63, 230, .08); }

/* Themenwahl im Profil */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.seg button { height: 40px; padding: 0 16px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--cyan); color: var(--bg); }
html[data-theme="light"] .seg button.on { color: #FFFFFF; }

/* Version 3: Installationskarte, Version 4: mittig, damit keine Browserleiste sie verdeckt */
.install { position: fixed; inset: 0; z-index: 3000; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.install-card { max-height: 80vh; overflow-y: auto; }
.install-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 20px; text-align: center; box-shadow: 0 16px 48px rgba(0, 0, 0, .5); animation: up .22s ease-out; }
.install-icon { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 10px; }
.install-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.install-text { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.install-steps { text-align: left; margin: 0 0 14px 20px; font-size: 14px; color: var(--text); }
.install-steps li { margin-bottom: 6px; }
.install-actions { display: flex; gap: 8px; }
.install-actions .btn { flex: 1; }
.install-never { margin-top: 12px; font-size: 12px; color: var(--muted); text-decoration: underline; }

/* Desktop */
@media (min-width: 900px) {
  :root { --nav-h: 0px; }
  .header-inner { padding: 0 24px; }
  .nav {
    top: env(safe-area-inset-top); bottom: auto; left: auto; right: 24px; height: var(--header-h);
    background: transparent; border: none; backdrop-filter: none; width: auto; gap: 4px; z-index: 1001;
    padding-bottom: 0;
  }
  .nav-item { flex: none; flex-direction: row; gap: 6px; padding: 0 12px; height: 36px; border-radius: 10px; font-size: 13px; }
  .nav-item svg { width: 18px; height: 18px; }
  .nav-item.active { background: rgba(46, 242, 230, .12); }
  .header-actions { margin-right: 470px; }
  .page-map { height: calc(100vh - var(--header-h) - var(--filter-h)); }
  .search-wrap { right: auto; width: 440px; }
  .sheet { left: auto; right: 24px; bottom: 24px; width: 440px; border-radius: 22px; max-height: 72vh; border: 1px solid var(--line); }
  .sheet-backdrop { background: transparent; }
  .toast { bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .page, .sheet { animation: none; }
  .spinner { animation-duration: 2s; }
}
