/* =============================================
   HOSPITATIONSBOGEN – Streamlined CSS
   ============================================= */

:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface2: #263348;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --radius: 0.5rem;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
}

:root.light {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface2: #f1f5f9;
    --border: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    padding: 1rem;
}

.container { max-width: 900px; margin: 0 auto; }

/* ── Header ── */
.header {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.875rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}
.header-top {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}
.header h1 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    margin-right: auto;
}

/* Delete button – compact icon */
.btn-delete {
    padding: 0;
    width: 2.75rem;
    height: 2.75rem;
    background: transparent;
    border: 1px solid #ef4444;
    border-radius: var(--radius);
    color: #ef4444;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-delete:hover { background: #ef4444; color: #fff; }

/* Theme toggle */
.btn-theme {
    padding: 0.55rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 0.9375rem;
    min-height: 2.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.btn-theme:hover { background: var(--border); color: var(--text); }

/* Session action buttons */
.btn-session {
    padding: 0.55rem 1rem;
    background: var(--surface2);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9375rem;
    min-height: 2.75rem;
    white-space: nowrap;
    font-family: inherit;
    transition: background .15s, color .15s;
}
.btn-session:hover { background: var(--border); color: var(--text); }

/* Session bar */
.session-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}
#session-select {
    padding: 0.55rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9375rem;
    min-width: 11rem;
    cursor: pointer;
    min-height: 2.75rem;
}
/* Grouped buttons */
.btn-group {
    display: flex;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    flex-shrink: 0;
}
.btn-group .btn-separator {
    width: 1px;
    background: var(--border);
    margin: 0.375rem 0;
    flex-shrink: 0;
}
.btn-group button {
    padding: 0.55rem 1rem;
    background: var(--surface2);
    color: var(--text-muted);
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.9375rem;
    min-height: 2.75rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.btn-group button:last-child { border-right: none; }
.btn-group button:hover { background: var(--border); color: var(--text); }
.btn-group button.btn-primary { background: var(--accent); color: #fff; }
.btn-group button.btn-primary:hover { background: var(--accent-hover); }
.btn-group button.btn-danger { background: #7f1d1d; color: #fca5a5; }
.btn-group button.btn-danger:hover { background: #991b1b; }

/* ── Tab Navigation ── */
.tab-nav {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 0.25rem;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}
.tab-btn {
    flex: 1;
    padding: 0.65rem 1rem;
    background: none;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { background: var(--accent); color: #fff; }

/* ── Tab Content ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Sections / Cards ── */
.section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.75rem;
}
.hint { color: var(--text-muted); font-size: 0.9375rem; margin-bottom: 0.75rem; }

.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 0.75rem;
}
.card h4 {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

/* ── Forms ── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.625rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-group.required label::after { content: ' *'; color: #f87171; }
.form-group label { font-size: 0.9375rem; font-weight: 500; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.65rem 0.75rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color .15s;
    min-height: 2.75rem;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}

/* ── Buttons ── */
.btn-add {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.7rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
    margin-top: 0.625rem;
    min-height: 2.75rem;
}
.btn-add:hover { background: var(--accent-hover); }

.btn-add-small {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.625rem;
    background: #059669;
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background .15s;
    margin-top: 0.375rem;
}
.btn-add-small:hover { background: #047857; }

.btn-action {
    padding: 0.7rem 1.25rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s;
    min-height: 2.75rem;
}
.btn-action:hover { background: var(--accent-hover); }
.btn-action.btn-green { background: #059669; }
.btn-action.btn-green:hover { background: #047857; }

/* ── Photo Upload ── */
.photo-upload-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.25rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: all .15s;
    justify-content: center;
}
.photo-upload-label:hover { border-color: var(--accent); color: var(--text); background: rgba(59,130,246,.05); }

#photos-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.625rem;
    margin-top: 0.75rem;
}
.photo-item { position: relative; border-radius: var(--radius); overflow: hidden; }
.photo-item:hover { transform: scale(1.01); }
#photos-preview img { width: 100%; height: 9rem; object-fit: cover; cursor: pointer; display: block; }
.remove-photo {
    position: absolute;
    top: 0.375rem;
    right: 0.375rem;
    background: rgba(239,68,68,.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.25rem;
    height: 2.25rem;
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.remove-photo:hover { background: #dc2626; }

/* ── Phasen ── */
.phase-item {
    display: grid;
    grid-template-columns: 110px 1.5fr 2fr auto;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    align-items: start;
}
.uhrzeit-input, .sozialform-select {
    padding: 0.65rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    width: 100%;
    min-height: 2.75rem;
}
.notiz-input {
    padding: 0.65rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 2.75rem;
    width: 100%;
}
.remove-phase {
    padding: 0.3rem;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: bold;
    transition: background .15s;
    align-self: start;
}
.remove-phase:hover { background: #b91c1c; }

/* ── Kategorie-Struktur ── */
.kategorie-section {
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 0.625rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* Hauptkategorien */
.main-kategorie-header {
    padding: 1rem 1.25rem;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: flex-start;
}
.main-kategorie-header::-webkit-details-marker { display: none; }
.main-kategorie-header::before {
    content: '▶';
    display: inline-block;
    margin-right: 0.625rem;
    transition: transform .2s;
    font-size: 0.75rem;
    color: rgba(255,255,255,.8);
    width: 1rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}
details.main-kategorie[open] > .main-kategorie-header::before { transform: rotate(90deg); }
.main-kategorie-info { flex: 1; }
.main-kategorie-title { font-size: 1rem; font-weight: 700; color: #fff; margin-bottom: 0.125rem; }
.main-kategorie-description { color: rgba(255,255,255,.85); font-size: 0.8125rem; line-height: 1.4; }
.main-kategorie-content { background: var(--bg); padding: 0.625rem; }

/* Farbklassen */
.color-purple .main-kategorie-header { background: #7c3aed; }
.color-purple .main-kategorie-header:hover { background: #6d28d9; }
.color-blue .main-kategorie-header { background: #2563eb; }
.color-blue .main-kategorie-header:hover { background: #1d4ed8; }
.color-green .main-kategorie-header { background: #16a34a; }
.color-green .main-kategorie-header:hover { background: #15803d; }
.color-yellow .main-kategorie-header { background: #d97706; }
.color-yellow .main-kategorie-header:hover { background: #b45309; }
.color-orange .main-kategorie-header { background: #ea580c; }
.color-orange .main-kategorie-header:hover { background: #c2410c; }
.color-red .main-kategorie-header { background: #dc2626; }
.color-red .main-kategorie-header:hover { background: #b91c1c; }

/* Unterkategorien */
.unterkategorie-section {
    background: var(--surface);
    margin: 0.625rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.kategorie-header {
    background: var(--bg);
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.kategorie-title-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.kategorie-toggle {
    font-size: 1.125rem;
    font-weight: bold;
    cursor: pointer;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border-radius: 0.25rem;
    flex-shrink: 0;
    transition: transform .15s;
}
.kategorie-toggle:hover { background: var(--accent-hover); transform: scale(1.08); }
.kategorie-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    flex: 1;
    cursor: pointer;
}
.rating-buttons { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.rating-btn {
    padding: 0.625rem 0.875rem;
    border: 1.5px solid var(--border);
    background: var(--surface);
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text);
    transition: all .15s;
    min-height: 2.75rem;
}
.rating-btn:hover { border-color: var(--accent); background: #1e3a5f; }
.rating-btn.active[data-value="0%"]   { border-color:#991b1b; background:#7f1d1d; color:#fecaca; }
.rating-btn.active[data-value="25%"]  { border-color:#9a3412; background:#7c2d12; color:#fed7aa; }
.rating-btn.active[data-value="50%"]  { border-color:#854d0e; background:#713f12; color:#fef08a; }
.rating-btn.active[data-value="75%"]  { border-color:#365314; background:#3f6212; color:#bef264; }
.rating-btn.active[data-value="100%"] { border-color:#14532d; background:#166534; color:#86efac; }
.rating-display { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; }
.rating-value { color: var(--accent); font-weight: bold; }

.kategorie-subcontent { padding: 1rem; }
.subcategory-items { background: var(--bg); padding: 0.75rem; border-radius: var(--radius); margin-bottom: 0.75rem; }
.subcategory-items h4 { font-weight: 600; margin-bottom: 0.5rem; color: var(--text); font-size: 1rem; }
.subcategory-items ul { list-style: disc; padding-left: 1.25rem; }
.subcategory-items li { margin-bottom: 0.5rem; color: var(--text-muted); line-height: 1.6; font-size: 0.9375rem; }
.notes-section label { font-size: 0.9375rem; font-weight: 500; color: var(--text); margin-bottom: 0.375rem; display: block; }
.category-notes {
    width: 100%;
    min-height: 5rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.8125rem;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
}
.category-notes:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59,130,246,.15); }

/* ── Auswertung ── */
.auswertung-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.stammdaten-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
    background: var(--bg);
    padding: 1.25rem;
    border-radius: var(--radius);
}
#stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}
.stat-box {
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 2px solid;
}
.stat-box-title { font-weight: 700; font-size: 0.9375rem; margin-bottom: 0.125rem; }
.stat-box-info { font-size: 0.8125rem; margin-bottom: 0.375rem; opacity: .85; }
.stat-box-value { font-size: 0.8125rem; }

/* Stat-box color variants */
.stat-box.color-purple { background:#2e1065; border-color:#7c3aed; color:#e9d5ff; }
.stat-box.color-blue   { background:#1e3a8a; border-color:#2563eb; color:#dbeafe; }
.stat-box.color-green  { background:#14532d; border-color:#16a34a; color:#d1fae5; }
.stat-box.color-yellow { background:#713f12; border-color:#d97706; color:#fef3c7; }
.stat-box.color-orange { background:#7c2d12; border-color:#ea580c; color:#fed7aa; }
.stat-box.color-red    { background:#7f1d1d; border-color:#dc2626; color:#fecaca; }

/* Rating-based overrides for stat-box */
.stat-box[data-rating="unbewertet"] { background:var(--surface); border-color:var(--border); color:var(--text); }
.stat-box[data-rating="0%"]   { background:#7f1d1d; border-color:#991b1b; color:#fecaca; }
.stat-box[data-rating="25%"]  { background:#7c2d12; border-color:#9a3412; color:#fed7aa; }
.stat-box[data-rating="50%"]  { background:#713f12; border-color:#854d0e; color:#fef08a; }
.stat-box[data-rating="75%"]  { background:#3f6212; border-color:#365314; color:#bef264; }
.stat-box[data-rating="100%"] { background:#166534; border-color:#14532d; color:#86efac; }

/* Stat-box rating colours – light mode */
:root.light .stat-box[data-rating="unbewertet"] { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }
:root.light .stat-box[data-rating="0%"]   { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
:root.light .stat-box[data-rating="25%"]  { background: #ffedd5; border-color: #fdba74; color: #7c2d12; }
:root.light .stat-box[data-rating="50%"]  { background: #fef9c3; border-color: #fde047; color: #713f12; }
:root.light .stat-box[data-rating="75%"]  { background: #dcfce7; border-color: #86efac; color: #14532d; }
:root.light .stat-box[data-rating="100%"] { background: #bbf7d0; border-color: #4ade80; color: #052e16; }

/* color-class variants intentionally omitted in light mode – rating colour takes priority */

/* Detail view */
.detail-section-title { font-weight: 700; font-size: 1rem; margin-top: 1.25rem; margin-bottom: 0.625rem; color: var(--text); }
.detail-list-item { margin-bottom: 0.875rem; padding-left: 0.875rem; }
.detail-list-header { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.detail-list-title { font-weight: 500; color: var(--text); flex: 1; }
.detail-list-rating {
    font-weight: 700;
    font-size: 0.875rem;
    padding: 0.2rem 0.6rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}
.detail-list-rating[data-rating="0%"]   { background:#7f1d1d; color:#fecaca; }
.detail-list-rating[data-rating="25%"]  { background:#7c2d12; color:#fed7aa; }
.detail-list-rating[data-rating="50%"]  { background:#713f12; color:#fef08a; }
.detail-list-rating[data-rating="75%"]  { background:#3f6212; color:#bef264; }
.detail-list-rating[data-rating="100%"] { background:#166534; color:#86efac; }
.detail-list-notes {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
    padding-left: 0.5rem;
    border-left: 2px solid var(--border);
    margin-top: 0.375rem;
}

/* Photos */
#auswertung-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}
#auswertung-photos-grid img {
    width: 100%;
    height: 11rem;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: pointer;
}

/* ── Zeitstrahl ── */
.tz-wrap { margin-bottom: 0.75rem; }
.tz-bar {
    display: flex;
    height: 2.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    width: 100%;
}
.tz-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
    transition: opacity .15s;
    cursor: default;
}
.tz-segment:hover { opacity: 0.85; }
.tz-seg-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.375rem;
    text-shadow: 0 1px 2px rgba(0,0,0,.3);
}
.tz-ticks {
    position: relative;
    height: 1.75rem;
    margin-top: 0.25rem;
}
.tz-tick {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}
.tz-tick::before {
    content: '';
    width: 1px;
    height: 6px;
    background: var(--border);
    display: block;
}
.tz-tick-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-top: 2px;
}
.tz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.5rem;
}
.tz-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: var(--text);
}
.tz-legend-item small { color: var(--text-muted); }
.tz-notizen { margin-top: 0.625rem; }
.tz-notiz {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.3rem 0;
    border-top: 1px solid var(--border);
    align-items: baseline;
}
.tz-notiz:first-child { border-top: none; }
.tz-notiz .tz-notiz-meta { white-space: nowrap; color: var(--text); font-weight: 500; min-width: 180px }
.tz-notiz .tz-notiz-text { line-height: 1.6; }

/* ── Column Chart (Statistiken) ── */
.col-chart-wrap { display: flex; flex-direction: column; gap: 1rem; }
.col-chart-svg { width: 100%; height: auto; display: block; min-height: 220px; }
.col-legend { display: flex; flex-direction: column; gap: 0.5rem; }
.col-legend-item { display: flex; align-items: center; gap: 0.625rem; font-size: 0.9375rem; padding: 0.375rem 0.625rem; border-radius: var(--radius); }
.col-legend-label { flex: 1; color: var(--text); font-weight: 500; }
.col-legend-value { color: var(--text-muted); white-space: nowrap; }
.col-legend-value small { opacity: 0.7; }

/* ── Donut Chart ── */
.pie-wrap { display: flex; align-items: center; gap: 2rem; flex-wrap: wrap; margin-top: 0.75rem; }
.pie-svg { width: 180px; height: 180px; flex-shrink: 0; }
.pie-center-top { font-size: 22px; font-weight: 700; fill: var(--text); }
.pie-center-bot { font-size: 13px; fill: var(--text-muted); }
.pie-legend { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 160px; }
.pie-legend-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; }
.pie-dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; flex-shrink: 0; }
.pie-legend-label { flex: 1; color: var(--text); }
.pie-legend-value { color: var(--text-muted); white-space: nowrap; }
.pie-legend-value strong { color: var(--text); }

/* ── Phasen display ── */
.phasen-list { margin-top: 0.375rem; }
.phase-display-item { padding: 0.375rem 0; border-bottom: 1px solid var(--border); color: var(--text); font-size: 0.875rem; }
.sozialform-distribution h4, .phasen-display h4 { font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.distribution-table { width: 100%; border-collapse: collapse; }
.distribution-table th, .distribution-table td { border: 1px solid var(--border); padding: 0.4rem 0.625rem; color: var(--text); font-size: 0.8125rem; }
.distribution-table th { background: var(--bg); font-weight: 600; }

/* Quill Editor */
#general-notes-editor .ql-toolbar { background: var(--surface); border-color: var(--border) !important; border-radius: var(--radius) var(--radius) 0 0; }
#general-notes-editor .ql-container { background: var(--bg); border-color: var(--border) !important; border-radius: 0 0 var(--radius) var(--radius); color: var(--text); min-height: 8rem; }
#general-notes-editor .ql-editor { color: var(--text); font-size: 0.875rem; }
#general-notes-editor .ql-editor.ql-blank::before { color: var(--text-muted) !important; }
#general-notes-editor .ql-stroke { stroke: var(--text-muted) !important; }
#general-notes-editor .ql-fill { fill: var(--text-muted) !important; }
#general-notes-editor .ql-picker-label { color: var(--text-muted) !important; }
#general-notes-editor .ql-picker-options { background: var(--surface); border-color: var(--border); }
#general-notes-editor .ql-picker-item { color: var(--text); }
#general-notes-editor .ql-picker-item:hover { background: var(--border); }
.ql-toolbar.ql-snow { border: 1px solid var(--border) !important; }
.ql-container.ql-snow { border: 1px solid var(--border) !important; }

/* Modal */
.modal { display: none; position: fixed; z-index: 1000; inset: 0; background: rgba(0,0,0,.85); }
.modal.active { display: flex; align-items: center; justify-content: center; }
.modal-content {
    background: var(--surface);
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    position: relative;
    padding: 1.25rem;
}
.close {
    position: absolute;
    top: 0.75rem; right: 0.75rem;
    color: var(--text-muted);
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    background: var(--border);
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    z-index: 1;
}
.close:hover { color: var(--text); background: #4b5563; }
#image-modal .modal-content { background: transparent; box-shadow: none; text-align: center; }
#image-modal .close { background: rgba(0,0,0,.7); color: #fff; }
#image-modal img { max-width: 100%; max-height: 80vh; display: block; margin: 0 auto; border-radius: var(--radius); }

/* Utility */
.hidden { display: none !important; }
label { display: block; }
input, textarea, select { font-family: inherit; }

/* Detail rating colours – light mode */
:root.light .detail-list-rating[data-rating="0%"]   { background: #fee2e2; color: #991b1b; }
:root.light .detail-list-rating[data-rating="25%"]  { background: #ffedd5; color: #9a3412; }
:root.light .detail-list-rating[data-rating="50%"]  { background: #fef9c3; color: #854d0e; }
:root.light .detail-list-rating[data-rating="75%"]  { background: #dcfce7; color: #166534; }
:root.light .detail-list-rating[data-rating="100%"] { background: #bbf7d0; color: #14532d; }

/* Rating buttons – light mode active states */
:root.light .rating-btn.active[data-value="0%"]   { border-color:#fca5a5; background:#fee2e2; color:#7f1d1d; }
:root.light .rating-btn.active[data-value="25%"]  { border-color:#fdba74; background:#ffedd5; color:#7c2d12; }
:root.light .rating-btn.active[data-value="50%"]  { border-color:#fde047; background:#fef9c3; color:#713f12; }
:root.light .rating-btn.active[data-value="75%"]  { border-color:#86efac; background:#dcfce7; color:#14532d; }
:root.light .rating-btn.active[data-value="100%"] { border-color:#4ade80; background:#bbf7d0; color:#052e16; }

/* ── Print ── */
@media print {
    :root, :root.light {
        --bg: #ffffff;
        --surface: #ffffff;
        --surface2: #f8fafc;
        --border: #cbd5e1;
        --text: #0f172a;
        --text-muted: #475569;
        --accent: #2563eb;
    }
    body { background: #fff !important; padding: 0 !important; }
    .container { max-width: none; margin: 0; }
    .header, .tab-nav, .session-bar, #kategorien-container, .auswertung-actions { display: none !important; }
    .tab-content:not(#auswertung) { display: none !important; }
    #auswertung { display: block !important; }
    .section { box-shadow: none !important; page-break-inside: avoid; }
    .stats { page-break-before: always; }
    .details { page-break-before: always; }
    #auswertung-photos-grid { grid-template-columns: 1fr !important; }
    #auswertung-photos-grid img { width: 70% !important; height: auto !important; margin: 0 auto 1rem !important; display: block; }
    .modal { display: none !important; }
    .distribution-table th, .distribution-table td { border: 1px solid #cbd5e1 !important; }

    /* Rating colours remain readable on white */
    .detail-list-rating[data-rating="0%"]   { background: #fee2e2; color: #991b1b; }
    .detail-list-rating[data-rating="25%"]  { background: #ffedd5; color: #9a3412; }
    .detail-list-rating[data-rating="50%"]  { background: #fef9c3; color: #854d0e; }
    .detail-list-rating[data-rating="75%"]  { background: #dcfce7; color: #166534; }
    .detail-list-rating[data-rating="100%"] { background: #bbf7d0; color: #14532d; }
    .stat-box[data-rating="0%"]   { background: #fee2e2 !important; border-color: #fca5a5 !important; color: #7f1d1d !important; }
    .stat-box[data-rating="25%"]  { background: #ffedd5 !important; border-color: #fdba74 !important; color: #7c2d12 !important; }
    .stat-box[data-rating="50%"]  { background: #fef9c3 !important; border-color: #fde047 !important; color: #713f12 !important; }
    .stat-box[data-rating="75%"]  { background: #dcfce7 !important; border-color: #86efac !important; color: #14532d !important; }
    .stat-box[data-rating="100%"] { background: #bbf7d0 !important; border-color: #4ade80 !important; color: #052e16 !important; }
    .stat-box[data-rating="unbewertet"] { background: #f1f5f9 !important; border-color: #cbd5e1 !important; color: #475569 !important; }
}

/* ── Responsive ── */

/* iPad portrait and smaller */
@media (max-width: 768px) {
    body { padding: 0.75rem; }
    .header-top { flex-direction: column; align-items: flex-start; gap: 0.625rem; }
    .session-bar { justify-content: flex-start; width: 100%; }
    .kategorie-title-row { flex-direction: column; align-items: flex-start; gap: 0.625rem; }
    .rating-buttons { width: 100%; }
    .rating-btn { flex: 1; text-align: center; }
    .phase-item { grid-template-columns: 1fr 1fr; }
    .phase-item .notiz-input { grid-column: 1 / -1; }
    .phase-item .remove-phase { justify-self: end; }
}

/* Phone */
@media (max-width: 480px) {
    .phase-item { grid-template-columns: 1fr; }
    #photos-preview, #auswertung-photos-grid { grid-template-columns: repeat(2, 1fr); }
    .btn-group { flex-wrap: wrap; }
}