:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c1f24;
  --muted: #6b7280;
  --border: #e3e6eb;
  --accent: #e5484d;
  --accent-soft: #fde8e8;
  --ok: #2f9e44;
  --danger: #c92a2a;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #2a2e36;
    --accent: #ff6369;
    --accent-soft: #3a1d1f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

/* Layout ------------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user { color: var(--muted); font-size: 14px; white-space: nowrap; }

main { max-width: 1100px; margin: 0 auto; padding: 24px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }

/* Bausteine --------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 20px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .unit { color: var(--muted); font-size: 14px; font-weight: 400; margin-left: 2px; }
.chart-box { position: relative; height: 260px; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--border); }
.badge.active, .badge.ok { background: #d3f9d8; color: #2b8a3e; }
.badge.paused { background: #fff3bf; color: #946200; }
.badge.error, .badge.revoked { background: #ffe3e3; color: var(--danger); }

/* Formulare ---------------------------------------------------------------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
.field { margin-bottom: 12px; }
button, .button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.5; cursor: default; }

.notice { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); margin-bottom: 16px; }
.hidden { display: none !important; }

/* Login -------------------------------------------------------------------- */
.login { max-width: 380px; margin: 10vh auto; }
.login .card { padding: 28px; }
.divider { text-align: center; color: var(--muted); margin: 20px 0; font-size: 13px; }
.login-providers { display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Sign in with Apple (schwarz, wie von Apple vorgegeben) */
.apple-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 320px; max-width: 100%; height: 40px; padding: 0 16px;
  background: #000; border: 1px solid #000; border-radius: 4px; color: #fff;
  font-size: 15px; font-weight: 500;
}
.apple-button:hover { background: #222; }
.apple-button svg { width: 15px; height: 18px; margin-top: -2px; }

/* Anmeldemethoden auf der Kontoseite */
.identity-list { display: flex; flex-direction: column; gap: 10px; }
.identity { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.identity .name { font-weight: 600; min-width: 70px; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  main { padding: 16px; }
  .user { display: none; }
}
