:root {
  --bg: #f6f5f1; --surface: #fffefb; --surface-2: #f0eee8; --line: #e2dfd7; --line-strong: #cdc9be;
  --ink: #1d1d1b; --ink-2: #52514e; --muted: #7a7872;
  --accent: #c4622d; --accent-ink: #fff; --accent-soft: #f7e6dc;
  --good: #0ca30c; --warning: #c98500; --serious: #ec835a; --critical: #d03b3b;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c; --line-strong: #44443f;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #9b9a92;
    --accent: #e07b45; --accent-ink: #1a1a19; --accent-soft: #3a2619;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --line: #2f2f2c; --line-strong: #44443f;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #9b9a92;
  --accent: #e07b45; --accent-ink: #1a1a19; --accent-soft: #3a2619;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tnum { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 12px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Layout */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 14px; font-weight: 700; }
.brand img { width: 30px; height: 30px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 20px; text-align: center; }
.side .foot { margin-top: auto; padding: 10px; font-size: .82rem; color: var(--muted); }
.main { padding: 22px 28px 90px; min-width: 0; max-width: 1400px; }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.bottomnav { display: none; }
.fab { position: fixed; right: 18px; bottom: 82px; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-size: 26px; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; display: none; z-index: 30; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 14px 16px 96px; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: .7rem; color: var(--muted); text-decoration: none; background: none; border: 0; font-family: inherit; }
  .bottomnav .ico { font-size: 1.2rem; }
  .bottomnav .active { color: var(--accent); }
  .fab { display: block; }
  h1 { font-size: 1.25rem; }
}

/* Karten & Kacheln */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.flat { box-shadow: none; }
.card h2 { margin-bottom: 10px; }
.card.pad0 { padding: 0; overflow: hidden; }
.tile .label { color: var(--ink-2); font-size: .82rem; }
.tile .value { font-size: 1.55rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: .82rem; margin-top: 2px; }

/* Listen & Tabellen */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list > li.click { cursor: pointer; }
.list > li.click:hover { background: var(--surface-2); }
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: .8rem; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); }

/* Formulare */
label.f { display: block; }
label.f > span { display: block; font-size: .8rem; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form .full { grid-column: 1 / -1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550; border-radius: 8px; padding: 8px 14px; min-height: 38px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--critical); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.rec { background: var(--critical); color: #fff; border-color: var(--critical); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.good { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, transparent); }
.badge.serious { color: var(--serious); background: color-mix(in srgb, var(--serious) 16%, transparent); }
.badge.critical { color: var(--critical); background: color-mix(in srgb, var(--critical) 14%, transparent); }
.badge.accent { color: var(--accent); background: var(--accent-soft); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* Fortschritt */
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(10,10,10,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 4vh 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 720px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal.wide { max-width: 1000px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 8px; }
.modal .body { padding: 16px 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal footer .left { margin-right: auto; }
@media (max-width: 600px) { .backdrop { padding: 0; } .modal { border-radius: 0; min-height: 100vh; } }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 200; box-shadow: var(--shadow); max-width: 90vw; }
.toast.err { background: var(--critical); color: #fff; }

/* Medien */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: .68rem; padding: 1px 6px; border-radius: 6px; }
.thumb .x { position: absolute; right: 3px; top: 3px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 300; display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 96vw; max-height: 88vh; }
.lightbox .cap { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; color: #ddd; font-size: .9rem; }
.lightbox button { position: absolute; top: 12px; right: 12px; }

/* Aufnahme */
.recorder { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 14px; background: var(--surface-2); }
.level { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.level > i { display: block; height: 100%; background: var(--critical); transition: width .08s; }

/* Gantt */
.gantt { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: 75vh; }
.gantt svg { display: block; }
.gantt text { font-family: var(--font); }

/* Grundriss */
.plan { position: relative; display: inline-block; max-width: 100%; touch-action: manipulation; }
.plan img { max-width: 100%; display: block; border-radius: 8px; border: 1px solid var(--line); user-select: none; }
.pin { position: absolute; transform: translate(-50%, -100%); cursor: pointer; font-size: 11px; font-weight: 700; color: #fff; background: var(--critical); border-radius: 12px 12px 12px 2px; padding: 2px 6px; border: 2px solid var(--surface); white-space: nowrap; }
.pin.raum { background: var(--s1); transform: translate(-50%, -50%); border-radius: 6px; font-weight: 600; }
.pin.done { background: var(--good); }
.pin.sel { outline: 3px solid var(--accent); }

/* Diagramme */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart text { fill: var(--ink-2); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82rem; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.tip { position: fixed; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: var(--shadow); z-index: 400; min-width: 160px; }
.tip b { display: block; margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }

.savebar { justify-content: flex-end; position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; border-top: 1px solid var(--line); z-index: 5; }
@media (max-width: 860px) { .savebar { bottom: calc(58px + env(safe-area-inset-bottom)); } }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.login { max-width: 420px; margin: 12vh auto; text-align: center; padding: 0 16px; }
.login img { width: 72px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; font: inherit; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: .9rem; }
.alert.warn { background: color-mix(in srgb, var(--warning) 16%, transparent); }
.alert.err { background: color-mix(in srgb, var(--critical) 14%, transparent); }
.timeline > div { border-left: 2px solid var(--line-strong); padding: 0 0 12px 12px; position: relative; }
.timeline > div::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media print { .side, .bottomnav, .fab, .noprint { display: none !important; } .app { display: block; } .card { box-shadow: none; } }

/* Wiki */
.wiki-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.wiki-layout.mit-seite { grid-template-columns: minmax(240px, 320px) 1fr; align-items: start; }
.wiki-zurueck { display: none; }
@media (max-width: 860px) {
  .wiki-layout.mit-seite { grid-template-columns: 1fr; }
  .wiki-layout.mit-seite .wiki-liste { display: none; }
  .wiki-zurueck { display: inline; }
}
.md { line-height: 1.55; overflow-wrap: anywhere; }
.md h2 { font-size: 1.25rem; margin: 18px 0 8px; } .md h3 { font-size: 1.08rem; margin: 16px 0 6px; } .md h4, .md h5 { font-size: 1rem; margin: 14px 0 4px; }
.md p { margin: 0 0 10px; } .md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li.task { list-style: none; margin-left: -20px; }
.md blockquote { margin: 0 0 10px; padding: 6px 12px; border-left: 3px solid var(--accent); background: var(--surface-2); }
.md code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; font-size: .9em; }
.md .tablewrap { margin: 0 0 12px; overflow-x: auto; } .md table td, .md table th { vertical-align: top; }
.md a.wikilink { text-decoration: underline dotted; }
@media print { .wiki-liste, .pagehead { display: none !important; } .wiki-layout.mit-seite { display: block; } }
