* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    color-scheme: light;
    --color-bg: #f9fafb;
    --color-surface: #ffffff;
    --color-surface-2: #f9fafb;
    --color-surface-hover: #f3f4f6;
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;
    --color-text: #1f2937;
    --color-text-strong: #111827;
    --color-text-heading: #374151;
    --color-text-muted: #6b7280;
    --color-text-faint: #9ca3af;
    --color-accent: #1d4ed8;
    --color-accent-hover: #1e40af;
    --color-accent-soft: #eff6ff;
    --color-accent-soft-hover: #dbeafe;
    --color-accent-border: #bfdbfe;
    --color-input-border: #d1d5db;
    --color-btn-text: #374151;
    --color-danger: #dc2626;
    --color-danger-soft: #fef2f2;
    --color-danger-border: #fecaca;
    --color-success-soft: #dcfce7;
    --color-success-text: #166534;
    --color-warning-soft: #fef9c3;
    --color-warning-text: #854d0e;
    --color-relevance-hoch-bg: #fecaca;
    --color-relevance-hoch-text: #991b1b;
    --color-relevance-mittel-bg: #fef3c7;
    --color-relevance-mittel-text: #92400e;
    --color-relevance-tief-bg: #f3f4f6;
    --color-relevance-tief-text: #6b7280;
    --color-kategorie-bg: #eff6ff;
    --color-kategorie-text: #1d4ed8;
    --color-gemeinde-bg: #f0fdf4;
    --color-gemeinde-text: #166534;
    --color-gemeinde-hover: #dcfce7;
    --color-pill-bg: #eff6ff;
    --color-pill-text: #1d4ed8;
    --color-trend-bar: #3b82f6;
    --color-modal-overlay: rgba(17, 24, 39, 0.5);
    --color-shadow: rgba(29, 78, 216, 0.08);
    --color-focus-ring: rgba(29, 78, 216, 0.1);
    --color-artikel-text: #374151;
    --color-modal-shadow: rgba(0, 0, 0, 0.2);
    --color-toast-bg: #065f46;
    --color-toast-text: #ffffff;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --color-bg: #0b1120;
    --color-surface: #151f32;
    --color-surface-2: #1a2740;
    --color-surface-hover: #243049;
    --color-border: #2d3f5c;
    --color-border-light: #243049;
    --color-text: #e2e8f0;
    --color-text-strong: #f1f5f9;
    --color-text-heading: #cbd5e1;
    --color-text-muted: #94a3b8;
    --color-text-faint: #64748b;
    --color-accent: #60a5fa;
    --color-accent-hover: #93c5fd;
    --color-accent-soft: #1e3a5f;
    --color-accent-soft-hover: #254875;
    --color-accent-border: #3b82f6;
    --color-input-border: #3d5275;
    --color-btn-text: #e2e8f0;
    --color-danger: #f87171;
    --color-danger-soft: #3f1d1d;
    --color-danger-border: #7f1d1d;
    --color-success-soft: #14532d;
    --color-success-text: #86efac;
    --color-warning-soft: #422006;
    --color-warning-text: #fcd34d;
    --color-relevance-hoch-bg: #450a0a;
    --color-relevance-hoch-text: #fca5a5;
    --color-relevance-mittel-bg: #451a03;
    --color-relevance-mittel-text: #fcd34d;
    --color-relevance-tief-bg: #1e293b;
    --color-relevance-tief-text: #94a3b8;
    --color-kategorie-bg: #1e3a5f;
    --color-kategorie-text: #93c5fd;
    --color-gemeinde-bg: #14532d;
    --color-gemeinde-text: #86efac;
    --color-gemeinde-hover: #166534;
    --color-pill-bg: #1e3a5f;
    --color-pill-text: #93c5fd;
    --color-trend-bar: #60a5fa;
    --color-modal-overlay: rgba(0, 0, 0, 0.65);
    --color-shadow: rgba(0, 0, 0, 0.35);
    --color-focus-ring: rgba(96, 165, 250, 0.25);
    --color-artikel-text: #cbd5e1;
    --color-modal-shadow: rgba(0, 0, 0, 0.5);
    --color-toast-bg: #064e3b;
    --color-toast-text: #ecfdf5;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    transition: background-color 0.2s, color 0.2s;
}

