/* Fortschritt und Lehrkraft-Bereich – aufgebaut wie in der Netzwerktechnik-Plattform,
   Farben passend zur ESP32-Plattform (Lachs/Orange, dunkle Kopfzeile) */
:root {
  --g9: #2c2c2e; --g7: #e85336; --g5: #ff7a52; --g3: #ffc4b2; --g1: #ffeee8; --g0: #f7f4f2;
  --ink: #2c2c2e; --muted: #646569; --line: #efe1dc; --bad: #b03a2e; --warn: #f2b705; --card: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--g0); background-image: radial-gradient(circle at 1px 1px, #eadbd5 1px, transparent 0); background-size: 22px 22px;
  color: var(--ink); font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; }
a { color: var(--g7); }
.topbar { position: sticky; top: 0; z-index: 20; background: #121626; box-shadow: 0 2px 10px rgba(44, 44, 46, .25); }
.topbar .inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: space-between; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.brand::before { content: ""; width: 20px; height: 23px; background: #ffab92; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.brand span { font-weight: 400; opacity: .8; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 6px; }
.topbar nav a, .topbar nav button { color: #f3f3f3; background: rgba(255, 255, 255, .1); text-decoration: none; padding: 6px 12px; border-radius: 999px; font: 600 .92rem inherit; border: 0; cursor: pointer; }
.topbar nav a:hover, .topbar nav button:hover { background: rgba(255, 255, 255, .22); }
.topbar nav a.active { background: #ffab92; color: var(--g9); }
main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }
.hero { background: linear-gradient(120deg, #121a33, var(--g9) 45%, var(--g7)); color: #fff; border-radius: 14px; padding: 26px 28px; margin-bottom: 20px; box-shadow: 0 12px 30px rgba(44, 44, 46, .22); }
.hero h1 { margin: 0 0 4px; font-size: clamp(1.7rem, 4vw, 2.5rem); }
.hero p { margin: 0; opacity: .92; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: 0 4px 18px rgba(44, 44, 46, .07); }
.card h2 { margin: 0 0 12px; font-size: 1.2rem; color: var(--g9); }
.muted { color: var(--muted); }
button, .btn { font: inherit; font-weight: 700; cursor: pointer; border: 0; border-radius: 8px; padding: 10px 16px; background: var(--g7); color: #fff; min-height: 42px; }
button:hover { background: var(--g9); }
button.ghost { background: #fff; color: var(--g9); border: 2px solid var(--g3); }
button.ghost:hover { border-color: var(--g7); background: var(--g1); }
button.danger { background: #fff; color: var(--bad); border: 2px solid #f0c7c2; }
button.danger:hover { background: #fdeeec; }
button.klein { min-height: 34px; padding: 6px 11px; font-size: .88rem; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
label { display: block; font-weight: 600; margin-bottom: 14px; }
input, select { font: inherit; font-size: 16px; width: 100%; margin-top: 4px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus { border-color: var(--g5); outline: none; }
.fehler { color: var(--bad); font-weight: 600; min-height: 1.4em; }
.ok-msg { color: var(--g7); font-weight: 600; }

/* Anmeldung */
.login { max-width: 440px; margin: 30px auto; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--g1); padding: 5px; border-radius: 10px; margin-bottom: 18px; }
.tabs button { background: transparent; color: var(--g9); }
.tabs button.active { background: #fff; box-shadow: 0 2px 6px rgba(44, 44, 46, .15); }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: 0 4px 14px rgba(44, 44, 46, .06); }
.kpi .wert { font-size: 2rem; font-weight: 800; color: var(--g9); line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .lbl { color: var(--muted); font-size: .9rem; }

/* Fortschrittsbalken */
.bar { height: 12px; border-radius: 999px; background: var(--g1); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--g5), var(--g7)); border-radius: 999px; }
.ring { --p: 0; width: 120px; height: 120px; border-radius: 50%; background: conic-gradient(var(--g7) calc(var(--p) * 1%), var(--g1) 0); display: grid; place-items: center; flex: none; }
.ring b { width: 92px; height: 92px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 1.5rem; color: var(--g9); }
.summary { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }

/* Kapitelkarten (Schüler) */
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.kcard .kopf { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.kcard .nr { font-weight: 800; color: var(--g7); }
.kcard a { font-weight: 700; color: var(--ink); text-decoration: none; }
.kcard a:hover { color: var(--g7); }
.kcard.zu { opacity: .65; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--g1); color: var(--g9); white-space: nowrap; }
.badge.zu { background: #eee; color: #555; }
.badge.voll { background: var(--g7); color: #fff; }
details.ue summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details.ue ul { margin: 6px 0 0; padding-left: 18px; font-size: .9rem; }

/* Lehrkraft-Bereich */
.admin { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.side { position: sticky; top: 72px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; box-shadow: 0 4px 14px rgba(44, 44, 46, .06); }
.side a { display: flex; gap: 10px; align-items: center; padding: 11px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600; }
.side a:hover { background: var(--g1); }
.side a.active { background: var(--g7); color: #fff; }
.side a .zahl { margin-left: auto; font-size: .8rem; background: var(--g1); color: var(--g9); border-radius: 999px; padding: 1px 8px; }
.side a.active .zahl { background: rgba(255, 255, 255, .25); color: #fff; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 8px 4px; }
.ansicht[hidden] { display: none; }
.werkzeug { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.werkzeug input { width: auto; flex: 1 1 220px; margin: 0; }
.werkzeug select { width: auto; margin: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { background: var(--g1); color: var(--g9); font-size: .85rem; position: sticky; top: 0; }
.tbl tr.klick { cursor: pointer; }
.tbl tr.klick:hover td { background: #fff7f4; }
.tbl td.zahl, .tbl th.zahl { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll { overflow-x: auto; }
.heat { border-collapse: separate; border-spacing: 3px; font-size: .82rem; }
.heat th { font-weight: 700; color: var(--g9); padding: 4px 6px; white-space: nowrap; }
.heat th.name { text-align: left; position: sticky; left: 0; background: #fff; }
.heat td { width: 40px; height: 32px; text-align: center; border-radius: 6px; font-variant-numeric: tabular-nums; }
.heat td.name { text-align: left; width: auto; font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: #fff; }
.chart-row { display: grid; grid-template-columns: minmax(0, 230px) minmax(0, 1fr) 54px; gap: 12px; align-items: center; padding: 6px 0; }
.chart-row .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .92rem; }
.chart-row .p { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.freiliste { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.freiliste li { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: #fff; }
.freiliste .titel { flex: 1; font-weight: 600; }
.switch { position: relative; width: 50px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #d6d2d0; border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + span { background: var(--g7); }
.switch input:checked + span::before { transform: translateX(22px); }
.switch input:focus-visible + span { outline: 3px solid var(--warn); outline-offset: 2px; }
.detail-kopf { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.leer { text-align: center; padding: 30px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--g9); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 60; }
@media (max-width: 820px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
  .side hr { display: none; }
  .chart-row { grid-template-columns: minmax(0, 1fr) 54px; }
  .chart-row .bar { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { .switch span, .switch span::before { transition: none; } }

/* ESP32: Freigaben pro Übung */
.tbl th.mitte, .tbl td.mitte { text-align: center; width: 170px; }
.tbl td.mitte .switch { display: inline-block; vertical-align: middle; }
.tbl tr.gruppe td { background: var(--g1); }
