/* =========================================================================
   Payback Farmer – Design-System
   Eine Datei für alle Seiten (inkl. Login). Farben als Tokens, Dark Mode
   folgt dem System.
   ========================================================================= */
:root {
  color-scheme: light dark;
  --bg: #f5f4f8;
  --bg-elev: #ffffff;
  --surface: rgba(255, 255, 255, .78);
  --surface-solid: #ffffff;
  --surface-sunken: rgba(22, 16, 41, .045);
  --border: rgba(22, 16, 41, .08);
  --border-strong: rgba(22, 16, 41, .14);
  --text: #15141a;
  --text-2: #5f5b69;
  --text-3: #8e8a98;
  --accent: #6552f0;
  --accent-hover: #5641e6;
  --accent-tint: rgba(101, 82, 240, .10);
  --accent-tint-2: rgba(101, 82, 240, .18);
  --watch: #2f73f0;
  --watch-tint: rgba(47, 115, 240, .10);
  --strong: #b86e00;
  --hot-a: #fb923c;
  --hot-b: #ec4899;
  --hot-tint: rgba(236, 72, 153, .11);
  --hot-text: #be2d7c;
  --ok: #0c8a50;
  --ok-tint: rgba(16, 163, 96, .12);
  --warn: #b45309;
  --warn-tint: rgba(245, 158, 11, .15);
  --bad: #c0163f;
  --bad-tint: rgba(244, 63, 94, .11);
  --shadow-sm: 0 1px 2px rgba(22, 16, 41, .05);
  --shadow: 0 1px 2px rgba(22, 16, 41, .04), 0 6px 20px rgba(22, 16, 41, .05);
  --shadow-lg: 0 2px 6px rgba(22, 16, 41, .06), 0 18px 40px rgba(22, 16, 41, .12);
  --side-bg: #13111a;
  --side-text: rgba(255, 255, 255, .6);
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(139, 124, 255, .2);
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sidebar-w: 240px;
  --tabbar-h: 62px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0f;
    --bg-elev: #15141c;
    --surface: rgba(255, 255, 255, .05);
    --surface-solid: #16151d;
    --surface-sunken: rgba(255, 255, 255, .045);
    --border: rgba(255, 255, 255, .09);
    --border-strong: rgba(255, 255, 255, .16);
    --text: #f4f4f7;
    --text-2: rgba(235, 235, 245, .66);
    --text-3: rgba(235, 235, 245, .42);
    --accent: #a394ff;
    --accent-hover: #b5a9ff;
    --accent-tint: rgba(163, 148, 255, .14);
    --accent-tint-2: rgba(163, 148, 255, .24);
    --watch: #6aa8ff;
    --watch-tint: rgba(106, 168, 255, .14);
    --strong: #ffb547;
    --hot-tint: rgba(236, 72, 153, .16);
    --hot-text: #ff9fcf;
    --ok: #4fe0a2;
    --ok-tint: rgba(52, 211, 153, .14);
    --warn: #fbbf24;
    --warn-tint: rgba(251, 191, 36, .14);
    --bad: #ff8a9e;
    --bad-tint: rgba(251, 113, 133, .15);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 20px 44px rgba(0, 0, 0, .5);
    --side-bg: #0d0c12;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
svg.ic { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
code { font: 12.5px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-sunken); padding: 1px 5px; border-radius: 5px; }

/* ---------------------------------------------------------------------------
   App-Rahmen: Sidebar (Desktop) / Topbar + Tabbar (Handy)
   --------------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 18px 12px 14px;
  background: var(--side-bg); color: var(--side-text);
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; text-decoration: none; }
.brand-mark {
  height: 32px; padding: 0 9px; border-radius: 9px; background: #fff;
  display: flex; align-items: center; box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.brand-mark img { height: 12px; display: block; }
.brand-name { color: #fff; font-weight: 650; font-size: 14.5px; letter-spacing: -.01em; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .32); padding: 14px 12px 6px; }
.navitem {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 10px; text-decoration: none; font-size: 13.5px;
  color: var(--side-text); transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.navitem:hover { background: var(--side-hover); color: #fff; }
.navitem.active { background: var(--side-active); color: #fff; font-weight: 600; }
.navitem.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; width: 3px; height: 18px; transform: translateY(-50%);
  border-radius: 0 3px 3px 0; background: #a78bfa;
}
.badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px; text-align: center;
  font-size: 11px; font-weight: 650; color: #fff; background: linear-gradient(135deg, var(--hot-a), var(--hot-b));
}
.sidebar-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 2px; }
.health {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; text-decoration: none;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06); margin-bottom: 6px;
  transition: background-color 150ms var(--ease);
}
.health:hover { background: rgba(255, 255, 255, .08); }
.health-text { display: flex; flex-direction: column; min-width: 0; font-size: 12px; line-height: 1.35; }
.health-text strong { color: #fff; font-size: 12.5px; font-weight: 600; }
.health-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.ok { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }
.dot.warnung { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .2); }
.dot.fehler { background: #fb7185; box-shadow: 0 0 0 3px rgba(251, 113, 133, .22); }
.dot.laeuft { background: #a78bfa; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(167, 139, 250, .25); } }

.topbar, .tabbar, .sheet { display: none; }
.content { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------------------
   Seitenkopf
   --------------------------------------------------------------------------- */
.page-head {
  max-width: 980px; margin: 0 auto; padding: 30px 24px 6px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.page-icon {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--watch)); color: #fff;
  box-shadow: 0 8px 20px -8px var(--accent);
}
.page-icon svg.ic { width: 20px; height: 20px; }
.page-title { flex: 1; min-width: 200px; }
.page-title h1 { margin: 0; font-size: 25px; line-height: 1.2; font-weight: 700; letter-spacing: -.022em; }
.page-title p { margin: 3px 0 0; font-size: 13px; color: var(--text-3); }
.page-actions { display: flex; gap: 8px; align-items: center; }
main { max-width: 980px; margin: 0 auto; padding: 18px 24px 64px; }

