/* PB – Design-System. Dunkel zuerst, hell optional (data-theme="light"). */

:root {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --surface-3: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #f26b3a;
  --accent-2: #ff8a5c;
  --accent-ink: #1a0f0a;
  --accent-soft: rgba(242, 107, 58, 0.14);
  --good: #0ca30c;
  --good-soft: rgba(12, 163, 12, 0.16);
  --bad: #e66767;
  --bad-soft: rgba(230, 103, 103, 0.16);
  --warn: #fab219;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #008300;
  --s7: #9085e9;
  --s8: #e66767;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --radius-s: 12px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --surface-3: #e6e5e0;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.20);
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #e4572a;
  --accent-2: #f26b3a;
  --accent-ink: #ffffff;
  --accent-soft: rgba(228, 87, 42, 0.12);
  --good: #006300;
  --good-soft: rgba(0, 99, 0, 0.12);
  --bad: #d03b3b;
  --bad-soft: rgba(208, 59, 59, 0.12);
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0; }
svg { display: block; }
.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }
.num-good { color: var(--good); font-weight: 600; }
.num-bad { color: var(--bad); font-weight: 600; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Layout */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__title { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.topbar__logo { width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 800; border: 1px solid var(--border); }
.topbar__logo i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); transform: translate(10px, -9px); }
.topbar__actions { display: flex; gap: 6px; align-items: center; }
.main { max-width: 820px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--nav-h); color: var(--ink-3); font-size: 11px; font-weight: 600; background: none; border: 0; cursor: pointer;
}
.nav__item svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav__item--active { color: var(--ink); }
.nav__item--primary .nav__fab {
  width: 50px; height: 50px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; transform: translateY(-14px); box-shadow: 0 8px 24px rgba(242, 107, 58, 0.35);
}
.nav__item--primary .nav__fab svg { width: 26px; height: 26px; stroke: var(--accent-ink); stroke-width: 2.4; }
.nav__item--primary span { transform: translateY(-10px); color: var(--ink); }

