:root {
    --bg: #0f1720;
    --bg-elevated: #16222d;
    --bg-soft: #1d2d3c;
    --text: #edf6ff;
    --muted: #9db5c9;
    --primary: #176b87;
    --accent: #ffb703;
    --danger: #d62839;
    --success: #2a9d8f;
    --border: rgba(255, 255, 255, 0.12);
    --shadow: 0 18px 40px rgba(4, 11, 18, 0.35);
    --radius: 18px;
    --radius-sm: 12px;
    --font: "Segoe UI", Tahoma, sans-serif;
}

html[data-theme="light"] {
    --bg: #edf3f8;
    --bg-elevated: #ffffff;
    --bg-soft: #dfe8f0;
    --text: #11202d;
    --muted: #496477;
    --primary: #0b6e8a;
    --accent: #d97706;
    --border: rgba(17, 32, 45, 0.12);
    --shadow: 0 20px 42px rgba(28, 50, 73, 0.12);
}

html[data-theme="bos"] {
    --bg: #10181a;
    --bg-elevated: #162327;
    --bg-soft: #1f3034;
    --text: #f5fff7;
    --muted: #9ec4aa;
    --primary: #2a9d8f;
    --accent: #e9c46a;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(255, 183, 3, 0.12), transparent 28%),
        linear-gradient(160deg, var(--bg) 0%, #0a1118 100%);
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
    padding: 1.5rem;
    background: linear-gradient(180deg, rgba(6, 12, 18, 0.92), rgba(17, 31, 43, 0.92));
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
}
.brand {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 1rem;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.brand img, .public-brand img { width: 44px; height: 44px; }
.brand strong, .public-brand span { display: block; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: 0.88rem; }
.nav { display: grid; gap: 0.45rem; }
.nav a, .tenant-switcher summary {
    padding: 0.85rem 1rem;
    border-radius: 14px;
    color: var(--muted);
    transition: 0.2s ease;
    cursor: pointer;
}
.nav a:hover, .nav a.active, .tenant-switcher summary:hover {
    color: var(--text);
    background: rgba(42, 157, 143, 0.14);
}

.main { padding: 1.5rem; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.topbar h1, .panel h2, .hero h1 { margin: 0; }
.topbar p { margin: 0.4rem 0 0; color: var(--muted); }
.topbar-actions, .button-row, .toolbar-actions, .actions, .hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.page-content, .content-grid, .panel-grid, .leitstelle-grid { display: grid; gap: 1rem; }
.content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.leitstelle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.panel-map { grid-column: 1 / -1; }

.panel, .auth-card, .hero-panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.15rem;
}
.panel.narrow { max-width: 700px; margin: 3rem auto; }
.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.panel-header p { margin: 0; color: var(--muted); }
.stat-card strong { display: block; font-size: 2rem; margin-bottom: 0.35rem; }
.stat-card span { color: var(--muted); }

.form-grid { display: grid; gap: 1rem; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.full-span { grid-column: 1 / -1; }
label span, legend { display: block; margin-bottom: 0.45rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="search"], select, textarea {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 0.82rem 0.9rem;
    color: var(--text);
    background: rgba(0, 0, 0, 0.18);
}
textarea { min-height: 120px; resize: vertical; }
select[multiple] { min-height: 180px; }

.button, button.button, .theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.78rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.button:hover, .theme-toggle:hover { transform: translateY(-1px); }
.button.primary, .theme-toggle { background: var(--primary); color: #fff; }
.button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
.button.danger { background: var(--danger); color: #fff; }

.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.table-wrapper { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 0.85rem 0.7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.9rem; }

.flash-stack { display: grid; gap: 0.6rem; margin-bottom: 1rem; }
.flash { padding: 0.9rem 1rem; border-radius: 14px; border: 1px solid transparent; }
.flash-success { background: rgba(42, 157, 143, 0.14); border-color: rgba(42, 157, 143, 0.35); }
.flash-error { background: rgba(214, 40, 57, 0.15); border-color: rgba(214, 40, 57, 0.28); }
.flash-info { background: rgba(23, 107, 135, 0.16); border-color: rgba(23, 107, 135, 0.3); }

.timeline { display: grid; gap: 0.75rem; }
.timeline-item { padding: 0.85rem; border-radius: 14px; background: rgba(255, 255, 255, 0.04); }
.timeline-item strong, .timeline-item span, .timeline-item small { display: block; }
.timeline-item small { color: var(--muted); margin-top: 0.35rem; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.detail-grid strong { display: block; color: var(--muted); margin-bottom: 0.35rem; }
.detail-grid p { margin: 0; }
.tag-list { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.tag { padding: 0.4rem 0.75rem; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.65rem; }
.checkbox-grid label { display: flex; gap: 0.55rem; align-items: center; padding: 0.7rem; border-radius: 12px; background: rgba(255,255,255,0.04); }

.map { width: 100%; height: 420px; border-radius: var(--radius); overflow: hidden; }
.map.large { height: 72vh; }

.hero {
    display: grid;
    grid-template-columns: 1.35fr 0.95fr;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
}
.eyebrow { display: inline-block; text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); font-size: 0.8rem; margin-bottom: 0.65rem; }
.hero p { color: var(--muted); }
.hero-panel ul { margin: 0; padding-left: 1.1rem; }

.public-body { min-height: 100vh; }
.public-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(0,0,0,0.15);
}
.public-brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; }
.public-nav { display: flex; gap: 1rem; color: var(--muted); }
.public-main { padding: 1.5rem; max-width: 1280px; margin: 0 auto; }
.auth-card { max-width: 540px; margin: 3rem auto; }
.auth-card.wide { max-width: 900px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; color: var(--muted); }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.news-card + .news-card { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.link-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.85rem; }

@media (max-width: 1080px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .leitstelle-grid, .content-grid, .hero, .form-grid.two-columns { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .main, .public-main, .sidebar { padding: 1rem; }
    .topbar, .panel-header, .public-header { flex-direction: column; align-items: stretch; }
    table { min-width: 620px; }
}
