:root {
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --text: #1f2933;
    --muted: #6b7785;
    --primary: #2f6f4f;
    --primary-dark: #24583e;
    --border: #e2e6ea;
    --danger: #c0392b;
    --warn: #c9971e;
    --ok: #2f8f4e;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary-dark); }

.topbar {
    background: var(--primary);
    color: #fff;
    position: relative;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: relative;
}
.brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
    white-space: nowrap;
}

/* Hamburger-Toggle: per Checkbox-Hack ohne JavaScript */
.nav-toggle-checkbox { display: none; }
.nav-toggle-label {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle-label span {
    display: block;
    width: 100%;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle-checkbox:checked ~ .nav-toggle-label span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.nav-toggle-checkbox:checked ~ .nav-toggle-label span:nth-child(2) { opacity: 0; }
.nav-toggle-checkbox:checked ~ .nav-toggle-label span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.main-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}
.topbar nav a {
    color: #eafff2;
    text-decoration: none;
    margin-left: 16px;
    font-size: 0.92rem;
    white-space: nowrap;
}
.topbar nav a:hover { text-decoration: underline; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    min-width: 0;
}

h1 { font-size: 1.5rem; margin-top: 0; }
h2 { font-size: 1.2rem; margin-top: 0; }
h3 { font-size: 1.02rem; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    min-width: 0;
}
.grid > * { min-width: 0; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.94rem;
}
th, td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 600; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
}

.type-akut { color: var(--danger); }
.type-reha { color: #2f6fa0; }
.type-sonstige { color: var(--muted); }

form.stacked label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}
form.stacked input[type=text],
form.stacked input[type=password],
form.stacked input[type=date],
form.stacked input[type=number],
form.stacked select,
form.stacked textarea {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary {
    background: transparent;
    color: var(--primary-dark);
    border: 1px solid var(--primary-dark);
}
.btn.danger {
    background: var(--danger);
}

.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.92rem;
}
.alert.error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c1; }
.alert.success { background: #e9f7ee; color: var(--ok); border: 1px solid #bfe8cc; }
.alert.info { background: #eef4fb; color: #2f6fa0; border: 1px solid #cfe0f2; }

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.82rem;
    padding: 20px;
}

.bars {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin: 20px 0 10px;
    width: 100%;
    min-width: 0;
}
.bar-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.bar-track {
    height: 160px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.bar-stack {
    width: 100%;
    max-width: 56px;
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-start;
}
.bar-seg-akut, .bar-seg-reha, .bar-seg-sonstige { width: 100%; }
.bar-seg-akut { background: var(--danger); }
.bar-seg-reha { background: #2f6fa0; }
.bar-seg-sonstige { background: #9aa5b1; }
.bar-label { margin-top: 8px; font-size: 0.82rem; color: var(--muted); text-align: center; }
.bar-value { font-size: 0.78rem; color: var(--text); white-space: nowrap; margin-bottom: 4px; }

.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 0.85rem; margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; display: inline-block; border-radius: 2px; }

.reasons li { margin-bottom: 10px; }

.setup-box {
    max-width: 460px;
    margin: 60px auto;
}

/* PWA "Neue Version verfügbar"-Banner: zentrierte, schwebende Karte */
.pwa-update-banner {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 380px;
    z-index: 1000;
    background: var(--primary-dark);
    color: #fff;
    padding: 18px 20px;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    font-size: 0.96rem;
    animation: pwa-banner-in 0.25s ease-out;
}
.pwa-update-banner .pwa-update-text { font-weight: 500; }
.pwa-update-banner .pwa-update-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.pwa-update-banner button {
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.pwa-update-banner button.pwa-update-confirm {
    background: #fff;
    color: var(--primary-dark);
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.92rem;
    white-space: nowrap;
}
.pwa-update-banner button.pwa-update-confirm:disabled { opacity: 0.7; cursor: default; }
.pwa-update-banner button.dismiss {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    font-size: 1.15rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
@keyframes pwa-banner-in {
    from { transform: translateX(-50%) translateY(24px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@media (max-width: 640px) {
    .pwa-update-banner { bottom: 14px; width: calc(100% - 24px); }
}

/* ---------------------------------------------------------------------
 * Mobile: Hamburger-Dropdown-Navigation
 * ------------------------------------------------------------------- */
@media (max-width: 768px) {
    .nav-toggle-label { display: flex; }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--primary-dark);
        padding: 6px 20px 14px;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
        z-index: 100;
    }
    .nav-toggle-checkbox:checked ~ .main-nav { display: flex; }

    .topbar nav a {
        margin-left: 0;
        padding: 12px 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }
    .topbar nav a:last-child { border-bottom: none; }
}

/* ---------------------------------------------------------------------
 * Mobile: Tabellen als Karten statt horizontalem Scrollen
 * ------------------------------------------------------------------- */
@media (max-width: 700px) {
    table.rtable, table.rtable thead, table.rtable tbody,
    table.rtable th, table.rtable td, table.rtable tr {
        display: block;
    }
    table.rtable thead {
        position: absolute;
        width: 1px; height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }
    table.rtable tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 4px 0;
        background: var(--card-bg);
    }
    table.rtable td {
        border: none;
        border-bottom: 1px solid var(--border);
        padding: 8px 10px 8px 44%;
        position: relative;
        min-height: 20px;
    }
    table.rtable tr td:last-child { border-bottom: none; }
    table.rtable td[data-label]::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        top: 8px;
        width: 40%;
        font-weight: 600;
        color: var(--muted);
        font-size: 0.8rem;
    }
    table.rtable td:empty { display: none; }
}

@media (max-width: 640px) {
    .bars { gap: 6px; }
    .bar-track { height: 120px; }
    .bar-stack { max-width: 30px; }
    .bar-value { font-size: 0.68rem; }
    .bar-label { font-size: 0.72rem; margin-top: 6px; }
    .card { padding: 14px; }
    h1 { font-size: 1.3rem; }
}