a {
    color: var(--color-accent);
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header — scoped to site header only (avoid sticky on in-content <header> e.g. dossier) */
body > header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 0 10px;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.2s, border-color 0.2s;
}

body > header .header-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 1100px;
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

body > header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-strong);
    flex-shrink: 0;
    margin: 0;
}

.site-home {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text-strong);
    cursor: pointer;
    transition: color 0.15s;
}

.site-home:hover {
    color: var(--color-accent);
}

.header-utilities {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: 2px;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.logout-form {
    display: inline-flex;
    margin: 0;
}

.nav-btn {
    background: none;
    border: none;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    transition: all 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
}

.nav-btn.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.logout-btn {
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.logout-btn:hover {
    border-color: var(--color-danger-border);
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.theme-toggle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--color-input-border);
    border-radius: 8px;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.theme-toggle:hover {
    background: var(--color-surface-hover);
    color: var(--color-text);
    border-color: var(--color-accent-border);
}

/* Main — .container wins over bare `main` (class beats element), so set vertical padding here */
main.container {
    padding-top: 32px;
    padding-bottom: 32px;
}

/* Typography */
h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-strong);
}

h2 a {
    color: var(--color-text-strong);
    text-decoration: none;
}

h2 a:hover {
    color: var(--color-accent);
}

h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-heading);
}

.muted {
    color: var(--color-text-muted);
    font-size: 13px;
}

.error {
    color: var(--color-danger);
    font-size: 13px;
}

.empty {
    color: var(--color-text-faint);
    font-style: italic;
    text-align: center;
    padding: 24px;
}

/* Header Row */
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
}

.header-row-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-row-title h2 {
    margin: 0;
}

.header-row-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

thead th {
    background: var(--color-surface-2);
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.sort-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.sort-btn:hover {
    color: var(--color-accent);
}

.sort-btn-active {
    color: var(--color-accent);
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: top;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--color-surface-hover);
}

td.actions {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid var(--color-input-border);
    background: var(--color-surface);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--color-btn-text);
}

.btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-text-faint);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

a.btn {
    text-decoration: none;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
    border-color: var(--color-accent);
}

.btn-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

.btn-danger {
    color: var(--color-danger);
    border-color: var(--color-danger-border);
}

.btn-danger:hover {
    background: var(--color-danger-soft);
    border-color: var(--color-danger);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-active {
    background: var(--color-success-soft);
    color: var(--color-success-text);
}

.badge-inactive {
    background: var(--color-surface-hover);
    color: var(--color-text-muted);
}

.badge-sent {
    background: var(--color-success-soft);
    color: var(--color-success-text);
}

.badge-failed {
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.badge-started {
    background: var(--color-warning-soft);
    color: var(--color-warning-text);
}

/* Forms */
.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 24px;
    max-width: 600px;
}

.form-card label {
    display: block;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-heading);
}

.form-card input[type="text"],
.form-card input[type="url"],
.form-card input[type="password"],
.form-card textarea,
.form-card select {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 12px;
    border: 1px solid var(--color-input-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s;
}

.form-card input:focus,
.form-card textarea:focus,
.form-card select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* Login */
.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, var(--color-accent-soft) 0, transparent 34rem),
        linear-gradient(135deg, var(--color-bg), var(--color-surface-2));
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
}

.login-panel {
    width: min(100%, 440px);
    padding: 34px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: color-mix(in srgb, var(--color-surface) 94%, transparent);
    box-shadow: 0 24px 70px var(--color-shadow);
}

