:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --text: #14211f;
  --muted: #5b6b68;
  --line: #dfe6e4;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #d9f0ec;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 16px rgb(0 0 0 / .05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1514;
    --surface: #16201f;
    --text: #e8f0ee;
    --muted: #9ab0ab;
    --line: #26332f;
    --primary: #2dd4bf;
    --primary-ink: #04211d;
    --primary-soft: #12332f;
    --danger: #f87171;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- Formulare & Buttons ---------- */

label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 6px; }

input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
}

.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-block { width: 100%; }
.btn-small { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.btn-danger { color: var(--danger); }

.btn-link {
  background: none; border: 0; padding: 0; color: var(--primary);
  text-decoration: underline; cursor: pointer; font: inherit;
}

a { color: var(--primary); }

.error { color: var(--danger); font-size: .92rem; margin: 0 0 12px; min-height: 1.2em; }

/* ---------- Layout ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stack > * + * { margin-top: 14px; }

.shell { max-width: 640px; margin: 0 auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
}

.topbar h1 { font-size: 1.25rem; }
.content { padding: 0 16px 16px; }
.site-footer { text-align: center; font-size: .85rem; padding: 8px 16px 24px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 64px; justify-content: center;
  background: none; border: 0; color: var(--muted); font-size: .78rem; font-weight: 600; cursor: pointer;
}

.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--primary); }

/* ---------- Login ---------- */

.login {
  min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  max-width: 400px; margin: 0 auto; padding: 24px 16px;
}

.brand { text-align: center; margin-bottom: 24px; }
.brand img { width: 72px; height: 72px; border-radius: 18px; }
.brand h1 { margin-top: 12px; font-size: 1.6rem; }
.login .site-footer { margin-top: 12px; }

/* ---------- Erfassen ---------- */

/* ---------- Kalender ---------- */

.cal-head {
  display: grid; grid-template-columns: 48px 1fr 48px;
  align-items: center; gap: 8px; margin-bottom: 12px;
}

.cal-title { text-align: center; font-size: 1.05rem; }
.btn-icon { min-width: 48px; padding: 10px 0; font-size: 1.3rem; line-height: 1; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-wd { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; }

.cal-day {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--bg); color: inherit;
  font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
}

.cal-empty { background: none; border: 0; }
.cal-day[disabled] { opacity: .35; cursor: default; }
.cal-day.booked { background: var(--primary-soft); }
.cal-day.today { border-color: var(--primary); }
.cal-day.selected { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.cal-dot {
  position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--primary);
}

.cal-day.selected .cal-dot { background: var(--primary-ink); }

.cal-legend {
  display: flex; align-items: center; gap: 14px;
  font-size: .8rem; margin-top: 12px; padding-left: 2px;
}

.cal-legend .cal-dot { position: static; transform: none; }

/* Feste Spalten: die Knöpfe behalten ihre Position unabhängig vom Inhalt. */
.cal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.day-info { margin-top: 10px; font-size: .9rem; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.quick .btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 92px; font-size: 1.05rem;
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink);
}

.quick .btn span { font-weight: 500; font-size: .95rem; opacity: .9; }
.card h2 + * { margin-top: 12px; }

/* ---------- Fortschritt ---------- */

.figures { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.figures .big { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }

.meter {
  position: relative; height: 34px; border-radius: 10px; overflow: hidden;
  background: var(--primary-soft); border: 1px solid var(--line); margin-top: 10px;
}

.meter-fill {
  height: 100%; width: 0; background: var(--primary);
  transition: width .6s ease;
}

.meter-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; color: var(--text);
  text-shadow: 0 0 6px var(--surface), 0 0 2px var(--surface);
}

.meter-scale { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); margin-top: 4px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 1.15rem; }
.stat span { font-size: .8rem; color: var(--muted); }

.goal-reached {
  margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--primary-soft); font-weight: 600;
}

/* ---------- Monatsdiagramm ---------- */

.months { display: flex; align-items: flex-end; gap: 10px; height: 170px; overflow-x: auto; padding-top: 8px; }
.month-col { flex: 1 0 44px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; }
.month-bar { width: 100%; max-width: 44px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; }
.month-val { font-size: .75rem; font-weight: 700; }
.month-name { font-size: .72rem; color: var(--muted); white-space: nowrap; }

/* ---------- Übersicht ---------- */

.group-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 8px; }
.group-head h2 { text-transform: capitalize; }
.entries { list-style: none; margin: 0; padding: 0; }

.entry {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line);
}

.entry:first-child { border-top: 0; }
.entry-date { font-weight: 600; }
.entry-meta { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
.entry-hours { font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 24px 8px; color: var(--muted); }

/* ---------- Dialog / Toast ---------- */

dialog {
  width: min(92vw, 440px); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); padding: 20px;
}

dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
dialog h2 { margin-bottom: 14px; }
dialog hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.ok { color: var(--primary); font-size: .92rem; min-height: 1.2em; margin: 0 0 8px; }

/* left/right statt left:50%: sonst steht nur die halbe Breite zur Verfuegung
   und der Text bricht unnoetig um. margin-inline zentriert stattdessen. */
.toast {
  position: fixed; left: 16px; right: 16px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 20;
  width: fit-content; max-width: min(100%, 520px); margin-inline: auto;
  display: flex; align-items: center; gap: 14px;
  background: var(--text); color: var(--bg);
  padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .25);
}

.toast[hidden] { display: none; }
.toast > span { flex: 1 1 auto; }

.toast button {
  flex: 0 0 auto; white-space: nowrap;
  background: none; border: 0; color: inherit;
  font-weight: 800; text-decoration: underline; cursor: pointer;
}
.toast.error-toast { background: var(--danger); color: #fff; }

/* ---------- Impressum ---------- */

.legal-page { max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px 32px; }
.back-link { display: inline-block; margin-bottom: 14px; }
.legal-card h1 { font-size: 1.5rem; margin-bottom: 12px; }
.legal-card h2 { margin: 18px 0 6px; }
.legal-card p { margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  .meter-fill { transition: none; }
}

.day-info:empty { display: none; }