/* ---------------------------------------------------------------------------
   Bausteine
   --------------------------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.panel-pad { padding: 18px; }
.stack > * + * { margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-solid); color: var(--text); font-size: 13.5px; font-weight: 550;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), transform 100ms ease-out, opacity 150ms;
}
.btn:hover { border-color: var(--text-3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-soft { background: var(--accent-tint); border-color: transparent; color: var(--accent); }
.btn-soft:hover { background: var(--accent-tint-2); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-sunken); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 6px; border-radius: 8px; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  border: 1.6px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite;
}
.btn.is-error { background: var(--bad-tint); color: var(--bad); border-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 550; line-height: 1.6; white-space: nowrap;
  background: var(--surface-sunken); color: var(--text-2);
}
.chip svg.ic { width: 12px; height: 12px; stroke-width: 2.2; }
.chip-ok { background: var(--ok-tint); color: var(--ok); }
.chip-warn { background: var(--warn-tint); color: var(--warn); }
.chip-bad { background: var(--bad-tint); color: var(--bad); }
.chip-hot { background: var(--hot-tint); color: var(--hot-text); }
.chip-watch { background: var(--watch-tint); color: var(--watch); }
.chip-accent { background: var(--accent-tint); color: var(--accent); }

input[type=text], input[type=search], input[type=number], input[type=password], select {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface-solid); font-size: 14px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
label.field small { font-weight: 400; color: var(--text-3); }

/* Erklärtexte: eingeklappt, damit die Seite aufgeräumt bleibt */
details.info {
  margin-bottom: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); font-size: 13.5px; color: var(--text-2);
}
details.info summary {
  list-style: none; cursor: pointer; padding: 10px 14px; display: flex; align-items: center; gap: 8px;
  font-weight: 550; color: var(--text-2); user-select: none;
}
details.info summary::-webkit-details-marker { display: none; }
details.info summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border: solid var(--text-3); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); transition: transform 200ms var(--ease); }
details.info[open] summary::after { transform: rotate(-135deg); }
details.info summary svg.ic { color: var(--accent); width: 16px; height: 16px; }
details.info .info-body { padding: 0 14px 14px 38px; line-height: 1.6; }
details.info .info-body p { margin: 0 0 8px; }
details.info .info-body p:last-child { margin: 0; }

