:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-2: #eef3f7;
    --text: #18202a;
    --muted: #697586;
    --border: #d9e1ea;
    --primary: #1d4ed8;
    --primary-strong: #1742b5;
    --secondary: #0f766e;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --success: #15803d;
    --success-soft: #dcfce7;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 8px;
    --sidebar-width: 264px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.9;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-body {
    padding-bottom: 82px;
}

.main {
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 14px;
}

.mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 10px 14px;
    background: rgba(246, 248, 251, 0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.sidebar {
    display: none;
}

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

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    color: #ffffff;
    background: #172033;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 800;
}

.system-mark {
    background: #111827;
}

.brand strong,
.brand span:last-child {
    display: block;
    min-width: 0;
    font-weight: 800;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.brand.compact .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
}

.topbar {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.14;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.topbar-actions,
.object-actions,
.sticky-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    color: #ffffff;
    background: var(--primary);
}

.button-primary:hover {
    background: var(--primary-strong);
}

.button-secondary {
    color: #ffffff;
    background: var(--secondary);
}

.button-danger {
    color: #ffffff;
    background: var(--danger);
}

.button-ghost {
    border-color: var(--border);
    background: var(--surface);
}

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

.quiet-link {
    color: var(--primary);
    font-size: 14px;
    font-weight: 800;
}

.panel {
    margin-bottom: 14px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel h2,
.panel-head h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.24;
}

.panel p,
.panel-head p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.quick-search {
    padding: 12px;
}

.search-form,
.filter-form {
    display: grid;
    gap: 10px;
}

.search-field input {
    min-height: 48px;
}