.login-kicker {
    display: inline-flex;
    margin-bottom: 14px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.login-panel h1 {
    margin-bottom: 10px;
    color: var(--color-text-strong);
    font-size: 28px;
    line-height: 1.15;
}

.login-panel p {
    margin-bottom: 24px;
    color: var(--color-text-muted);
}

.login-alert {
    margin-bottom: 18px;
    padding: 10px 12px;
    border: 1px solid var(--color-danger-border);
    border-radius: 10px;
    background: var(--color-danger-soft);
    color: var(--color-danger);
    font-size: 14px;
    font-weight: 500;
}

.login-alert-success {
    border-color: transparent;
    background: var(--color-success-soft);
    color: var(--color-success-text);
}

.flash {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
}

.flash-success {
    border: 1px solid transparent;
    background: var(--color-success-soft);
    color: var(--color-success-text);
}

.flash-error {
    border: 1px solid var(--color-danger-border);
    background: var(--color-danger-soft);
    color: var(--color-danger);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-form label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    color: var(--color-text-heading);
    font-size: 14px;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--color-input-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.login-submit {
    justify-content: center;
    margin-top: 6px;
    padding: 11px 16px;
    border-radius: 10px;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    flex-direction: row !important;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Inline Forms */
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.inline-form input {
    padding: 6px 10px;
    border: 1px solid var(--color-input-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.inline-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.source-form {
    flex-wrap: wrap;
}

.source-form input {
    flex: 1;
    min-width: 150px;
}

/* Filter Bar */
.filter-bar {
    margin-bottom: 16px;
}

.filter-bar select {
    padding: 6px 10px;
    border: 1px solid var(--color-input-border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--color-surface);
    color: var(--color-text);
}

/* Tag/Keyword Lists */
.tag-list,
.source-list {
    list-style: none;
}

.tag-list li,
.source-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border: 1px solid var(--color-border-light);
    border-radius: 6px;
    margin-bottom: 6px;
    background: var(--color-surface);
}

.source-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Sub-sections */
.sub-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border-light);
}

.pagination span {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-toast-bg);
    color: var(--color-toast-text);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.2s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text-strong);
}

.stat-label {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.section-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 28px;
}

.section-half {
    min-width: 0;
}

.section-half h3 {
    margin-bottom: 12px;
}

.badge-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-badge {
    padding: 4px 10px;
    background: var(--color-surface-hover);
    border-radius: 12px;
    font-size: 13px;
    text-transform: capitalize;
    color: var(--color-text);
}

.simple-list {
    list-style: none;
    padding: 0;
}

.simple-list li {
    padding: 6px 0;
    border-bottom: 1px solid var(--color-border-light);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Detail Card */
.detail-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    margin: 16px 0;
}

.detail-card p {
    margin-bottom: 8px;
    font-size: 14px;
}

/* Relevance badges */
.badge-hoch { background: var(--color-relevance-hoch-bg); color: var(--color-relevance-hoch-text); }
.badge-mittel { background: var(--color-relevance-mittel-bg); color: var(--color-relevance-mittel-text); }
.badge-tief { background: var(--color-relevance-tief-bg); color: var(--color-relevance-tief-text); }

/* Category / municipality badges */
.badge-kategorie {
    background: var(--color-kategorie-bg);
    color: var(--color-kategorie-text);
    text-transform: capitalize;
    cursor: pointer;
}

.badge-kategorie:hover {
    background: var(--color-accent-soft-hover);
}

.badge-gemeinde {
    background: var(--color-gemeinde-bg);
    color: var(--color-gemeinde-text);
}

.badge-gemeinde[hx-get] {
    cursor: pointer;
}

.badge-gemeinde[hx-get]:hover {
    background: var(--color-gemeinde-hover);
}

