/* ===== Farben: folgen dem Gerät, per data-theme="light|dark" auf <html> umschaltbar ===== */
:root {
  color-scheme: light dark;
  --accent: #ffd100;
  --on-accent: #141414;
  --bg:    light-dark(#f4f4f2, #0d0e10);
  --card:  light-dark(#ffffff, #15171a);
  --raise: light-dark(#efefeb, #1d2024);
  --fg:    light-dark(#17181a, #ececec);
  --muted: light-dark(#6b6e74, #8d929b);
  --line:  light-dark(#e3e3de, #25292e);
  --link:  light-dark(#8a6a00, #ffd100);  /* Gelb als Schrift nur im Dunkeln, im Hellen dunkles Gold */
  --tint:  color-mix(in srgb, var(--accent) 14%, transparent);
  --ferien:   light-dark(#e4ecfb, #16223a);  /* Schulferien */
  --feiertag: light-dark(#fbe3e3, #3a1c1f);  /* Feiertage */
  --up:    light-dark(#15803d, #4ade80);
  --down:  light-dark(#b91c1c, #f87171);
  --r: 14px;
  --side: 248px;
}
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=dark] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 1.5rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 2rem 0 .75rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .75rem; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Seitenleiste ===== */
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--side);
  display: flex; flex-direction: column; gap: .15rem; padding: 1.25rem .75rem; overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 0 .6rem 1.25rem; font-weight: 700; font-size: 1.05rem; color: var(--fg); text-decoration: none; letter-spacing: -.01em; }
.logo { width: 28px; height: 28px; display: block; }
.item {
  display: flex; align-items: center; gap: .7rem; width: 100%; padding: .55rem .65rem;
  border: 0; border-radius: 9px; background: none; color: var(--muted); font: inherit; font-weight: 500; text-align: left; text-decoration: none; cursor: pointer;
  justify-content: flex-start; min-height: 0;
}
.item:hover { color: var(--fg); background: var(--raise); }
.item.active { color: var(--fg); background: var(--raise); }
.item.active .i { color: var(--link); }
.sub { display: grid; margin: .15rem 0 .5rem 1.6rem; padding-left: .6rem; border-left: 1px solid var(--line); }
.sub a { padding: .35rem .6rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: .92rem; }
.sub a:hover { color: var(--fg); }
.sub a.active { color: var(--fg); font-weight: 600; background: var(--tint); }
.side-foot { margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--line); display: grid; gap: .15rem; }
.theme { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin-top: .6rem; padding: 3px; border-radius: 10px; background: var(--raise); }
.theme button { min-height: 30px; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: .78rem; }
:root:not([data-theme]) [data-theme-set=auto], :root[data-theme=light] [data-theme-set=light], :root[data-theme=dark] [data-theme-set=dark] {
  background: var(--card); color: var(--fg); box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}

main { margin-left: var(--side); padding: 2.5rem 3rem 4rem; }
.content { max-width: 1080px; }
.tabbar, .scrim { display: none; }

/* ===== Handy: Leiste unten, Seitenleiste als ausklappbares Menü ===== */
@media (max-width: 899px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / .4); }
  .nav-toggle:checked ~ .scrim { display: block; position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / .5); }
  main { margin-left: 0; padding: 1.5rem 1rem calc(90px + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.5rem; margin-bottom: 1.1rem; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; inset: auto 0 0 0; z-index: 10;
    padding: .4rem .25rem calc(.4rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar label { display: grid; justify-items: center; gap: 3px; padding: .25rem 0; color: var(--muted); font-size: .7rem; text-decoration: none; cursor: pointer; }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar .active { color: var(--fg); font-weight: 600; }
  .tabbar .active .i { color: var(--link); }
}

/* ===== Login ===== */
main.login { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 2rem 1.75rem; }
.login-card .brand { padding: 0 0 1.5rem; }
.login-card h1 { font-size: 1.3rem; }
.login-card button.primary { width: 100%; }

/* ===== Formulare & Knöpfe ===== */
input, textarea, select, button, .btn {
  font: inherit; color: inherit; min-height: 42px; padding: .5rem .75rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
input, textarea, select { font-size: 16px; } /* verhindert Auto-Zoom auf iPhone */
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }
input[type=checkbox] { min-height: 0; width: 1.2rem; height: 1.2rem; padding: 0; accent-color: var(--accent); }
textarea { width: 100%; min-height: 6rem; resize: vertical; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; background: var(--raise); color: var(--fg); font-weight: 500; text-decoration: none; cursor: pointer; }
button:hover, .btn:hover { border-color: var(--muted); }
.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.primary:hover, .btn.primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn .i, button .i { width: 18px; height: 18px; }
form { margin: 0; }
td form { display: inline; }
.stack { display: grid; gap: 1rem; max-width: 720px; }
.stack label, fieldset label { display: grid; gap: .3rem; font-size: .9rem; color: var(--muted); }
.stack label > input:not([type=checkbox]), .stack label > select, .stack label > textarea, fieldset label > select { color: var(--fg); width: 100%; }
label.inline { display: flex; gap: .55rem; align-items: center; color: var(--fg); font-size: .95rem; }
.narrow { max-width: 360px; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0 0 1rem; }
.grid2 { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
fieldset { display: grid; gap: .9rem; margin: 0; padding: 1rem 1.15rem 1.15rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
legend { padding: 0 .4rem; font-weight: 600; }

/* ===== Karten, Tabellen, Hinweise ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.15rem 1.25rem; }
.content > .card { margin-bottom: 1rem; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
th, td { padding: .65rem .85rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; background: var(--raise); }
tbody tr:hover td, table tr:hover td { background: color-mix(in srgb, var(--raise) 50%, transparent); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pre { white-space: pre-line; }
.flash { margin: 0 0 1rem; padding: .7rem 1rem; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; background: var(--card); }
.flash.error { border-left-color: var(--down); }
.done { text-decoration: line-through; color: var(--muted); }
code { word-break: break-all; font-size: .85em; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 500; white-space: nowrap; background: var(--raise); color: var(--muted); }
.badge.ok { background: color-mix(in srgb, var(--up) 15%, transparent); color: var(--up); }
.badge.no { text-decoration: line-through; opacity: .6; }
.badge.warn { background: color-mix(in srgb, var(--down) 15%, transparent); color: var(--down); font-weight: 700; }
.contact { display: grid; gap: .6rem; margin-bottom: 1.25rem; }
.contact > div { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.contact strong { min-width: 8rem; }

/* ===== Kacheln ===== */
.tiles { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: grid; gap: .3rem; padding: 1.25rem; color: var(--fg); text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); transition: border-color .15s, transform .15s; }
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile strong { font-size: 1.05rem; }
.tile .muted { font-size: .88rem; }
.tile-icon { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: .5rem; border-radius: 11px; background: var(--tint); color: var(--link); }

/* ===== Anwesenheit: große Tippflächen ===== */
.checks { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.checks label { display: flex; align-items: center; gap: .65rem; padding: .65rem .8rem; color: var(--fg); font-size: .95rem; cursor: pointer; user-select: none; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.checks label:has(input:checked) { border-color: var(--accent); background: var(--tint); }

/* ===== Kalender ===== */
.calhead strong { min-width: 9.5rem; text-align: center; font-size: 1.1rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; max-width: 580px; margin-bottom: .75rem; }
.cal .wd { padding: .25rem 0; text-align: center; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.cal .day { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--fg); text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.cal .day:hover { border-color: var(--muted); }
.cal .day.today { border-color: var(--accent); }
.cal .day.ferien, .lg.ferien::before { background: var(--ferien); }
.cal .day.feiertag, .lg.feiertag::before { background: var(--feiertag); }
.cal .day.has, .lg.has::before { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal .day.multi, .lg.multi::before { background: repeating-linear-gradient(135deg, var(--accent) 0 6px, color-mix(in srgb, var(--accent) 70%, #000) 6px 12px); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal .day.unknown, .lg.unknown::before { background: var(--tint); border: 2px dashed var(--accent); font-weight: 700; }
.cal .day.cancelled, .lg.cancelled::before { border: 2px dashed var(--down); color: var(--muted); }
.cal .day.cancelled span { text-decoration: line-through; }
.cal .day.cancelled small { color: var(--down); }
.cal .day small { font-size: .65rem; font-weight: 500; }
.cal-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-bottom: 1rem; }
.lg { display: inline-flex; align-items: center; gap: .4rem; }
.lg::before { content: ""; width: .9rem; height: .9rem; border-radius: 4px; border: 1px solid var(--line); box-sizing: border-box; }
/* Anwesenheit nur bei "stattgefunden" abfragen */
.meeting-form:has(option[value=unknown]:checked) .attendance,
.meeting-form:has(option[value=cancelled]:checked) .attendance { display: none; }

/* ===== Dashboard ===== */
.pills { display: flex; flex-wrap: wrap; gap: .35rem; }
.pills a { padding: .4rem .85rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); text-decoration: none; font-size: .9rem; font-variant-numeric: tabular-nums; }
.pills a.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.kpis { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 1rem; }
.kpi { display: grid; gap: .2rem; padding: 1.1rem 1.25rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.kpi > span { color: var(--muted); font-size: .82rem; }
.kpi strong { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.trend { font-weight: 600; }
.trend.up { color: var(--up); }
.trend.down { color: var(--down); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); margin-bottom: 1rem; }
.chart { display: grid; width: max-content; min-width: 100%; }
.chart svg { display: block; min-width: 100%; height: 150px; }
.chart .s0 { fill: var(--accent); }
.chart .s1 { fill: var(--muted); opacity: .45; }
.chart .hit { fill: transparent; }
.chart g:hover .s0 { fill: color-mix(in srgb, var(--accent) 75%, var(--fg)); }
.chart-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin-top: .4rem; text-align: center; font-size: .68rem; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-labels b { display: block; color: var(--fg); font-size: .9rem; }
.chart-labels small { display: block; font-size: .7rem; }
.card table { border: 0; border-radius: 0; background: none; }
.card th { background: none; padding-top: 0; }
.card td, .card th { padding-left: .25rem; padding-right: .25rem; }
.gap-top { margin-top: 1rem; }
.legend { display: flex; gap: 1rem; color: var(--muted); font-size: .8rem; margin: -.4rem 0 .75rem; }
.legend span::before { content: ""; display: inline-block; width: .65rem; height: .65rem; margin-right: .35rem; border-radius: 3px; background: var(--accent); }
.legend span.s1::before { background: var(--muted); opacity: .45; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.rank li { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) minmax(70px, 38%) 6.5rem; gap: .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.rank li:last-child { border-bottom: 0; }
.rank .pos { color: var(--muted); font-variant-numeric: tabular-nums; }
.rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 99px; overflow: hidden; background: var(--raise); }
progress::-webkit-progress-bar { background: var(--raise); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
/* Karten passen ihren Inhalt an die eigene Breite an, nicht an die Bildschirmbreite */
.card { container-type: inline-size; }
@container (max-width: 480px) {
  .rank li { grid-template-columns: 1.4rem minmax(0, 1fr) 6rem; row-gap: .3rem; }
  .rank progress { grid-column: 2 / -1; grid-row: 2; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .kpi { padding: .9rem 1rem; }
  .kpi strong { font-size: 1.6rem; }
}

/* ===== Druck ===== */
.print-only { display: none; }
@media print {
  :root { color-scheme: light; --accent: #333; --link: #000; --card: #fff; --bg: #fff; --line: #bbb; }
  body { font-size: 10pt; }
  .no-print, .flash, .tabbar, .sidebar, h1 { display: none !important; }
  .print-only { display: block; }
  main { margin: 0; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .card, .kpi, table { border-color: #bbb; break-inside: avoid; }
  tr { break-inside: avoid; }
  .scroll { overflow: visible; }
  th, td { padding: .3rem .45rem; }
}
