:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e3e6ea;
  --text: #15181c; --text-2: #525a66; --muted: #7d8794;
  --de: #2a78d6; --at: #eb6834; --vj: #b7bcc4; --soll: #6250d6;
  --gruen: #008300; --gelb: #c98500; --rot: #d93a39; --gruen-bg: #e6f4e6; --gelb-bg: #fff4dc; --rot-bg: #fde7e7;
  --accent: #15181c; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121416; --surface: #1b1e22; --surface-2: #22262b; --border: #2e333a;
    --text: #eef0f2; --text-2: #b9c0c9; --muted: #818a96;
    --de: #3987e5; --at: #d95926; --vj: #4a515a; --soll: #9085e9;
    --gruen: #3fb33f; --gelb: #e0a63a; --rot: #e66767; --gruen-bg: #1d2e1d; --gelb-bg: #33290f; --rot-bg: #3a1d1d;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin-top: 1.5rem; }
h3 { font-size: 1rem; color: var(--text-2); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .mono { font-variant-numeric: tabular-nums; }
.fehler { color: var(--rot); }

/* Login */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 2.5rem; width: min(440px, 92vw); text-align: center; box-shadow: var(--shadow); }
.logo { font-weight: 700; font-size: 1.3rem; letter-spacing: -.02em; } .logo span { font-weight: 400; color: var(--muted); }
.btn { display: inline-block; padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-decoration: none; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--muted); } .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-google { background: #fff; color: #222; border-color: #d0d4d9; font-weight: 500; margin: 1rem 0 .5rem; }
.btn.klein { padding: .3rem .6rem; font-size: .85rem; } .btn.danger { color: var(--rot); }
.btn:disabled { opacity: .5; cursor: default; }

/* Kopf */
header.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1.5rem; padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.tabs a { text-decoration: none; padding: .45rem .8rem; border-radius: 8px; color: var(--text-2); white-space: nowrap; }
.tabs a.aktiv { background: var(--surface-2); color: var(--text); font-weight: 600; }
.user { display: flex; gap: 1rem; align-items: center; white-space: nowrap; }
main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }
.laden { color: var(--muted); padding: 2rem; text-align: center; }

/* Karten */
.grid { display: grid; gap: 1rem; } .grid.k4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); } .grid.k2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.card h3 { margin-bottom: .75rem; }
.stat .label { color: var(--muted); font-size: .85rem; } .stat .wert { font-size: 1.7rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: .15rem 0; }
.stat .sub { color: var(--text-2); font-size: .85rem; }
.delta.pos { color: var(--gruen); } .delta.neg { color: var(--rot); }
.chart-wrap { position: relative; height: 300px; } .chart-wrap.hoch { height: 360px; } .chart-wrap.flach { height: 220px; }
.hinweis { background: var(--surface-2); border-left: 3px solid var(--soll); padding: .6rem .9rem; border-radius: 6px; color: var(--text-2); margin: .75rem 0; font-size: .9rem; }

/* Tabellen */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.klick { cursor: pointer; } tr.klick:hover { background: var(--surface-2); }
tr.summe td { font-weight: 600; border-top: 2px solid var(--border); }
.tabelle-scroll { overflow-x: auto; }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.de { color: var(--de); border-color: var(--de); } .badge.at { color: var(--at); border-color: var(--at); }
.ampel { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; margin-right: .35rem; }
.ampel.gruen { background: var(--gruen); } .ampel.gelb { background: var(--gelb); } .ampel.rot { background: var(--rot); } .ampel.leer { background: var(--border); }
.status-aktiv { color: var(--gruen); } .status-schlafend { color: var(--gelb); } .status-verloren { color: var(--rot); } .status-migriert { color: var(--soll); font-weight: 600; }
.klasse-balken { display: inline-block; height: .55rem; background: var(--de); border-radius: 3px; vertical-align: middle; }

/* Formulare */
.filter { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
label.feld { display: flex; flex-direction: column; gap: .2rem; font-size: .8rem; color: var(--muted); }
input, select, textarea { font: inherit; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); }
input[type=number] { width: 9rem; text-align: right; } input.schmal { width: 6rem; }
.zeile { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.gewichte input { width: 4.2rem; padding: .25rem .3rem; font-size: .8rem; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal.hidden { display: none; }
.modal-box .grid.k4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.modal-box { background: var(--surface); border-radius: 14px; padding: 1.5rem; width: min(900px, 96vw); max-height: 92vh; overflow: auto; position: relative; }
.modal-close { position: absolute; right: .8rem; top: .6rem; border: 0; background: none; font-size: 1.5rem; color: var(--muted); cursor: pointer; }
pre { background: var(--surface-2); padding: .6rem .8rem; border-radius: 7px; overflow: auto; font-size: .8rem; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 60; }
@media (max-width: 720px) { header.top { flex-wrap: wrap; gap: .5rem; } .user span:not(#sync-info) { display: none; } main { padding: .75rem; } .grid.k2 { grid-template-columns: 1fr; } }