label span,
fieldset legend {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.field-note {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text);
    outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

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

.status-tile {
    min-height: 82px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.status-tile span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.status-tile strong {
    display: block;
    margin-top: 7px;
    font-size: 25px;
    line-height: 1;
}

.status-normal {
    border-color: #bbf7d0;
}

.status-warning {
    border-color: #fde68a;
}

.status-danger {
    border-color: #fecaca;
}

.status-dot {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    margin-top: 5px;
    border-radius: 999px;
    background: var(--success);
}

.status-dot.status-besonderheit,
.status-badge.status-besonderheit,
.map-marker.status-besonderheit span {
    background: var(--warning);
}

.status-dot.status-akut,
.status-badge.status-akut,
.map-marker.status-akut span {
    background: var(--danger);
}

.status-dot.status-muted {
    background: #64748b;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 9px;
    border-radius: 999px;
    color: #ffffff;
    background: var(--success);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.status-badge.status-badge-muted {
    background: #64748b;
}

.system-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.object-list,
.compact-list,
.contact-list,
.document-list,
.event-list,
.member-list {
    display: grid;
    gap: 10px;
}

.object-row,
.contact-row,
.document-row,
.event-row,
.member-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfcfe;
}

.object-row strong,
.contact-row strong,
.document-row strong,
.event-row strong,
.member-row strong {
    display: block;
}

.object-row small,
.contact-row small,
.document-row small,
.event-row small,
.member-row small {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.responsive-table {
    overflow-x: auto;
}

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

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

td small {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.table-actions {
    text-align: right;
}

.object-access-head {
    margin-bottom: 16px;
}

.object-access-head h2,
.object-hero h2 {
    margin: 8px 0 4px;
    font-size: 26px;
    line-height: 1.14;
}

.object-access-head p,
.object-hero p {
    margin: 0;
    color: var(--muted);
}

.reason-grid {
    display: grid;
    gap: 8px;
    padding: 0;
    border: 0;
}

.reason-grid label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfcfe;
}

.reason-grid input {
    width: auto;
    min-height: auto;
}

.stack {
    display: grid;
    gap: 12px;
}

.object-hero {
    display: grid;
    gap: 14px;
    margin-bottom: 12px;
    padding: 16px;
    background: #172033;
    color: #ffffff;
    border-radius: var(--radius);
}

.object-hero p {
    color: #cbd5e1;
}

.session-strip {
    margin-bottom: 14px;
    padding: 10px 12px;
    color: #14532d;
    background: var(--success-soft);
    border: 1px solid #86efac;
    border-radius: var(--radius);
    font-weight: 800;
}

.summary-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.summary-list div {
    min-height: 72px;
    padding: 12px;
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.summary-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.summary-list dd {
    margin: 5px 0 0;
    font-size: 20px;
    font-weight: 900;
}

.summary-list.small dd {
    font-size: 16px;
}

.alert-list,
.line-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.alert-list li {
    padding: 11px 12px;
    color: #7f1d1d;
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    font-weight: 800;
}

.line-list li {
    padding: 10px 12px;
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.contact-row,
.document-row,
.event-row,
.member-row {
    display: grid;
    gap: 3px;
}

.contact-row span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.contact-row a {
    color: var(--primary);
    font-weight: 900;
}

.meta-footer {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
}

.object-form {
    padding-bottom: 84px;
}

.form-section {
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.sticky-actions {
    position: sticky;
    right: 0;
    bottom: 82px;
    z-index: 8;
    justify-content: flex-end;
    padding: 10px;
    background: rgba(246, 248, 251, 0.95);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
}

.admin-grid,
.object-grid,
.dashboard-grid {
    display: grid;
    gap: 14px;
}

.avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: #ffffff;
    background: var(--secondary);
    border-radius: var(--radius);
    font-weight: 900;
}

.member-row {
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
}

.map-canvas {
    position: relative;
    height: 360px;
    overflow: hidden;
    background:
        linear-gradient(90deg, rgba(29, 78, 216, 0.08) 1px, transparent 1px),
        linear-gradient(0deg, rgba(29, 78, 216, 0.08) 1px, transparent 1px),
        #eef4f8;
    background-size: 44px 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

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

.map-marker span {
    width: 18px;
    height: 18px;
    border: 3px solid #ffffff;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.24);
}

.map-marker strong {
    padding: 2px 5px;
    color: #172033;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px;
}

.flash {
    margin-bottom: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-weight: 800;
}

.flash-success {
    color: #14532d;
    background: var(--success-soft);
    border-color: #86efac;
}

.flash-danger {
    color: #7f1d1d;
    background: var(--danger-soft);
    border-color: #fecaca;
}

.empty-state,
.hint-box,
.debug-box {
    padding: 14px;
    background: #fbfcfe;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.debug-box {
    white-space: pre-wrap;
}

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

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 70px;
    padding: 7px 8px 9px;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--border);
    box-shadow: 0 -12px 26px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
}

.bottom-nav a {
    display: grid;
    place-items: center;
    gap: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
}

.bottom-nav a.is-active {
    color: var(--primary);
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 16px;
    background:
        linear-gradient(145deg, rgba(29, 78, 216, 0.1), transparent 34%),
        var(--bg);
}

.auth-shell {
    width: min(100%, 440px);
}

.auth-panel {
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-brand {
    margin-bottom: 24px;
}

.auth-copy h1 {
    margin: 0 0 6px;
    font-size: 28px;
    line-height: 1.12;
}

.auth-copy p {
    margin: 0 0 18px;
    color: var(--muted);
}

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

.org-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfcfe;
}

.org-option input {
    width: auto;
    min-height: auto;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfcfe;
}

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

.check-row span {
    margin: 0;
    color: var(--text);
}

.org-option small {
    display: block;
    color: var(--muted);
}

@media (max-width: 720px) {
    .responsive-table table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table th,
    .responsive-table td {
        display: block;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        margin-bottom: 10px;
        padding: 10px;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: #fbfcfe;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
    }

    .responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 900;
        text-align: left;
        text-transform: uppercase;
    }

    .table-actions {
        justify-content: flex-end;
    }
}

@media (min-width: 760px) {
    .main {
        padding: 22px;
    }

    .search-form {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .filter-form {
        grid-template-columns: minmax(220px, 1.2fr) minmax(150px, 0.7fr) minmax(170px, 0.8fr) auto auto;
        align-items: end;
    }

    .system-filter-form {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .system-status-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .dashboard-grid,
    .object-grid,
    .admin-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .panel-wide {
        grid-column: 1 / -1;
    }

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

    .form-grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .object-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .reason-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (min-width: 940px) {
    .app-body {
        padding-bottom: 0;
    }

    .mobile-topbar,
    .bottom-nav {
        display: none;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        display: flex;
        flex-direction: column;
        width: var(--sidebar-width);
        padding: 18px;
        background: #ffffff;
        border-right: 1px solid var(--border);
    }

    .main {
        width: auto;
        max-width: 1280px;
        margin-left: var(--sidebar-width);
        padding: 26px 28px;
    }

    .topbar {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .topbar h1 {
        font-size: 32px;
    }

    .side-nav {
        display: grid;
        gap: 6px;
        margin-top: 28px;
    }

    .side-nav a {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 44px;
        padding: 0 10px;
        color: var(--muted);
        border-radius: var(--radius);
        font-size: 14px;
        font-weight: 900;
    }

    .side-nav a.is-active,
    .side-nav a:hover {
        color: var(--primary);
        background: #eff6ff;
    }

    .sidebar-context {
        margin-top: auto;
        padding: 12px;
        background: var(--surface-2);
        border-radius: var(--radius);
    }

    .sidebar-context span,
    .sidebar-context small {
        display: block;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
    }

    .sidebar-context strong {
        display: block;
        margin: 4px 0;
        font-size: 14px;
        line-height: 1.3;
    }

    .sticky-actions {
        bottom: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
