:root {
    --teal: #004f4f;
    --teal-2: #006a6a;
    --mint: #00dddd;
    --bar: #79dddd;
    --bg: #f4f7f7;
    --card: #ffffff;
    --ink: #1c2424;
    --muted: #5d6b6b;
    --line: #d5e0e0;
    --danger: #9f1d30;
    --ok: #0d6b4d;
    --shadow: 0 8px 24px rgba(0, 40, 40, 0.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.45 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

a { color: var(--teal-2); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 8px 12px;
    background: var(--teal);
    color: white;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
    font-weight: 650;
    white-space: nowrap;
}

.brand img { width: 34px; height: 34px; }

.main-nav {
    display: flex;
    flex: 1;
    justify-content: space-evenly;
    gap: 4px;
    overflow-x: auto;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 64px;
    padding: 4px 6px;
    border-radius: 10px;
    color: var(--mint);
    text-decoration: none;
}

.nav-btn svg { width: 24px; height: 24px; fill: currentColor; }

.nav-label { font-size: 11px; line-height: 1.1; text-align: center; }

.nav-btn:hover, .nav-btn.is-active { background: rgba(255, 255, 255, 0.12); color: white; }

.page { padding: 16px; }

.page-heading {
    margin: 0 0 14px;
    font-size: 1.35rem;
    font-weight: 650;
    color: var(--teal);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: end;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.toolbar .field { flex: 0 1 220px; max-width: 240px; height: auto; }
.toolbar .field.grow, .toolbar > .grow { flex: 1 1 280px; max-width: none; height: auto; }
.toolbar input, .toolbar select, .toolbar .btn {
    height: 40px;
    min-height: 40px;
    font-size: 15px;
    line-height: 1.2;
    border-radius: 8px;
    padding: 0 12px;
}
.toolbar .btn { width: auto; padding: 0 14px; }
.toolbar label.field { font-size: 15px; font-weight: 600; }

.toolbar .spacer { margin-left: auto; }

.grow { flex: 1; min-width: 180px; }

label.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 13px; color: var(--teal); }

input, select, textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    border-radius: 4px;
    accent-color: var(--teal);
    flex: 0 0 18px;
}

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

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--mint);
    border-color: var(--teal-2);
}

.btn {
    border: 1px solid #c5d4d4;
    border-radius: 8px;
    height: 40px;
    padding: 0 14px;
    background: #f7fafa;
    color: var(--teal);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:hover { filter: brightness(0.97); }

.btn-primary { background: var(--teal); color: white; }

.btn-ghost { background: transparent; border: 1px solid rgba(0, 79, 79, 0.25); }

.btn.is-on { background: var(--teal); color: white; }

.btn-danger { background: var(--danger); color: white; }

.btn:disabled { opacity: 0.55; cursor: default; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.card, .panel {
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px;
}

.card h2, .panel h2, .panel h3 { margin: 0 0 8px; }

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

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }

.badge {
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e7f6f6;
}

.card-actions { display: flex; gap: 8px; }

.icon-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: #e7f6f6;
    color: var(--teal);
    cursor: pointer;
    text-decoration: none;
    display: grid;
    place-items: center;
}

.icon-btn.danger { background: #fde8ec; color: var(--danger); }

.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }

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

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

.person-form { max-width: 880px; }
.form-grid > .field > input,
.form-grid > .field > select,
.form-grid > .field > textarea {
    align-self: stretch;
    height: 40px;
    min-height: 40px;
    font-size: 15px;
    border-radius: 8px;
}
.form-grid textarea { height: 72px; min-height: 72px; padding-top: 8px; }
.person-form .form-grid > .field > textarea[name="telefon"],
.person-form .form-grid > .field > textarea[name="email"] {
    height: 76px;
    min-height: 76px;
    line-height: 1.4;
}
.person-form .form-grid > .field > textarea[name="adresse"],
.person-form .form-grid > .field > textarea[name="notfallkontaktadresse"] {
    height: 168px;
    min-height: 168px;
    line-height: 1.4;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px 14px;
    align-items: start;
}