.section-head { display: flex; align-items: baseline; gap: 10px; margin: 28px 2px 10px; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.section-head .count { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.section-head .spacer { flex: 1; }
details.section > summary { list-style: none; cursor: pointer; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary .section-head { margin-bottom: 10px; }
details.section > summary h2::after {
  content: ""; display: inline-block; margin-left: 8px; width: 6px; height: 6px; vertical-align: 3px;
  border: solid var(--text-3); border-width: 0 1.6px 1.6px 0; transform: rotate(-45deg); transition: transform 200ms var(--ease);
}
details.section[open] > summary h2::after { transform: rotate(45deg); vertical-align: 5px; }

.empty {
  text-align: center; padding: 34px 20px; color: var(--text-3); font-size: 14px;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
}
.empty strong { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 3px; }

/* ---------------------------------------------------------------------------
   KPI-Kacheln
   --------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 15px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  text-decoration: none; cursor: pointer; transition: transform 150ms var(--ease), box-shadow 150ms var(--ease), border-color 150ms;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.kpi-label { font-size: 12px; font-weight: 550; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.kpi-label svg.ic { width: 14px; height: 14px; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-value small { font-size: 14px; font-weight: 550; color: var(--text-3); }
.kpi-sub { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi .bar { height: 4px; border-radius: 99px; background: var(--surface-sunken); margin-top: 7px; overflow: hidden; }
.kpi .bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--watch), var(--accent)); }
.kpi.is-good .kpi-value { color: var(--ok); }
.kpi.is-alert .kpi-value { color: var(--hot-text); }

/* Schnellzugriff "Deine Läden" */
.shops { display: flex; gap: 8px; margin: 0 0 16px; padding-bottom: 2px; }
.shop {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-size: 13px; font-weight: 600;
  transition: border-color 150ms var(--ease), transform 150ms var(--ease);
}
.shop:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.shop-max { color: var(--accent); font-variant-numeric: tabular-nums; }
.logo.logo-sm { width: 28px; height: 28px; border-radius: 50%; font-size: 10.5px; }
.logo.logo-sm img { padding: 2px; }
.logo.logo-lg { width: 64px; height: 64px; border-radius: 16px; font-size: 20px; }
a.partner, .stat-partner a { text-decoration: none; }
a.partner:hover, .stat-partner a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Laden-Auswahl */
.store-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.store-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; min-height: 124px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  text-decoration: none; transition: transform 150ms var(--ease), border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.store-tile:hover { transform: translateY(-1px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.store-tile:active { transform: scale(.98); }
.store-tile .logo { width: 56px; height: 40px; border-radius: 10px; }
.store-name { font-weight: 650; font-size: 14.5px; line-height: 1.25; }
.store-meta { font-size: 12px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: auto; }
.store-meta b { color: var(--accent); }
.shops .shop:last-child { padding-left: 12px; color: var(--text-2); }

/* Kompakte Karte (Partner-Seite): ohne Logo/Partnername, eine Zeile Wert + Text */
.card.is-compact { padding: 10px 12px 10px 14px; gap: 12px; }
.card.is-compact .card-text, .card.is-compact.is-active .card-text { color: var(--text); font-weight: 550; -webkit-line-clamp: 2; margin: 0; }
.card.is-compact .card-meta { margin-top: 5px; }
.card.is-compact .card-meta:empty { display: none; }
.done { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; background: var(--ok-tint); color: var(--ok); }
.done svg.ic { width: 15px; height: 15px; stroke-width: 2.4; }
.card.is-compact .card-side { flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
.card.is-compact .value-main { font-size: 21px; }
.cards:has(.is-compact) { gap: 6px; }
.partner-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.partner-hero > div { display: flex; flex-wrap: wrap; gap: 6px; }

/* Partner-Seite */
.offer { padding: 16px; }
.offer + .offer { margin-top: 10px; }
.offer-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.offer-head h3 { margin: 0; font-size: 14.5px; font-weight: 620; flex: 1; min-width: 200px; }
.offer-now { font-size: 20px; font-weight: 750; color: var(--accent); font-variant-numeric: tabular-nums; }
.offer-facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }
.forecast { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--accent-tint); color: var(--text); font-size: 13px; }
.forecast svg.ic { color: var(--accent); width: 16px; height: 16px; margin-top: 1px; }

/* Einkaufsrechner (Partner-Seite) */
.rechner { margin: 12px 0 4px; }
.rechner-zeile { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.rechner-betrag { flex: 0 0 130px; }
.rechner .grow { flex: 1 1 200px; min-width: 0; }
.euro-input { position: relative; display: block; }
.euro-input input { padding-right: 30px; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.euro-input span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-weight: 600; }
.rechner-ergebnis { margin-top: 12px; font-size: 14px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.rechner-ergebnis .gross { font-size: 26px; font-weight: 750; letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.rechner-ergebnis .hinweis { width: 100%; font-size: 12.5px; }
.miles.is-bonus { border-color: color-mix(in srgb, var(--hot-a) 50%, var(--border)); background: linear-gradient(90deg, rgba(251, 146, 60, .08), transparent 70%), var(--surface); }

/* Punkte */
.big-number { font-size: 40px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-number small { font-size: 18px; color: var(--text-3); font-weight: 600; }
.month-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.month-table td, .month-table th { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; font-variant-numeric: tabular-nums; }
.month-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; }
.month-table td:first-child, .month-table th:first-child { text-align: left; }
.month-table tr:last-child td { border-bottom: 0; }
.plus { color: var(--ok); }
.minus { color: var(--bad); }

/* ---------------------------------------------------------------------------
   Filterleiste
   --------------------------------------------------------------------------- */
.filterbar {
  position: sticky; top: 10px; z-index: 20; margin-bottom: 18px; padding: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.search { position: relative; flex: 1 1 200px; min-width: 160px; }
.search.wide { flex-basis: 320px; }
.search svg.ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search input { padding-left: 34px; padding-right: 58px; }
.search input::-webkit-search-cancel-button { display: none; }
.search .kbd, .search .clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.kbd { font: 11px ui-monospace, Consolas, monospace; color: var(--text-3); border: 1px solid var(--border-strong); border-radius: 5px; padding: 1px 6px; }
.search .clear { border: 0; background: var(--surface-sunken); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; display: none; color: var(--text-2); line-height: 1; }
.search.has-value .clear { display: block; }
.search.has-value .kbd { display: none; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-strong); background: transparent; font-size: 13px; font-weight: 550; color: var(--text-2);
  transition: all 150ms var(--ease); user-select: none; white-space: nowrap;
}
.toggle:hover { color: var(--text); border-color: var(--text-3); }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: transparent; color: #fff; }
.toggle svg.ic { width: 14px; height: 14px; }
.filterbar select { width: auto; padding: 7px 30px 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 550; color: var(--text-2); }
.filter-row { display: contents; }
.filter-count { font-size: 12.5px; color: var(--text-3); margin-left: auto; padding: 0 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }

.segmented { position: relative; display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--surface-sunken); }
.seg-btn {
  position: relative; z-index: 1; border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--text-2); transition: color 150ms var(--ease);
}
.seg-btn[aria-pressed="true"] { color: var(--text); }
.seg-btn .n { color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.seg-thumb {
  position: absolute; top: 3px; left: 0; height: calc(100% - 6px); border-radius: 8px;
  background: var(--surface-solid); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px var(--border);
  transition: transform 260ms var(--ease), width 260ms var(--ease);
}
.scroll-x { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.scroll-x::-webkit-scrollbar { display: none; }
.is-hidden { display: none !important; }

/* ---------------------------------------------------------------------------
   Coupon-Karte
   --------------------------------------------------------------------------- */
.cards { display: flex; flex-direction: column; gap: 8px; }
.card {
  position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 14px 12px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform 150ms var(--ease), box-shadow 150ms var(--ease), border-color 150ms var(--ease);
}
.card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.card.is-watch::before, .card.is-hot::before, .card.is-prio::before {
  content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0; background: var(--watch);
}
.card.is-hot::before { background: linear-gradient(var(--hot-a), var(--hot-b)); }
.card.is-prio::before { background: linear-gradient(var(--hot-a), var(--hot-b)); width: 4px; }
.card.is-active .card-text { color: var(--text-3); }

.logo {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 12px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: hsl(var(--h) 55% 92%); color: hsl(var(--h) 45% 32%);
  font-size: 15px; font-weight: 700; letter-spacing: -.02em;
  box-shadow: inset 0 0 0 1px var(--border);
}
@media (prefers-color-scheme: dark) { .logo { background: hsl(var(--h) 30% 22%); color: hsl(var(--h) 70% 82%); } }
.logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 4px 2px; background: #fff; }

.card-body { flex: 1; min-width: 0; }
.card-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.partner { font-weight: 620; font-size: 14.5px; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { color: var(--watch); flex: none; display: inline-flex; }
.star svg.ic { width: 14px; height: 14px; fill: currentColor; }
.card-text { font-size: 13.5px; color: var(--text-2); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }

.card-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 7px; min-width: 74px; }
.value { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.value-pre { font-size: 10.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.value-main { font-size: 23px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--accent); display: flex; align-items: center; gap: 3px; }
.value-main small { font-size: 15px; font-weight: 650; opacity: .8; }
.value-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.card.is-strong .value-main { color: var(--strong); }
.trend { display: inline-flex; width: 16px; height: 16px; }
.trend svg { width: 11px; height: 11px; margin: auto; stroke: currentColor; }
.trend.top { color: var(--ok); }
.trend.mid { color: var(--text-3); }
.trend.flop { color: var(--bad); }

/* ---------------------------------------------------------------------------
   Statistik-Tabelle
   --------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
table.stat { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.stat th, table.stat td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.stat th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-solid);
  font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); white-space: nowrap;
}
table.stat th[data-sort] { cursor: pointer; user-select: none; }
table.stat th[data-sort]:hover { color: var(--text); }
table.stat th.sort-asc::after { content: " ↑"; }
table.stat th.sort-desc::after { content: " ↓"; }
table.stat .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.stat tbody tr.row { cursor: pointer; transition: background-color 120ms var(--ease); }
table.stat tbody tr.row:hover { background: var(--surface-sunken); }
table.stat tbody tr.row td:first-child { box-shadow: inset 3px 0 0 transparent; }
table.stat tr.r-top td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
table.stat tr.r-flop td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.stat tr.r-gone { opacity: .55; }
table.stat tr.r-prio { background: linear-gradient(90deg, rgba(251, 146, 60, .14), rgba(236, 72, 153, .07)); }
table.stat tr.r-prio td:first-child { box-shadow: inset 4px 0 0 var(--hot-a); }
table.stat tr.row.is-open { background: var(--surface-sunken); }
table.stat tr.detail td { background: var(--surface-sunken); padding: 4px 16px 18px; }
table.stat tr:last-child td { border-bottom: 0; }
.stat-partner { font-weight: 620; }
.stat-sub { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rating-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.rating-pill svg { width: 10px; height: 10px; stroke: currentColor; }
.rating-pill.top { color: var(--ok); }
.rating-pill.mid { color: var(--text-3); }
.rating-pill.flop { color: var(--bad); }
.rating-pill.gone { color: var(--text-3); }
.range { position: relative; width: 90px; height: 6px; border-radius: 99px; background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--border); }
.range .fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--watch), var(--accent)); }
.range .mean { position: absolute; top: -3px; width: 2px; height: 12px; margin-left: -1px; border-radius: 1px; background: var(--text-3); }
.range .now { position: absolute; top: -3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--surface-solid); border: 2.5px solid var(--accent); }
.range-cell { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.mini-btn { border: 0; background: var(--accent-tint); color: var(--accent); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.mini-btn:hover { background: var(--accent-tint-2); }
.mini-btn.is-on { background: var(--ok-tint); color: var(--ok); }

.chart { width: 100%; height: auto; max-height: 190px; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-3); font-size: 10.5px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.chart .area { fill: var(--accent-tint); }
.chart .pt { fill: var(--surface-solid); stroke: var(--accent); stroke-width: 2; }
.chart .pt-label { fill: var(--text-2); font-size: 10.5px; font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: 1fr 200px; gap: 18px; align-items: center; }
.detail-facts { font-size: 12.5px; color: var(--text-2); display: grid; gap: 5px; }
.detail-facts b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------------
   Watchlist & Alarme
   --------------------------------------------------------------------------- */
.term-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.term {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 6px; border-radius: 999px;
  background: var(--watch-tint); color: var(--watch); font-size: 13.5px; font-weight: 550;
  transition: box-shadow 150ms var(--ease);
}
.term .handle { cursor: grab; touch-action: none; opacity: .5; padding: 0 2px 0 4px; font-size: 14px; line-height: 1; }
.term .handle:hover { opacity: .9; }
.term .n { font-size: 11.5px; font-weight: 650; background: color-mix(in srgb, currentColor 14%, transparent); padding: 0 7px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.term .n.zero { opacity: .55; }
.term form { display: inline; margin: 0; }
.term button { border: 0; width: 20px; height: 20px; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; opacity: .6; font-size: 15px; line-height: 1; }
.term button:hover { opacity: 1; background: color-mix(in srgb, currentColor 16%, transparent); }
.term.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); position: relative; z-index: 5; }
.term .rank { font-size: 10.5px; font-weight: 700; opacity: .5; font-variant-numeric: tabular-nums; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .grow { flex: 1 1 220px; }
.preview { margin-top: 10px; font-size: 12.5px; color: var(--text-2); min-height: 20px; }
.preview ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.preview li { display: flex; gap: 8px; align-items: baseline; }
.preview li b { min-width: 34px; text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.preview li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rules { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.rule {
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-solid);
}
.rule.is-live { border-color: color-mix(in srgb, var(--hot-a) 50%, var(--border)); background: linear-gradient(90deg, rgba(251, 146, 60, .08), transparent 60%), var(--surface-solid); }
.rule-icon { font-size: 18px; flex: none; }
.rule-body { flex: 1; min-width: 0; }
.rule-name { font-weight: 620; }
.rule-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.rule-hits { font-size: 12px; color: var(--text-2); margin-top: 5px; }
.rule-actions { display: flex; gap: 4px; flex: none; }
.rule-form { display: grid; grid-template-columns: 2fr 1fr 2fr auto; gap: 10px; align-items: end; }
.rule-form.is-editing { padding: 12px; margin: -12px; border-radius: 12px; background: var(--accent-tint); }

/* ---------------------------------------------------------------------------
   System
   --------------------------------------------------------------------------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.fact { padding: 14px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border); }
.fact-label { font-size: 12px; color: var(--text-3); font-weight: 550; }
.fact-value { font-size: 16px; font-weight: 650; margin-top: 3px; display: flex; align-items: center; gap: 8px; }
.fact-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.log {
  margin: 0; padding: 12px 14px; border-radius: 12px; max-height: 320px; overflow: auto;
  background: #0f0e14; color: #d6d3e0; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.log:empty::before { content: "Noch keine Ausgabe."; color: #77738a; }
.status-big { display: flex; align-items: center; gap: 14px; }
.status-big .dot { width: 14px; height: 14px; }
.status-big h3 { margin: 0; font-size: 17px; }
.status-big p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }

/* ---------------------------------------------------------------------------
   Prioritäts-Banner & Toasts
   --------------------------------------------------------------------------- */
.prio-banner {
  max-width: 932px; margin: 16px auto 0; padding: 11px 12px 11px 16px; border-radius: 14px;
  display: flex; align-items: center; gap: 12px; color: #fff;
  background: linear-gradient(120deg, var(--hot-a), var(--hot-b)); box-shadow: 0 10px 28px -10px rgba(236, 72, 153, .6);
}
.prio-banner-icon { font-size: 20px; flex: none; }
.prio-banner-text { flex: 1; min-width: 0; font-size: 13.5px; line-height: 1.4; }
.prio-banner-text b { font-weight: 700; }
.prio-banner a { flex: none; color: #fff; text-decoration: none; font-weight: 650; font-size: 12.5px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .22); white-space: nowrap; }
.prio-banner a:hover { background: rgba(255, 255, 255, .32); }

.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; max-width: 360px; padding: 12px 12px 12px 14px;
  border-radius: 13px; background: #1b1924; color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; line-height: 1.4;
  transform: translateY(12px); opacity: 0; transition: transform 240ms var(--ease), opacity 240ms var(--ease);
}
.toast.show { transform: none; opacity: 1; }
.toast-icon { font-size: 17px; line-height: 1.2; flex: none; }
.toast-body { flex: 1; }
.toast-body strong { display: block; font-size: 14px; }
.toast-body span { color: rgba(255, 255, 255, .72); }
.toast-body a { color: #fff; font-weight: 600; }
.toast.ok .toast-icon { color: #4fe0a2; }
.toast.fehler .toast-icon { color: #ff8a9e; }
.toast.info .toast-icon { color: #b5a9ff; }
.toast-close { border: 0; background: rgba(255, 255, 255, .12); color: #fff; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; flex: none; line-height: 1; }

/* ---------------------------------------------------------------------------
   Login
   --------------------------------------------------------------------------- */
.login-body { display: flex; align-items: center; justify-content: center; padding: 20px; overflow: hidden; }
.login-glow { position: fixed; top: -25%; left: 50%; transform: translateX(-50%); width: 70vw; height: 70vw; max-width: 700px; max-height: 700px; pointer-events: none; background: radial-gradient(circle, rgba(139, 124, 255, .2), transparent 68%); }
.login-card { position: relative; width: 100%; max-width: 340px; padding: 32px 26px 26px; text-align: center; }
.login-card .brand-mark { display: inline-flex; height: 44px; padding: 0 12px; margin-bottom: 18px; }
.login-card .brand-mark img { height: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.015em; }
.login-card p { margin: 0 0 22px; font-size: 13px; color: var(--text-2); }
.login-card input { font-size: 22px; letter-spacing: .35em; text-align: center; padding: 12px; }
.login-card .btn { width: 100%; margin-top: 12px; padding: 11px; font-size: 14.5px; }
.login-error { margin-top: 12px; padding: 9px 12px; border-radius: 10px; background: var(--bad-tint); color: var(--bad); font-size: 13px; }

/* ---------------------------------------------------------------------------
   Handy / Tablet
   --------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .topbar .brand-name { color: var(--text); }
  .topbar .health-pill {
    margin-left: auto; display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 9px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 550; color: var(--text-2); text-decoration: none;
    max-width: 55vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg-elev) 86%, transparent);
    backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
    border-top: 1px solid var(--border);
  }
  .tab {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 10.5px; font-weight: 550; color: var(--text-3); text-decoration: none; border: 0; background: none; cursor: pointer;
  }
  .tab svg.ic { width: 22px; height: 22px; }
  .tab.active { color: var(--accent); }
  .tab .badge { position: absolute; top: 6px; left: calc(50% + 6px); margin: 0; font-size: 10px; padding: 0 5px; min-width: 16px; }
  .sheet {
    display: block; position: fixed; inset: 0; z-index: 120; pointer-events: none;
  }
  .sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); opacity: 0; transition: opacity 220ms var(--ease); }
  .sheet-panel {
    position: absolute; left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
    padding: 8px; border-radius: 18px; background: var(--bg-elev); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
    transform: translateY(16px); opacity: 0; transition: transform 240ms var(--ease), opacity 240ms var(--ease);
  }
  .sheet.open { pointer-events: auto; }
  .sheet.open .sheet-backdrop { opacity: 1; }
  .sheet.open .sheet-panel { transform: none; opacity: 1; }
  .sheet-item { display: flex; align-items: center; gap: 12px; padding: 13px 12px; border-radius: 12px; text-decoration: none; font-weight: 550; }
  .sheet-item:hover, .sheet-item.active { background: var(--surface-sunken); }
  .sheet-item .badge { margin-left: auto; }
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .page-head { padding: 20px 16px 2px; }
  .page-title h1 { font-size: 22px; }
  main { padding: 14px 16px 40px; }
  .prio-banner { margin: 12px 16px 0; }
  .filterbar { top: 62px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpis .kpi:last-child:nth-child(odd) { grid-column: span 2; }
  .toasts { left: 12px; right: 12px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); align-items: stretch; }
  .toast { max-width: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .rule-form { grid-template-columns: 1fr 1fr; }
  .rule-form .span-2 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .page-icon { display: none; }
  .card { gap: 11px; padding: 11px 12px 11px 11px; align-items: flex-start; }
  .logo { width: 40px; height: 40px; border-radius: 10px; font-size: 13px; }
  .card-side { min-width: 0; }
  .value-main { font-size: 20px; }
  /* Am Handy nicht sticky: Topbar + Tabbar kosten schon Platz, eine
     klebende Filterleiste wuerde den halben Bildschirm fuellen. Die
     Bedienelemente laufen in EINER horizontal wischbaren Zeile. */
  .filterbar { position: static; padding: 8px; flex-wrap: nowrap; flex-direction: column; align-items: stretch; }
  .filterbar .search { flex: none; }
  .filter-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px; }
  .filter-row::-webkit-scrollbar { display: none; }
  .filter-row .toggles { flex-wrap: nowrap; }
  .filter-count { margin: 0; text-align: right; font-size: 12px; }
  .search .kbd { display: none; }
  .kpi-value { font-size: 21px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  table.stat .hide-sm { display: none; }
}

/* ---------------------------------------------------------------------------
   Barrierefreiheit
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .panel, .filterbar, .topbar, .tabbar, .card { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface-solid); }
}
@media (prefers-contrast: more) {
  :root { --border: currentColor; --text-3: var(--text-2); }
}
