:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --ink: #1b2230;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e3e7ee;
  --accent: #2f6fed;
  --accent-ink: #ffffff;
  --accent-soft: #e7efff;
  --good: #12805c;
  --good-soft: #e3f5ec;
  --bad: #c4320a;
  --bad-soft: #fdece6;
  --warn: #b54708;
  --warn-soft: #fff3e0;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  --radius: 16px;
  --radius-sm: 10px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --surface: #182030;
    --surface-2: #212b3d;
    --ink: #e8ecf3;
    --muted: #9aa5b8;
    --faint: #6b778c;
    --line: #2a3447;
    --accent: #6b9bff;
    --accent-ink: #0b1220;
    --accent-soft: #1f2d4d;
    --good: #4cc79a;
    --good-soft: #15342a;
    --bad: #ff8a65;
    --bad-soft: #3a2018;
    --warn: #ffb547;
    --warn-soft: #3a2c14;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 28px; letter-spacing: -0.02em; }
h2 { font-size: 18px; letter-spacing: -0.01em; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- Grundlayout ---------- */
.app { min-height: 100dvh; }
.boot { display: grid; place-items: center; min-height: 100dvh; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.shell { display: flex; min-height: 100dvh; }
.main {
  flex: 1; min-width: 0;
  padding: calc(env(safe-area-inset-top) + 20px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  max-width: 760px; margin: 0 auto; width: 100%;
}
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .eyebrow { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* Navigation: unten auf dem Handy, links auf großen Bildschirmen */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: 11px; font-weight: 600; position: relative;
}
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab .dot {
  position: absolute; top: 8px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.brand { display: none; }

@media (min-width: 900px) {
  .tabbar {
    position: sticky; top: 0; height: 100dvh; width: 230px; flex: none;
    display: flex; flex-direction: column; gap: 4px; padding: 24px 14px;
    border-top: 0; border-right: 1px solid var(--line); background: var(--surface);
  }
  .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 10px 20px; }
  .brand img { width: 32px; height: 32px; border-radius: 8px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; border-radius: 10px; font-size: 15px; color: var(--muted); }
  .tab:hover { background: var(--surface-2); }
  .tab[aria-current="page"] { background: var(--accent-soft); }
  .tab .dot { position: static; margin-left: auto; }
  .main { padding: 36px 32px 48px; }
}

/* ---------- Karten und Kennzahlen ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px;
}
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; }

.hero {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #7c3aed));
  color: #fff; border-radius: 20px; padding: 18px; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .hero { color: #0b1220; } }
.hero .label { font-size: 13px; opacity: 0.85; font-weight: 600; }
.hero .big { font-size: 40px; font-weight: 750; letter-spacing: -0.03em; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.hero .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; opacity: 0.92; }
.hero .bar { height: 6px; border-radius: 3px; background: rgb(255 255 255 / 25%); overflow: hidden; margin-bottom: 12px; }
.hero .bar > span { display: block; height: 100%; background: currentColor; border-radius: 3px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

/* ---------- Listen ---------- */
.list { display: grid; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px;
  border-top: 1px solid var(--line); color: inherit; min-height: 56px;
}
.item:first-child { border-top: 0; }
a.item:active { background: var(--surface-2); }
.date-badge {
  width: 46px; flex: none; text-align: center; border-radius: 12px; padding: 5px 0;
  background: var(--surface-2); line-height: 1.1;
}
.date-badge .d { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.date-badge .w { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.date-badge.today { background: var(--accent); color: var(--accent-ink); }
.date-badge.today .w { color: inherit; opacity: 0.85; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 13px; color: var(--muted); }
.item .end { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chev { color: var(--faint); flex: none; }

.pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650;
  padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.offen { background: var(--bad-soft); color: var(--bad); }
.pill.erfasst { background: var(--good-soft); color: var(--good); }
.pill.geplant { background: var(--accent-soft); color: var(--accent); }
.pill.frei { background: var(--surface-2); color: var(--muted); }
.pill.urlaub { background: var(--warn-soft); color: var(--warn); }
.pill.krank { background: var(--bad-soft); color: var(--bad); }

.empty { text-align: center; color: var(--muted); padding: 20px 8px; font-size: 15px; }
.empty .icon { font-size: 30px; margin-bottom: 6px; }

/* ---------- Banner ---------- */
.banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px;
  background: var(--accent-soft); color: var(--ink);
}
.banner.warn { background: var(--warn-soft); }
.banner.bad { background: var(--bad-soft); }
.banner .icon { font-size: 22px; line-height: 1; }
.banner .body { flex: 1; display: grid; gap: 8px; font-size: 15px; }
.banner b { font-weight: 650; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; }

/* ---------- Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--surface-2); color: var(--ink); font-weight: 650; text-align: center;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.good { background: var(--good); color: #fff; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ghost { background: transparent; color: var(--accent); padding: 0 10px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 650; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); font-size: 16px;
}
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--bad); font-size: 14px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Auswahl-Kacheln (z. B. Pause ja/nein) */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.choice {
  min-height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 650; cursor: pointer; padding: 6px 8px; line-height: 1.2;
}
.choice small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; margin-top: 2px; }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice[aria-pressed="true"] small { color: inherit; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background 0.2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 25%); transition: transform 0.2s; }
.switch input:checked { background: var(--good); }
.switch input:checked::after { transform: translateX(20px); }

/* Großes Antwortformular */
.answer-head { text-align: center; padding: 8px 0 4px; }
.answer-head .when { font-size: 14px; color: var(--muted); font-weight: 600; }
.answer-head .shift { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; }
.answer-head .code { margin-top: 6px; }
.result-line {
  display: flex; justify-content: space-between; align-items: baseline; padding: 14px; border-radius: 14px;
  background: var(--surface-2); font-weight: 650;
}
.result-line .v { font-size: 22px; font-variant-numeric: tabular-nums; }

/* Monatstabelle */
.month-nav { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--shadow);
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.icon-btn svg { width: 20px; height: 20px; }
.table-wrap { overflow-x: auto; }
table.days { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.days th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.days td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.days td.r, table.days th.r { text-align: right; }
table.days tr.weekend td:first-child { color: var(--accent); }
table.days tr.clickable { cursor: pointer; }
table.days tr.clickable:hover td { background: var(--surface-2); }
table.days tr.none td { color: var(--faint); }
table.days tfoot td { font-weight: 700; border-bottom: 0; }
.only-wide { display: none; }
@media (min-width: 700px) { .only-wide { display: block; } .only-narrow { display: none; } }

/* Plan-Upload */
.drop {
  display: grid; place-items: center; gap: 8px; text-align: center; padding: 28px 16px; border-radius: var(--radius);
  border: 2px dashed var(--line); background: var(--surface); cursor: pointer;
}
.drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop .icon { font-size: 34px; }
.names { display: grid; gap: 6px; max-height: 320px; overflow-y: auto; }
.name-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; }

/* Anmeldung */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 400px; padding: 24px; }
.auth .logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }

/* Hinweis unten */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

.fade-in { animation: fade 0.25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Berichte ---------- */
.report { display: grid; gap: 12px; }
.report-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.report-head .title { font-weight: 650; }
.report-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.report-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.report-actions .btn { gap: 6px; padding: 0 8px; }

/* ---------- PDF-Ansicht ---------- */
.viewer { min-height: 100dvh; background: var(--surface-2); display: flex; flex-direction: column; }
.viewer-bar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.viewer-bar .btn { justify-self: start; gap: 4px; min-height: 44px; }
.viewer-title { font-weight: 700; text-align: center; white-space: nowrap; }
.viewer-pages {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
}
.pdf-page { background: #fff; border-radius: 4px; box-shadow: var(--shadow); max-width: 100%; height: auto; }
.viewer-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.viewer-actions .btn { gap: 8px; padding: 0 10px; white-space: nowrap; font-size: 15px; }
@media (min-width: 700px) { .viewer-actions { left: 50%; right: auto; transform: translateX(-50%); width: 520px; border: 1px solid var(--line); border-radius: 16px 16px 0 0; } }

/* ---------- Admin ---------- */
.eyebrow a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.members { display: grid; gap: 8px; }
.member {
  display: grid; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid var(--line);
  color: inherit; background: var(--surface);
}
.member:active { background: var(--surface-2); }
.member-main { display: flex; align-items: center; gap: 12px; }
.member-main .body { flex: 1; min-width: 0; }
.member-main .title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-main .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-main .end { text-align: right; font-weight: 700; }
.member-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.member-pills:empty { display: none; }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 750; font-size: 17px;
}
.log { display: grid; }
.log-item { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.log-item:first-child { border-top: 0; padding-top: 0; }
.log-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.banner a { color: inherit; text-decoration: underline; }
@media (max-width: 899px) { .tabbar .tab span:not(.dot) { font-size: 10px; } }
