/* ==== Design-Tokens (aus dem Handoff) ==== */
:root {
  --bg: oklch(96% 0.004 250);
  --card: #ffffff;
  --card-2: oklch(98% 0.003 250);
  --border: oklch(90% 0.006 250);
  --sidebar: oklch(20% 0.012 255);
  --sidebar-active: oklch(30% 0.02 255);
  --sidebar-border: oklch(32% 0.01 255);
  --text: oklch(22% 0.012 250);
  --muted: oklch(50% 0.01 250);
  --nav-inactive: oklch(75% 0.01 255);
  --nav-dot: oklch(50% 0.01 255);
  --accent: oklch(55% 0.14 260);
  --accent-hover: oklch(49% 0.14 260);
  --danger: oklch(52% 0.15 25);
  --track: oklch(94% 0.004 250);
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 26px; font-weight: 700; margin: 0; color: var(--text); }
h2 { font-size: 15px; font-weight: 600; margin: 0; }
.subtitle { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.muted { color: var(--muted); }
a { color: var(--accent); }

/* ==== App-Layout: Sidebar + Hauptbereich ==== */
.layout {
  display: flex;
  min-height: calc(100vh - 24px);
  margin: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px oklch(0% 0 0 / 0.06);
  background: var(--card-2);
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 0 4px; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); display: inline-block; }
.brand-name { font-size: 15px; font-weight: 600; color: #fff; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  font-size: 13.5px; font-weight: 500;
  color: var(--nav-inactive); text-decoration: none;
}
.nav-item:hover { background: oklch(26% 0.015 255); color: #fff; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--nav-dot); flex-shrink: 0; }
.nav-item.active { color: #fff; background: var(--sidebar-active); }
.nav-item.active .dot { background: var(--accent); }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--sidebar-border); display: flex; flex-direction: column; gap: 10px; }
.sidebar-footer .email { font-size: 12px; color: oklch(70% 0.01 255); word-break: break-all; }
.sidebar-actions { display: flex; gap: 8px; }

.main { flex: 1; padding: 32px 40px; overflow: auto; display: flex; flex-direction: column; gap: 24px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }

/* ==== Buttons ==== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600; font-size: 13.5px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-danger-outline { background: #fff; color: var(--danger); border-color: oklch(85% 0.06 25); }
.btn-danger-outline:hover { background: oklch(96% 0.02 25); }
.btn-dark { background: var(--sidebar-active); color: #fff; }
.btn-dark:hover { background: oklch(35% 0.02 255); }
.btn-outline-light { background: transparent; color: var(--nav-inactive); border-color: oklch(40% 0.02 255); }
.btn-outline-light:hover { background: oklch(26% 0.015 255); color: #fff; }
.btn-block { width: 100%; }
.btn-tiny { padding: 6px 11px; font-size: 12.5px; border-radius: 6px; }
.sidebar-actions .btn { flex: 1; }
.inline { display: inline; margin: 0; }

/* ==== Karten ==== */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; box-shadow: 0 1px 3px oklch(0% 0 0 / 0.04); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

/* ==== Statistik-/Wert-Karten ==== */
.stat-row { display: flex; gap: 16px; }
.stat-card { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: 0 1px 3px oklch(0% 0 0 / 0.04); }
.stat-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-value { font-family: var(--mono); font-size: 28px; font-weight: 600; margin-top: 8px; letter-spacing: -0.01em; }

/* ==== Übersicht: zwei Spalten (Torte + Liste) ==== */
.two-col { display: grid; grid-template-columns: 1fr 2fr; gap: 24px; align-items: start; }
.pie-card { display: flex; align-items: center; gap: 24px; }
.pie { width: 150px; height: 150px; border-radius: 50%; flex-shrink: 0; }
.pie-legend { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.legend-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.legend-row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; }
.legend-pct { font-family: var(--mono); color: var(--muted); }