/* Karten und Abschnitte */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card--flat { background: transparent; border-style: dashed; }
.card--accent { background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--surface)), var(--surface) 70%); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.card--hero { background: linear-gradient(160deg, #1f1f1e, #111 60%); border-color: var(--border-strong); }
:root[data-theme="light"] .card--hero { background: linear-gradient(160deg, #ffffff, #f3f2ee 60%); }
.card__title { font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card__title .badge { text-transform: none; letter-spacing: 0; font-weight: 600; }
.card__title .btn { text-transform: none; letter-spacing: 0; }
.kicker { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.1em; }
.section { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section h2 { font-size: 18px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.page-head { margin: 4px 0 16px; }
.page-head h1 { font-size: 26px; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }

/* Stat-Kacheln und Hero */
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 12px 14px; min-width: 0; }
.stat__label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.stat__value { font-size: 26px; font-weight: 700; line-height: 1.15; margin-top: 2px; letter-spacing: -0.02em; }
.stat__value small { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-left: 3px; }
.stat__sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.stat__delta { font-size: 13px; font-weight: 700; margin-top: 2px; }
.stat__delta--up { color: var(--good); }
.stat__delta--down { color: var(--bad); }
.hero { display: flex; flex-direction: column; gap: 2px; }
.hero__value { font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.hero__label { font-size: 13px; color: var(--ink-2); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink); font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; min-height: 42px; transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--outline { background: transparent; }
.btn--danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn--small { padding: 6px 12px; min-height: 32px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--icon { padding: 8px; width: 38px; height: 38px; min-height: 38px; border-radius: 50%; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field__label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field__hint { font-size: 12px; color: var(--ink-3); }
.field__error { font-size: 13px; color: var(--bad); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-s); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--ink); min-height: 46px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input--error { border-color: var(--bad); }
.input--time { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 600; letter-spacing: 0.02em; }
.select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--accent); }
.range { width: 100%; accent-color: var(--accent); }
.entry-row { display: grid; grid-template-columns: 1fr 128px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.entry-row .input { min-height: 46px; }

/* Listen */
.list { display: flex; flex-direction: column; }
.list__item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list__item:last-child { border-bottom: 0; }
.list__item--link { cursor: pointer; }
.list__item--link:hover .list__title { color: var(--accent-2); }
.list__main { flex: 1; min-width: 0; }
.list__title { font-weight: 600; }
.list__sub { font-size: 13px; color: var(--ink-2); margin-top: 1px; }
.list__aside { text-align: right; font-variant-numeric: tabular-nums; }
.list__aside .big { font-size: 18px; font-weight: 700; }
.rank { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none; }
.rank--1 { background: var(--accent); color: var(--accent-ink); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; color: #fff; }
.avatar--small { width: 30px; height: 30px; font-size: 12px; }

/* Badges, Chips, Punkte */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.badge--good { background: var(--good-soft); color: var(--good); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--accent { background: var(--accent-soft); color: var(--accent-2); }
.badge--muted { background: transparent; border: 1px solid var(--border); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 8px 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; font-weight: 600; cursor: pointer; }
.chip--active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--surface-3); }
.dot--on { background: var(--accent); }
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; max-width: 100%; overflow: auto; }
.segmented__btn { border: 0; background: transparent; color: var(--ink-2); padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.segmented__btn--active { background: var(--ink); color: var(--bg); }
.meter { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter__fill { height: 100%; background: var(--s1); border-radius: 999px; }
.typebar { position: relative; height: 10px; border-radius: 999px; background: linear-gradient(90deg, var(--s1), var(--surface-3) 50%, var(--s2)); margin: 10px 0 6px; }
.typebar__marker { position: absolute; top: -5px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); border: 3px solid var(--bg); transform: translateX(-50%); }
.typebar__labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }

/* Tabellen */
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 8px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; }
.table th { color: var(--ink-3); font-weight: 600; font-size: 12px; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--surface); }
.table th.sorted { color: var(--ink); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table--compact th, .table--compact td { padding: 6px 6px; font-size: 12px; }
.table .actions { padding-right: 0; }
.table .actions .btn--icon { width: 34px; height: 34px; min-height: 34px; }
@media (max-width: 520px) { .hide-sm { display: none !important; } .table th, .table td { padding: 8px 5px; } }

/* Diagramme */
.chart { position: relative; margin-top: 8px; }
.chart__svg { width: 100%; height: auto; overflow: visible; }
.chart__svg text { font-family: var(--font); font-size: 11px; fill: var(--ink-3); }
.chart__svg .grid line { stroke: var(--grid); stroke-width: 1; }
.chart__svg .axis line { stroke: var(--axis); stroke-width: 1; }
.chart__svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__svg .area { opacity: 0.10; }
.chart__svg .marker { stroke: var(--surface); stroke-width: 2; }
.chart__svg .bar { rx: 4; }
.chart__svg .hit { fill: transparent; cursor: pointer; }
.chart__svg .crosshair { stroke: var(--ink-3); stroke-width: 1; opacity: 0; }
.chart__svg .label { fill: var(--ink-2); font-weight: 600; }
.chart__tooltip {
  position: absolute; pointer-events: none; z-index: 5; display: none;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 10px;
  font-size: 12px; box-shadow: var(--shadow); min-width: 120px; max-width: 220px;
}
.chart__tooltip .tt-title { color: var(--ink-3); margin-bottom: 4px; }
.chart__tooltip .tt-row { display: flex; align-items: center; gap: 6px; }
.chart__tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.chart__tooltip .tt-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.chart__legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--ink-2); margin-top: 8px; }
.chart__legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart__legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart__legend i.rect { height: 10px; border-radius: 2px; }
.chart__table { margin-top: 8px; }
.sparkline { width: 100%; height: 36px; }

/* Zustände */
.empty { text-align: center; color: var(--ink-2); padding: 28px 12px; }
.empty__icon { font-size: 34px; margin-bottom: 8px; }
.loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--ink-2); }
.loading__logo { font-size: 44px; font-weight: 800; letter-spacing: -0.04em; color: var(--ink); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); z-index: 60; display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
}
.toast--error { background: var(--bad); color: #fff; }
.toast button { background: transparent; border: 0; color: inherit; font-weight: 800; cursor: pointer; text-decoration: underline; }

/* Bottom-Sheet / Dialog */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, 0.55); }
.sheet__panel {
  width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom)); border: 1px solid var(--border); box-shadow: var(--shadow);
}
@media (min-width: 700px) { .sheet { align-items: center; } .sheet__panel { border-radius: 22px; } }
.sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 0 auto 12px; }
.sheet__title { font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.sheet__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sheet__img { width: 100%; border-radius: 12px; border: 1px solid var(--border); }

/* Login */
.login { max-width: 420px; margin: 10vh auto 0; padding: 24px 20px; }
.login .hero__value { font-size: 44px; }

/* Details (aufklappbar) */
details.details { border: 1px solid var(--border); border-radius: var(--radius-s); padding: 0 14px; margin-bottom: 10px; background: var(--surface); }
details.details summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.details summary::-webkit-details-marker { display: none; }
details.details summary::after { content: "+"; color: var(--ink-3); font-size: 18px; }
details.details[open] summary::after { content: "–"; }
details.details .details__body { padding: 0 0 14px; color: var(--ink-2); font-size: 14px; }
details.details .details__body p + p { margin-top: 8px; }

/* Ergebnis-Karte (nach dem Eintragen) */
.result-card { border-radius: var(--radius); padding: 18px; margin-bottom: 12px; background: linear-gradient(150deg, #20201f, #141413 70%); border: 1px solid var(--border-strong); }
:root[data-theme="light"] .result-card { background: linear-gradient(150deg, #ffffff, #f2f1ec 70%); }
.result-card .time { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }

/* Quartals-Auszeichnung */
.award { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: var(--radius-s); background: var(--surface-2); border: 1px solid var(--border); }
.award__icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); flex: none; }
.award__title { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.award__name { font-size: 17px; font-weight: 700; }
.award__sub { font-size: 13px; color: var(--ink-2); }

/* Zahlen-Highlight */
.big-number { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Import-Prüfung */
.imp-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.imp-row:last-child { border-bottom: 0; }
.imp-row--needs { background: var(--bad-soft); margin: 0 -8px; padding: 10px 8px; border-radius: 10px; border-bottom: 0; }
