:root {
    color-scheme: dark;
    --bg: #101214;
    --panel: #1b2025;
    --panel-2: #242a30;
    --text: #f3f6f8;
    --muted: #a9b4bf;
    --accent: #e53935;
    --warn: #f6b93b;
    --ok: #2ecc71;
    --line: #38414a;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: #070809;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 24px;
    min-height: 64px;
    padding: 0 24px;
}

.brand {
    color: var(--accent);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

nav a {
    color: var(--muted);
    font-weight: 600;
}

.page {
    margin: 0 auto;
    max-width: 1180px;
    padding: 24px;
}

.status-grid,
.admin-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: 24px;
}

.status-grid.compact .metric strong {
    font-size: 18px;
    overflow-wrap: anywhere;
}

.metric,
.admin-grid a,
.panel,
.login {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metric {
    padding: 18px;
}

.metric span,
.admin-grid span,
.alarm-row span,
.empty,
time {
    color: var(--muted);
}

.metric strong {
    display: block;
    font-size: 42px;
    margin-top: 8px;
}

.metric.danger strong {
    color: var(--accent);
}

.metric.warning strong {
    color: var(--warn);
}

.panel,
.login {
    padding: 20px;
}

.panel-title {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

h1 {
    font-size: 26px;
    margin: 0;
}

button,
.button {
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    min-height: 42px;
    padding: 0 16px;
}

.secondary-button {
    background: var(--panel-2);
    border: 1px solid var(--line);
}

.danger-button,
.icon-danger {
    background: #8f1f1b;
}

.icon-danger {
    font-size: 13px;
    min-height: 34px;
    padding: 0 10px;
}

.icon-button {
    align-items: center;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: inline-flex;
    font-size: 16px;
    height: 34px;
    justify-content: center;
    min-height: 34px;
    padding: 0;
    width: 34px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.button-row.centered {
    justify-content: center;
}

.row-actions,
.hero-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.hero-actions {
    align-items: flex-end;
    flex-direction: column;
}

.compact-actions {
    justify-content: flex-start;
}

.notification-status {
    color: var(--muted);
    font-size: 13px;
    max-width: 220px;
    text-align: right;
}

.status-button {
    border-radius: 999px;
    font-size: 14px;
    min-height: 34px;
    padding: 0 12px;
}

.status-button.open {
    background: var(--accent);
}

.status-button.active {
    background: var(--warn);
    color: #1b1200;
}

.status-button.done {
    background: var(--ok);
    color: #02180a;
}

.status-close-button {
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--text);
    font-size: 12px;
    min-height: 30px;
    padding: 0 10px;
}

.fullscreen-button {
    background: #303943;
    border: 1px solid var(--line);
    min-height: 36px;
}

.monitor-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    max-width: 460px;
}

.alarm-hero .notification-status {
    display: none;
}

.button.secondary {
    align-items: center;
    background: var(--panel-2);
    display: inline-flex;
}

.alarm-list,
.alarmnetz-registered-list,
.event-list,
.table {
    display: grid;
    gap: 10px;
}

.alarm-row,
.table-head,
.table-row,
.event-row {
    align-items: center;
    background: var(--panel-2);
    border-radius: 6px;
    display: grid;
    gap: 12px;
    padding: 14px;
}

.alarm-row {
    grid-template-columns: 1.4fr 1.6fr auto auto;
}

.table-head,
.table-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.table-head {
    color: var(--muted);
    font-weight: 700;
}

.event-row {
    grid-template-columns: 170px 170px 1fr;
}

.alarmnetz-registered-row {
    align-items: start;
    background: var(--panel-2);
    border-left: 4px solid var(--warn);
    border-radius: 6px;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1.2fr 1.4fr auto;
    padding: 14px;
}

.alarmnetz-registered-row strong,
.alarmnetz-registered-row span,
.alarmnetz-registered-row small {
    display: block;
    overflow-wrap: anywhere;
}

.alarmnetz-registered-row span,
.alarmnetz-registered-row small {
    color: var(--muted);
}

.event-row.warnung {
    border-left: 4px solid var(--warn);
}

.event-row.fehler {
    border-left: 4px solid var(--accent);
}

.detail-grid {
    display: grid;
    gap: 10px 16px;
    grid-template-columns: 140px 1fr;
    margin-bottom: 18px;
}

.detail-grid span {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.raw-log {
    background: #08090a;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    max-height: 520px;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

.badge {
    background: #33404a;
    border-radius: 999px;
    color: var(--text);
    font-weight: 700;
    padding: 6px 10px;
}

.admin-grid a {
    padding: 18px;
}

.admin-grid strong,
.admin-grid span {
    display: block;
}

.login {
    margin: 8vh auto;
    max-width: 420px;
}

.login form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

.settings-form {
    display: grid;
    gap: 14px;
    max-width: 680px;
}

.form-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.role-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.check {
    align-items: center;
    display: flex;
    flex-direction: row;
}

.check input {
    min-height: auto;
    width: 22px;
}

label {
    color: var(--muted);
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.hint {
    color: var(--muted);
    font-weight: 500;
}

input,
select,
textarea {
    background: #08090a;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 8px 10px;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.alert {
    background: rgba(229, 57, 53, 0.15);
    border: 1px solid rgba(229, 57, 53, 0.6);
    border-radius: 6px;
    padding: 12px;
}

.alert.success {
    background: rgba(46, 204, 113, 0.14);
    border-color: rgba(46, 204, 113, 0.55);
}

.inline-action {
    color: var(--warn);
    display: inline-block;
    font-weight: 700;
    margin-left: 10px;
}

.inline-form {
    display: inline;
    margin-left: 10px;
}

.link-danger {
    background: transparent;
    color: #ff8a80;
    font-weight: 700;
    min-height: auto;
    padding: 0;
}

.monitor-empty {
    align-items: center;
    display: grid;
    min-height: calc(100vh - 140px);
    text-align: center;
}

.monitor-empty.compact {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 260px;
    padding: 24px;
}

.monitor-empty h1 {
    font-size: 44px;
}

.page:has(.monitor-viewport) {
    max-width: none;
    padding: 14px;
}

.monitor-viewport {
    background: var(--bg);
    min-height: calc(100vh - 92px);
}

.monitor-viewport:fullscreen {
    background: var(--bg);
    min-height: 100vh;
    overflow: hidden;
    padding: 14px;
}

.monitor-viewport:fullscreen .monitor-info-shell,
.monitor-viewport:fullscreen .monitor-shell {
    height: calc(100vh - 28px);
}

.monitor-viewport:fullscreen .monitor-shell {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 25vw);
}

.monitor-viewport:fullscreen .monitor-main,
.monitor-viewport:fullscreen .monitor-side {
    min-height: 0;
}

.monitor-viewport:fullscreen .monitor-side {
    overflow: auto;
}

.monitor-viewport:fullscreen .unit-panel .unit-list {
    max-height: min(36vh, 320px);
    overflow: auto;
    padding-right: 4px;
}

.monitor-viewport:fullscreen .map-board {
    min-height: 0;
}

.monitor-info-shell {
    display: grid;
    gap: 18px;
    grid-template-rows: auto minmax(0, 1fr);
}

.monitor-info-header {
    align-items: start;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    padding: 18px;
}

.monitor-info-header h1 {
    color: var(--ok);
    font-size: 44px;
    margin-top: 6px;
}

.monitor-info-header p {
    color: var(--muted);
    font-size: 20px;
    margin: 8px 0 0;
}

.info-incident-grid {
    display: grid;
    gap: 12px;
    grid-auto-rows: minmax(0, auto);
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    overflow: auto;
}

.info-incident {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 5px solid var(--accent);
    border-radius: 8px;
    display: grid;
    gap: 12px;
    padding: 16px;
}

.info-incident.open {
    border-left-color: var(--accent);
}

.info-incident.active {
    border-left-color: var(--warn);
}

.info-incident.done {
    border-left-color: var(--ok);
}

.info-incident-title {
    align-items: start;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.info-incident-title strong {
    color: var(--warn);
    display: block;
    font-size: 22px;
    overflow-wrap: anywhere;
}

.info-incident-title span,
.info-address small,
.info-meta {
    color: var(--muted);
}

.info-status {
    display: grid;
    gap: 4px;
    justify-items: end;
    text-align: right;
}

.info-status span {
    border-radius: 999px;
    color: white;
    display: inline-block;
    font-size: 13px;
    font-weight: 800;
    padding: 5px 9px;
}

.info-incident.open .info-status span {
    background: var(--accent);
}

.info-incident.active .info-status span {
    background: var(--warn);
    color: #1b1200;
}

.info-incident.done .info-status span {
    background: var(--ok);
    color: #02180a;
}

.info-address span,
.info-address small {
    display: block;
    overflow-wrap: anywhere;
}

.info-units,
.info-meta,
.object-file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.badge.muted {
    background: var(--panel-2);
    color: var(--muted);
}

.monitor-shell {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 24vw);
    min-height: calc(100vh - 92px);
}

.monitor-main,
.monitor-panel,
.monitor-side section {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.monitor-panel summary {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    list-style: none;
}

.monitor-panel summary::-webkit-details-marker {
    display: none;
}

.monitor-panel summary span,
.monitor-side h2 {
    font-size: 20px;
    margin: 0;
}

.monitor-panel summary strong {
    background: var(--panel-2);
    border-radius: 999px;
    color: var(--muted);
    min-width: 32px;
    padding: 4px 9px;
    text-align: center;
}

.monitor-panel[open] summary {
    margin-bottom: 12px;
}

.monitor-main {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.monitor-side {
    align-content: start;
    display: grid;
    gap: 18px;
    max-height: calc(100vh - 92px);
    overflow: auto;
}

.alarm-hero {
    align-items: start;
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.eyebrow {
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.alarm-hero h1 {
    color: var(--accent);
    font-size: clamp(34px, 3vw, 56px);
    margin-top: 6px;
    overflow-wrap: anywhere;
}

.alarm-hero p {
    color: var(--muted);
    font-size: clamp(18px, 1.4vw, 24px);
    margin: 8px 0 0;
}

.address-band,
.message-band {
    background: var(--panel-2);
    border-radius: 6px;
    margin-top: 16px;
    padding: 14px;
}

.address-band strong,
.address-band span {
    display: block;
}

.address-band strong {
    font-size: 24px;
}

.address-band span,
.message-band {
    color: var(--muted);
}

.map-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.map-mode {
    background: var(--panel-2);
    border: 1px solid var(--line);
}

.map-mode.active {
    background: var(--accent);
    border-color: var(--accent);
}

.map-board {
    aspect-ratio: 16 / 9;
    background: #20282b;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 12px;
    flex: 1 1 auto;
    min-height: clamp(360px, 52vh, 720px);
    overflow: hidden;
    position: relative;
}

.leaflet-board {
    background: #111;
    overflow: hidden;
}

#alarmMap {
    inset: 0;
    height: 100%;
    min-height: 100%;
    position: absolute;
    width: 100%;
}

#alarmMap .leaflet-tile-container,
#alarmMap .leaflet-pane,
#alarmMap .leaflet-map-pane {
    position: absolute;
}

#alarmMap .leaflet-tile {
    position: absolute;
}

#alarmMap .leaflet-map-pane {
    z-index: 1;
}

#alarmMap .leaflet-tile-pane {
    z-index: 200;
}

#alarmMap .leaflet-overlay-pane {
    z-index: 400;
}

#alarmMap .leaflet-shadow-pane {
    z-index: 500;
}

