/* Praxisbörse – Gestaltung
   Layout: dunkle Kopfleiste, darunter Karten in einer Spalte (Berater, mobil zuerst)
   bzw. Kennzahlen + Reiter + Liste (Auswertung). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --fg: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --navy: #0f1f38;
  --navy-fg: #ffffff;
  --accent: #0369a1;
  --accent-hover: #075985;
  --accent-soft: #e0f2fe;
  --accent-fg: #ffffff;
  --ring: rgb(3 105 161 / .28);
  --seek: #0f766e;  --seek-soft: #ccfbf1;
  --give: #b45309;  --give-soft: #fef3c7;
  --good: #15803d;  --good-soft: #dcfce7;
  --mid:  #a16207;  --mid-soft:  #fef9c3;
  --low:  #b91c1c;  --low-soft:  #fee2e2;
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 2px 8px rgb(15 23 42 / .04);
  --f: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 14px;
  --r-sm: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #121b2c; --surface-2: #0f1727; --line: #223049; --line-strong: #334462;
    --fg: #e8eef6; --muted: #a3b1c4; --subtle: #8796ab;
    --navy: #0a1424; --navy-fg: #e8eef6;
    --accent: #38bdf8; --accent-hover: #7dd3fc; --accent-soft: #0c2a40; --accent-fg: #04121f; --ring: rgb(56 189 248 / .35);
    --seek: #5eead4; --seek-soft: #0d2f2c; --give: #fbbf24; --give-soft: #33270c;
    --good: #4ade80; --good-soft: #0f2e1b; --mid: #facc15; --mid-soft: #2f2a0c; --low: #f87171; --low-soft: #3a1717;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 16px/1.5 var(--f); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.25; text-wrap: balance; }
button { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* ---------- Kopfleiste ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: var(--navy-fg);
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px; }
.topbar-inner { max-width: var(--max, 640px); margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand-mark svg.i { width: 20px; height: 20px; }
.brand-text { min-width: 0; }
.brand-text b { display: block; font-weight: 600; font-size: 17px; letter-spacing: -.005em; }
.brand-text small { display: block; font-size: 13px; opacity: .72; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn-top { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid rgb(255 255 255 / .22); background: rgb(255 255 255 / .06); color: inherit; font-weight: 500; font-size: 15px; cursor: pointer; }
.topbar .btn-top:hover { background: rgb(255 255 255 / .12); }
.topbar .btn-top.dreht svg { animation: dreh .8s linear infinite; }
@keyframes dreh { to { transform: rotate(360deg); } }

/* ---------- Seite ---------- */
.page { max-width: var(--max, 640px); margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 16px; }
.page-berater { padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
.intro h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.intro p { margin: 6px 0 0; color: var(--muted); font-size: 15px; max-width: 60ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 14px; min-width: 0; }
.section-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.section-title .opt, .opt { color: var(--subtle); font-weight: 400; font-size: 13px; }
.hint { margin: -4px 0 0; font-size: 13px; color: var(--subtle); }

.banner { border-radius: var(--r-sm); padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); color: var(--fg); }
.banner.warn { background: var(--low-soft); color: var(--fg); }
.banner svg.i { margin-top: 1px; }

