:root {
  --bg: #f4f7fa; --surface: #fff; --text: #1d2733; --muted: #6b7785; --border: #d9e1e8;
  --accent: #1f6fb2; --accent-text: #fff; --ok: #e3f4e8; --ok-text: #1e6b37;
  --err: #fbe5e5; --err-text: #9b1c1c; --open: #fff8e1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c; --surface: #1a2129; --text: #e4e9ee; --muted: #8d99a6; --border: #2c3640;
    --accent: #5aa7e6; --accent-text: #0b1117; --ok: #183323; --ok-text: #8fd8a6;
    --err: #3a1d1d; --err-text: #f2a7a7; --open: #33301b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
.topbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; flex-wrap: wrap; gap: 1rem; flex: 1; }
.topbar nav a { text-decoration: none; }
.logout { display: flex; gap: .5rem; align-items: center; }
main { padding: 1.5rem 1.25rem; max-width: 1200px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.login { width: 100%; max-width: 360px; display: grid; gap: .75rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; align-items: end; }
.grid .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; margin-bottom: 1rem; }
.columns { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
@media (max-width: 800px) { .columns { grid-template-columns: 1fr; } }
label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--text); margin-bottom: .4rem; }
input, select, textarea { font: inherit; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; }
button { font: inherit; padding: .45rem .9rem; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
button.link { background: none; color: var(--accent); padding: 0; }
button.small { padding: .15rem .5rem; }
button.danger { background: var(--err-text); color: var(--surface); }
form.inline { display: flex; gap: .5rem; margin-top: .75rem; }
td.actions { display: flex; gap: .25rem; }
td.actions form { margin: 0; }
.table-wrap, table { width: 100%; }
table { border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: block; overflow-x: auto; }
@media (min-width: 900px) { table { display: table; } }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num { text-align: right; white-space: nowrap; }
tr.inactive td { color: var(--muted); }
tr.open td { background: var(--open); }
.muted { color: var(--muted); }
.flash { padding: .6rem .8rem; border-radius: 6px; margin-bottom: 1rem; }
.flash.ok { background: var(--ok); color: var(--ok-text); }
.flash.err { background: var(--err); color: var(--err-text); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.stat { color: var(--muted); }
.stat span { display: block; font-size: 2rem; font-weight: 700; color: var(--text); }

/* --- v2: Organisationen, Aufträge, Einsätze --- */
.topbar nav a.active { font-weight: 600; text-decoration: underline; text-underline-offset: 6px; }
.userbox { display: flex; gap: 1rem; align-items: center; margin-left: auto; }
.orgswitch { text-decoration: none; font-weight: 600; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .1rem .5rem; border-radius: 999px; background: var(--border); color: var(--text); vertical-align: middle; }
.badge.status-active, .badge.status-running { background: var(--ok); color: var(--ok-text); }
.badge.status-cancelled { background: var(--err); color: var(--err-text); }
.plate { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; letter-spacing: .03em; border: 1px solid var(--border); border-radius: 4px; padding: 0 .3rem; white-space: nowrap; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .5rem .9rem; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { border-color: var(--accent); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem 1.5rem; margin: 0 0 1.25rem; }
.facts > div { display: grid; gap: .1rem; }
.facts .muted { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.actions-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
button.secondary { background: var(--border); color: var(--text); }
.map { height: 420px; border-radius: 8px; border: 1px solid var(--border); position: relative; background: var(--surface); }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); z-index: 500; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .5rem 0 1rem; font-size: .85rem; color: var(--muted); }
.legend i, .dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; }
.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.attachment { display: grid; gap: .25rem; text-decoration: none; color: var(--text); padding: .5rem; overflow: hidden; }
.attachment img { width: 100%; height: 100px; object-fit: cover; border-radius: 4px; background: var(--bg); }
.attachment span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileicon { font-size: 3rem; text-align: center; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tile { display: grid; gap: .25rem; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); }
.prewrap { white-space: pre-wrap; }
.small { font-size: .85rem; }
.ok-text { color: var(--ok-text); font-weight: 600; }
.err-text { color: var(--err-text); font-weight: 600; }
.correction { margin-bottom: .5rem; }
form.inline { flex-wrap: wrap; align-items: center; }
form.inline input:not([type=checkbox]), form.inline select { width: auto; flex: 1 1 180px; }
main > form.inline { margin-top: .75rem; }
.small-map { height: 280px; }
.signature { display: inline-grid; gap: .25rem; justify-items: center; padding: .75rem 1.5rem; }
.signature img { max-width: 360px; width: 100%; background: #fff; border-radius: 6px; }
.badge.status-open { background: var(--open); color: var(--text); }
.badge.status-closed { background: var(--ok); color: var(--ok-text); }
.joincode { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.joincode > div { display: grid; gap: .3rem; max-width: 640px; }
.joincode .code { font: 700 1.8rem/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .35em; color: var(--text); }
