*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --primary: #24292f;
    --primary-dark: #171b20;
    --primary-soft: #eef1f4;

    --accent: #b42318;
    --accent-dark: #8f1c13;
    --accent-soft: #fdecea;

    --success: #166534;
    --success-soft: #dcfce7;

    --warning: #92400e;
    --warning-soft: #fef3c7;

    --info: #1d4ed8;
    --info-soft: #dbeafe;

    --text: #1f2937;
    --text-soft: #667085;
    --heading: #111827;

    --line: #d8e0e8;
    --line-strong: #c6d0da;

    --bg: #e9edf2;
    --bg-dark: #dde3ea;
    --card: rgba(255, 255, 255, 0.97);
    --white: #ffffff;

    --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    --shadow-strong: 0 18px 40px rgba(15, 23, 42, 0.14);

    --radius: 16px;
    --radius-sm: 12px;
    --container: 1220px;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Arial, sans-serif;
    color: var(--text);
    line-height: 1.5;
    background:
        linear-gradient(180deg, #edf1f5 0%, #e6ebf1 100%);
}

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

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

.container {
    width: min(var(--container), calc(100% - 32px));
    margin: 0 auto;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background:
        linear-gradient(180deg, rgba(23, 27, 32, 0.98), rgba(36, 41, 47, 0.98));
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 68px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(180, 35, 24, 0.18);
    flex: 0 0 auto;
}

.brand a {
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    cursor: pointer;
    font-size: 1.25rem;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a,
.nav button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
}