.check-grid label, .inline-check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-height: 40px;
    font-size: 15px;
    line-height: 1.25;
}

.check-grid input[type="checkbox"],
.inline-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    margin: 1px 0 0;
    padding: 0;
    flex: 0 0 18px;
    accent-color: var(--teal);
}

.section-title { margin: 22px 0 10px; color: var(--teal); }

.table-wrap { overflow: auto; background: white; border-radius: 16px; box-shadow: var(--shadow); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th, td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }

th { background: #eef6f6; position: sticky; top: 0; }

.reports .col-api { background: #f6d4d4; }
.reports .col-hipi { background: #d9efc2; }
.reports .col-part { background: #d5e2ff; }
.reports input { background: #fff; }

td input, td select { height: 36px; min-width: 0; padding: 4px 8px; }

td input[type="number"] {
    width: 6.4rem;
    min-width: 6.4rem;
    max-width: 6.4rem;
    margin: 0 auto;
    display: block;
    text-align: right;
}

td input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    margin: 0;
}

td input[type="text"], td input:not([type]) { width: 100%; min-width: 140px; }

.att th, .att td { text-align: center; }

.att .sticky-col { text-align: left; min-width: 140px; background: #fff; }

.att th.sticky-col { background: #f4f7f7; }

.att .col-we { background: #b2df87; }

.att .col-wd { background: #a5bfff; }

.att th { position: sticky; top: 0; z-index: 1; }

.att input { background: #fff; }

.sticky-col { position: sticky; left: 0; background: white; z-index: 1; min-width: 160px; }

th.sticky-col { background: #eef6f6; z-index: 2; }

.form-error {
    background: #fde8ec;
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 10px;
}

.toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 30;
    max-width: 320px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--teal);
    color: white;
    box-shadow: var(--shadow);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top, #d8ffff, transparent 40%),
        var(--bg);
}

.login-card {
    width: min(420px, calc(100% - 32px));
    background: white;
    padding: 28px;
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.login-card h1 { margin: 8px 0 0; }
.login-lead { margin-top: 4px; color: var(--muted); }
.login-logo { width: 64px; height: 64px; }
.login-card form { display: grid; gap: 12px; }
.login-card .btn { margin-top: 6px; }

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }

.print-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding-bottom: 32px;
}

.print-page {
    background: #fff;
    color: #000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    box-sizing: border-box;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

.print-page.portrait { width: 210mm; height: 296mm; padding: 10mm 8mm 8mm; }
.print-page.landscape { width: 297mm; height: 209mm; padding: 8mm 6mm 6mm; }

.print-inner { height: 100%; }

.form-title {
    margin: 0 0 3mm;
    text-align: center;
    font-size: 14pt;
    letter-spacing: 0.2px;
}

.form-code {
    margin-top: 3mm;
    font-size: 8pt;
    color: #222;
}

.tick {
    display: inline-block;
    width: 3.4mm;
    height: 3.4mm;
    border: 1px solid #000;
    text-align: center;
    line-height: 3.1mm;
    font-size: 8pt;
    margin-right: 1mm;
    vertical-align: -0.4mm;
}

.s21-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    column-gap: 8mm;
    row-gap: 1.2mm;
    font-size: 11pt;
    margin-bottom: 2mm;
}

.s21-head .span { grid-column: 1 / -1; }
.s21-roles {
    display: flex;
    justify-content: space-between;
    gap: 3mm;
    font-size: 11pt;
    margin: 1mm 0 4mm;
}

.s21-table, .s88-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
}

.s21-table th, .s21-table td, .s88-table th, .s88-table td {
    border: 1px solid #000;
    padding: 0.8mm 1mm;
    text-align: center;
    background: #fff;
    position: static;
    font-weight: 400;
}

.s21-table th, .s88-table th { font-weight: 700; font-size: 8pt; line-height: 1.15; }
.s21-table td.month, .s88-table td.month { text-align: left; font-weight: 700; }
.s21-table td.note, .s21-table th.note { text-align: left; }
.s21-table tr.sum td { border: 0; font-weight: 700; }
.s21-table tr.sum td.hours { border: 1px solid #000; }

.s88-block { margin-top: 4mm; }
.s88-block h2 { margin: 0 0 2mm; font-size: 12pt; }
.s88-pair { display: flex; gap: 3mm; }
.s88-pair table { width: 50%; }

.orga-title, .group-title {
    margin: 0 0 4mm;
    text-align: center;
    font-size: 16pt;
    font-weight: 700;
}

.orga-row, .group-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5mm;
}

.orga-col, .group-col { flex: 1 1 0; min-width: 0; }

.duty {
    border: 2px solid #1a1a1a;
    margin: 0 0.4mm 1.6mm;
    padding: 0.7mm 0.7mm 0.5mm;
    color: #111;
    overflow: hidden;
    font-size: 9pt;
}

.duty h3 {
    display: block;
    width: auto;
    max-width: 100%;
    margin: 0 0 0.3mm;
    padding: 0;
    text-align: center;
    font-size: 1em;
    line-height: 1.15;
    font-weight: 700;
    background: transparent;
    white-space: normal;
}

.duty ul, .group-box ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.duty li {
    margin: 0 0 0.35mm;
    line-height: 1.35;
    font-size: 1em;
    white-space: nowrap;
}

.duty li.grp { margin-top: 0.5mm; font-weight: 700; }

.orga-title, .group-title { font-size: 20pt; }
.print-page.landscape { font-size: 7pt; padding: 8mm 3mm 4mm; }
.print-page.landscape .duty { font-size: 7pt; }
.print-page.landscape .duty li { margin-bottom: 0.45mm; line-height: 1.35; }
.print-page.landscape .orga-title { font-size: 18pt; margin: 0 0 3mm; }
.print-page.portrait { font-size: 9pt; }
.print-page.sheet-flow { height: auto; min-height: 0; overflow: visible; }

.sheet-title {
    margin: 0 0 2mm;
    text-align: center;
    font-size: 14pt;
}

.stat-table { width: 100%; border-collapse: collapse; font-size: 8pt; }
.stat-table th, .stat-table td {
    border: 1px solid #7fadad;
    padding: 0.6mm 1mm;
    text-align: center;
    background: #fff;
    position: static;
}
.stat-table th { background: #004f4f; color: #fff; }
.stat-table td:first-child, .stat-table th:first-child { text-align: left; font-weight: 700; }
.stat-table td:first-child { background: #e7f6f6; color: #004f4f; }
.stat-table tbody tr:nth-child(even) td { background: #f3fafa; }
.stat-table tbody tr:nth-child(even) td:first-child { background: #d7efef; }
.stat-table tfoot th { background: #0d6b4d; color: #fff; }
.stat-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;
    gap: 3mm;
    margin-top: 3mm;
    font-size: 8pt;
}
.stat-bottom section { padding: 2mm 2.5mm; border: 1px solid #d5e0e0; }
.stat-idle { background: #fff4e5; }
.stat-out { background: #fdecec; }
.stat-live { background: #e8f6ea; }
.stat-bottom h3 { margin: 0 0 1mm; font-size: 9pt; color: #004f4f; }
.stat-bottom ol { margin: 0; padding-left: 4mm; }
.stat-bottom p { margin: 0 0 1.5mm; }

.notfall-sheet {
    overflow: auto;
    background: #fff;
    border-radius: 0;
    box-shadow: none;
}
.notfall-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    line-height: 1.25;
}
.notfall-table th, .notfall-table td {
    border: 0;
    border-right: 1px solid #222;
    border-bottom: 1px solid #222;
    border-radius: 0;
    padding: 2px 5px;
    vertical-align: top;
    background: #fff;
    position: static;
}
.notfall-table th:first-child, .notfall-table td:first-child { border-left: 1px solid #222; }
.notfall-table thead th { border-top: 1px solid #222; }
.notfall-table th { background: #f2f2f2; font-weight: 700; position: sticky; top: 0; }
.notfall-table .einzeilig, .notfall-table .zeile { white-space: nowrap; }
.notfall-table .zeile { display: block; }
.print-only { display: none; }

.group-box {
    border: 2px solid #1a1a1a;
    margin-bottom: 3.5mm;
    min-height: 28mm;
}

.group-box h3 {
    margin: 0;
    padding: 1mm 1.2mm;
    text-align: center;
    font-size: 12pt;
    color: #111;
}

.group-box li { font-size: 10.5pt; line-height: 1.28; padding: 0.35mm 1.2mm; }

.hint { font-size: 14px; color: var(--muted); }
.empty-note {
    margin: 0;
    padding: 14px 16px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--muted);
    font-size: 15px;
}

.person-pick { position: relative; }
.suggest {
    position: absolute;
    z-index: 30;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 220px;
    overflow: auto;
    box-shadow: var(--shadow);
}
.suggest button {
    display: block;
    width: 100%;
    height: 36px;
    text-align: left;
    border: 0;
    border-radius: 0;
    background: white;
    padding: 0 10px;
    cursor: pointer;
}

.group-admin { padding: 0; }
.group-admin summary {
    cursor: pointer;
    font-weight: 700;
    padding: 14px 16px;
    list-style: none;
}
.group-admin summary::-webkit-details-marker { display: none; }
.group-admin summary::before { content: "▸ "; color: var(--teal); }
.group-admin[open] summary::before { content: "▾ "; }
.group-admin[open] summary { border-bottom: 1px solid var(--line); }
.group-admin-body { padding: 12px 16px 16px; }
.group-admin .toolbar { max-width: 760px; margin-bottom: 0; }
.group-admin-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; max-width: 520px; }
.group-admin-list li { display: grid; grid-template-columns: 18px 1fr auto auto; align-items: center; gap: 10px; }
.group-admin-list .swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid #222; }
.group-admin-list .btn { width: auto; height: 36px; }
.duty-admin-list { max-width: 720px; }
.duty-admin-list li { grid-template-columns: 1fr auto auto; }
.color-field input[type="color"] { padding: 4px; }
.group-empty { border: 0; min-height: 0; margin: 0; background: transparent; }
.suggest button:hover { background: #e7f6f6; }

.karte-table td, .karte-table th { font-size: 13px; }
.check { text-align: center; }

@media (max-width: 1100px) {
    .check-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    .form-grid, .split { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav-label { display: none; }
    .nav-btn { min-width: 42px; }
    .page { overflow-x: auto; }
}

@page { margin: 0; }

@media print {
    .no-print, .topbar, .toast, .toolbar, .page-heading { display: none !important; }
    .print-only { display: block !important; }
    html, body, .page { background: white !important; padding: 0 !important; margin: 0 !important; overflow: visible !important; height: auto !important; }
    .notfall-sheet { overflow: visible !important; border-radius: 0 !important; box-shadow: none !important; }
    .print-stage { display: block; padding: 0; gap: 0; }
    .print-page {
        box-shadow: none;
        margin: 0;
        overflow: hidden;
        break-inside: avoid;
        page-break-inside: avoid;
        page-break-after: always;
        break-after: page;
    }
    .print-stage .print-page:last-child {
        page-break-after: auto;
        break-after: auto;
    }
    .print-page, .print-page *, .notfall-table, .notfall-table * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .notfall-table {
        width: max-content !important;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
        border-radius: 0;
    }
    .notfall-table thead { display: table-header-group; }
    .notfall-table tfoot { display: table-footer-group; }
    .notfall-table tr, .notfall-table th, .notfall-table td {
        break-inside: avoid;
        page-break-inside: avoid;
        border-radius: 0 !important;
    }
    .notfall-table th, .notfall-table td {
        border: 0;
        border-right: 1px solid #222;
        border-bottom: 1px solid #222;
        padding: 0.12em 0.35em;
        background: #fff;
        position: static !important;
    }
    .notfall-table th:first-child, .notfall-table td:first-child { border-left: 1px solid #222; }
    .notfall-table thead th { border-top: 1px solid #222; }
    .notfall-table th { background: #f2f2f2 !important; }
}
