:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --text: #1c1b19;
  --muted: #6b6860;
  --line: #e4e1d9;
  --accent: #1f5f5b;
  --accent-soft: #e3efed;
  --accent-text: #ffffff;
  --good: #2e7d4f;
  --good-soft: #e3f2e8;
  --warn: #a8650a;
  --warn-soft: #fbf0dc;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --done: #9a968c;
  --bar: #3d7f79;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1c1a; --surface-2: #232220; --text: #ecebe6; --muted: #a29f96;
    --line: #34322e; --accent: #5fb3aa; --accent-soft: #1f3331; --accent-text: #0e1716;
    --good: #6cc48f; --good-soft: #1b2d22; --warn: #e3a64a; --warn-soft: #33281a;
    --bad: #f08a80; --bad-soft: #3a1f1c; --done: #6f6c64; --bar: #4f9e96;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1c1a; --surface-2: #232220; --text: #ecebe6; --muted: #a29f96;
  --line: #34322e; --accent: #5fb3aa; --accent-soft: #1f3331; --accent-text: #0e1716;
  --good: #6cc48f; --good-soft: #1b2d22; --warn: #e3a64a; --warn-soft: #33281a;
  --bad: #f08a80; --bad-soft: #3a1f1c; --done: #6f6c64; --bar: #4f9e96;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.side {
  width: 232px; flex: 0 0 232px; background: var(--surface); border-right: 1px solid var(--line);
  padding: 20px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; }
.brand svg { width: 30px; height: 30px; flex: 0 0 30px; }
.brand b { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0;
  background: none; padding: 10px 10px; border-radius: 9px; cursor: pointer; min-height: 44px; font-size: 15px;
}
.nav button svg { width: 20px; height: 20px; flex: 0 0 20px; stroke: currentColor; }
.nav button:hover { background: var(--surface-2); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: 18px; padding: 12px 10px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

.main { flex: 1; min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }

.bottom-nav { display: none; }

@media (max-width: 860px) {
  .side { display: none; }
  .main { padding: 16px 16px calc(92px + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav button {
    flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center;
    gap: 2px; font-size: 11px; padding: 6px 2px; min-height: 52px; border-radius: 10px; cursor: pointer; position: relative;
  }
  .bottom-nav svg { width: 24px; height: 24px; stroke: currentColor; }
  .bottom-nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }
  .bottom-nav .dot { position: absolute; top: 4px; right: calc(50% - 18px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); }
  h1 { font-size: 20px; }
}

/* ---------- Bausteine ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .grow { flex: 1; }
.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.section { margin-top: 18px; }

.kpi { padding: 14px 16px; }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
@media (max-width: 480px) { .kpi .value { font-size: 20px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--surface); padding: 9px 14px; border-radius: 10px; cursor: pointer; min-height: 44px;
  font-size: 15px; font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 18px; height: 18px; stroke: currentColor; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.btn.ghost { border-color: transparent; background: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px;
  font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.ampel { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: 0 0 12px; }
.ampel.good { background: var(--good); } .ampel.warn { background: var(--warn); } .ampel.bad { background: var(--bad); }

/* Listen und Tabellen */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line);
  cursor: pointer; min-height: 52px;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 560; }
.row .meta { font-size: 13px; color: var(--muted); margin-top: 1px; }
.row .right { text-align: right; flex: 0 0 auto; }
.empty { color: var(--muted); padding: 18px 4px; font-size: 15px; }

.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl td.r, .tbl th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 650; border-bottom: 0; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; }
.alert + .alert { margin-top: 8px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--accent-soft); color: var(--accent); }
.alert b { font-weight: 650; }
.alert .act { margin-left: auto; }

.bar { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); } .bar.good > i { background: var(--good); }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; min-height: 36px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; min-height: 36px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }

/* ---------- Gantt ---------- */
.gantt { position: relative; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); max-height: 72vh; -webkit-overflow-scrolling: touch; }
.g-inner { position: relative; }
.g-head { position: sticky; top: 0; z-index: 3; display: flex; background: var(--surface); border-bottom: 1px solid var(--line); height: 34px; }
.g-head .g-corner { position: sticky; left: 0; z-index: 4; background: var(--surface); border-right: 1px solid var(--line); font-size: 12px; color: var(--muted); padding: 9px 10px; }
.g-months { position: relative; height: 34px; }
.g-month { position: absolute; top: 0; height: 34px; font-size: 12px; color: var(--muted); padding: 9px 6px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.g-row { display: flex; height: 40px; border-bottom: 1px solid var(--line); cursor: pointer; }
.g-row:hover .g-name, .g-row:hover .g-track { background: var(--surface-2); }
.g-name {
  position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--line);
  padding: 0 10px; display: flex; align-items: center; gap: 6px; font-size: 13.5px; overflow: hidden;
}
.g-name span.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-name .crit { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); flex: 0 0 7px; }
.g-track { position: relative; }
.g-bar {
  position: absolute; top: 10px; height: 20px; border-radius: 5px; background: var(--bar);
  min-width: 4px; overflow: hidden;
}
.g-bar.crit { background: var(--bad); }
.g-bar.done { background: var(--done); }
.g-bar .prog { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,255,255,.35); }
.g-slack { position: absolute; top: 18px; height: 4px; border-top: 2px dotted var(--muted); opacity: .55; }
.g-ms { position: absolute; top: 12px; width: 16px; height: 16px; transform: rotate(45deg); background: var(--text); border-radius: 2px; margin-left: -8px; }
.g-ms.crit { background: var(--bad); }
.g-ms.done { background: var(--done); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .7; z-index: 1; pointer-events: none; }
.g-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); pointer-events: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Chart ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .axis { stroke: var(--line); }
.chart .band { fill: var(--accent); opacity: .12; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .plan { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .pt { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.chart .pt.now { fill: var(--accent); }

/* ---------- Dialog ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,20,18,.45); z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 16px;
}
.dialog {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.dialog header { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
.dialog header h2 { flex: 1; }
.dialog .body { padding: 8px 20px 12px; overflow-y: auto; }
.dialog footer { padding: 12px 20px 18px; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.dialog footer .grow { flex: 1; }
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: 0; }
  .dialog { border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .dialog footer { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}
.field { margin: 12px 0; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=password], .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px;
  padding: 10px 12px; min-height: 46px; font-size: 16px;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.field .checks { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 6px; background: var(--surface-2); }
.check { display: flex; align-items: center; gap: 10px; padding: 7px 6px; min-height: 40px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 20px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .two { grid-template-columns: 1fr; } }

/* ---------- Login ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 26px; }
.login .brand { padding: 0 0 12px; }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; min-height: 20px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 60; background: var(--text);
  color: var(--bg); padding: 11px 16px; border-radius: 10px; font-size: 14.5px; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
@media (max-width: 860px) { .toast { bottom: calc(86px + env(safe-area-inset-bottom)); } }

.tag-crit { color: var(--bad); font-weight: 600; }
.split { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.stack > * + * { margin-top: 6px; }
.prewrap { white-space: pre-wrap; }
.offline { position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 70; }
@media (min-width: 861px) { .mobile-only-nav { display: none; } }
.grid > .card + .card { margin-top: 0; }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { opacity: 1; color: var(--text); -webkit-text-fill-color: var(--text); }
fieldset:disabled ::placeholder { -webkit-text-fill-color: transparent; color: transparent; }