/* ---------- Formularfelder ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field-label, .field > span:first-child { font-size: 14px; font-weight: 500; color: var(--fg); }
input, select {
  font: 400 16px/1.2 var(--f); color: var(--fg); background: var(--surface); width: 100%; min-width: 0;
  min-height: 48px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
select { -webkit-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
input::placeholder { color: var(--subtle); opacity: .8; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.field.ungueltig input, .field.ungueltig select { border-color: var(--low); }
.field-fehler { font-size: 13px; color: var(--low); display: flex; gap: 6px; align-items: center; }
.field-fehler svg.i { width: 16px; height: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 380px) { .row2 { grid-template-columns: 1fr; } }

/* Auswahlkarten: Bereich */
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice { display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 76px; padding: 12px 6px; text-align: center;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s; -webkit-tap-highlight-color: transparent; min-width: 0; }
.choice svg.i { width: 24px; height: 24px; color: var(--subtle); }
.choice .bc { font-size: 12px; font-weight: 400; color: var(--subtle); font-variant-numeric: tabular-nums; }
.choice:hover { border-color: var(--line-strong); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice[aria-pressed="true"] svg.i { color: var(--accent); }
.choice:active { transform: scale(.98); }

/* Auswahlkarten: Art */
.typ-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.typ-card { display: grid; gap: 8px; align-content: start; text-align: left; padding: 14px; min-height: 96px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; -webkit-tap-highlight-color: transparent; min-width: 0; }
.typ-card b { font-weight: 600; font-size: 15px; display: block; }
.typ-card small { color: var(--muted); font-size: 13px; line-height: 1.35; display: block; }
.typ-card .typ-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--subtle); }
.typ-card[data-typ="suchend"][aria-checked="true"] { border-color: var(--seek); background: var(--seek-soft); }
.typ-card[data-typ="suchend"][aria-checked="true"] .typ-ico { background: var(--seek); color: #fff; }
.typ-card[data-typ="abgebend"][aria-checked="true"] { border-color: var(--give); background: var(--give-soft); }
.typ-card[data-typ="abgebend"][aria-checked="true"] .typ-ico { background: var(--give); color: #fff; }
.typ-card:active { transform: scale(.99); }

/* Quartal */
.quarters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quarters button { min-height: 52px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--surface); cursor: pointer;
  display: grid; place-content: center; gap: 1px; -webkit-tap-highlight-color: transparent; }
.quarters b { font-family: var(--f-mono); font-weight: 500; font-size: 15px; }
.quarters small { font-size: 11px; color: var(--subtle); }
.quarters button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.quarters button[aria-checked="true"] small { color: var(--accent); }

/* ---------- Knöpfe ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: var(--accent); color: var(--accent-fg); font-weight: 600; font-size: 16px; cursor: pointer;
  transition: background .15s, border-color .15s; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.secondary { background: var(--surface); color: var(--fg); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.block { width: 100%; }
.btn .spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: dreh .7s linear infinite; }

.form-stack { display: grid; gap: 16px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toast { font-size: 14px; color: var(--good); }
.toast.err { color: var(--low); }
/* Fester Speichern-Knopf auf dem Handy */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.actionbar .actions-inner { max-width: 640px; margin: 0 auto; display: grid; gap: 6px; }
.actionbar .toast:empty { display: none; }

/* Erfolg */
.success { justify-items: center; text-align: center; padding: 32px 20px; gap: 10px; }
.success .ok-ico { width: 56px; height: 56px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; }
.success .ok-ico svg.i { width: 28px; height: 28px; }
.success h2 { font-size: 20px; font-weight: 600; }
.success p { margin: 0; color: var(--muted); max-width: 40ch; }
.success .zusammenfassung { margin: 6px 0 8px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* ---------- Chips, Pillen ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); white-space: nowrap; }
.chip svg.i { width: 14px; height: 14px; color: var(--subtle); }
.chip.q { font-family: var(--f-mono); font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; letter-spacing: .01em; }
.pill.s { background: var(--seek-soft); color: var(--seek); }
.pill.a { background: var(--give-soft); color: var(--give); }

