/* Strompilot — dark-only, 1Komma5°-inspiriert, mobil zuerst. */

:root {
  color-scheme: dark;
  /* Flächen */
  --bg: #0a0a0b;
  --card: #161618;
  --card-2: #212124;
  --line: #2a2a2f;
  --line-soft: #1d1d20;
  /* Text */
  --ink: #f5f5f7;
  --ink-2: #b0b0ba;
  --muted: #74747e;
  /* Marke */
  --brand: #a06af8;
  --brand-strong: #8b5cf6;
  --brand-soft: rgba(160, 106, 248, 0.16);
  --grad: linear-gradient(110deg, #7c3aed 0%, #4f46a3 45%, #0f766e 100%);
  --grad-text: linear-gradient(100deg, #b69cff, #5eead4);
  /* Semantik */
  --teal: #2dd4bf;
  --solar: #d9a514;
  --good: #34d399;
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  /* Preis-Chart */
  --price-low: #34d399;
  --price-mid: #56565f;
  --price-high: #f97316;
  --price-past: #3a3a41;
  --viz-charge: var(--brand);
  /* Haus */
  --house-wall: #303036;
  --house-wall-2: #3a3a41;
  --house-roof: #232328;
  --house-roof-2: #1a1a1e;
  --house-line: #4a4a54;
  --house-pv: #131c2e;
  --house-pv-line: #33465f;
  --shadow: none;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
/* Doppeltipp-Zoom auf iOS unterbinden, Taps bleiben sofort wirksam */
button, input, .btn, .tile, .switch, .chip { touch-action: manipulation; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Instrument Sans", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.shell {
  max-width: 620px;
  margin: 0 auto;
  /* safe-area oben: die PWA läuft unter der iOS-Statusleiste (Uhr/Akku) */
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(48px + env(safe-area-inset-bottom));
}

/* --------------------------- Pull-to-Refresh ------------------------------ */

#ptr {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -60px);
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 99px;
  z-index: 20;
  opacity: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  pointer-events: none;
}
#ptr.visible { opacity: 1; transform: translate(-50%, 0); }
#ptr.armed { color: var(--brand); border-color: var(--brand); }

.num, .soc-number, .plan-title, .step-value, .plan-savings b {
  font-family: "Space Grotesk", "Instrument Sans", sans-serif;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------- Kopf ---------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 18px;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark .bolt {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
}
.wordmark .bolt svg { width: 14px; height: 14px; }
.topbar form button, .topbar .demo-pill {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 99px;
  cursor: pointer;
}
.topbar .demo-pill { color: var(--amber); border-color: transparent; background: var(--amber-soft); cursor: default; }
.topbar .right { display: flex; gap: 8px; align-items: center; }

/* ------------------------------- Karten --------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 20px;
  margin-bottom: 14px;
}
.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* --------------------------- Schutz-Banner ------------------------------- */

.guard-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 16px;
  padding: 13px 14px;
  margin-bottom: 14px;
}
.guard-icon { color: var(--teal); flex-shrink: 0; display: grid; place-items: center; }
.guard-icon svg { width: 22px; height: 22px; }
.guard-text { flex: 1; font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.guard-text b { display: block; color: var(--ink); font-size: 14px; }
.guard-release {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ------------------------------- Hero ----------------------------------- */

.hero-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.soc-number { font-size: 56px; font-weight: 700; line-height: 1; }
.soc-number small { font-size: 26px; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.soc-number.charging span {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.soc-caption { color: var(--muted); font-size: 13.5px; margin-top: 6px; }

.house-wrap { margin: 6px -6px 0; }
.house-wrap svg { display: block; width: 100%; height: auto; }
.callout polyline { stroke: #4a4a55; stroke-width: 1; }
.callout .co-val { font-size: 14px; font-weight: 650; fill: var(--ink);
  font-family: "Space Grotesk", sans-serif; letter-spacing: -0.01em; }
.callout .co-cap { font-size: 10.5px; fill: var(--muted); }
.callout { transition: opacity 0.4s ease; }
.callout.dim { opacity: 0.38; }
#h-pv.active polygon {
  stroke: var(--teal);
  filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.5));
}
#h-bat.pulse #h-bat-fill { animation: pulse 2s ease-in-out infinite; }
#h-lock { transition: opacity 0.3s ease; }

/* ------------------------------ Plan-Karte ------------------------------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
  background: var(--card-2);
  color: var(--ink-2);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--muted); }
.status-pill.proposed { background: var(--amber-soft); color: var(--amber); }
.status-pill.proposed .dot { background: var(--amber); }
.status-pill.confirmed, .status-pill.applied { background: var(--brand-soft); color: var(--brand); }
.status-pill.confirmed .dot, .status-pill.applied .dot { background: var(--brand); }
.status-pill.applied .dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

.plan-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; margin-bottom: 6px; flex-wrap: wrap; }
.plan-title { font-size: 18px; font-weight: 700; }
.plan-block.plan-divider { border-top: 1px solid var(--line-soft); margin-top: 18px; padding-top: 16px; }
.plan-savings { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.plan-savings b {
  background: var(--grad-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 16px;
}
.plan-reason { color: var(--ink-2); font-size: 14.5px; margin: 10px 0 16px; }
.plan-reason:empty { margin: 6px 0 10px; }

.window-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.window-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-2);
  border-radius: 14px;
  padding: 12px 16px;
}
.window-row .win-check { display: none; color: var(--good); width: 18px; height: 18px; flex-shrink: 0; }
.window-row .win-check svg { width: 18px; height: 18px; }
.window-row.done { opacity: 0.65; }
.window-row.done .win-check { display: block; }
.window-row .time { font-weight: 600; font-variant-numeric: tabular-nums; flex: 1; }
.window-row .time small { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.window-row .price { color: var(--good); font-weight: 650; font-variant-numeric: tabular-nums; }

.plan-stats {
  display: flex;
  gap: 6px 20px;
  padding: 2px 2px 18px;
  font-size: 14px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.plan-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.plan-stats .save b { color: var(--good); }

.charge-progress { margin: 0 0 18px; }
.progress-caption {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--ink-2); margin-bottom: 6px;
}
.progress-caption b { color: var(--ink); }
.progress-bar { height: 8px; border-radius: 99px; background: var(--card-2); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  border-radius: 99px;
  background: var(--brand);
  transition: width 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font: inherit;
  font-size: 16px;
  font-weight: 620;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: transform 0.05s ease, opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-confirm { background: var(--brand-strong); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--line);
  font-size: 14.5px;
  padding: 11px 20px;
}
.btn-ghost.neutral { color: var(--ink-2); }
.btn-ghost.armed { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn + .btn { margin-top: 8px; }
.btn-row { margin-top: 4px; }
.btn-row form + form .btn { margin-top: 8px; }

.empty-plan { display: flex; align-items: center; gap: 14px; }
.empty-plan .sun {
  width: 42px; height: 42px; border-radius: 13px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; flex-shrink: 0;
}
.empty-plan .sun svg { width: 22px; height: 22px; }
.empty-plan p { font-size: 14.5px; color: var(--ink-2); }
.empty-plan b { color: var(--ink); }

/* --------------------------- Aktionskacheln ------------------------------- */

/* ------------------------------ Bilanz ------------------------------------ */

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-tile {
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px 14px 12px;
}
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-value {
  font-family: "Space Grotesk", "Instrument Sans", sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-value small { font-size: 13px; font-weight: 500; color: var(--ink-2); margin-left: 4px; }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }

.tile-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 82px;
  justify-content: center;
  background: var(--card-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s ease, border-color 0.15s ease;
}
.tile:active { transform: scale(0.98); }
.tile .tile-icon {
  width: 30px; height: 30px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.tile .tile-icon svg { width: 17px; height: 17px; }

/* ---------------------------- Automatik-Zeile ----------------------------- */

.auto-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--line-soft);
  margin-top: 18px;
  padding-top: 16px;
}
.auto-text { flex: 1; font-size: 13px; color: var(--muted); line-height: 1.4; }
.auto-text b { display: block; color: var(--ink); font-size: 14.5px; font-weight: 600; }
.switch {
  width: 48px; height: 28px; border-radius: 99px;
  background: var(--card-2);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.switch .knob {
  position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; border-radius: 99px;
  background: var(--muted);
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch.on { background: var(--brand-strong); border-color: transparent; }
.switch.on .knob { transform: translateX(20px); background: #fff; }

/* ------------------------------ Bottom-Sheet ------------------------------ */

dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100%;
  max-height: 100dvh;
  width: 100%;
  margin: auto 0 0;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); }
.sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 620px;
  margin: 0 auto;
}
.sheet-grip {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--line);
  margin: 6px auto 16px;
}
.sheet-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
}
.sheet-block { margin-bottom: 18px; }

.seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--card-2);
  border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.seg-btn {
  border: none; background: transparent;
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 6px; border-radius: 9px; cursor: pointer;
}
.seg-btn.active { background: var(--brand-soft); color: var(--brand); }

