:root {
  --ground: #F4F5F1; --card: #FFFFFF; --line: #E2E5DF; --line-strong: #C9CFC7;
  --ink: #17201B; --ink-2: #4A554E; --muted: #5B665F;
  --green: #1F6B45; --green-dark: #14492F; --green-soft: #E8F1EC;
  --house: #2F6FDE; --ev: #E07A2E; --pv: #E3A21A; --grid: #9AA39C;
  --warn-bg: #FFF6E5; --warn-ink: #8A5A00; --err-bg: #FDECEC; --err-ink: #9B1C1C;
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--ground);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); font-size: 15px; line-height: 1.45; }
h1, h2 { font-family: "Space Grotesk", Inter, system-ui, sans-serif; font-weight: 600; margin: 0; }
h1 { font-size: 24px; } h2 { font-size: 18px; }
a { color: var(--green); }
.muted { color: var(--muted); } .small { font-size: 13px; }
[hidden] { display: none !important; }

/* Kopf */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 14px 24px;
       background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-family: "Space Grotesk", Inter, sans-serif; font-weight: 600; font-size: 19px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.tabs a[aria-current="page"] { background: var(--green-soft); color: var(--green); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.top-right form { margin: 0; }

main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 20px; }
.tab { display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px;
        display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.grow { flex: 1 1 480px; }

/* Banner */
#banners { display: flex; flex-direction: column; gap: 10px; }
#banners:empty { display: none; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; font-size: 14px; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.error { background: var(--err-bg); color: var(--err-ink); }
.banner b { font-weight: 600; }

/* Kacheln */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
        display: flex; flex-direction: column; gap: 4px; }
.tile .label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.tile .dot { width: 10px; height: 10px; border-radius: 3px; }
.tile .value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .note { font-size: 13px; color: var(--muted); }

/* Badges & Buttons */
.badge { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #F1F2EF; color: var(--ink-2); white-space: nowrap; }
.badge:empty { display: none; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.err { background: var(--err-bg); color: var(--err-ink); }
.btn { min-height: 44px; padding: 0 20px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card);
       color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--green-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.link-btn { background: none; border: none; color: var(--green); font: inherit; font-weight: 500; cursor: pointer; padding: 8px 6px; min-height: 40px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* Plan */
.plan-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; justify-content: space-between; }
.plan-head h1, .plan-head h2 { margin-right: auto; }
.plan-text { margin: 0; font-size: 16px; max-width: 820px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.facts:empty { display: none; }
.fact { background: #F7F8F5; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.fact .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fact .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fact .n { font-size: 13px; color: var(--muted); }
.target-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.target-form input { width: 90px; }

.snow-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 14px 16px; border-radius: 12px; background: #FBF5E6; }
.snow-box.covered { background: #EEF3F9; }
.snow-box .txt { flex: 1 1 280px; display: flex; flex-direction: column; gap: 2px; }
.snow-box .t { font-size: 17px; font-weight: 600; }
.snow-box .s { font-size: 13px; color: var(--ink-2); }

/* Formulare */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], select {
  min-height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; background: #fff; color: var(--ink); }
fieldset { border: none; padding: 0; margin: 0 0 18px; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px 22px; }
legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 10px; grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 14px; font-weight: 500; }
.field .help { font-size: 12.5px; color: var(--muted); }
.field .inline { display: flex; align-items: center; gap: 8px; }
.field .inline input { flex: 1; min-width: 0; }
.field.check { flex-direction: row; align-items: flex-start; gap: 10px; }
.field.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--green); }
.form-error { color: var(--err-ink); background: var(--err-bg); padding: 10px 12px; border-radius: 10px; margin: 0; font-size: 14px; }
#settings-msg.ok { color: var(--green); } #settings-msg.err { color: var(--err-ink); }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em;
            padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid #EEF0EC; vertical-align: top; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
details summary { cursor: pointer; color: var(--green); font-weight: 500; padding: 6px 0; }

/* Diagramme */
.chart { width: 100%; min-height: 200px; position: relative; }
.chart.tall { min-height: 260px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 11px; fill: var(--muted); font-family: Inter, system-ui, sans-serif; }
.chart .grid line { stroke: #ECEEE9; }
.chart .empty { fill: var(--muted); font-size: 13px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; margin: 0 4px 0 10px; }
.key-charge { background: var(--green); }
.key-house { background: var(--house); }
.key-ev { background: var(--ev); }
.tooltip { position: fixed; z-index: 20; pointer-events: none; background: #17201B; color: #fff; font-size: 13px; padding: 7px 10px;
           border-radius: 8px; max-width: 260px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }

/* Login */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px;
              display: flex; flex-direction: column; gap: 10px; }
.login-card h1 { margin: 10px 0 4px; font-size: 22px; }
.login-card label { font-size: 14px; font-weight: 500; margin-top: 6px; }
.login-card .btn { margin-top: 12px; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; } main { padding: 16px; }
  .top-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile .value { font-size: 22px; }
  .card { padding: 16px; }
}

.chart-title { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.chart-title .key:first-child { margin-left: 12px; }
.key-pv { background: var(--pv); }
.key-unsplit { background: #B8BEB7; }
.key-line-house, .key-line-soc, .key-line-base { height: 3px; width: 16px; border-radius: 2px; vertical-align: 3px; }
.key-line-house { background: var(--house); }
.key-line-soc { background: var(--green); }
.key-line-base { background: repeating-linear-gradient(90deg, #8A948C 0 4px, transparent 4px 7px); }
.chart .cursor { stroke: #17201B; stroke-width: 1; opacity: .35; }

/* Wetter */
.wx-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.wx-day { background: #F7F8F5; border-radius: 10px; padding: 12px 14px; display: grid;
          grid-template-columns: 56px 1fr; gap: 2px 12px; align-items: center; }
.wx-day svg { grid-row: span 3; }
.wx-day .d { font-weight: 600; }
.wx-day .t { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wx-day .t .lo { color: var(--muted); font-weight: 500; font-size: 16px; }
.wx-day .n { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.wx-hours { display: flex; overflow-x: auto; gap: 2px; padding-bottom: 6px; scroll-snap-type: x proximity; }
.wx-h { flex: 0 0 52px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0;
        border-radius: 10px; scroll-snap-align: start; font-variant-numeric: tabular-nums; }
.wx-h.night { background: #F1F3F6; }
.wx-h .h { font-size: 12.5px; color: var(--muted); }
.wx-h .tc { font-size: 14px; font-weight: 600; }
.wx-h .p { font-size: 11.5px; color: var(--house); min-height: 15px; white-space: nowrap; }
.wx-sep { flex: 0 0 auto; display: flex; align-items: center; padding: 0 6px; font-size: 12.5px; font-weight: 600;
          color: var(--ink-2); writing-mode: vertical-rl; transform: rotate(180deg); border-left: 1px solid var(--line); }
.wx-place { margin: -4px 0 0; }
.chart .wx-t { font-size: 11px; fill: var(--ink-2); font-family: Inter, system-ui, sans-serif; }
.tile .flaky { display: block; color: var(--warn-ink); margin-top: 2px; }
.tile .flaky .status-dot { margin-right: 6px; }