.nav a:hover,
.nav button:hover,
.nav a.is-active {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

/* Layout */
.content {
    padding: 22px 0 40px;
}

.card {
    background: var(--card);
    border: 1px solid rgba(17, 24, 39, 0.05);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    backdrop-filter: blur(6px);
}

.card h1,
.card h2,
.card h3 {
    margin-top: 0;
    color: var(--heading);
}

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

.section-title {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.section-title h2 {
    margin: 0;
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-weight: 700;
    border: 1px solid transparent;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Buttons */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 16px;
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

button:hover,
.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn:active,
button:active {
    transform: translateY(1px);
}

.btn-secondary {
    background: #e7edf3;
    color: var(--text);
    border: 1px solid #d6dee7;
}

.btn-secondary:hover {
    background: #dde5ed;
}

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

.btn-danger:hover {
    background: var(--accent-dark);
}

.btn-block {
    width: 100%;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 700;
    font-size: 0.94rem;
    color: var(--heading);
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border: 1px solid #ccd5de;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #8d98a4;
    box-shadow: 0 0 0 4px rgba(36, 41, 47, 0.08);
    background: #fff;
}

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

small {
    color: var(--text-soft);
}

/* Dashboard / Lageboard */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 74px;
    height: 74px;
    border-radius: 0 0 0 100%;
    background: rgba(255, 255, 255, 0.28);
}

.stat-card__label {
    color: var(--text-soft);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.76rem;
}

.stat-card__value {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1;
    color: var(--heading);
}

.stat-card__sub {
    font-size: 0.88rem;
    color: var(--text-soft);
}

.stat-card--open {
    background: linear-gradient(180deg, #fff5f5 0%, #fee2e2 100%);
}

.stat-card--progress {
    background: linear-gradient(180deg, #eef4ff 0%, #dbeafe 100%);
}

.stat-card--waiting {
    background: linear-gradient(180deg, #fff9e8 0%, #fef3c7 100%);
}

.stat-card--done {
    background: linear-gradient(180deg, #edfdf2 0%, #dcfce7 100%);
}

.stat-card--neutral {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
}

.stat-link {
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-link:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Leitstellenkopf / Einsatzkopf */
.incident-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.incident-code {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #f3f6f9;
    border: 1px solid #dde5ec;
    font-weight: 800;
    color: var(--heading);
    letter-spacing: 0.03em;
}

.incident-code::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--accent);
    flex: 0 0 auto;
}

.incident-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Meta-Lagekarten */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.info-panel {
    background: #f8fafc;
    border: 1px solid #e0e7ef;
    border-radius: 14px;
    padding: 16px;
}

.info-panel h3 {
    margin-bottom: 12px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

.info-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    align-items: start;
}

.info-row dt {
    margin: 0;
    color: var(--text-soft);
    font-weight: 700;
}

.info-row dd {
    margin: 0;
    color: var(--heading);
    font-weight: 600;
}

/* Tables */
.table-wrap {
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

thead th {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    font-size: 0.8rem;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

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

tbody tr:hover td {
    background: rgba(17, 24, 39, 0.018);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.badge-offen {
    background: #fee2e2;
    color: #991b1b;
}

.badge-in_bearbeitung {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-wartend {
    background: #fef3c7;
    color: #92400e;
}

.badge-abgeschlossen {
    background: #dcfce7;
    color: #166534;
}

.badge-archived {
    background: #eceff3;
    color: #4b5563;
}

.actions-row .badge {
    min-height: 34px;
}

/* Utility */
.actions-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.inline-form {
    display: inline;
}

.log-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.log-item:last-child {
    border-bottom: 0;
}

.log-item__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.muted {
    color: var(--text-soft);
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 18px 0;
}

/* Images */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.image-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.image-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    border: 1px solid var(--line);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

/* Login */
body.login-page {
    background:
        radial-gradient(circle at top left, rgba(180, 35, 24, 0.08), transparent 35%),
        radial-gradient(circle at bottom right, rgba(36, 41, 47, 0.1), transparent 35%),
        linear-gradient(180deg, #edf1f4 0%, #e6ebf0 100%);
}

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

.login-card {
    width: min(100%, 460px);
    background: rgba(255, 255, 255, 0.97);
    border-radius: 22px;
    box-shadow: 0 20px 50px rgba(31, 35, 40, 0.14);
    padding: 28px;
    border: 1px solid rgba(31, 35, 40, 0.05);
}

.login-card h1 {
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.login-card p {
    color: var(--text-soft);
    margin-top: 0;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 980px) {
    .meta-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    .nav-toggle {
        display: inline-flex;
    }

    .nav {
        position: absolute;
        top: 68px;
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 14px 16px 18px;
        background: var(--primary-dark);
        box-shadow: 0 16px 30px rgba(15, 23, 42, 0.24);
    }

    .nav.is-open {
        display: flex;
    }

    .nav a,
    .nav button {
        justify-content: flex-start;
        width: 100%;
        padding: 12px 14px;
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.06);
    }
}

@media (max-width: 760px) {
    .content {
        padding: 18px 0 30px;
    }

    .card {
        padding: 18px;
    }

    .form-grid,
    .meta-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .info-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .actions-row,
    .incident-actions,
    .quick-actions {
        flex-direction: column;
    }

    .actions-row .btn,
    .actions-row button,
    .actions-row form,
    .incident-actions .btn,
    .incident-actions button,
    .incident-actions form,
    .quick-actions .btn {
        width: 100%;
    }

    .actions-row form button,
    .incident-actions form button {
        width: 100%;
    }

    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap tr,
    .table-wrap th,
    .table-wrap td {
        display: block;
        width: 100%;
    }

    .table-wrap thead {
        display: none;
    }

    .table-wrap tbody {
        display: grid;
        gap: 14px;
    }

    .table-wrap tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 14px;
        padding: 10px 12px;
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
    }

    .table-wrap td {
        border: 0;
        padding: 8px 0;
    }

    .table-wrap td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--text-soft);
        font-size: 0.8rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .image-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 520px) {
    .container {
        width: min(var(--container), calc(100% - 20px));
    }

    .topbar-inner {
        min-height: 64px;
    }

    .nav {
        top: 64px;
    }

    .brand a {
        font-size: 0.94rem;
    }

    .login-card {
        padding: 22px 18px;
        border-radius: 18px;
    }

    .image-grid {
        grid-template-columns: 1fr;
    }

    .stat-card__value {
        font-size: 1.8rem;
    }
}