:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #5d6677;
  --line: #e2e5ea;
  --accent: #2f6fde;
  --accent-soft: #e7effd;
  --good: #1f9d55;
  --good-soft: #e3f6ea;
  --ok: #b7791f;
  --ok-soft: #fdf3dc;
  --no: #d64545;
  --no-soft: #fde8e8;
  --weekend: #f3eefe;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 1px 8px rgba(20, 30, 50, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d; --card: #1d2129; --text: #e8ebf1; --muted: #9aa3b2; --line: #2e3440;
    --accent: #6b9cff; --accent-soft: #22304d; --good: #4cc27d; --good-soft: #193425;
    --ok: #e0a846; --ok-soft: #3a2f17; --no: #f07272; --no-soft: #3d1f22; --weekend: #272238;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); margin-right: .5rem; }
.nav { display: flex; gap: .2rem; flex-wrap: wrap; flex: 1; }
.nav a { text-decoration: none; color: var(--muted); padding: .35rem .6rem; border-radius: 8px; }
.nav a.active, .nav a:hover { background: var(--accent-soft); color: var(--accent); }
main { max-width: 1280px; margin: 0 auto; padding: 1rem 1rem 4rem; }
main.narrow { max-width: 720px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .6rem; }

/* ---------- Kennzahlen ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }

/* ---------- Meldungen ---------- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; background: var(--good-soft); border: 1px solid var(--good); }
.flash.error { background: var(--no-soft); border-color: var(--no); }
.alert { padding: .8rem 1rem; border-radius: var(--radius); margin: .6rem 0; border-left: 4px solid; }
.alert.bad { background: var(--no-soft); border-color: var(--no); }
.alert.warn { background: var(--ok-soft); border-color: var(--ok); }
.alert.good { background: var(--good-soft); border-color: var(--good); }
.alert.info { background: var(--accent-soft); border-color: var(--accent); }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
label.inline { display: inline-flex; gap: .4rem; align-items: center; font-weight: normal; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; font: inherit;
  background: var(--card); color: var(--text);
}
textarea { min-height: 6rem; resize: vertical; }
.field { margin-bottom: .8rem; }
.field .hint { color: var(--muted); font-size: .82rem; margin-top: .15rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; gap: .35rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--no); border-color: var(--no); }
.btn.small { padding: .25rem .55rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }
details > summary { cursor: pointer; font-weight: 600; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .45rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; }
tr.highlight td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.best { font-weight: 700; color: var(--good); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: .75rem; padding: .08rem .45rem; border-radius: 99px; background: var(--line); color: var(--text); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.no { background: var(--no-soft); color: var(--no); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.weekend { background: var(--weekend); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; vertical-align: middle; }

/* ---------- Wochenraster ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: .5rem; overflow-x: auto; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; min-height: 6rem; }
.day.weekend-day { background: linear-gradient(var(--weekend), var(--card)); }
.day h4 { margin: 0 0 .4rem; font-size: .9rem; }
.shift {
  display: block; width: 100%; text-align: left; border: 1px solid var(--line); border-left: 4px solid var(--cat, #888);
  border-radius: 8px; padding: .35rem .45rem; margin-bottom: .35rem; background: var(--card); color: var(--text);
  font: inherit; font-size: .85rem; text-decoration: none; cursor: pointer;
}
.shift:hover { border-color: var(--accent); border-left-color: var(--cat, #888); }
.shift .time { font-weight: 600; }
.shift .who { display: block; font-weight: 600; margin-top: .1rem; }
.shift.problem { background: var(--no-soft); border-color: var(--no); }
.shift.compromise .who::after { content: " 🟡"; }
.shift.weekend { box-shadow: inset 0 0 0 999px var(--weekend); }
.shift.problem.weekend { box-shadow: none; }
@media (max-width: 800px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 1rem 0; overflow-x: auto; }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Dialog (Editor) ---------- */
dialog { border: none; border-radius: 14px; padding: 0; width: min(640px, 96vw); max-height: 90vh; background: var(--card); color: var(--text); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 15, 25, .45); }
.dialog-head { padding: 1rem 1rem .5rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.dialog-body { padding: .8rem 1rem 1rem; }
.option { display: flex; gap: .6rem; align-items: flex-start; padding: .55rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .4rem; }
.option.impossible { opacity: .75; }
.option.current { border-color: var(--accent); background: var(--accent-soft); }
.option .main { flex: 1; }
.option .notes { font-size: .82rem; color: var(--muted); margin: .15rem 0 0; padding-left: 1rem; }
.verdict { padding: .6rem .8rem; border-radius: 8px; margin: .6rem 0; }
.verdict.good { background: var(--good-soft); }
.verdict.bad { background: var(--no-soft); }

/* ---------- Mitarbeiter-Umfrage ---------- */
.survey-top { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); padding: .6rem 1rem; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: .35rem; }
.progress > div { height: 100%; background: var(--good); width: 0; transition: width .2s; }
.save-state { font-size: .8rem; color: var(--muted); }
.sday { margin: 1rem 0 .4rem; display: flex; align-items: center; gap: .5rem; }
.sday h3 { margin: 0; flex: 1; }
.sshift { background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--cat, #888); border-radius: var(--radius); padding: .6rem .7rem; margin-bottom: .5rem; }
.sshift.unanswered { border-color: var(--ok); border-left-color: var(--cat, #888); }
.sshift .title { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-top: .5rem; }
.choice {
  border: 2px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); padding: .6rem .2rem;
  font: inherit; font-size: .85rem; cursor: pointer; line-height: 1.2; min-height: 3.2rem;
}
.choice .ico { font-size: 1.2rem; display: block; }
.choice[aria-pressed=true][data-rating=good] { border-color: var(--good); background: var(--good-soft); font-weight: 700; }
.choice[aria-pressed=true][data-rating=ok] { border-color: var(--ok); background: var(--ok-soft); font-weight: 700; }
.choice[aria-pressed=true][data-rating=no] { border-color: var(--no); background: var(--no-soft); font-weight: 700; }
.week-title { margin-top: 1.5rem; padding-top: .5rem; border-top: 2px solid var(--line); }
.linkbox { display: flex; gap: .4rem; }
.linkbox input { font-size: .85rem; }

/* ---------- Antwort-Matrix ---------- */
.matrix td, .matrix th { padding: .2rem .25rem; text-align: center; font-size: .8rem; }
.matrix th.rot { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; height: 7rem; }
.matrix td.name { text-align: left; white-space: nowrap; }
.r-good { background: var(--good-soft); }
.r-ok { background: var(--ok-soft); }
.r-no { background: var(--no-soft); }
.progress .indeterminate { height: 100%; width: 30%; background: var(--accent); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -30%; } to { margin-left: 100%; } }