/* ==== Abo-Liste ==== */
.list-card { padding: 8px 22px; }
.abo-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.abo-row:last-child { border-bottom: none; }
.avatar { width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0; color: #fff; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; }
.abo-main { flex: 1; min-width: 0; }
.abo-name { font-size: 14px; font-weight: 600; }
.abo-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.abo-price { font-family: var(--mono); font-size: 14px; font-weight: 600; text-align: right; }
.abo-cycle { font-size: 12.5px; color: var(--muted); width: 92px; text-align: right; }
.abo-actions { display: flex; gap: 8px; }
.empty { padding: 18px 0; }

/* ==== Meine Abos: Suche + Filter ==== */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; }
.pill:hover { background: var(--bg); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ==== Statistik-Balken ==== */
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; align-items: center; gap: 16px; padding: 10px 0; }
.bar-label { font-size: 13.5px; }
.bar-track { height: 14px; background: var(--track); border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.bar-value { font-family: var(--mono); font-size: 13.5px; font-weight: 600; text-align: right; }

/* ==== Einstellungen ==== */
.settings-wrap { max-width: 520px; display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle-row:first-child { padding-top: 4px; }
.toggle-row:last-child { border-bottom: none; padding-bottom: 4px; }
.toggle-title { font-size: 14px; font-weight: 600; }
.toggle-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.toggle { position: relative; width: 42px; height: 24px; border-radius: 999px; border: none; background: oklch(85% 0.01 255); cursor: pointer; flex-shrink: 0; transition: background .15s; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--accent); }
.toggle.on .knob { left: 21px; }

/* ==== Formulare / Inputs ==== */
.stack { display: flex; flex-direction: column; gap: 14px; }
label { font-size: 13px; font-weight: 600; color: var(--text); }
.stack > label { display: flex; flex-direction: column; gap: 6px; }
input, select { font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-weight: 400; width: 100%; }
input:focus, select:focus, .search:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[readonly] { background: var(--bg); color: var(--muted); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 4px; }

/* ==== Alerts ==== */
.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; }
.alert-error { background: oklch(96% 0.03 25); color: var(--danger); border: 1px solid oklch(85% 0.06 25); }
.alert-info { background: oklch(96% 0.03 260); color: var(--accent-hover); border: 1px solid oklch(88% 0.05 260); }

/* ==== Badges (Nutzerverwaltung) ==== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-on { background: oklch(93% 0.05 150); color: oklch(45% 0.12 150); }
.badge-off { background: var(--track); color: var(--muted); }

/* ==== Modal (Abo anlegen/bearbeiten) ==== */
.modal-overlay { position: fixed; inset: 0; background: oklch(20% 0.02 255 / 0.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal-overlay.open { display: flex; }
.modal { width: 460px; max-width: 100%; background: #fff; border-radius: 12px; padding: 24px; box-shadow: 0 20px 50px oklch(0% 0 0 / 0.25); }
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ==== Login (eigenes, schlichtes Layout) ==== */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 380px; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 32px; box-shadow: 0 1px 3px oklch(0% 0 0 / 0.06); }
.login-card .brand { justify-content: center; margin-bottom: 20px; }
.brand-name-dark { font-size: 16px; font-weight: 600; color: var(--text); }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 20px; }

/* ==== Standalone (Fehlerseite) ==== */
.standalone { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; }
.standalone .card { max-width: 420px; }

/* ==== Responsive ==== */
@media (max-width: 820px) {
  .layout { flex-direction: column; margin: 0; border-radius: 0; border: none; min-height: 100vh; }
  .sidebar { width: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; }
  .brand { margin-bottom: 0; margin-right: 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .sidebar-footer { margin-top: 0; border-top: none; padding-top: 0; flex-direction: row; align-items: center; width: 100%; }
  .sidebar-footer .email { flex: 1; }
  .main { padding: 20px 16px; }
  .two-col { grid-template-columns: 1fr; }
  .stat-row { flex-direction: column; }
  .pie-card { flex-direction: column; align-items: flex-start; }
  .bar-row { grid-template-columns: 110px 1fr auto; gap: 10px; }
  .abo-cycle { display: none; }
}