/* Article cards (Medienspiegel) */
.artikel-liste {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.artikel-karte {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 16px 20px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.artikel-karte:hover {
    border-color: var(--color-accent-border);
    box-shadow: 0 1px 4px var(--color-shadow);
}

.artikel-karte-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.quelle-tag {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.artikel-karte-titel {
    font-size: 16px;
    margin-bottom: 6px;
}

.artikel-karte-titel a {
    color: var(--color-text-strong);
    text-decoration: none;
}

.artikel-karte-titel a:hover {
    color: var(--color-accent);
}

.extern-link {
    color: var(--color-text-faint);
    text-decoration: none;
    font-size: 14px;
    margin-left: 4px;
}

.extern-link:hover {
    color: var(--color-accent);
}

.artikel-karte-text {
    font-size: 14px;
    color: var(--color-artikel-text);
    margin-bottom: 6px;
}

.artikel-detail h3 {
    margin-top: 16px;
    margin-bottom: 4px;
}

.quellentitel {
    font-size: 13px;
    margin: 4px 0 8px;
}

/* Filter bar grid (search + selects) */
.filter-bar-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-suche {
    flex: 1 1 240px;
    padding: 7px 12px;
    border: 1px solid var(--color-input-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
}

.filter-suche:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

/* Trend bars */
.trend-liste {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.trend-row {
    display: grid;
    grid-template-columns: 140px 1fr 32px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 6px;
}

.trend-row:hover {
    background: var(--color-surface-hover);
}

.trend-label {
    text-transform: capitalize;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trend-balken-wrap {
    background: var(--color-surface-hover);
    border-radius: 4px;
    height: 10px;
    overflow: hidden;
}

.trend-balken {
    background: var(--color-trend-bar);
    height: 100%;
    border-radius: 4px;
}

/* Clickable stat cards */
.stat-card[hx-get] {
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.stat-card[hx-get]:hover {
    border-color: var(--color-accent-border);
    box-shadow: 0 1px 4px var(--color-shadow);
}

/* Event list entries */
.ereignis-liste li {
    flex-wrap: wrap;
}

.ereignis-liste li p {
    width: 100%;
    margin: 2px 0 0;
}

/* Person rows (dashboard) */
.person-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 7px 6px !important;
    border-radius: 8px;
    cursor: pointer;
    box-sizing: border-box;
}

.personen-scroll {
    --scroll-row-height: 52px;
    --scroll-visible-rows: 6;
    max-height: calc(var(--scroll-row-height) * var(--scroll-visible-rows));
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
}

.personen-scroll .simple-list {
    padding: 4px 8px;
}

.personen-scroll .simple-list li:last-child {
    border-bottom: none;
}

.person-row:hover {
    background: var(--color-surface-hover);
}

.person-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.person-info a {
    font-weight: 500;
    color: var(--color-text-strong);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-info a:hover {
    color: var(--color-accent);
}

.person-info .muted {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Rows with count pill (Gemeinden, Quellen) */
.ranking-panel {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    padding: 4px 10px;
}

.ranking-panel .simple-list li:last-child {
    border-bottom: none;
}

.zeile-mit-pill {
    width: fit-content;
    max-width: 100%;
    gap: 8px;
    padding: 7px 4px !important;
    border-radius: 6px;
}

.zeile-mit-pill:hover {
    background: var(--color-surface-hover);
}

.zeile-mit-pill a {
    flex: 0 1 auto;
    font-weight: 500;
    color: var(--color-text-strong);
    text-decoration: none;
}

.zeile-mit-pill a:hover {
    color: var(--color-accent);
}

.count-pill {
    flex-shrink: 0;
    min-width: 24px;
    padding: 1px 8px;
    border-radius: 12px;
    background: var(--color-pill-bg);
    color: var(--color-pill-text);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.person-row .count-pill {
    margin-left: auto;
}

/* Modal dialog */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: modal-fade 0.15s ease-out;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: calc(100% - 48px);
    box-shadow: 0 20px 40px var(--color-modal-shadow);
    animation: modal-pop 0.15s ease-out;
}

.modal h3 {
    margin-bottom: 8px;
    font-size: 17px;
    color: var(--color-text-strong);
}

.modal p {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

@keyframes modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-pop {
    from { opacity: 0; transform: scale(0.96) translateY(4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* HTMX loading indicator */
#content.htmx-request {
    opacity: 0.5;
    transition: opacity 0.2s;
}

/* Fälle / case threading */
.section-intro {
    margin: -8px 0 16px;
    font-size: 14px;
}

.fall-karte {
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
}

.badge-status-aktiv { background: var(--color-accent-soft, #e8f4ea); color: var(--color-accent, #2d6a3e); }
.badge-status-abgeschlossen { background: var(--color-muted-bg); color: var(--color-text-muted); }
.badge-status-ruhend { background: #f5f0e6; color: #8a6d2f; }
.badge-similarity { background: #e8eef8; color: #2c5282; }
.badge-keyword { background: #f0ebe3; color: #6b5b3e; }

.suche-hinweis {
    margin: 0 0 12px;
    font-size: 13px;
}

.suche-treffer-stichwort {
    border-left-color: #8a6d2f;
}

.fall-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 2px solid var(--color-border);
}

.fall-timeline-item {
    position: relative;
    padding: 0 0 20px 20px;
    margin-left: 8px;
}

.fall-timeline-item::before {
    content: "";
    position: absolute;
    left: -7px;
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-accent, #2d6a3e);
    border: 2px solid var(--color-surface);
}

.fall-timeline-date {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.fall-timeline-titel {
    font-weight: 600;
}

/* Semantic search */
.suche-form {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 20px;
}

.suche-input {
    flex: 1;
}

.empty-hint {
    text-align: center;
    padding: 32px 16px;
}

.suche-treffer {
    border-left: 3px solid var(--color-accent, #2d6a3e);
}

/* RAG Chat */
.chat-shell {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 720px;
}

.chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.chat-header h2 {
    margin: 0 0 4px;
    font-size: 22px;
}

.chat-header-text p {
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}

.chat-clear-btn {
    flex-shrink: 0;
    display: none;
}

.chat-shell:has(.chat-turn) .chat-clear-btn {
    display: inline-flex;
}

.chat-panel {
    border: 1px solid var(--color-border);
    border-radius: 14px;
    background: var(--color-surface);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 0;
    overflow: hidden;
    padding: 0 16px;
    scroll-behavior: smooth;
}

.chat-panel:has(.chat-turn) .chat-messages {
    max-height: min(55vh, 480px);
    overflow-y: auto;
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.chat-composer {
    padding: 16px;
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 8px;
}

.chat-actions .btn-primary {
    min-width: 7rem;
}

.chat-filter {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 170px;
    margin-right: auto;
}

.chat-filter select {
    height: 36px;
    border: 1px solid var(--color-input-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text);
    padding: 0 10px;
    font: inherit;
    font-size: 13px;
}

.chat-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-input-border);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    min-height: 88px;
    background: var(--color-surface-2);
    color: var(--color-text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-accent-border);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
    background: var(--color-surface);
}

.chat-turn {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-bubble {
    border-radius: 12px;
    padding: 12px 16px;
    max-width: 100%;
}

.chat-user {
    align-self: flex-end;
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent-border);
    max-width: 88%;
}

.chat-assistant {
    align-self: flex-start;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    max-width: 100%;
}

.chat-loading-bubble {
    margin: 0 16px 12px;
}

.chat-panel:has(.chat-turn) .chat-loading-bubble {
    margin: 0 16px 12px;
}

.chat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.chat-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text);
}

.chat-text p {
    margin: 0 0 0.75em;
}

.chat-text p:last-child {
    margin-bottom: 0;
}

.chat-fn {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--color-accent);
    text-decoration: none;
    vertical-align: super;
    line-height: 0;
}

.chat-fn:hover {
    text-decoration: underline;
}

.chat-quellen {
    margin: 16px 0 0;
    padding-left: 1.25rem;
    font-size: 13px;
    border-top: 1px solid var(--color-border);
    padding-top: 12px;
}

.chat-quellen li {
    margin-bottom: 8px;
}

.chat-quelle-link {
    margin-left: 6px;
    font-size: 12px;
}

.chat-loading {
    opacity: 0.85;
}

.htmx-indicator {
    display: none;
}

.htmx-request.htmx-indicator {
    display: block;
}

.global-loading {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    align-items: center;
    justify-content: center;
}

.htmx-request.global-loading {
    display: flex;
}

.global-loading-backdrop {
    position: absolute;
    inset: 0;
    background: var(--color-modal-overlay);
}

.global-loading-card {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    min-width: 260px;
    max-width: 90vw;
    padding: 24px 28px;
    border-radius: 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    box-shadow: 0 12px 40px var(--color-modal-shadow);
}

.global-loading-text {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    text-align: center;
    line-height: 1.45;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spinner-drehen 0.75s linear infinite;
}

@keyframes spinner-drehen {
    to { transform: rotate(360deg); }
}

/* Dossier */
.dossier-composer {
    margin-bottom: 24px;
    padding: 20px;
}

.dossier-composer h3 {
    margin: 0 0 6px;
}

.dossier-form {
    margin-top: 16px;
    align-items: flex-end;
}

.dossier-report {
    margin-top: 8px;
}

.dossier-report-header {
    position: static;
    z-index: auto;
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.dossier-report-header h2 {
    margin: 0 0 6px;
}

.dossier-section {
    margin-bottom: 32px;
}

.dossier-section h3 {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.dossier-section h4 {
    margin: 20px 0 10px;
    font-size: 0.95rem;
}

.dossier-stats {
    margin: 12px 0;
    padding-left: 20px;
}

.dossier-stats li {
    margin: 4px 0;
}

.dossier-table {
    width: 100%;
    font-size: 13px;
}

.dossier-table td,
.dossier-table th {
    vertical-align: top;
}

.dossier-bar {
    height: 8px;
    min-width: 4px;
    border-radius: 4px;
    background: var(--color-accent);
}

.dossier-liste-table .col-name {
    min-width: 9.5rem;
    width: 12%;
    white-space: nowrap;
}

.dossier-liste-table td.actions {
    width: 1%;
    white-space: nowrap;
}

.dossier-table-quellen td:last-child {
    word-break: break-all;
    max-width: 280px;
}

.dossier-llm-text {
    margin: 16px 0 20px;
    line-height: 1.6;
    font-size: 15px;
}

.dossier-llm-text p {
    margin: 0 0 12px;
}

.dossier-llm-text h2,
.dossier-llm-text h3,
.dossier-llm-text h4 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text-heading);
    margin: 24px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border-light);
}

.dossier-llm-text h2:first-child,
.dossier-llm-text h3:first-child,
.dossier-llm-text h4:first-child {
    margin-top: 0;
}

.dossier-llm-text ul,
.dossier-llm-text ol {
    margin: 0 0 16px;
    padding-left: 1.35rem;
}

.dossier-llm-text li {
    margin: 10px 0;
}

.dossier-llm-text li::marker {
    color: var(--color-accent);
}

.dossier-llm-text li p {
    margin: 0;
}

.dossier-llm-text strong {
    font-weight: 600;
    color: var(--color-text-strong);
}

.dossier-fn {
    white-space: nowrap;
}

.dossier-fn a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
}

.dossier-quellen {
    margin: 16px 0 0;
    padding-left: 24px;
    font-size: 13px;
}

.dossier-quellen li {
    margin: 6px 0;
}

.dossier-datengrundlage {
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.relation-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.relation-explicit {
    background: #dbeafe;
    color: #1e40af;
}

.relation-komention {
    background: #f3f4f6;
    color: #4b5563;
}

.person-netzwerk-table {
    margin-bottom: 1.25rem;
}

.person-netzwerk-table .relation-direction {
    display: block;
    margin-top: 4px;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

.netzwerk-quellen {
    max-width: 320px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 0 16px; }
    body > header { padding: 10px 0 8px; }
    .header-nav { margin: 0 -16px; padding: 0 16px 2px; }
    .nav-btn { padding: 7px 10px; font-size: 12px; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .section-row { grid-template-columns: 1fr; }
    table { font-size: 13px; }
    td.actions { flex-direction: column; }
}