.stepper {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-2); border-radius: 14px; padding: 8px;
}
.step-btn {
  width: 52px; height: 52px; border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink); font-size: 26px; font-weight: 500;
  cursor: pointer;
}
.step-btn:active { transform: scale(0.96); }
.step-btn:disabled { opacity: 0.35; }
.step-value { display: flex; align-items: baseline; justify-content: center; font-size: 34px; font-weight: 700; }
.step-value small { font-size: 18px; color: var(--ink-2); margin-left: 2px; }
.step-value input {
  width: 3.2ch;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}
.step-value input::-webkit-outer-spin-button,
.step-value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-value input:focus { outline: none; color: var(--brand); }

.seg-day { margin-bottom: 10px; }
.time-wrap {
  background: var(--card-2);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  place-items: center;
}
#deadline-time {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: "Space Grotesk", "Instrument Sans", sans-serif;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
  border-radius: 10px;
  color-scheme: dark;
  text-align: center;
  width: 100%;
}
#deadline-time:focus { outline: 2px solid var(--brand); }

.preview {
  min-height: 42px;
  font-size: 13.5px;
  color: var(--ink-2);
  background: var(--line-soft);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.45;
}
.preview b { color: var(--ink); }
.preview.error { color: var(--amber); background: var(--amber-soft); }

