:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1c2430; --muted: #5d6b7c; --line: #e2e6ec;
  --brand: #1f4e79; --brand-2: #2d6aa3; --brand-soft: #e8f0f8;
  --ok: #1d7a4c; --warn: #a86200; --warn-soft: #fff4e2; --crit: #b42318; --crit-soft: #fdecea; --soon-soft: #eef4fb;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* Kopfzeile */
.topbar { background: var(--brand); color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: 0 1.25rem; display: flex; align-items: center; gap: 1.5rem; height: 56px; }
.logo { font-weight: 700; letter-spacing: .12em; color: #fff; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.logo:hover { text-decoration: none; }
.logo .eye { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--brand); font-size: .9rem; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a { color: #dce8f5; padding: .4rem .75rem; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.userbox a, .userbox button { color: #dce8f5; }
.userbox button { background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.subnav { background: #fff; border-bottom: 1px solid var(--line); }
.subnav .inner { max-width: 1280px; margin: 0 auto; padding: 0 1.25rem; display: flex; gap: 1.25rem; height: 44px; align-items: center; }
.subnav a { color: var(--muted); font-size: .92rem; }
.subnav a.active { color: var(--ink); font-weight: 600; }

main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

/* Karten, Raster */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 1rem; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1.25rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; color: var(--ink);
       padding: .45rem .9rem; border-radius: 8px; font: inherit; font-size: .92rem; cursor: pointer; }
.btn:hover { text-decoration: none; background: #f8f9fb; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { color: var(--crit); border-color: #f2c6c2; }
.btn-danger:hover { background: var(--crit-soft); }
.btn-ms { background: #2f2f2f; color: #fff; border-color: #2f2f2f; padding: .7rem 1.2rem; font-size: 1rem; }
.btn-ms:hover { background: #444; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
form.inline { display: inline; }

/* Tabellen */
table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
                border-bottom: 1px solid var(--line); padding: .6rem .75rem; background: #fafbfc; }
table.list td { border-bottom: 1px solid var(--line); padding: .6rem .75rem; vertical-align: top; }
table.list tr:hover td { background: #fafcff; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }

/* Badges / Fristen */
.badge { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 99px; background: #eef1f5; color: var(--muted); white-space: nowrap; }
.badge.active { background: #e7f5ee; color: var(--ok); }
.badge.cancelled { background: var(--warn-soft); color: var(--warn); }
.badge.ended, .badge.expired { background: #eef1f5; color: var(--muted); }
.badge.private { background: #f1eafd; color: #5b3a9b; }
.badge.dep { background: var(--brand-soft); color: var(--brand); }
.badge.read { background: #f3f4f6; color: var(--muted); }
.due { font-weight: 600; white-space: nowrap; }
.due.critical { color: var(--crit); }
.due.warning { color: var(--warn); }
.due.soon { color: var(--brand-2); }
tr.critical td:first-child { box-shadow: inset 3px 0 0 var(--crit); }
tr.warning td:first-child { box-shadow: inset 3px 0 0 var(--warn); }

/* Filter */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { min-width: 240px; }
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid #cfd6df; border-radius: 7px; background: #fff; color: var(--ink); max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand-2); }
textarea { width: 100%; }

/* Formulare */
.form-section { margin-bottom: 1rem; }
.form-section h2 { display: flex; align-items: center; gap: .5rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; }
.field.wide { grid-column: 1 / -1; }
.field .help { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.field .errorlist { list-style: none; margin: .25rem 0 0; padding: 0; color: var(--crit); font-size: .85rem; }
.field.check label { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.field.deps { margin-bottom: 1rem; }
.field.deps > div[id^="id_"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .15rem .75rem;
  background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; }
.field.deps > div[id^="id_"] label { font-weight: 400; display: flex; gap: .45rem; align-items: center; font-size: .92rem; margin: 0; }
.access-box { border: 1px dashed #c9d3df; border-radius: 8px; padding: 1rem; }
.access-box.disabled { opacity: .45; pointer-events: none; }
.form-actions { position: sticky; bottom: 0; background: rgba(245,246,248,.95); padding: .75rem 0; display: flex; gap: .5rem; border-top: 1px solid var(--line); }
.errorlist.nonfield { background: var(--crit-soft); color: var(--crit); padding: .75rem 1rem; border-radius: 8px; list-style: none; }

/* Meldungen */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .5rem; background: var(--brand-soft); }
.messages li.success { background: #e7f5ee; color: #135c38; }
.messages li.warning { background: var(--warn-soft); color: #7a4700; }
.messages li.error { background: var(--crit-soft); color: var(--crit); }

/* Startseite */
.tile h2 { display: flex; align-items: center; gap: .5rem; }
.stat { font-size: 1.8rem; font-weight: 700; }
.stats { display: flex; gap: 2rem; margin: .5rem 0 1rem; }
.upcoming { list-style: none; padding: 0; margin: 0; }
.upcoming li { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-top: 1px solid var(--line); }

/* Verlauf */
.history { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.history li { padding: .5rem 0; border-top: 1px solid var(--line); }
.history .changes { color: var(--muted); margin-top: .15rem; word-break: break-word; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #1f4e79 0%, #163a5b 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 2.5rem; width: min(420px, 92vw); text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .eye-big { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1.8rem; margin: 0 auto 1rem; }
.login-card h1 { letter-spacing: .15em; }

.pagination { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
