:root {
  color-scheme: light dark;
  --bg: 265 20% 97%;
  --fg: 266 22% 13%;
  --muted: 264 9% 40%;
  --primary: 268 52% 30%;
  --primary-fg: 265 40% 98%;
  --bar: 268 48% 48%;
  --bar-active: 268 60% 26%;
  --line: 265 18% 86%;
  --input-bg: 0 0% 100%;
  --bad: 354 68% 44%;
  --good: 158 50% 28%;
  --warn: 32 85% 34%;
  --surface: 0 0% 100% / 0.66;
  --glass-line: 0 0% 100% / 0.75;
  --inset: 268 52% 30% / 0.06;
  --glow-1: 268 60% 70%;
  --glow-2: 290 55% 82%;
  --glow-3: 230 70% 85%;
  --shadow: 266 30% 20%;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: 266 25% 8%;
    --fg: 265 25% 94%;
    --muted: 265 10% 68%;
    --primary: 266 70% 76%;
    --primary-fg: 266 25% 10%;
    --bar: 266 62% 68%;
    --bar-active: 266 90% 86%;
    --line: 266 15% 24%;
    --input-bg: 266 20% 14%;
    --bad: 354 80% 72%;
    --good: 158 50% 62%;
    --warn: 38 90% 66%;
    --surface: 266 22% 14% / 0.66;
    --glass-line: 0 0% 100% / 0.08;
    --inset: 266 70% 76% / 0.08;
    --glow-1: 268 50% 30%;
    --glow-2: 290 40% 22%;
    --glow-3: 230 40% 22%;
    --shadow: 0 0% 0%;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  color: hsl(var(--fg));
  background-color: hsl(var(--bg));
  background-image:
    radial-gradient(40rem 28rem at 8% -6%, hsl(var(--glow-1) / 0.45), transparent 70%),
    radial-gradient(36rem 30rem at 100% 10%, hsl(var(--glow-2) / 0.55), transparent 70%),
    radial-gradient(44rem 30rem at 50% 110%, hsl(var(--glow-3) / 0.45), transparent 70%);
  background-attachment: fixed;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
:focus-visible { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.muted { color: hsl(var(--muted)); }
.small { font-size: 13px; }
.label { color: hsl(var(--muted)); font-size: 12.5px; font-weight: 400; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.strong { font-weight: 600; }
.good { color: hsl(var(--good)); }
.bad { color: hsl(var(--bad)); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.top-gap { margin-top: 12px; }
.eyebrow { color: hsl(var(--primary)); font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }

.glass {
  background: hsl(var(--surface));
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid hsl(var(--glass-line));
  border-radius: 20px;
  box-shadow: 0 16px 36px -18px hsl(var(--shadow) / 0.2), 0 3px 10px -4px hsl(var(--shadow) / 0.08);
}
.inset { background: hsl(var(--inset)); border-radius: 14px; padding: 12px 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  background: none; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-fg)); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.btn-dark { background: hsl(var(--fg)); color: hsl(var(--bg)); }
.btn-ghost { border-color: hsl(var(--line)); }
.btn-ghost:hover { background: hsl(var(--inset)); }
.btn-wide { width: 100%; margin-top: 4px; }

.alert { padding: 10px 14px; border-radius: 12px; background: hsl(var(--bad) / 0.12); color: hsl(var(--bad)); font-size: 14px; }
.notice { padding: 10px 14px; border-radius: 12px; background: hsl(var(--inset)); font-size: 14px; }
.notice-warn { background: hsl(var(--warn) / 0.14); }

/* Anmeldung */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { width: min(400px, 100%); padding: 32px; display: grid; gap: 14px; }
.auth h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.field { display: grid; gap: 4px; font-size: 13px; }
.field input { height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid hsl(var(--line)); background: hsl(var(--input-bg)); font-size: 16px; }

/* Rahmen */
.brand { text-decoration: none; font-size: 15px; letter-spacing: -0.01em; }
.brand-strong { font-weight: 700; color: hsl(var(--primary)); }
.brand-large { font-size: 16px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 1120px; margin: 0 auto; padding: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-user { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { max-width: 1120px; margin: 0 auto; padding: 16px 16px 64px; }
.page-title { font-size: clamp(26px, 5vw, 36px); font-weight: 600; letter-spacing: -0.025em; margin: 8px 0 24px; }
.crumbs { font-size: 13px; color: hsl(var(--muted)); margin-bottom: 8px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

/* Auswahl */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.tile { display: block; padding: 24px; text-decoration: none; min-height: 132px; }
a.tile { transition: transform 160ms ease; }
a.tile:hover { transform: translateY(-2px); }
.tile h2 { font-size: 20px; margin-bottom: 6px; }
.tile-placeholder { border: 1px dashed hsl(var(--line)); border-radius: 20px; display: grid; place-items: center; text-align: center; }
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 16px; }
.person { padding: 20px; font-size: 18px; font-weight: 600; text-decoration: none; }
.person:hover { background: hsl(var(--inset)); }

/* Bericht */
.report-wrap { display: grid; gap: 16px; }
.report { display: grid; gap: 16px; transition: opacity 120ms; min-width: 0; }
.report.is-loading { opacity: 0.55; }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.report-title { margin: 2px 0; }
.title-select { font-size: clamp(28px, 5vw, 40px); font-weight: 600; letter-spacing: -0.025em; border: 0; background: none; padding: 0 4px 0 0; margin-left: -4px; max-width: 100%; cursor: pointer; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.preset-row, .range-extra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.range-extra input { height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid hsl(var(--line)); background: hsl(var(--input-bg)); }
.month-label { min-width: 118px; text-align: center; font-size: 14px; font-weight: 500; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid hsl(var(--line)); background: hsl(var(--surface)); font-size: 18px; line-height: 1; }
.chip-btn { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid hsl(var(--line)); background: hsl(var(--surface)); font-size: 14px; }
.chip-btn:hover { background: hsl(var(--inset)); }
.chip-btn[aria-pressed="true"] { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-fg)); }
.chip-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid hsl(var(--line)); background: hsl(var(--surface)); height: 40px; }
.seg-btn { border: 0; background: none; border-radius: 999px; padding: 0 12px; font-size: 14px; color: hsl(var(--muted)); }
.seg-btn[aria-pressed="true"] { background: hsl(var(--primary)); color: hsl(var(--primary-fg)); }

.panel { padding: 22px; min-width: 0; }
.kpis { display: grid; grid-template-columns: 2fr 1fr 1fr; }
.kpi { padding: 24px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid hsl(var(--line) / 0.7); }
.hero-number { font-size: clamp(42px, 8vw, 60px); font-weight: 600; letter-spacing: -0.03em; color: hsl(var(--primary)); line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-number { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

.stats-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { display: block; min-width: 0; }
.weekly { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.weekly input { width: 76px; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid hsl(var(--line)); background: hsl(var(--input-bg)); font-variant-numeric: tabular-nums; }

.totals-bar { display: flex; overflow-x: auto; border-radius: 14px; }
.total-field { flex: 1 1 0; display: grid; gap: 1px; padding: 8px 4px; text-align: center; min-width: 66px; }
.total-field + .total-field { border-left: 1px solid hsl(var(--line) / 0.7); }
.total-value { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.total-label { font-size: 11px; color: hsl(var(--muted)); white-space: nowrap; }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split-chart { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.divider { margin-top: 18px; padding-top: 16px; border-top: 1px solid hsl(var(--line) / 0.7); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px; border: 0; font-size: 12.5px; }
.pill-bad { background: hsl(var(--bad) / 0.12); color: hsl(var(--bad)); }
.pill-muted { background: hsl(var(--inset)); color: hsl(var(--muted)); }
.pill-accent { background: hsl(var(--inset)); color: hsl(var(--primary)); }
button.pill:hover { filter: brightness(0.94); }

.popover { position: fixed; z-index: 20; display: flex; flex-wrap: wrap; gap: 4px; max-width: min(360px, calc(100vw - 32px)); padding: 8px; border-radius: 14px; background: hsl(var(--input-bg)); border: 1px solid hsl(var(--line)); box-shadow: 0 12px 28px -10px hsl(var(--shadow) / 0.35); }

.loc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { margin-top: 10px; }
.metric-head { display: flex; justify-content: space-between; gap: 12px; }

.chart { position: relative; }
.chart-plot { position: relative; height: 230px; margin-left: 34px; }
.chart-empty { padding: 80px 0; text-align: center; }
.grid-line { position: absolute; left: 0; right: 0; border-top: 1px solid hsl(var(--line) / 0.7); }
.grid-line span { position: absolute; left: -34px; top: -9px; font-size: 11px; color: hsl(var(--muted)); }
.grid-target { border-top: 1px dashed hsl(var(--muted)); }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid hsl(var(--line)); }
.bar { flex: 1 1 0; min-width: 0; height: 100%; padding: 0; border: 0; background: none; display: flex; align-items: flex-end; justify-content: center; border-radius: 4px 4px 0 0; }
.bar-fill { display: block; width: 100%; max-width: 30px; min-height: 2px; background: hsl(var(--bar)); border-radius: 4px 4px 0 0; }
.bar:hover .bar-fill, .bar.is-selected .bar-fill { background: hsl(var(--bar-active)); }
.bar-labels { display: flex; gap: 2px; margin: 6px 0 0 34px; }
.bar-labels span { flex: 1 1 0; min-width: 0; font-size: 11px; color: hsl(var(--muted)); text-align: center; white-space: nowrap; overflow: visible; display: flex; justify-content: center; }
.chart-tip { position: fixed; z-index: 15; padding: 5px 10px; border-radius: 8px; background: hsl(var(--fg)); color: hsl(var(--bg)); font-size: 12.5px; pointer-events: none; white-space: nowrap; }

.tasks { display: grid; gap: 12px; }
.task-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.task-track { height: 6px; margin-top: 4px; border-radius: 3px; background: hsl(var(--inset)); }
.task-fill { height: 100%; min-width: 2px; border-radius: 3px; background: hsl(var(--bar)); }

.table-wrap { overflow-x: auto; }
.table-wrap table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 14px; }
.table-wrap th { padding: 12px 16px; text-align: left; font-size: 12.5px; font-weight: 500; color: hsl(var(--muted)); border-bottom: 1px solid hsl(var(--line)); }
.table-wrap th.right { text-align: right; }
.table-wrap td { padding: 12px 16px; border-bottom: 1px solid hsl(var(--line) / 0.5); }
.table-wrap tr:last-child td { border-bottom: 0; }
.badge { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: hsl(var(--inset)); color: hsl(var(--primary)); font-size: 12px; }

.day-panel { outline: 1px solid hsl(var(--primary) / 0.3); }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.day-head h2 { margin: 0; }
.absence-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 14px; }
.absence-row .label { margin-right: 6px; }
.daily-item + .daily-item { margin-top: 16px; padding-top: 16px; border-top: 1px solid hsl(var(--line)); }
.daily-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.files { margin-top: 12px; padding: 12px; border: 1px dashed hsl(var(--line)); border-radius: 12px; display: grid; gap: 6px; }

@media (max-width: 820px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-main { grid-column: 1 / -1; border-bottom: 1px solid hsl(var(--line) / 0.7); }
  .kpi:nth-child(2) { border-left: 0; }
  .stats-4 { grid-template-columns: 1fr 1fr; }
  .split-2, .split-chart { grid-template-columns: minmax(0, 1fr); }
  .topbar-user { display: none; }
  .controls { flex-direction: column; align-items: flex-start; }
}

#print-sheet { display: none; }

@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff !important; color: #221a2e; font-size: 10.5pt; }
  #app { display: none; }
  #print-sheet { display: block; }
  #print-sheet .eyebrow { color: #3f2270; }
  #print-sheet h1 { font-size: 24pt; font-weight: 500; margin: 2pt 0; }
  #print-sheet h2 { font-size: 13pt; margin: 18pt 0 6pt; break-after: avoid; }
  #print-sheet p { margin: 3pt 0; }
  #print-sheet .muted, #print-sheet .label { color: #6d6578; }
  #print-sheet table { width: 100%; border-collapse: collapse; }
  #print-sheet th { text-align: left; font-weight: 600; }
  #print-sheet th.right { text-align: right; }
  #print-sheet td, #print-sheet th { padding: 4pt 2pt; border-bottom: 0.5pt solid #e4ddef; }
  #print-sheet tr { break-inside: avoid; }
  .print-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8pt; margin: 14pt 0; }
  .print-kpis div { padding: 8pt 10pt; border: 0.5pt solid #e4ddef; }
  .print-kpis strong { font-size: 18pt; font-weight: 600; }
}