.sheet-actions .btn + .btn { margin-top: 8px; }
.auto-confirm-text { font-size: 15px; color: var(--ink-2); margin: 4px 2px 18px; line-height: 1.55; }

/* ------------------------------- Chart ----------------------------------- */

.chart-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.chart-sub { font-size: 13px; color: var(--muted); }
.chart-now { font-size: 14px; font-weight: 650; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
#chart { position: relative; margin-top: 10px; }
#chart svg { display: block; width: 100%; }
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: #26262b;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 6px 10px;
  border-radius: 10px;
  white-space: nowrap;
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 3;
}
.chart-tooltip .tip-win { color: var(--brand); }

/* ---------------------------- Mitteilungen -------------------------------- */

.push-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.push-status { font-size: 14px; color: var(--ink-2); }
.push-status b { color: var(--good); }
.btn-small {
  width: auto;
  flex-shrink: 0;
  font-size: 14px;
  padding: 9px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 11px;
}
.push-secondary {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  padding: 8px 0 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ------------------------------ Verlauf ---------------------------------- */

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 14.5px;
}
.history-row:last-child { border-bottom: none; }
.history-row .date { font-weight: 600; }
.history-row .meta { color: var(--muted); font-size: 13px; }
.history-row .kwh { font-variant-numeric: tabular-nums; color: var(--ink-2); }

details.events { margin-top: 4px; }
details.events summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
  list-style: none;
}
details.events summary::-webkit-details-marker { display: none; }
.event-row {
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px;
  font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--line-soft);
}
.event-row.error { color: var(--danger); }

/* ------------------------------- Login ----------------------------------- */

.login-wrap { min-height: 82dvh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 360px; text-align: center; padding: 36px 28px; }
.login-card .bolt {
  width: 46px; height: 46px; border-radius: 14px; margin: 0 auto 16px;
  background: var(--grad); color: #fff; display: grid; place-items: center;
}
.login-card .bolt svg { width: 22px; height: 22px; }
.login-card h1 { font-size: 20px; font-weight: 650; margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 13px;
  padding: 13px 16px;
  font: inherit;
  margin-bottom: 10px;
  text-align: center;
}
.login-card input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.login-error { color: var(--danger); font-size: 13.5px; margin-bottom: 12px; }

/* ------------------------------ Plan-Seite ------------------------------- */

.back-link {
  display: inline-block;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
  margin-bottom: 14px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
}
.plan-page-note { color: var(--muted); font-size: 13px; text-align: center; margin-top: 14px; }

@media (min-width: 700px) {
  .shell { padding-top: 36px; }
  .card { padding: 26px 26px; }
  dialog { margin: auto; max-width: 480px; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); }
}
