:root {
    --bg: #ffffff;
    --bg-page: #f8f8f8;
    --text: #111;
    --text-secondary: #666;
    --text-muted: #aaa;
    --accent: #dc2626;
    --accent-hover: #b91c1c;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --border: #eee;
    --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ===== NAV ===== */
nav {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
}

.logo {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    display: flex;
    align-items: baseline;
}

.logo-rail { color: var(--accent); }
.logo-watch { color: var(--text); }
.logo-domain { color: var(--text-muted); font-weight: 400; font-size: 0.85rem; }

.nav-links { display: flex; gap: 0.1rem; }

.nav-links a {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
}

.nav-links a:hover { color: #fff; background: var(--text); }
.nav-links a.active { color: #fff; background: var(--accent); }

/* ===== LAYOUT ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.25rem;
    flex: 1;
    width: 100%;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.page-header .tagline {
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    margin-top: 0.2rem;
}

/* ===== HEADINGS ===== */
h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.75rem; }

h2 {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    margin: 1.25rem 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

h3 { font-size: 0.95rem; font-weight: 600; }

/* ===== STATS ROW ===== */
.stats-row {
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.stat-value.accent { color: var(--accent); }

.stat-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

/* Legacy stat cards (detail pages) */
.stats-overview {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-card.highlight { border-color: var(--accent); }
.stat-card.highlight .stat-value { color: var(--accent); }

/* ===== GRADE BADGE ===== */
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.grade-excellent { background: #dcfce7; color: var(--success); border: 1.5px solid var(--success); }
.grade-good { background: #dcfce7; color: var(--success); border: 1.5px solid #86efac; }
.grade-ok { background: #fef3c7; color: var(--warning); border: 1.5px solid var(--warning); }
.grade-bad { background: #fef2f2; color: var(--danger); border: 1.5px solid var(--danger); }
.grade-terrible { background: #fef2f2; color: var(--danger); border: 1.5px solid #fca5a5; }

/* ===== STATION GRID ===== */
.station-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.rail-map {
    display: grid;
    grid-template-columns: 0.8fr 1.4fr;
    gap: 1rem;
    align-items: stretch;
    min-height: 260px;
    overflow: hidden;
}

.rail-map-copy {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.rail-map-copy h2 { margin-top: 0; }

.rail-map-copy p {
    color: var(--text-secondary);
    font-size: 0.86rem;
    max-width: 16rem;
}

.station-map {
    min-height: 260px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.rail-map-marker span {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.35), 0 2px 6px rgba(0, 0, 0, 0.22);
}

.leaflet-tooltip {
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    color: var(--text);
    font-weight: 700;
    font-size: 0.75rem;
}

.leaflet-popup-content {
    font-size: 0.82rem;
    line-height: 1.45;
}

.station-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
    display: block;
    color: var(--text);
    transition: border-color 0.15s;
}

.station-card:hover { border-color: var(--accent); }

.station-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.station-card-header h3 { font-size: 0.9rem; }

.station-stats { display: flex; gap: 1rem; }
.mini-stat { display: flex; flex-direction: column; gap: 0.02rem; }

.mini-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.mini-label {
    font-size: 0.55rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ===== STATION LIST ===== */
.station-list { display: flex; flex-direction: column; gap: 0.35rem; }

.station-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
}

.station-info { display: flex; flex-direction: column; gap: 0.1rem; }
.station-name { font-weight: 600; font-size: 0.9rem; }
.station-id { font-size: 0.7rem; color: var(--text-muted); font-family: monospace; }
.station-actions { display: flex; gap: 0.35rem; }

/* ===== SEARCH ===== */
.search-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
    margin-bottom: 0.75rem;
}

.search-section h3 { margin-bottom: 0.4rem; font-size: 0.85rem; }
.search-form { display: flex; gap: 0.35rem; }

.search-form input {
    flex: 1;
    padding: 0.45rem 0.65rem;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
}

.search-form input:focus { outline: none; border-color: var(--accent); }
.search-form input::placeholder { color: var(--text-muted); }

.search-results { display: flex; flex-direction: column; gap: 0.35rem; }

.search-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.85rem;
}

.result-info { display: flex; flex-direction: column; gap: 0.05rem; }
.result-name { font-weight: 600; font-size: 0.9rem; }
.result-id { font-size: 0.7rem; color: var(--text-muted); font-family: monospace; }

/* ===== BUTTONS ===== */
button, .btn-primary {
    padding: 0.45rem 0.85rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.8rem;
}

button:hover, .btn-primary:hover { background: var(--accent-hover); }

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.72rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-small:hover { background: var(--bg-page); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.btn-danger:hover { background: #fef2f2; }

/* ===== TABLES ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 0.5rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.82rem;
}

.data-table th {
    font-size: 0.62rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    font-weight: 700;
    background: var(--bg);
}

.data-table tbody tr:hover { background: #fafafa; }

.rank-num {
    font-weight: 800;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
}

.rank-num.top-3 { color: var(--accent); }

/* ===== DELAY INDICATORS ===== */
.delay-badge {
    display: inline-block;
    padding: 0.08rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.delay-low, .delay-badge.on-time { color: var(--success); background: #dcfce7; }
.delay-medium, .delay-badge.minor { color: var(--warning); background: #fef3c7; }
.delay-high, .delay-badge.major { color: var(--danger); background: #fef2f2; }

/* ===== SECTIONS ===== */
.chart-section, .section-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem;
    margin: 0.4rem 0;
}

.chart-section canvas { width: 100% !important; height: auto; }

.chart-note {
    color: var(--text-muted);
    font-size: 0.72rem;
    margin: -0.2rem 0 0.45rem;
}

/* ===== MISC ===== */
.flash-message {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    color: var(--accent);
    font-weight: 500;
    font-size: 0.85rem;
}

.field-error {
    color: var(--accent);
    font-size: 0.85rem;
    margin-top: 0.4rem;
}

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}
.error-page h1 {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    color: var(--accent);
    letter-spacing: -0.02em;
}
.error-page .error-tagline {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem 1.5rem;
    font-size: 0.85rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.back-link:hover { color: var(--accent); }
.back-link::before { content: '\2190 '; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

/* ===== FOOTER ===== */
footer {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    margin-top: auto;
    background: var(--bg);
}

footer .container {
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

footer p { font-size: 0.72rem; color: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .container { padding: 0.85rem; }
    nav { padding: 0 0.85rem; }
    .stats-overview { grid-template-columns: repeat(2, 1fr); }
    .stats-row { flex-wrap: wrap; gap: 1.25rem; }
    .station-grid { grid-template-columns: 1fr; }
    .rail-map { grid-template-columns: 1fr; min-height: 0; }
    .rail-map-copy { gap: 0.35rem; }
    .two-col { grid-template-columns: 1fr; }
    .station-row { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .search-form { flex-direction: column; }
    .search-result-row { flex-direction: column; align-items: flex-start; gap: 0.4rem; }
    .data-table th, .data-table td { padding: 0.35rem; font-size: 0.78rem; }
    footer .container { flex-direction: column; gap: 0.2rem; text-align: center; }
    h1 { font-size: 1.1rem; }
    .stat-value { font-size: 1.2rem; }
    .station-map { min-height: 230px; }
}

@media (max-width: 480px) {
    .stats-overview { grid-template-columns: 1fr 1fr; }
    .nav-container { height: auto; padding: 0.5rem 0; flex-direction: column; gap: 0.2rem; }
    .leaflet-tooltip { display: none; }
}

/* ===== BAUHAUS SYSTEM PASS ===== */
:root {
    --bg: #fff;
    --bg-page: #f0f0f0;
    --text: #121212;
    --text-secondary: #333;
    --text-muted: #666;
    --accent: #d02020;
    --accent-hover: #a81818;
    --bau-red: #d02020;
    --bau-blue: #1040c0;
    --bau-yellow: #f0c020;
    --success: #1040c0;
    --warning: #f0c020;
    --danger: #d02020;
    --border: #121212;
    --muted: #e0e0e0;
    --radius: 0;
    --border-strong: 3px solid var(--border);
    --shadow-hard: 6px 6px 0 #121212;
    --shadow-small: 3px 3px 0 #121212;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background:
        radial-gradient(rgba(18, 18, 18, 0.07) 1px, transparent 1px),
        var(--bg-page);
    background-size: 18px 18px;
    color: var(--text);
    font-weight: 500;
}

a { color: var(--bau-blue); }
a:hover { color: var(--bau-red); }

nav {
    background: var(--bg);
    border-bottom: var(--border-strong);
    padding: 0;
    box-shadow: 0 3px 0 rgba(18, 18, 18, 0.08);
    z-index: 2000;
}

.nav-container {
    max-width: 1500px;
    width: 100%;
    height: 58px;
    padding: 0 1.75rem;
}

.logo {
    align-items: center;
    gap: 0.55rem;
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--text);
}

.logo:hover { color: var(--text); }

.logo-word {
    display: inline-flex;
    align-items: baseline;
    gap: 0;
    line-height: 1;
}

.logo-mark {
    display: block;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
}

.logo-rail { color: var(--bau-red); }
.logo-watch { color: var(--text); }
.logo-domain {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    line-height: 1;
}

.nav-links { gap: 0.45rem; }

.nav-links a {
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.46rem 0.72rem;
    border: 2px solid transparent;
    border-radius: 0;
}

.nav-links a:hover {
    background: var(--bau-yellow);
    color: var(--text);
    border-color: var(--border);
}

.nav-links a.active {
    background: var(--bau-red);
    border-color: var(--border);
    color: #fff;
    box-shadow: var(--shadow-small);
}

.container {
    max-width: 1500px;
    padding: 1.5rem 1.75rem 2.5rem;
}

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(520px, 1.6fr);
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1rem;
}

.page-header {
    position: relative;
    margin: 0;
    background: var(--bg);
    border: var(--border-strong);
    box-shadow: var(--shadow-hard);
    padding: 1.4rem 1.5rem;
    min-height: 180px;
    overflow: hidden;
}

.page-header h1,
.page-header p {
    position: relative;
    z-index: 1;
}

.page-header h1,
h1 {
    font-size: clamp(2.4rem, 5vw, 5.5rem);
    line-height: 0.9;
    font-weight: 900;
    letter-spacing: -0.055em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    max-width: 10ch;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 1rem;
    max-width: 34rem;
}

.page-header .tagline {
    display: inline-block;
    margin-top: 0.65rem;
    color: var(--text);
    background: var(--bau-yellow);
    border: 2px solid var(--border);
    padding: 0.18rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.station-title {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.station-title h1 {
    margin: 0;
    max-width: none;
}

.page-intro {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin: -0.25rem 0 1.5rem;
    font-weight: 600;
}

h2 {
    color: var(--text);
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    font-weight: 900;
}

h3 {
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    padding: 0;
    border: var(--border-strong);
    box-shadow: var(--shadow-hard);
    background: var(--bg);
}

.stat-item {
    min-height: 180px;
    padding: 1.2rem;
    justify-content: space-between;
    border-right: var(--border-strong);
}

.stat-item:last-child { border-right: 0; }

.stat-item:nth-child(2) { background: var(--bau-yellow); }
.stat-item:nth-child(2) .stat-value { color: var(--text) !important; }
.stat-item:nth-child(4) { background: var(--bau-red); color: #fff; }
.stat-item:nth-child(4) .stat-label,
.stat-item:nth-child(4) .stat-value { color: #fff !important; }
.stat-item:nth-child(4) .stat-value {
    font-size: clamp(1.6rem, 2.4vw, 2.8rem);
    overflow-wrap: anywhere;
}

.stat-value {
    font-size: clamp(2rem, 3vw, 3.4rem);
    line-height: 0.9;
    font-weight: 900;
    letter-spacing: -0.045em;
}

.stat-value.accent { color: var(--bau-red); }

.stat-label {
    color: var(--text);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    font-weight: 900;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.section-heading a,
.section-link {
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--bau-yellow);
    border: 2px solid var(--border);
    padding: 0.32rem 0.48rem;
    box-shadow: var(--shadow-small);
}

.section-heading a:hover,
.section-link:hover {
    color: var(--text);
    transform: translate(-1px, -1px);
}

.collector-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0;
    align-items: stretch;
    margin: 1rem 0 1.1rem;
    background: var(--bg);
    border: var(--border-strong);
    box-shadow: var(--shadow-hard);
}

.collector-copy,
.collector-meter,
.collector-action {
    padding: 0.9rem 1rem;
    border-right: var(--border-strong);
}

.collector-action { border-right: 0; }

.collector-copy h2 {
    background: var(--text);
    color: #fff;
    display: inline-block;
    padding: 0.22rem 0.45rem;
    margin: 0 0 0.45rem;
}

.collector-copy p {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 700;
}

.collector-meter {
    min-width: 210px;
    background: var(--bau-yellow);
}

.collector-meter span {
    display: block;
    font-size: 2.1rem;
    line-height: 0.95;
    font-weight: 900;
    letter-spacing: -0.04em;
}

.collector-meter small,
.collector-action small {
    display: block;
    margin-top: 0.2rem;
    color: var(--text);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    line-height: 1.2;
    text-transform: uppercase;
}

.collector-action {
    min-width: 210px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.rail-map {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 0;
    min-height: 410px;
    margin: 1.2rem 0 0.65rem;
    background: var(--bg);
    border: var(--border-strong);
    box-shadow: var(--shadow-hard);
    isolation: isolate;
}

.rail-map-copy {
    padding: 1.15rem;
    border-right: var(--border-strong);
    background:
        linear-gradient(135deg, transparent 0 62%, rgba(18, 18, 18, 0.08) 62% 64%, transparent 64%),
        var(--bau-blue);
    color: #fff;
}

.rail-map-copy h2,
.rail-map-copy p { color: #fff; }

.rail-map-copy h2 {
    font-size: 1.25rem;
    letter-spacing: 0.12em;
    margin-bottom: 0.75rem;
}

.rail-map-copy p {
    font-size: 1.4rem;
    line-height: 1.12;
    font-weight: 900;
    max-width: 12rem;
}

.station-map {
    min-height: 410px;
    border: 0;
    border-radius: 0;
    z-index: 0;
}

.rail-map-marker span {
    width: 18px;
    height: 18px;
    background: var(--bau-red);
    border: 3px solid var(--border);
    box-shadow: 3px 3px 0 #fff;
}

.leaflet-tooltip {
    border: 2px solid var(--border);
    border-radius: 0;
    box-shadow: var(--shadow-small);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
}

.leaflet-control-zoom a,
.leaflet-bar {
    border-color: var(--border) !important;
    border-radius: 0 !important;
}

.station-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.7rem;
}

.station-card {
    position: relative;
    border: 2px solid var(--border);
    border-radius: 0;
    box-shadow: var(--shadow-small);
    padding: 0.78rem;
    min-height: 126px;
    transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
}

.station-card::after {
    content: '';
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    width: 11px;
    height: 11px;
    background: var(--bau-blue);
}

.station-card:nth-child(3n)::after {
    border-radius: 50%;
    background: var(--bau-red);
}

.station-card:nth-child(3n + 2)::after {
    background: var(--bau-yellow);
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
}

.station-card:hover {
    border-color: var(--border);
    color: var(--text);
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 var(--border);
}

.station-card-header {
    margin-bottom: 0.7rem;
    padding-right: 1rem;
}

.station-card-header h3 {
    max-width: 11rem;
    line-height: 1.05;
}

.station-stats {
    display: grid;
    grid-template-columns: 0.78fr 1.25fr 1fr;
    gap: 0.45rem;
    border-top: 2px solid var(--border);
    padding-top: 0.55rem;
}

.mini-value { font-size: 1rem; font-weight: 900; }
.mini-label {
    color: var(--text-muted);
    font-size: 0.5rem;
    letter-spacing: 0.04em;
    font-weight: 900;
    line-height: 1.05;
}

.grade-badge {
    width: 34px;
    height: 34px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: #fff;
    color: var(--text);
    font-size: 0.8rem;
    box-shadow: 2px 2px 0 var(--border);
}

.grade-excellent,
.grade-good { background: #fff; color: var(--bau-blue); border-color: var(--bau-blue); }
.grade-ok { background: var(--bau-yellow); color: var(--text); border-color: var(--border); }
.grade-bad,
.grade-terrible { background: #fff; color: var(--bau-red); border-color: var(--bau-red); }

.analytics-grid {
    display: grid;
    grid-template-columns: 0.92fr 1.08fr;
    gap: 0.9rem;
    margin-top: 1rem;
}

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
}

.chart-section,
.section-card,
.search-section,
.station-row,
.search-result-row,
.stat-card {
    background: var(--bg);
    border: var(--border-strong);
    border-radius: 0;
    box-shadow: var(--shadow-hard);
    padding: 1rem;
}

.chart-section,
.section-card { margin: 0.9rem 0; }

.chart-section h2,
.section-card h2,
.search-section h3 {
    background: var(--text);
    color: #fff;
    display: inline-block;
    padding: 0.24rem 0.48rem;
    margin-bottom: 0.75rem;
}

.chart-section canvas {
    background: #fff;
    border-top: 2px solid var(--border);
    padding-top: 0.35rem;
    min-height: 230px;
}

.chart-note {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    margin: -0.35rem 0 0.5rem;
}

.data-table th,
.data-table td {
    border-bottom: 2px solid var(--border);
    font-size: 0.9rem;
    padding: 0.68rem 0.78rem;
}

.data-table th {
    background: var(--bau-yellow);
    color: var(--text);
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    font-weight: 900;
}

.data-table tbody tr:hover { background: #fff7d1; }

.rank-num {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 900;
}

.rank-num.top-3 {
    color: var(--bau-red);
}

.delay-badge {
    border: 2px solid currentColor;
    border-radius: 0;
    padding: 0.08rem 0.42rem;
    font-weight: 900;
}

.delay-badge.on-time,
.delay-low { background: #fff; }
.delay-badge.minor,
.delay-medium { background: var(--bau-yellow); color: var(--text); }
.delay-badge.major,
.delay-high { background: #fff; color: var(--bau-red); }

button,
.btn-primary,
.btn-small {
    border: 2px solid var(--border);
    border-radius: 0;
    box-shadow: var(--shadow-small);
    background: var(--bau-red);
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 900;
    transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}

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

/* Outlined buttons keep their own colour palette on hover so the label
   doesn't go white-on-white over a light hover background. */
.btn-small:hover {
    background: var(--bg-page);
    color: var(--text);
}

.btn-danger:hover {
    background: #fef2f2;
    color: var(--bau-red);
}

button:active,
.btn-primary:active,
.btn-small:active {
    transform: translate(3px, 3px);
    box-shadow: none;
}

button:disabled,
.btn-primary:disabled,
.btn-small:disabled {
    cursor: not-allowed;
    background: var(--muted);
    color: var(--text-muted);
    box-shadow: none;
    transform: none;
}

.btn-small {
    background: #fff;
    color: var(--text);
}

.btn-danger {
    color: var(--bau-red);
    background: #fff;
    border-color: var(--bau-red);
}

.search-form input {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-family: inherit;
    font-weight: 700;
}

.station-list,
.search-results {
    gap: 0.65rem;
}

.station-row,
.search-result-row {
    box-shadow: var(--shadow-small);
}

.station-name,
.result-name {
    color: var(--text);
    font-size: 1rem;
    font-weight: 900;
}

.station-id,
.result-id {
    color: var(--text-muted);
    font-weight: 800;
}

.flash-message,
.field-error,
.empty-state {
    border: 2px solid var(--border);
    border-radius: 0;
    background: var(--bau-yellow);
    color: var(--text);
    box-shadow: var(--shadow-small);
}

footer {
    background: var(--text);
    border-top: var(--border-strong);
    color: #fff;
}

footer .container {
    max-width: 1500px;
}

footer p,
footer a {
    color: #fff;
    font-weight: 700;
}

footer .container {
    border: 0;
    box-shadow: none;
}

.back-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    margin-bottom: 1rem;
    padding: 0.34rem 0.55rem;
    background: #fff;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-small);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    line-height: 1;
    text-transform: uppercase;
}

.back-link:hover {
    color: var(--text);
    background: var(--bau-yellow);
    transform: translate(-1px, -1px);
}

.back-link::before {
    content: '\2190';
    margin-right: 0.35rem;
    font-size: 1rem;
    line-height: 0.7;
}

@media (max-width: 1100px) {
    .dashboard-hero { grid-template-columns: 1fr; }
    .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-item:nth-child(2) { border-right: 0; }
    .stat-item:nth-child(1),
    .stat-item:nth-child(2) { border-bottom: var(--border-strong); }
    .station-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .analytics-grid { grid-template-columns: 1fr; }
    .two-col { grid-template-columns: 1fr; }
    .collector-panel { grid-template-columns: 1fr; }
    .collector-copy,
    .collector-meter,
    .collector-action {
        border-right: 0;
        border-bottom: var(--border-strong);
    }
    .collector-action { border-bottom: 0; }
}

@media (max-width: 768px) {
    .container { padding: 1rem; }
    nav { padding: 0; }
    .nav-container {
        height: auto;
        align-items: flex-start;
        padding: 0.75rem 1rem;
        gap: 0.75rem;
    }
    .nav-links {
        flex-wrap: wrap;
    }
    .nav-links a {
        font-size: 0.72rem;
        padding: 0.36rem 0.5rem;
    }
    .dashboard-hero { gap: 0.8rem; }
    .page-header { min-height: 0; padding: 1.1rem; }
    .page-header h1,
    h1 {
        font-size: clamp(2rem, 13vw, 3.4rem);
        max-width: 12ch;
    }
    .station-title {
        align-items: flex-start;
        justify-content: space-between;
    }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .stat-item {
        min-height: 126px;
        padding: 0.9rem;
    }
    .stat-item:nth-child(2n) { border-right: 0; }
    .rail-map { grid-template-columns: 1fr; min-height: 0; }
    .rail-map-copy {
        border-right: 0;
        border-bottom: var(--border-strong);
        min-height: 150px;
    }
    .station-map { min-height: 300px; }
    .station-grid { grid-template-columns: 1fr; }
    .station-card { min-height: 0; }
    .data-table {
        min-width: 640px;
    }
    .section-card,
    .chart-section {
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .logo { font-size: 1.1rem; }
    .logo-domain { font-size: 0.78rem; }
    .stats-row { grid-template-columns: 1fr; }
    .stat-item {
        border-right: 0;
        border-bottom: var(--border-strong);
    }
    .stat-item:last-child { border-bottom: 0; }
    .stats-overview { grid-template-columns: 1fr; }
    .alerts-grid { grid-template-columns: 1fr; }
}

/* ===== Alerts (BEM) ===== */
.alerts-actions {
    margin-bottom: 1.5rem;
}

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.alert-card {
    border: var(--border-strong);
    background: #fff;
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-small);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.alert-card--paused { background: var(--bg-page); opacity: 0.7; }
.alert-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}
.alert-card__email {
    margin: 0;
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 800;
    font-size: 1rem;
    word-break: break-word;
}
.alert-card__meta {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.alert-card__badge {
    border: 2px solid var(--bau-black);
    background: var(--bau-yellow);
    padding: 0.05rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.alert-card--paused .alert-card__badge {
    background: var(--bg-page);
}
.alert-card__stations {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.alert-card__stations li {
    border: 2px solid var(--border);
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 700;
}
/* Dashboard alert-summary block */
.alert-summary {
    border: var(--border-strong);
    background: #fff;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-small);
}
.alert-summary__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.alert-summary__head h2 { margin: 0; }
.alert-summary__head p { margin: 0.2rem 0 0; color: var(--text-secondary); font-size: 0.85rem; }
.alert-summary__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.alert-summary__row {
    display: grid;
    grid-template-columns: 56px 80px 1fr 1fr auto;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.85rem;
    padding: 0.25rem 0;
    border-bottom: 1px dashed var(--border);
}
.alert-summary__row:last-child { border-bottom: 0; }
.alert-summary__time { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-weight: 700; }
.alert-summary__line { font-weight: 800; }
.alert-summary__station { color: var(--text-secondary); }
.alert-summary__dest { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-summary__delay {
    background: var(--bau-red);
    color: #fff;
    padding: 0.05rem 0.45rem;
    font-weight: 800;
    font-size: 0.75rem;
}

@media (max-width: 640px) {
    .alert-summary__row {
        grid-template-columns: 50px 1fr auto;
    }
    .alert-summary__station, .alert-summary__dest { display: none; }
}

.alert-card__triggers {
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}
.alert-card__trigger-count {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}
.alert-card__trigger-num {
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--bau-red);
    line-height: 1;
}
.alert-card__trigger-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-secondary);
}
.alert-card__last-fired {
    margin: 0.35rem 0 0.5rem;
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.alert-card__trigger-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.alert-card__trigger-list li {
    display: flex;
    gap: 0.4rem;
    align-items: baseline;
    font-size: 0.78rem;
}
.alert-card__trigger-line {
    font-weight: 800;
}
.alert-card__trigger-dest {
    color: var(--text-secondary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alert-card__trigger-delay {
    background: var(--bau-red);
    color: #fff;
    padding: 0 0.35rem;
    font-weight: 800;
    font-size: 0.7rem;
}
.alert-card__actions {
    display: flex;
    gap: 0.4rem;
    margin-top: auto;
}

.alert-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    max-width: 560px;
    border: var(--border-strong);
    background: #fff;
    padding: 1.25rem;
    box-shadow: var(--shadow-small);
}
.alert-form__field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.alert-form__field > span,
.alert-form__field > legend {
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.78rem;
}
.alert-form__field input[type="email"],
.alert-form__field input[type="number"] {
    border: var(--border-strong);
    padding: 0.5rem 0.65rem;
    font: inherit;
    background: #fff;
}
.alert-form__stations {
    border: var(--border-strong);
    padding: 0.75rem 1rem 1rem;
}
.alert-form__station {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.2rem 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}
.alert-form__station input { accent-color: var(--bau-red); }
.alert-form__actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