#alarmMap .leaflet-marker-pane {
    z-index: 650;
}

#alarmMap .leaflet-tooltip-pane {
    z-index: 700;
}

#alarmMap .leaflet-popup-pane {
    z-index: 750;
}

#alarmMap .leaflet-marker-icon,
#alarmMap .leaflet-marker-shadow {
    display: block;
    position: absolute;
}

#alarmMap .leaflet-control-container {
    position: relative;
    z-index: 800;
}

.map-grid {
    inset: 0;
    position: absolute;
}

.map-marker {
    align-items: center;
    display: grid;
    gap: 6px;
    justify-items: center;
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.map-marker span {
    align-items: center;
    background: var(--accent);
    border: 3px solid white;
    border-radius: 999px;
    display: inline-flex;
    font-size: 13px;
    font-weight: 900;
    height: 28px;
    justify-content: center;
    width: 28px;
}

.map-marker.incident {
    left: 50%;
    top: 50%;
}

.map-marker.incident span {
    height: 38px;
    width: 38px;
}

.map-marker.hydrant span {
    background: #2f80ed;
}

.map-marker strong {
    background: rgba(7, 8, 9, 0.78);
    border-radius: 4px;
    font-size: 12px;
    padding: 4px 6px;
    white-space: nowrap;
}

.map-caption {
    background: rgba(7, 8, 9, 0.76);
    border-radius: 4px;
    bottom: 12px;
    color: var(--muted);
    left: 12px;
    padding: 6px 8px;
    position: absolute;
}

.unit-list {
    display: grid;
    gap: 10px;
}

.unit-item {
    background: var(--panel-2);
    border-left: 4px solid var(--line);
    border-radius: 6px;
    display: grid;
    gap: 4px;
    padding: 12px;
}

.unit-item.known {
    border-left-color: var(--ok);
}

.unit-item.unknown {
    border-left-color: var(--warn);
}

.unit-item.with-status {
    border-left-color: var(--unit-status-color, var(--line));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--unit-status-color, var(--line)) 45%, transparent);
}

