:root {
    --bg: #f1f5f9;
    --sidebar-bg: #0b1220;
    --sidebar-fg: #94a3b8;
    --sidebar-fg-hover: #e2e8f0;
    --sidebar-active-bg: #1e293b;
    --panel: #ffffff;
    --border: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --green: #16a34a;
    --green-soft: #ecfdf5;
    --amber: #b45309;
    --amber-soft: #fffbeb;
    --amber-border: #fde68a;
    --red: #dc2626;
    --red-soft: #fef2f2;
}

* { box-sizing: border-box; }

/* Kein Fokus-Rahmen bei programmatischem Fokus (z. B. FocusOnNavigate auf die
   Überschrift). Überschriften sind keine Bedienelemente – dort nie einen
   Fokus-Rahmen zeigen. Für echte Bedienelemente bleibt der Tastatur-Fokus sichtbar. */
:focus:not(:focus-visible) { outline: none; }
h1:focus, h2:focus, h3:focus { outline: none; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.45;
}

.material-symbols-outlined {
    font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
    font-size: 20px;
    line-height: 1;
    vertical-align: middle;
    user-select: none;
}

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.login-card {
    width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 16px; padding: 28px 26px; box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}
.login-form { display: flex; flex-direction: column; gap: 10px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 16px;
}
.brand-name { font-weight: 700; letter-spacing: 1.5px; color: #fff; font-size: 15px; }
/* Logo-Bild (wwwroot/logo.svg) – bringt seine eigene abgerundete Kachel mit */
.brand-logo { border-radius: 8px; display: block; flex-shrink: 0; }
/* Branding-/Versionszeile ganz unten in der Sidebar */
.sidebar-brandinfo {
    margin-top: 8px; padding: 10px 10px 2px; display: flex; flex-direction: column; gap: 2px;
    font-size: 10.5px; line-height: 1.35; color: #64748b;
}
.sidebar-brandinfo strong { color: #cbd5e1; font-weight: 700; letter-spacing: .5px; }

.nav-list { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 9px;
    color: var(--sidebar-fg); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav-link .material-symbols-outlined { font-size: 20px; color: var(--muted-2); }
.nav-link:hover { background: #131c2e; color: var(--sidebar-fg-hover); }
.nav-link.active { background: var(--sidebar-active-bg); color: #fff; }
.nav-link.active .material-symbols-outlined { color: #60a5fa; }

.sidebar-footer {
    margin-top: 12px; padding: 12px 10px; font-size: 12px; color: var(--muted);
    border-top: 1px solid #1e293b; display: flex; align-items: center; justify-content: space-between;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Top bar ---------- */
.topbar {
    height: 62px; background: var(--panel); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 5;
}
.search {
    flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px;
    background: #f1f5f9; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
    color: var(--muted);
}
.search input { border: none; background: transparent; outline: none; width: 100%; font: inherit; color: var(--text); }
.topbar-spacer { flex: 1; }
.icon-btn {
    width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
    background: #fff; display: grid; place-items: center; color: var(--muted); cursor: pointer;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; background: #1e293b; color: #fff;
    display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 12px; color: var(--muted); }

/* ---------- Page ---------- */
.page { padding: 26px 28px; max-width: 1180px; width: 100%; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 16px; }
h1 { font-size: 30px; font-weight: 700; margin: 0 0 4px; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.motto { color: var(--muted); font-size: 15px; text-align: right; max-width: 220px; margin: 4px 0 0; }

/* ---------- Stat cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 22px; }
.stat-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 16px;
    display: flex; align-items: center; gap: 12px;
}
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.stat-icon.blue { background: var(--accent-soft); color: var(--accent); }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-num { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-card.warn { border-color: var(--amber-border); }

/* ---------- Grid + panels ---------- */
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.panel h2 { font-size: 17px; font-weight: 700; margin: 0 0 12px; }
.panel-link { color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; }
.hint { color: var(--muted); font-size: 14px; }

.ai-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 13px; margin-bottom: 12px; }
.ai-badge .material-symbols-outlined { font-size: 18px; }
.ai-sub { color: var(--muted); font-weight: 400; }

.summary-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.summary-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.summary-list .material-symbols-outlined { font-size: 18px; margin-top: 1px; flex-shrink: 0; }
.ic-blue { color: var(--accent); }
.ic-green { color: var(--green); }
.ic-amber { color: var(--amber); }
.ic-slate { color: var(--muted); }

.link-row { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Termine list ---------- */
.termin-list { display: flex; flex-direction: column; gap: 10px; }
.termin {
    display: flex; align-items: stretch; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.termin-time { font-weight: 600; font-size: 13px; color: var(--text); width: 48px; flex-shrink: 0; padding-top: 1px; }
.termin-bar { width: 3px; border-radius: 3px; background: var(--accent); flex-shrink: 0; }
.termin-bar.red { background: var(--red); }
.termin-title { font-weight: 600; font-size: 14px; }
.termin-sub { color: var(--muted); font-size: 12.5px; }

/* ---------- Kind-Akte: Profilkopf ---------- */
.back-link {
    display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
    text-decoration: none; font-size: 13px; font-weight: 500; margin-bottom: 16px;
}
.back-link:hover { color: var(--text); }

.profile-head { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.profile-avatar {
    width: 76px; height: 76px; border-radius: 16px; flex-shrink: 0;
    background: linear-gradient(135deg, #64748b, #334155); color: #fff;
    display: grid; place-items: center; font-size: 26px; font-weight: 700;
}
.profile-main { flex: 1; min-width: 0; }
.profile-name { font-size: 26px; font-weight: 700; margin: 0; }
.profile-meta { color: var(--muted); font-size: 13.5px; margin: 2px 0 10px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500;
    padding: 4px 10px; border-radius: 999px; background: #f1f5f9; color: #334155; border: 1px solid var(--border);
}
.badge .material-symbols-outlined { font-size: 15px; }
.badge.green { background: var(--green-soft); color: #15803d; border-color: #bbf7d0; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.actions-btn {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
    background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 8px 14px;
    font: inherit; font-weight: 600; font-size: 13px; color: var(--text); cursor: pointer;
}

/* ---------- Kind-Akte: Tabs ---------- */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
    background: none; border: none; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
    color: var(--muted); padding: 10px 2px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- Kind-Akte: Layout + Timeline ---------- */
.detail-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 16px; }

.date-nav { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13.5px; }
.date-nav button {
    width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: #fff;
    display: grid; place-items: center; cursor: pointer; color: var(--muted);
}

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 52px 28px 1fr; gap: 10px; padding: 10px 0; }
.tl-time { font-weight: 600; font-size: 13px; color: var(--text); padding-top: 2px; }
.tl-icon {
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
}
.tl-icon .material-symbols-outlined { font-size: 16px; }
.tl-icon.amber { background: var(--amber-soft); color: var(--amber); }
.tl-title { font-weight: 600; font-size: 14px; }
.tl-sub { color: var(--muted); font-size: 13px; }

.btn-add {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
    background: var(--accent-soft); color: var(--accent); border: 1px solid #bfdbfe; border-radius: 9px;
    padding: 8px 14px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
}

/* Formular „Eintrag hinzufügen" in der Kind-Akte */
.entry-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.form-input {
    width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 8px 11px;
    font: inherit; font-size: 13.5px; color: var(--text); background: #fff; resize: vertical;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.form-check input { width: 15px; height: 15px; }
.form-error { color: #b91c1c; font-size: 12.5px; }
/* Feldbeschriftung über einem Eingabefeld im entry-form */
.form-label { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.form-actions { display: flex; gap: 8px; }

/* Dokumentations-Tab der Kind-Akte */
.doku-list { display: flex; flex-direction: column; }
.doku-item { padding: 14px 2px; border-top: 1px solid var(--border); }
.doku-item:first-child { border-top: none; }
.doku-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.doku-time { color: var(--muted); font-size: 12.5px; }
.doku-text { font-size: 14px; white-space: pre-wrap; }

/* Themen-/Terminlisten in der rechten Spalte */
.theme-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.theme-list li { display: flex; gap: 9px; font-size: 13.5px; }
.theme-list li::before { content: "•"; color: var(--accent); font-weight: 700; }
.mini-termine { display: flex; flex-direction: column; gap: 10px; }
.mini-termin { display: flex; gap: 12px; font-size: 13.5px; }
.mini-date { font-weight: 600; color: var(--accent); width: 42px; flex-shrink: 0; }
.notice-box {
    background: var(--amber-soft); border: 1px solid var(--amber-border); border-radius: 12px; padding: 14px 16px;
    display: flex; gap: 10px; font-size: 13.5px; color: #92400e;
}
.notice-box .material-symbols-outlined { font-size: 18px; color: var(--amber); flex-shrink: 0; }

/* Kinderliste */
.kind-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.kind-row {
    display: flex; align-items: center; gap: 14px; padding: 12px 16px; text-decoration: none; color: inherit;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.kind-row:hover { border-color: #cbd5e1; background: #fafcff; }
.kind-avatar { position: relative; width: 42px; height: 42px; border-radius: 50%; background: #334155; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; overflow: hidden; flex-shrink: 0; }
/* Profilbild füllt den Avatar-Kreis/-Kachel vollständig aus (absolut positioniert,
   damit die Grid-Zentrierung des Containers die Bildgröße nicht beeinflusst) */
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.profile-avatar { position: relative; overflow: hidden; }
/* Kleiner Foto-ändern-Link unter dem Profilbild */
.foto-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; font-size: 12.5px; }
.foto-actions label { color: var(--accent); font-weight: 600; cursor: pointer; }
.foto-actions button { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }

/* ---------- KI-Übergabe (Dokumentation) ---------- */
.btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent); color: #fff; border: none; border-radius: 9px;
    padding: 9px 15px; font: inherit; font-weight: 600; font-size: 13px;
    cursor: pointer; text-decoration: none;
}
.btn-primary:hover { background: #1d4ed8; }

.subtabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin: 14px 0 18px; }
.subtab {
    background: none; border: none; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
    color: var(--muted); padding: 8px 2px; border-bottom: 2px solid transparent;
}
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.uebergabe-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }

.ai-card { background: #f8faff; border: 1px solid #e0e9ff; border-radius: 12px; padding: 16px; margin-bottom: 8px; }
.ai-card p { margin: 0; font-size: 14px; }

.kind-summary { display: flex; gap: 12px; padding: 14px 2px; border-top: 1px solid var(--border); }
.kind-summary .kind-avatar { width: 38px; height: 38px; flex-shrink: 0; }
.ks-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.ks-text { color: var(--muted); font-size: 13.5px; }

.success-box {
    background: var(--green-soft); border: 1px solid #bbf7d0; border-radius: 12px;
    padding: 12px 14px; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; color: #15803d; font-size: 13.5px; margin-top: 14px;
}
.success-box .sb-left { display: flex; align-items: center; gap: 10px; }
.success-box .material-symbols-outlined { color: var(--green); }

.task-list { display: flex; flex-direction: column; gap: 14px; }
.task-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.task-item input { margin-top: 2px; width: 16px; height: 16px; flex-shrink: 0; }
.task-sub { color: var(--muted); font-size: 12.5px; }

.quick-actions { display: flex; flex-direction: column; gap: 8px; }
.quick-action {
    display: flex; align-items: center; gap: 11px; padding: 9px 11px; width: 100%;
    border: 1px solid var(--border); border-radius: 10px; background: #fff;
    font: inherit; font-size: 13.5px; color: var(--text); text-align: left; cursor: pointer; text-decoration: none;
}
.quick-action:hover { background: #fafcff; border-color: #cbd5e1; }
.qa-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex-shrink: 0; }
.qa-icon .material-symbols-outlined { font-size: 18px; }

/* ---------- §8a Kindeswohlgefährdung ---------- */
.badge.red { background: var(--red-soft); color: #b91c1c; border-color: #fecaca; }
.badge.amber { background: var(--amber-soft); color: #b45309; border-color: var(--amber-border); }
.badge.gray { background: #f1f5f9; color: #475569; border-color: var(--border); }

.case-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.case-stat { border-radius: 14px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); }
.case-stat.red { background: var(--red-soft); border-color: #fecaca; }
.case-stat.amber { background: var(--amber-soft); border-color: var(--amber-border); }
.case-stat.green { background: var(--green-soft); border-color: #bbf7d0; }
.cs-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.case-stat.red .cs-icon { background: #fee2e2; color: #dc2626; }
.case-stat.amber .cs-icon { background: #fde68a; color: #b45309; }
.case-stat.green .cs-icon { background: #d1fae5; color: #059669; }
.cs-num { font-size: 24px; font-weight: 700; }
.cs-label { font-size: 12.5px; color: var(--muted); }

.case-list { display: flex; flex-direction: column; }
.case-row { display: flex; align-items: center; gap: 14px; padding: 14px 2px; border-top: 1px solid var(--border); }
.case-row:first-child { border-top: none; }
.case-status { width: 96px; flex-shrink: 0; }
.case-main { flex: 1; min-width: 0; }
.case-name { font-weight: 600; font-size: 14px; }
.case-desc { color: var(--muted); font-size: 13px; }
.case-meta { color: var(--muted-2); font-size: 12px; margin-top: 2px; }
.btn-outline {
    border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 7px 12px;
    font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; color: var(--text); flex-shrink: 0;
}
.btn-outline:hover { background: #fafcff; border-color: #cbd5e1; }

.process-list { display: flex; flex-direction: column; gap: 16px; }
.proc-item { display: flex; gap: 12px; }
.proc-num {
    width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.proc-title { font-weight: 600; font-size: 13.5px; }
.proc-sub { color: var(--muted); font-size: 12.5px; }

/* ---------- Mobile / responsive ---------- */
/* Hamburger, Off-Canvas-Checkbox und Verdunklung sind auf dem Desktop aus. */
.hamburger { display: none; }
.menu-toggle { display: none; }
.menu-scrim { display: none; }

@media (max-width: 1000px) {
    .stat-row { grid-template-columns: repeat(2, 1fr); }
    .case-stats { grid-template-columns: 1fr; }
    .grid-2, .detail-grid, .uebergabe-grid { grid-template-columns: 1fr; }
}

/* Ab hier wird die Sidebar zum ausklappbaren Menü (Tablet/Handy). */
@media (max-width: 820px) {
    .hamburger {
        display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0;
        border-radius: 9px; border: 1px solid var(--border); background: #fff;
        color: var(--muted); cursor: pointer;
    }
    .sidebar {
        position: fixed; left: 0; top: 0; height: 100vh; z-index: 40;
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: 2px 0 18px rgba(15, 23, 42, 0.25);
    }
    /* Menü geöffnet: Sidebar einblenden + Hintergrund verdunkeln. */
    #menu-toggle:checked ~ .app .sidebar { transform: translateX(0); }
    #menu-toggle:checked ~ .app .menu-scrim {
        display: block; position: fixed; inset: 0; z-index: 35;
        background: rgba(15, 23, 42, 0.45);
    }
    .page { padding: 18px 16px; }
    .page-header { flex-direction: column; }
    .motto { text-align: left; max-width: none; margin-top: 6px; }
    .topbar { padding: 0 14px; gap: 10px; }
    .search { max-width: none; }
}

@media (max-width: 560px) {
    .stat-row { grid-template-columns: 1fr; }
    .user-name, .user-role { display: none; }
    h1 { font-size: 24px; }
    .tabs { gap: 16px; }
}
