:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1f2933;
    --muted: #6b7280;
    --line: #e2e8f0;
    --brand: #1f4e79;
    --brand-ink: #ffffff;
    --brand-accent: #5eb0ef;
    --primary: #1f6feb;
    --danger: #c23b3b;
    --rot: #d64545;
    --gelb: #e0a106;
    --gruen: #2f9e44;
    --offen: #94a3b8;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; }

/* ---------- Sidebar / Navigation ---------- */
.sidebar {
    width: 232px; flex-shrink: 0;
    background: var(--brand); color: var(--brand-ink);
    display: flex; flex-direction: column;
    position: sticky; top: 0; align-self: flex-start;
    height: 100vh; overflow-y: auto;
}
.brand {
    display: block; color: var(--brand-ink); text-decoration: none;
    padding: 1.1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand:hover { text-decoration: none; }
.brand-mark { display: block; font-weight: 700; font-size: 1.4rem; line-height: 1.1; }
.brand-fm { color: var(--brand-accent); }
.brand-sub { display: block; margin-top: .3rem; font-size: .72rem; color: #aec4de; letter-spacing: .02em; }

.mainnav { display: flex; flex-direction: column; gap: .12rem; padding: .6rem; flex: 1; }
.mainnav a {
    color: #d7e3f2; padding: .5rem .7rem; border-radius: 6px; font-size: .92rem;
}
.mainnav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }

.userbox {
    display: flex; flex-direction: column; align-items: flex-start; gap: .35rem;
    padding: .85rem 1.1rem; border-top: 1px solid rgba(255,255,255,.12);
    font-size: .85rem; color: #d7e3f2;
}
.userbox .inline { margin: 0; }
.linkbtn {
    background: none; border: none; color: #d7e3f2; cursor: pointer;
    font: inherit; padding: .2rem .3rem; text-decoration: underline;
}
.linkbtn:hover { color: #fff; }
.linkbtn.danger { color: var(--danger); text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; align-items: stretch; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.container { max-width: 1100px; width: 100%; margin: 1.4rem auto; padding: 0 1rem; }
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin: 1.2rem 0 .8rem; flex-wrap: wrap;
}
.page-head:first-child { margin-top: 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.footer { text-align: center; color: var(--muted); padding: 1.5rem 1rem; }

/* ---------- Flash ---------- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: .8rem; border: 1px solid transparent; }
.flash-success { background: #e7f6ec; border-color: #b6e3c4; color: #1c6b34; }
.flash-error   { background: #fce8e8; border-color: #f3bcbc; color: #9c2a2a; }
.flash-info    { background: #e8f0fc; border-color: #bcd3f3; color: #234e8c; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--panel); box-shadow: var(--shadow); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f0f3f6; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; color: #4b5563; }
.table tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table .actions { white-space: nowrap; }
.table .actions a { margin-right: .6rem; }
.row-inactive { opacity: .6; }
.row-expired { background: #fff7f0; }

/* ---------- Cards / Stats ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem; margin: 1rem 0; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card.stat { border-left: 5px solid var(--line); }
.card.stat .num { font-size: 1.9rem; font-weight: 700; }
.card.stat .lbl { color: var(--muted); font-size: .85rem; }
.card.stat.status-rot   { border-left-color: var(--rot); }
.card.stat.status-gelb  { border-left-color: var(--gelb); }
.card.stat.status-gruen { border-left-color: var(--gruen); }
.card.stat.status-offen { border-left-color: var(--offen); }

/* ---------- Badges / Pills ---------- */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; }
.badge.status-rot   { background: var(--rot); }
.badge.status-gelb  { background: var(--gelb); }
.badge.status-gruen { background: var(--gruen); }
.badge.status-offen { background: var(--offen); }
.pill { display: inline-block; padding: .05rem .45rem; border-radius: 999px; font-size: .78rem; background: #eef2f6; color: #4b5563; }
.pill-ok { background: #e7f6ec; color: #1c6b34; }
.pill-warn { background: #fde9d6; color: #9a4b09; }
.erg { font-size: .85rem; }
.erg-bad { color: var(--rot); font-weight: 600; }
.erg-mid { color: var(--gelb); }
.erg-ok  { color: var(--gruen); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .8rem; color: var(--muted); }

/* ---------- Detail grid ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem 1.5rem;
    background: var(--panel); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-grid .dt { display: block; font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }
.meta { display: flex; gap: 1.5rem; flex-wrap: wrap; color: #374151; margin-bottom: .5rem; }
.textblock { background: var(--panel); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.linklist { padding-left: 1.2rem; }

/* ---------- Forms ---------- */
.card.form { max-width: 720px; }
.card { background: var(--panel); }
.form label { display: block; margin-bottom: .9rem; font-weight: 600; font-size: .9rem; }
.form label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=number], .form input[type=date], .form select, .form textarea {
    display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem;
    border: 1px solid #cbd5e1; border-radius: 6px; font: inherit; font-weight: 400; background: #fff;
}
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid #bcd3f3; border-color: var(--primary); }
.form .check input { width: auto; margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }
.hint { color: var(--muted); font-size: .85rem; }
.hint-inline { color: var(--muted); font-weight: 400; font-size: .82rem; }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 .9rem; padding: .8rem 1rem; }
fieldset legend { font-weight: 600; font-size: .9rem; padding: 0 .4rem; }
.check-group label.check { margin-bottom: .4rem; }
.upload-box { background: #fbfcfe; }
.inline-form { display: flex; align-items: flex-end; gap: .8rem; margin-bottom: 1rem; flex-wrap: wrap; }
.inline-form label { margin: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-block; padding: .45rem .85rem; border-radius: 6px; border: 1px solid #cbd5e1;
    background: #fff; color: var(--ink); cursor: pointer; font: inherit; text-decoration: none; }
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1a5fd0; }
.btn-danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: #fcecec; }

/* ---------- Misc ---------- */
.empty { color: var(--muted); background: var(--panel); padding: 1rem; border-radius: var(--radius); box-shadow: var(--shadow); }
.hidden { display: none; }
.inline { display: inline; }
.login-wrap { max-width: 380px; margin: 8vh auto; }
.login-brand { text-align: center; margin-bottom: 1.4rem; }
.login-brand .brand-mark { font-size: 2rem; color: var(--brand); }
.login-brand .brand-fm { color: var(--primary); }
.login-brand .brand-sub { color: var(--muted); font-size: .8rem; margin-top: .35rem; }
.report-head { margin: 1rem 0; }

@media (max-width: 860px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: auto; height: auto; position: static; overflow: visible;
        flex-direction: row; flex-wrap: wrap; align-items: center;
        gap: .3rem .9rem; padding: .5rem .8rem;
    }
    .brand { padding: 0; border-bottom: none; }
    .brand-mark { font-size: 1.2rem; }
    .brand-sub { display: none; }
    .mainnav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; padding: .35rem 0 0; gap: .15rem; }
    .userbox {
        flex-direction: row; align-items: center; border-top: none;
        padding: 0; gap: .6rem; margin-left: auto;
    }
}

@media (max-width: 640px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Print (Stichtagsbericht) ---------- */
@media print {
    .sidebar, .footer, .no-print, .form-actions { display: none !important; }
    body { background: #fff; }
    .container { margin: 0; max-width: none; }
    .table { box-shadow: none; }
    .table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .badge { color: #000 !important; background: none !important; border: 1px solid #000; }
}

/* ---------- Öffentliche Kopfleiste (anonyme Seiten) ---------- */
.pubbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .7rem 1.2rem; background: var(--brand); color: #fff; }
.pubbar-brand { color: #fff; font-weight: 700; font-size: 1.3rem; text-decoration: none; }
.pubbar-brand:hover { text-decoration: none; }
.pubbar-nav { display: flex; align-items: center; gap: 1rem; }
.pubbar-nav a { color: #d7e3f2; }
.pubbar-nav a:hover { color: #fff; }
.pubbar-nav a.btn-primary { color: #fff; }

/* ---------- Footer-Links ---------- */
.footer-links { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: .6rem; }
.footer-links a { color: var(--muted); font-size: .85rem; }

/* ---------- Landing One-Pager ---------- */
.hero { text-align: center; padding: 3rem 1rem 2.5rem; }
.hero h1 { font-size: 2.3rem; line-height: 1.15; margin: 0 auto .8rem; max-width: 760px; }
.hero .lead { font-size: 1.15rem; color: #374151; max-width: 640px; margin: 0 auto 1.6rem; }
.hero .cta { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; }
.hero .cta .btn { padding: .7rem 1.3rem; font-size: 1.02rem; }
.hero .trial-note { color: var(--muted); font-size: .85rem; margin-top: .9rem; }
.section { padding: 1.6rem 0; }
.section h2 { text-align: center; font-size: 1.5rem; margin: 0 0 1.4rem; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.feature { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem; }
.feature h3 { margin: .2rem 0 .4rem; font-size: 1.05rem; color: var(--brand); }
.feature p { margin: 0; color: #4b5563; font-size: .92rem; }
.audience { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.pill-lg { background: #eef4fb; color: #234e8c; border-radius: 999px; padding: .4rem 1rem; font-weight: 600; }
.note-box { background: #eef4fb; border: 1px solid #cfe0f5; border-radius: var(--radius);
    padding: 1.1rem 1.3rem; max-width: 760px; margin: 0 auto; color: #234e8c; }
.cta-block { text-align: center; padding: 2.2rem 1rem 1rem; }

/* ---------- Rechtsseiten (lesbarer Fließtext) ---------- */
.legal { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.6rem 1.8rem; max-width: 820px; margin: 0 auto; }
.legal h1 { margin-bottom: .3rem; }
.legal h2 { font-size: 1.1rem; margin: 1.6rem 0 .5rem; }
.legal p, .legal li { color: #374151; }
.legal ul { padding-left: 1.3rem; }
.legal .platzhalter { background: #fff5d6; border-bottom: 1px dashed #d9a300; padding: 0 .2rem; }
.legal .muster-hinweis { background: #fde9d6; border: 1px solid #f3c79a; color: #9a4b09;
    border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1.2rem; font-size: .9rem; }

@media (max-width: 640px) { .hero h1 { font-size: 1.8rem; } }
