/* App-Layout (ergänzt mbsmart.css) */
html, body { height: 100%; }
body { overscroll-behavior-y: none; }
#app { min-height: 100%; }
.grid { display: grid; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.logo-xl { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #2bb5e8); color: var(--on-accent); box-shadow: 0 20px 50px -14px var(--accent); }
.logo-xl svg { width: 40px; height: 40px; }

/* Shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(96px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; }
.main > * { flex: none; }
.shell .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; }
@media (min-width: 900px) {
  .shell .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 520px; bottom: 16px;
    border: 1px solid var(--border); border-radius: 22px; padding-bottom: 8px; box-shadow: var(--shadow); }
}

.apphead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px 4px; }
.apphead p { font-size: 13px; color: var(--text-3); font-weight: 600; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 4px 0; }
.section-title a, .linkbtn { font-size: 14px; font-weight: 600; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; text-decoration: none; font-family: inherit; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--text-2); }
.kv span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.hero-car { position: relative; overflow: hidden; }
.hero-car::after { content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%); pointer-events: none; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text-2); cursor: pointer; flex: none; }
.iconbtn svg { width: 20px; height: 20px; }
.month { display: flex; align-items: center; justify-content: space-between; }
.month h2 { font-size: 18px; }
.daygroup { font-size: 12px; font-weight: 700; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; padding: 4px 4px 0; }
.row.click { cursor: pointer; }
.row.excluded { opacity: .5; }
.empty { text-align: center; padding: 28px 12px; color: var(--text-3); font-size: 14px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.muted { background: var(--surface-3); color: var(--text-3); }
.tariff { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
.hint-line { font-size: 13px; color: var(--text-3); padding: 0 4px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); margin-right: 6px; vertical-align: middle; }
.live-dot.off { background: var(--text-3); box-shadow: none; }
.big-live { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.field label .val { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
select.input { appearance: none; background-image: none; }
textarea.input { min-height: 80px; padding: 12px 16px; resize: vertical; }
details.card summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary svg { width: 18px; height: 18px; color: var(--text-3); transition: transform var(--dur) var(--ease); }
details.card[open] summary svg { transform: rotate(90deg); }

/* Login */
.login { min-height: 100vh; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 24px) 28px calc(env(safe-area-inset-bottom) + 28px); }
.login .logo-xl { margin: 40px 0 28px; }
.login h1 { font-size: 32px; }
.login form { display: grid; gap: 16px; margin-top: 32px; }
.login .error { color: var(--danger); font-size: 14px; font-weight: 600; min-height: 20px; }
.secure { margin-top: auto; padding-top: 32px; display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 12px; color: var(--text-3); }
.secure svg { width: 16px; height: 16px; color: var(--accent); }

/* Bottom-Sheet */
.sheet-bg { position: fixed; inset: 0; background: #0008; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s var(--ease); }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 16px;
  animation: up .22s var(--ease); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto 4px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; z-index: 60; }
.toast-wrap .toast { animation: up .2s var(--ease); }
.toast.err svg { color: var(--danger); }

/* Diagramm */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 160px; padding-top: 8px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; align-items: stretch; }
.bar .stack { display: flex; flex-direction: column-reverse; border-radius: 6px; overflow: hidden; min-height: 2px; background: var(--surface-3); }
.bar .stack i { display: block; }
.bar small { font-size: 10px; text-align: center; color: var(--text-3); font-weight: 600; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 18px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.bars.days { gap: 2px; height: 120px; }
.bars.days .bar .stack { border-radius: 3px; }
.bars.days .bar.we .stack:not(:has(i)) { background: var(--surface-2); }
.bars.days .bar.today small { color: var(--accent); }
.bars.days .bar.today .stack { outline: 1px solid var(--accent); outline-offset: 1px; }
.bars.days small, .bars.months small { height: 14px; line-height: 14px; }
.bars.months { position: relative; height: 120px; }
.bars.months .bar.sel small { color: var(--accent); }
.avgline { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--text-3); pointer-events: none; opacity: .7; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; border: 0; border-radius: var(--r-pill); background: none; color: var(--text-2); font: 600 14px var(--font); cursor: pointer; }
.seg button svg { width: 16px; height: 16px; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px #0003; }
.seg button[aria-selected="true"] svg { color: var(--accent); }
.avatar.warn { background: var(--danger-soft); color: var(--danger); }
.evlist .row { align-items: flex-start; }
.evlist .avatar { width: 34px; height: 34px; }
.evlist .avatar svg { width: 17px; height: 17px; }
.evlist .meta { word-break: break-word; }
.evlist .end b { font-size: 13px; color: var(--text-2); font-weight: 600; }
.pies { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) { .pies { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .pies:not(.two) { grid-template-columns: repeat(3, 1fr); } .pies:has(> :nth-child(4):last-child) { grid-template-columns: repeat(2, 1fr); } .stats.six { grid-template-columns: repeat(6, 1fr); }
  .pies:not(.two):has(> :nth-child(3):last-child) .donut { flex-direction: column; align-items: stretch; }
  .pies:not(.two):has(> :nth-child(3):last-child) .donut .ring { align-self: center; } }
.donut-card h3 { font-size: 15px; margin-bottom: 12px; }
.donut { display: flex; align-items: center; gap: 18px; }
.donut .ring { position: relative; width: 120px; height: 120px; flex: none; }
.donut .ring svg { width: 100%; height: 100%; display: block; }
.donut .ring circle { transition: opacity .15s; }
.donut .ring circle:hover { opacity: .8; }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut .center b { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut .center span { font-size: 11px; color: var(--text-3); font-weight: 600; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 10px 1fr auto 40px; align-items: center; gap: 8px; }
.legend i, .legend-row i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .l { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .v { font-weight: 600; text-align: right; }
.legend .v small { color: var(--text-3); font-weight: 500; }
.legend .p { color: var(--text-3); text-align: right; font-size: 12px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }
.legend-row span { display: inline-flex; align-items: center; gap: 6px; }
.bars .bar.sel small { color: var(--accent); }
.pill.muster::before { display: none; }
.pill.muster { background: var(--pv-soft); color: var(--pv); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; margin-left: 6px; padding: 2px 8px; vertical-align: middle; }
.muster-note { border-style: dashed; }
.is-muster .card { border-style: dashed; }
.stats.glance { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 700px) { .stats.glance { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .stats.glance { grid-template-columns: repeat(6, 1fr); } }
.glance-tile .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; font-variant-numeric: tabular-nums; }
.glance-tile { position: relative; }
.glance-tile.muster { border-style: dashed; }
.glance-tile .mtag { position: absolute; top: -8px; right: 10px; margin: 0; }
.mtag { margin-left: auto; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; color: var(--pv); background: var(--pv-soft); border-radius: 4px; padding: 1px 5px; font-weight: 700; }
.fin-row .mtag { margin-left: 8px; vertical-align: 1px; }
.fin { display: grid; grid-template-columns: 1fr; gap: 14px 28px; margin-top: 18px; }
@media (min-width: 900px) { .fin { grid-template-columns: 1fr 1fr; } }
.fin h4 { font-size: 13px; color: var(--text-2); margin: 0 0 6px; font-weight: 700; }
.fin-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.fin-row small { display: block; font-size: 12px; color: var(--text-3); }
.fin-row b.neg { color: var(--grid); }
.fin-row.total { border-bottom: 0; font-weight: 700; padding-top: 10px; }
.fin-row.total b { font-size: 17px; }
.split { display: grid; grid-template-columns: 1fr; gap: 14px; min-width: 0; }
.split > .vstack { align-content: start; }
@media (min-width: 1200px) { .split { grid-template-columns: 1fr 1fr; align-items: start; } .split .stats { grid-template-columns: repeat(2, 1fr); } }

.qr { background: #fff; border-radius: 12px; padding: 4px; width: 260px; max-width: 100%; margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }
code.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; display: block; text-align: center; }
.sim { border-style: dashed; }

/* Auswahl-Chips (Fahrzeug, Filter) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2); font: 600 14px var(--font); cursor: pointer; }
.chip svg { width: 16px; height: 16px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip[aria-pressed="true"] svg { color: var(--accent); }
.chip[disabled] { opacity: .5; cursor: default; }
.btn { text-decoration: none; }

/* ---------- Abstände in verschachtelten Bereichen ---------- */
.vstack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.vstack:empty { display: none; }
.vstack > * { flex: none; }
.dash { display: flex; flex-direction: column; gap: 14px; }
.notice + .notice { margin-top: 0; }

/* ---------- Tablet ---------- */
@media (min-width: 700px) {
  .main { padding-left: 24px; padding-right: 24px; gap: 18px; }
  .vstack, .dash { gap: 18px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .card { padding: 20px; }
}

/* ---------- Desktop: Seitennavigation, breitere Inhalte ---------- */
.brand-side { display: none; }
@media (min-width: 1024px) {
  .shell { flex-direction: row; }
  .shell .tabbar, .shell .tabbar:is(*) {
    position: sticky; top: 0; left: 0; right: auto; bottom: auto; transform: none;
    width: 232px; height: 100vh; flex: none; order: -1;
    display: flex; flex-direction: column; gap: 4px; padding: 24px 14px;
    border: 0; border-right: 1px solid var(--border); border-radius: 0; box-shadow: none;
    background: color-mix(in srgb, var(--surface) 70%, transparent);
  }
  .brand-side { display: flex; align-items: center; gap: 10px; padding: 4px 12px 22px; font: 700 18px var(--font-display); }
  .brand-side svg { width: 30px; height: 30px; padding: 6px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #2bb5e8); color: var(--on-accent); }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; font-size: 15px; border-radius: 12px; }
  .tab:hover { background: var(--surface-2); color: var(--text); }
  .tab[aria-current="page"] { background: var(--accent-soft); }
  .main { max-width: 1180px; padding: 36px 40px 64px; gap: 20px; }
  .main[data-route="laden"], .main[data-route="historie"], .main[data-route="mehr"] { max-width: 860px; }
  .apphead h1 { font-size: 34px; }
  .dash { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-areas: "car flow" "rest flow"; gap: 20px; align-items: start; }
  .dash .d-car { grid-area: car; } .dash .d-flow { grid-area: flow; } .dash .d-rest { grid-area: rest; }
  .vstack, .dash { gap: 20px; }
  .toast-wrap { bottom: 32px; }
  .sheet-bg { align-items: center; }
}

/* ---------- Energiefluss (animiertes SVG) ---------- */
.flowbox { width: 100%; max-width: 520px; margin: 0 auto; }
.fl-svg { width: 100%; height: auto; display: block; overflow: visible; }
.fl-line { fill: none; stroke: var(--surface-3); stroke-width: 2.5; stroke-linecap: round; }
.fl-line.off { stroke-dasharray: 2 6; opacity: .6; }
.fl-glow { fill: none; stroke-linecap: round; opacity: .28; }
.fl-dot { opacity: .95; }
.fl-halo { fill: color-mix(in srgb, var(--c) 12%, transparent); }
.fl-bubble { fill: var(--surface-2); stroke: var(--c); stroke-width: 2; }
.fl-icon { fill: none; stroke: var(--c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fl-node.on .fl-halo { animation: fl-pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.fl-node.off { opacity: .38; filter: grayscale(1); }
.fl-node.off .fl-bubble { stroke-dasharray: 3 4; }
.fl-val { font: 700 15px var(--font-display); fill: var(--text); text-anchor: middle; font-variant-numeric: tabular-nums; }
.fl-lbl { font: 600 10.5px var(--font); fill: var(--text-3); text-anchor: middle; letter-spacing: .02em; }
.fl-hubval { font: 700 12px var(--font-display); fill: var(--text-2); text-anchor: middle; }
@keyframes fl-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .55; } }
.flow-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; font-size: 12px; color: var(--text-3); margin-top: 6px; }
.flow-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
