:root {
  --bg: #0b0f17;
  --side: #0e1420;
  --card: #131a26;
  --row: #172033;
  --inset: #0f1521;
  --line: #1c2638;
  --line2: #243047;
  --text: #e8edf5;
  --muted: #9aa7bd;
  --accent: #34d399;
  --accent-ink: #06281d;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 248px; flex: 0 0 248px; background: var(--side); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 4px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; flex: none;
}
.brand-name { font-weight: 700; font-size: 17px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--card); color: var(--text); }
.nav a[aria-current="page"] { background: var(--row); color: var(--text); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.me {
  margin-top: auto; padding: 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
.me-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 13px; color: var(--muted); }
.me-actions { display: flex; gap: 6px; }
.me-actions .btn { flex: 1 1 0; min-width: 0; height: 36px; padding: 0 6px; gap: 6px; font-size: 13px; }

.main { flex: 1; min-width: 0; padding: 32px 36px 56px; max-width: 1280px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.head h1 { font-size: 30px; }
.head .sub { color: var(--muted); margin-top: 4px; }

/* ---------- Bausteine ---------- */
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #0b0f17;
}
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.btn {
  height: 44px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card);
  color: var(--text); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; white-space: nowrap;
}
.btn:hover { background: var(--row); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #6ee7b7; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.6; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 19px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .meta { color: var(--muted); font-size: 14px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.kpi-note { font-size: 13px; color: var(--muted); }
.kpi.warn .kpi-value { color: var(--warn); }

.grid2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.task {
  display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 12px;
  background: var(--row); border: 1px solid var(--line2); cursor: pointer; text-align: left; width: 100%;
}
.task:hover { border-color: #33435f; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.task.done .task-title { color: var(--muted); text-decoration: line-through; }
.check {
  width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid #3a4a68; background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--accent-ink);
}
.check:hover { border-color: var(--accent); }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.check svg { opacity: 0; }
.check[aria-checked="true"] svg { opacity: 1; }
.pill {
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--card);
  color: var(--muted); border: 1px solid var(--line2); white-space: nowrap;
}
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); }
.pill.hot { color: var(--danger); border-color: rgba(248, 113, 113, 0.45); }
.pill.prog { color: #93c5fd; border-color: rgba(147, 197, 253, 0.4); }
.pills { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.empty { color: var(--muted); padding: 28px 12px; text-align: center; border: 1px dashed var(--line2); border-radius: 12px; }

.load { display: flex; flex-direction: column; gap: 14px; }
.load-row { display: flex; flex-direction: column; gap: 8px; }
.load-top { display: flex; align-items: center; gap: 10px; }
.load-top .nm { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.load-top .ct { color: var(--muted); font-size: 13px; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line2); background: transparent;
  color: var(--muted); font-weight: 600; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-pressed="true"] { background: var(--row); color: var(--text); border-color: #33435f; }
.tab .n { margin-left: 6px; color: var(--muted); font-weight: 500; }

.table { display: flex; flex-direction: column; gap: 8px; }
.urow {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: var(--row);
  border: 1px solid var(--line2);
}
.urow.off { opacity: 0.6; }
.urow .info { flex: 1; min-width: 0; }
.urow .nm { font-weight: 600; }
.urow .em { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.urow .btn { height: 36px; padding: 0 14px; }

/* ---------- Formulare & Dialoge ---------- */
dialog {
  border: 1px solid var(--line2); border-radius: 20px; background: var(--card); color: var(--text);
  padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(4, 7, 12, 0.7); }
.dlg { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dlg h2 { font-size: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px; background: var(--inset);
  border: 1px solid var(--line2); color: var(--text);
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input[type="date"] { color-scheme: dark; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 13px; color: var(--muted); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.actions .spacer { flex: 1; }
.checkrow { display: flex; align-items: center; gap: 10px; }
.checkrow input { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
.checkrow label { color: var(--text); font-size: 15px; font-weight: 500; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 32px 28px; display: flex; flex-direction: column; gap: 18px;
}
.login-card .brand { padding: 0; }
.login-card h1 { font-size: 26px; }

/* ---------- Schmale Bildschirme ---------- */
@media (max-width: 900px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 20px 16px 48px; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { position: static; width: auto; height: auto; flex: none; padding: 14px 16px; gap: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav a { padding: 10px 14px; white-space: nowrap; }
  .me { margin-top: 0; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
  .head h1 { font-size: 26px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 28px; }
  .task { flex-wrap: wrap; row-gap: 8px; }
  .task-body { flex: 1 1 0; min-width: 120px; }
  .pills { order: 3; flex-basis: 100%; justify-content: flex-start; padding-left: 38px; }
  .urow { flex-wrap: wrap; }
  .urow .info { flex-basis: calc(100% - 60px); }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .task, .tab, .nav a { transition: background-color 0.15s, border-color 0.15s, color 0.15s; }
}