.unit-item span,
.unit-item small {
    color: var(--muted);
}

.vehicle-status-dot {
    background: var(--vehicle-status-color, var(--muted));
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 999px;
    display: inline-block;
    height: 0.75em;
    margin: 0 4px;
    vertical-align: -0.05em;
    width: 0.75em;
}

@media (max-width: 1100px) {
    .page:has(.monitor-viewport) {
        padding: 10px;
    }

    .monitor-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .monitor-main,
    .monitor-side {
        max-height: none;
    }

    .monitor-side {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
    }

    .monitor-side section {
        min-width: 0;
    }

    .map-board {
        min-height: clamp(360px, 58vh, 620px);
    }

    .info-incident-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .page {
        padding: 16px;
    }

    .panel-title {
        align-items: stretch;
        flex-direction: column;
    }

    .alarm-row,
    .alarmnetz-registered-row,
    .table-head,
    .table-row,
    .event-row {
        grid-template-columns: 1fr;
    }

    .monitor-shell,
    .monitor-info-header,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .monitor-viewport,
    .monitor-shell {
        min-height: auto;
    }

    .monitor-info-header,
    .info-incident-title {
        flex-direction: column;
    }

    .monitor-side {
        grid-template-columns: 1fr;
    }

    .alarm-hero {
        flex-direction: column;
    }

    .alarm-hero h1 {
        font-size: 36px;
    }

    .map-board {
        aspect-ratio: 4 / 3;
        min-height: 320px;
    }

    .table-head {
        display: none;
    }
}
