:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e4e3df;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --grid: #e8e7e3;
  --axis: #b5b4ae;
  --empty: #eeede9;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --accent: #2a78d6;
  --good: #008300;
  --warn: #b97800;
  --bad: #d03b3a;
  --p-vcheap: #1c5cab;
  --p-cheap: #86b6ef;
  --p-normal: #c9c8c3;
  --p-exp: #f0a19c;
  --p-vexp: #c93a39;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --grid: #2a2a28;
    --axis: #55544f;
    --empty: #242422;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --accent: #3987e5;
    --good: #3fae3f;
    --warn: #e0a326;
    --bad: #e66767;
    --p-vcheap: #3987e5;
    --p-cheap: #1c5cab;
    --p-normal: #4a4a46;
    --p-exp: #8f3a39;
    --p-vexp: #e66767;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #2a2a28; --axis: #55544f; --empty: #242422;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --accent: #3987e5;
  --good: #3fae3f; --warn: #e0a326; --bad: #e66767;
  --p-vcheap: #3987e5; --p-cheap: #1c5cab; --p-normal: #4a4a46; --p-exp: #8f3a39; --p-vexp: #e66767;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--bad); }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 14px; color: var(--text-2); letter-spacing: .01em; }
b { font-weight: 650; }
input, select, button { font: inherit; color: inherit; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-box .logo { font-size: 48px; }
.login-box input { text-align: center; font-size: 20px; letter-spacing: .2em; }

/* Kopf + Tabs */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  color: var(--text-2); display: flex; align-items: center; gap: 6px;
}
.tabs button.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.tabs .ico { font-size: 14px; opacity: .8; }

main { max-width: 1120px; margin: 0 auto; padding: 16px 16px 40px; }
.view { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 760px) {
  /* backdrop-filter würde die fixierte Tab-Leiste im Kopf einsperren */
  .top { padding-bottom: 10px; backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around; gap: 0;
    padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .tabs button { flex-direction: column; gap: 1px; font-size: 11px; padding: 4px 8px; background: none !important; }
  .tabs button.active { color: var(--accent); }
  .tabs .ico { font-size: 18px; }
  main { padding-bottom: calc(env(safe-area-inset-bottom) + 90px); }
}

/* Karten */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; box-shadow: var(--shadow); min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.hero-row { display: flex; align-items: center; gap: 12px; }
.hero-num { font-size: 46px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-num small { font-size: 18px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.tiles.four { grid-template-columns: repeat(2, 1fr); }
.tiles.six { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 760px) {
  .tiles.four { grid-template-columns: repeat(4, 1fr); }
  .tiles.six { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1000px) { .tiles.six { grid-template-columns: repeat(6, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); min-width: 0;
}
.tile .label { font-size: 12px; color: var(--muted); }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile .sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; }

.pill { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.ok::before, .pill.off::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.pill.ok::before { background: var(--good); }
.pill.off::before { background: var(--muted); }
.pill.accent { background: var(--series-3); color: #fff; }

.banner {
  background: var(--surface); border: 1px solid var(--accent); border-radius: 12px; padding: 12px 14px;
}
.empty { color: var(--text-2); font-size: 14px; padding: 18px 4px 6px; }
.card.empty { padding: 16px; }

/* Diagramme */
.chart { width: 100%; min-height: 40px; position: relative; }
.chart-svg { display: block; overflow: visible; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--grid); stroke-width: 1; }
.chart-svg .baseline { stroke: var(--axis); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-svg .bar { transition: opacity .1s; }
.chart-svg .bar.hover { opacity: .75; }
.chart-svg .bar.hl { stroke: var(--text); stroke-width: 1.5; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .area { opacity: .14; }
.chart-svg .band { fill: var(--series-3); opacity: .14; }
.chart-svg .band-shower { fill: var(--series-3); opacity: .22; }
.chart-svg .marker { stroke: var(--text); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; }
.chart-svg .marker-label { fill: var(--text-2); font-size: 10.5px; font-weight: 600; }
.chart-svg .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .cell:hover { stroke: var(--text); stroke-width: 1.5; }

.chart-tip {
  position: fixed; z-index: 100; pointer-events: none; display: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0,0,0,.14); max-width: 240px; font-variant-numeric: tabular-nums;
}
.chart-tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .ramp { display: inline-flex; height: 10px; width: 120px; border-radius: 3px; overflow: hidden; }
.legend .ramp i { flex: 1; border-radius: 0; }

/* Zeitfenster */
.windows { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 700px) { .windows { grid-template-columns: repeat(4, 1fr); } }
.win { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.win .what { font-size: 12px; color: var(--muted); }
.win .when { font-weight: 650; font-variant-numeric: tabular-nums; }
.win .price { font-size: 12.5px; color: var(--text-2); }

/* Segment-Umschalter */
.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 10px; gap: 2px; align-self: flex-start; }
.seg button { border: 0; background: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.seg button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.day-nav { display: flex; gap: 8px; align-items: center; }
.day-nav input { flex: 0 1 180px; }

/* Tipps */
.tips { display: flex; flex-direction: column; gap: 8px; }
.tipc { display: flex; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.tipc .ic { font-weight: 700; width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; }
.tipc.good .ic { background: var(--good); }
.tipc.warn .ic { background: var(--warn); }
.tipc.tip .ic { background: var(--accent); }
.tipc.info .ic { background: var(--muted); }
.tipc b { display: block; margin-bottom: 2px; }
.tipc p { margin: 0; font-size: 13.5px; color: var(--text-2); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--muted); font-size: 12px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.list-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.list-row:last-child { border-bottom: 0; }

/* Formulare */
input[type=text], input[type=password], input[type=number], input[type=date], select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row input { flex: 1 1 220px; }
.row label { color: var(--text-2); font-size: 13.5px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--text-2); }
.form-grid label small { color: var(--muted); }
.form-grid .btn { justify-self: start; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); padding: 9px 14px; border-radius: 10px;
  cursor: pointer; text-decoration: none; color: var(--text); font-weight: 550; font-size: 14px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { width: 40px; padding: 8px 0; font-size: 18px; }
.btn.danger-outline { color: var(--bad); }
.btn.mini { padding: 2px 8px; font-size: 12px; }
button.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }

.status-list { display: flex; flex-direction: column; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv span:nth-child(odd) { color: var(--muted); }
.msg-ok { color: var(--good); }
.msg-err { color: var(--bad); }

/* Waschtrockner */
.washer-plan { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 700px) { .washer-plan { grid-template-columns: repeat(3, 1fr); } }
.win.best { outline: 2px solid var(--accent); outline-offset: -2px; }
.w-status { font-size: 15px; display: flex; flex-direction: column; gap: 2px; }
.w-status b { font-size: 18px; }
details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; padding: 4px 0; }
.steps { padding-left: 20px; color: var(--text-2); }
.steps li { margin: 4px 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; word-break: break-all; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; }
.form-grid label.check input { width: 18px; height: 18px; }
input[type=datetime-local] { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