/* ---------- Auswertung ---------- */
.page-wide { --max: 1120px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 2px; min-width: 0; }
.kpi span { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi b { font-size: 28px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.s { background: var(--seek); } .dot.a { background: var(--give); } .dot.m { background: var(--accent); } .dot.g { background: var(--good); }
.stand { font-size: 13px; color: var(--subtle); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 14px; min-height: 48px; font-weight: 500; font-size: 15px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .count { font-variant-numeric: tabular-nums; margin-left: 6px; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }

.toolbar { display: grid; gap: 12px; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; align-items: end; }
@media (max-width: 900px) { .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); } .toolbar .reset { grid-column: 1 / -1; } }
.toolbar .field > span:first-child { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.toolbar select { min-height: 44px; font-size: 15px; }
.filter-kopf { display: none; }
@media (max-width: 900px) {
  .filter-kopf { display: flex; justify-content: space-between; align-items: center; min-height: 44px; background: none; border: 0; padding: 0; font-weight: 600; font-size: 15px; cursor: pointer; width: 100%; }
  .filter-kopf .aktiv { font-weight: 500; font-size: 13px; color: var(--accent); }
  #filter-panel:not(.offen) .toolbar { display: none; }
}

/* Match-Karten */
.matches { display: grid; gap: 12px; }
.match { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); display: grid; grid-template-columns: 92px 1fr; overflow: hidden; }
.score { display: grid; place-content: center; justify-items: center; gap: 4px; padding: 14px 8px; text-align: center; border-right: 1px solid var(--line); }
.score b { font-size: 30px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.score span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; }
.score.hi b { color: var(--good); } .score.hi span { background: var(--good-soft); color: var(--good); }
.score.md b { color: var(--mid); }  .score.md span { background: var(--mid-soft); color: var(--mid); }
.score.lo b { color: var(--low); }  .score.lo span { background: var(--low-soft); color: var(--low); }
.match-body { display: grid; min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; min-width: 0; }
.pair .swap { display: grid; place-items: center; color: var(--subtle); padding: 0 2px; }
.side { padding: 14px 16px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.side .name { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.side .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.who { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; overflow-wrap: anywhere; }
.who svg.i { width: 14px; height: 14px; color: var(--subtle); }
.why { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
.why .r { display: inline-flex; gap: 5px; align-items: center; }
.why svg.i { width: 15px; height: 15px; }
.why .ok { color: var(--good); } .why .no { color: var(--subtle); }
@media (max-width: 640px) {
  .match { grid-template-columns: 1fr; }
  .score { grid-auto-flow: column; justify-content: start; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 16px; }
  .score b { font-size: 22px; }
  .pair { grid-template-columns: 1fr; }
  .pair .swap { display: none; }
  .side + .swap + .side { border-top: 1px dashed var(--line); }
}

/* Tabelle: alle Einträge */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
table.eintraege { width: 100%; border-collapse: collapse; font-size: 15px; }
.eintraege th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.eintraege td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.eintraege tr:last-child td { border-bottom: 0; }
.eintraege tbody tr:hover { background: var(--surface-2); }
.eintraege .kuerzel { font-weight: 600; }
.eintraege .klein { display: block; font-size: 13px; color: var(--muted); }
.eintraege .q { font-family: var(--f-mono); font-size: 14px; white-space: nowrap; }
.eintraege td.aktionen { text-align: right; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); border-color: var(--line); color: var(--fg); }
.icon-btn.danger:hover { color: var(--low); }
.confirm { display: inline-flex; gap: 6px; align-items: center; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.danger { background: var(--low); color: #fff; }
@media (max-width: 760px) {
  table.eintraege, .eintraege tbody, .eintraege tr, .eintraege td { display: block; }
  .eintraege thead { display: none; }
  .eintraege tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
  .eintraege td { padding: 0; border: 0; }
  .eintraege td.c-art { grid-column: 1 / -1; }
  .eintraege td.c-wer, .eintraege td.c-fach, .eintraege td.c-ort { grid-column: 1; }
  .eintraege td.c-zeit { grid-column: 2; grid-row: 2; text-align: right; }
  .eintraege td.aktionen { grid-column: 2; grid-row: 3 / span 3; align-self: end; }
  .eintraege td.c-ort, .eintraege td.c-fach { font-size: 14px; color: var(--muted); }
}

.empty { padding: 36px 20px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 8px; font-size: 15px; }
.empty .e-ico { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--subtle); }
.empty b { color: var(--fg); font-weight: 600; }
.empty p { margin: 0; max-width: 46ch; }

.edit-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

@media (min-width: 768px) {
  .page { padding-top: 28px; }
  .intro h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kpi .dot { display: inline-block; }
@media (max-width: 480px) { .topbar .btn-top .lbl { display: none; } .topbar .btn-top { padding: 0 12px; } }
.actionbar { display: block; }
.choice span:not(.bc) { white-space: nowrap; }
@media (max-width: 420px) { .choice { font-size: 12.5px; padding: 10px 2px; min-height: 72px; letter-spacing: -.01em; } .choice-grid { gap: 6px; } .card { padding: 16px; } }
@media (max-width: 480px) {
  .choice .bc-m { display: none; }
  .kpi { padding: 10px 12px; }
  .kpi b { font-size: 22px; }
  .kpi span { font-size: 12px; }
  .kpis { gap: 8px; }
  .tabs button { padding: 10px 10px; font-size: 14px; }
}
/* Symbole auf farbigen Flächen: im Dunkelmodus dunkel statt weiß */
.brand-mark { color: var(--accent-fg); }
.typ-card[aria-checked="true"] .typ-ico { color: var(--accent-fg) !important; }
@media (prefers-color-scheme: light) { .brand-mark, .typ-card[aria-checked="true"] .typ-ico { color: #fff !important; } }
