/* ============================================================================
   GASTROOS STAFF-APP — DIENSTPLAN / MITARBEITER-APP
   Gemeinsame Oberfläche. Die Betriebsfarben werden im Basistemplate gesetzt.
   ============================================================================ */

/* Author-level display rules (for example modal flex layouts) must never
   override the semantic HTML hidden state. */
[hidden] { display: none !important; }

:root {
    --primary:        #2c3e50;
    --primary-light:  #34495e;
    --primary-dark:   #1a252f;
    --on-primary:     #ffffff;
    --accent:         #27ae60;
    --accent-hover:   #219a52;
    --accent-light:   rgba(39, 174, 96, 0.10);
    --on-accent:      #ffffff;
    --focus-ring:     #1f7a45;

    --nav-text:       color-mix(in srgb, var(--on-primary) 85%, var(--primary));
    --nav-muted:      color-mix(in srgb, var(--on-primary) 70%, var(--primary));
    --nav-hover:      color-mix(in srgb, var(--on-primary) 12%, var(--primary));
    --nav-border:     color-mix(in srgb, var(--on-primary) 20%, var(--primary));

    --bg:             #e2e7ec;
    --bg-subtle:      #e6ebef;
    --text:           #202d3a;
    --text-secondary: #4c5e70;
    --text-muted:     #59697a;
    --card:           #f6f7f8;
    --border:         #cbd3db;
    --border-light:   #e2e7ec;

    --success:        #26734d;
    --warning:        #965912;
    --danger:         #b42336;
    --info:           #38596e;

    --shadow-xs:  0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.04);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.03);

    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-full: 999px;

    --sidebar-width: 260px;
    --topbar-height: 68px;
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { touch-action: manipulation; }
.mobile-menu-button, .sidebar-close, .mobile-bottom-nav, .sidebar-backdrop { display: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── LAYOUT ──────────────────────────────────────────────────────── */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) minmax(0, 1fr);
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    height: 100vh;
    overflow: hidden;
}

.topbar {
    grid-area: topbar;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    box-shadow: var(--shadow-xs);
    z-index: 10;
}
.topbar .page-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.topbar .spacer { flex: 1; }
.topbar .user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-subtle);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.topbar .user-chip .avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
}

/* ─── USER DROPDOWN ────────────────────────────────────────────── */
.user-menu-wrapper { position: relative; }
.user-menu-trigger {
    cursor: pointer; border: none; background: var(--bg-subtle);
    font: inherit; color: inherit;
}
.user-dropdown {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    min-width: 220px; background: var(--card, #fff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius, 10px);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 200; padding: 6px 0;
    animation: dropIn .15s ease;
}
.user-dropdown.open { display: block; }
@keyframes dropIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.user-dropdown .dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; border: 0; background: transparent; cursor: pointer;
    font-family: inherit; text-align: left;
    padding: 9px 16px; font-size: 0.85rem;
    color: var(--text, #1e293b); text-decoration: none;
    transition: background .12s;
}
.user-dropdown .dropdown-item:hover {
    background: var(--bg-subtle, #f1f5f9);
}
.user-dropdown .dropdown-item i { width: 18px; text-align: center; font-size: .88rem; opacity: .7; }
.user-dropdown .dropdown-item-danger { color: var(--danger, #dc2626); }
.user-dropdown .dropdown-item-danger:hover { background: #fef2f2; }
.user-dropdown .dropdown-divider {
    height: 1px; background: var(--border, #e2e8f0);
    margin: 4px 0;
}
.user-dropdown .dropdown-label {
    padding: 6px 16px 2px; font-size: .7rem;
    text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-secondary, #475569); font-weight: 600;
}

/* ─── SIDEBAR ─────────────────────────────────────────────────────── */
.sidebar {
    grid-area: sidebar;
    background: var(--primary);
    color: var(--on-primary);
    border-right: 1px solid var(--nav-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar .brand {
    padding: 16px 20px;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--nav-border);
}
.sidebar .brand .dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.sidebar nav { flex: 1; padding: 12px 8px; overflow-y: auto; scrollbar-color: var(--nav-hover) var(--primary); scrollbar-width: thin; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: var(--nav-text);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 2px;
    transition: background 0.15s;
}
.sidebar nav a:hover {
    background: var(--nav-hover);
    color: var(--on-primary);
}
.sidebar nav a.active {
    background: var(--accent);
    color: var(--on-accent);
    box-shadow: var(--shadow-sm);
}
.sidebar nav .nav-group { margin-bottom: 2px; }
.sidebar nav .nav-group > a { justify-content: flex-start; }
.sidebar nav .nav-caret {
    margin-left: auto;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: transform 0.15s;
}
.sidebar nav .nav-group.open .nav-caret { transform: rotate(180deg); }
.sidebar nav .nav-submenu {
    display: none;
    margin: 4px 0 6px 14px;
    padding-left: 10px;
    border-left: 1px solid var(--nav-border);
}
.sidebar nav .nav-group.open .nav-submenu { display: block; }
.sidebar nav a.nav-subitem {
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.84rem;
    color: var(--nav-text);
    margin-bottom: 1px;
}
.sidebar nav a.nav-subitem.active {
    background: var(--nav-hover);
    color: var(--on-primary);
    box-shadow: none;
}
.sidebar nav .nav-subdot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    flex-shrink: 0;
}
.sidebar nav .nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--nav-muted);
    padding: 14px 14px 6px;
    font-weight: 600;
}
.sidebar .icon { width: 18px; flex: 0 0 18px; text-align: center; opacity: 0.85; }
.sidebar .footer {
    padding: 12px 16px;
    font-size: 0.78rem;
    color: var(--nav-muted);
    border-top: 1px solid var(--nav-border);
}
.logout-status { margin: 8px 12px; padding: 10px; color: var(--danger); background: #fff2f3; font-size: .8rem; }
.sidebar .footer:empty { display: none; }
.sidebar .footer a { color: var(--nav-text); }

/* ─── MAIN ──────────────────────────────────────────────────────── */
.main {
    grid-area: main;
    overflow-y: auto;
    min-width: 0;
    padding: 28px 32px;
}
.main h1 { font-size: 1.6rem; letter-spacing: -0.025em; line-height: 1.25; margin: 0 0 6px; }
.main .lead { color: var(--text-secondary); margin-bottom: 24px; }

/* ─── CARDS ──────────────────────────────────────────────────────── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-xs);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -2px 0 14px;
}
.card-header h3 {
    font-size: 1rem;
    margin: 0;
    font-weight: 600;
}

/* ─── KPI ────────────────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.kpi {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-xs);
}
.kpi .label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}
.kpi .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
    margin-top: 6px;
}
.kpi .sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.kpi .icon-bubble {
    width: 38px; height: 38px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 10px;
}

/* ─── BUTTONS ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid transparent;
    cursor: pointer;
    min-height: 44px;
    justify-content: center;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--bg-subtle);
    color: var(--text);
}
.btn:hover { border-color: var(--text-muted); }
.btn.primary {
    background: var(--accent);
    color: var(--on-accent);
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost {
    background: transparent;
    border-color: var(--border);
}
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ─── TABLES ─────────────────────────────────────────────────────── */
table.tbl {
    width: 100%;
    border-collapse: collapse;
}
table.tbl th, table.tbl td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
table.tbl th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--bg-subtle);
}
table.tbl tbody tr:hover { background: var(--bg-subtle); }

/* ─── BADGES / STATUS ────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.badge.green  { background: rgba(22,163,74,0.10);  color: var(--success); }
.badge.amber  { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge.red    { background: rgba(239,68,68,0.10);  color: var(--danger);  }
.badge.blue   { background: rgba(59,130,246,0.10); color: var(--info);    }
.badge.gray   { background: var(--bg-subtle);       color: var(--text-secondary); }

/* ─── INPUTS ──────────────────────────────────────────────────────── */
input[type=text], input[type=date], input[type=time], input[type=email],
input[type=search], input[type=password], input[type=number], textarea, select {
    width: 100%;
    padding: 9px 12px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    transition: border 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* ─── DIENSTPLAN GRID ────────────────────────────────────────────── */
.week-grid {
    display: grid;
    grid-template-columns: 180px repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}
.week-grid .head, .week-grid .cell, .week-grid .row-head {
    background: var(--card);
    padding: 10px;
    min-height: 70px;
    font-size: 0.85rem;
}
.week-grid .head {
    background: var(--bg-subtle);
    font-weight: 700;
    text-align: center;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.4px;
    min-height: auto;
}
.week-grid .head .day-num {
    display: block;
    font-size: 1.2rem;
    color: var(--text);
    margin-top: 2px;
    font-weight: 700;
}
.week-grid .row-head {
    font-weight: 600;
    color: var(--text);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.week-grid .row-head .position {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 2px;
}
.shift-pill {
    width: 100%;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 7px 8px;
    font-size: 0.78rem;
    margin-bottom: 4px;
    cursor: pointer;
    font-weight: 650;
    text-align: left;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.shift-pill:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
div.shift-pill {
    cursor: default;
    box-shadow: none;
}
div.shift-pill:hover {
    transform: none;
    box-shadow: none;
}
.shift-main {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.25;
}
.shift-main i {
    width: 14px;
    text-align: center;
    opacity: .85;
}
.shift-note {
    display: block;
    margin-top: 3px;
    font-size: 0.7rem;
    line-height: 1.2;
    font-weight: 500;
    color: inherit;
    opacity: .82;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Verfügbarkeit / Frei-Wunsch Badges ─────────────────────── */
.avail-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
    width: 100%;
    padding: 5px 7px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 3px;
}
.avail-badge i { font-size: 0.65rem; }
.avail-unavailable {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}
.avail-preferred {
    background: #ede9fe;
    color: #5b21b6;
    border: 1px solid #c4b5fd;
}
.avail-available {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}
/* Status-Überlagerungen */
.avail-pending {
    border-style: dashed;
}
.avail-approved {
    background: #dcfce7 !important;
    color: #166534 !important;
    border-color: #86efac !important;
    border-style: solid;
}
.avail-rejected {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border-color: #fca5a5 !important;
    border-style: solid;
    opacity: .7;
}
.avail-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.avail-status {
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(0,0,0,.08);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.avail-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.avail-btn {
    border: none;
    border-radius: 5px;
    padding: 3px 7px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background .12s;
    line-height: 1;
}
.avail-btn.approve {
    background: #16a34a;
    color: #fff;
}
.avail-btn.approve:hover { background: #15803d; }
.avail-btn.reject {
    background: #dc2626;
    color: #fff;
}
.avail-btn.reject:hover { background: #b91c1c; }
.avail-btn.remove {
    background: transparent;
    color: var(--text-muted);
    padding: 3px 5px;
}
.avail-btn.remove:hover { color: #dc2626; }
/* Eigene Zelle für Mitarbeiter hervorheben */
.own-cell {
    border: 2px dashed var(--accent-light, #a5b4fc) !important;
    background: rgba(99,102,241,0.03);
}

/* ── Frei-Wunsch Modal ────────────────────────────────────── */
.fd-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    animation: fdFadeIn .15s ease;
}
@keyframes fdFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.fd-modal {
    background: #fff;
    border-radius: 14px;
    width: 420px;
    max-width: 92vw;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
    animation: fdSlideUp .2s ease;
}
@keyframes fdSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.fd-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.fd-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fd-date-label {
    font-size: 0.9rem;
    color: var(--text-secondary, #64748b);
    margin: 0 0 18px;
    font-weight: 500;
}
.fd-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #475569);
    margin-bottom: 5px;
}
.fd-select,
.fd-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.fd-select:focus,
.fd-textarea:focus {
    border-color: var(--accent, #6366f1);
    box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}
.fd-textarea {
    resize: vertical;
    min-height: 60px;
}
.fd-error {
    margin-top: 10px;
    padding: 8px 12px;
    background: #fee2e2;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #b91c1c;
}
.fd-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}
.shift-pill.shift-planned {
    background: #dbeafe;
    border-color: #93c5fd;
    border-left-color: #2563eb;
    color: #1e3a8a;
}
.shift-pill.shift-free {
    background: #f1f5f9;
    border-color: #cbd5e1;
    border-left-color: #64748b;
    color: #334155;
}
.shift-pill.shift-vacation {
    background: #dcfce7;
    border-color: #86efac;
    border-left-color: #16a34a;
    color: #14532d;
}
.shift-pill.shift-sick {
    background: #fee2e2;
    border-color: #fca5a5;
    border-left-color: #dc2626;
    color: #7f1d1d;
}
.tenant-brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-grid;
    place-items: center;
    overflow: hidden;
    border-radius: 11px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
}
.tenant-brand-mark-small { width: 32px; height: 32px; flex-basis: 32px; border-radius: 9px; }
.tenant-brand-mark img { width: 100%; height: 100%; object-fit: contain; background: var(--primary); }
.tenant-brand-mark [hidden] { display: none; }
.topbar-tenant-logo { display: none; }
.shift-pill.shift-absent {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}
.shift-pill.shift-school {
    background: #ede9fe;
    border-color: #c4b5fd;
    border-left-color: #7c3aed;
    color: #4c1d95;
}
.shift-warning {
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    color: #92400e;
    font-size: .85rem;
    font-weight: 600;
}
.cell-empty {
    cursor: pointer;
    position: relative;
    transition: background .12s, border-color .12s;
    border: 1px dashed transparent;
}
.cell-empty:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}
.cell-empty:hover::after {
    content: '+';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    opacity: .7;
}

.wgt-cell.has-entry {
    padding: 6px;
}
.wgt-cell.has-entry .shift-pill {
    flex: 1;
    min-height: 58px;
    margin-bottom: 0;
}

/* Vorlage-Schnellwahl-Chips in der Zelle */
.tpl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 3px;
}
.tpl-chip {
    padding: 2px 6px;
    border: none;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tpl-chip:hover { opacity: 1; transform: scale(1.05); }
.tpl-chip:disabled { opacity: 0.4; cursor: not-allowed; }

.tpl-manage-layout {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 18px;
}
.tpl-manage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.tpl-manage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 56vh;
    overflow: auto;
}
.tpl-manage-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
}
.tpl-manage-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.tpl-manage-swatch {
    width: 12px;
    height: 40px;
    border-radius: 999px;
    flex-shrink: 0;
}
.tpl-manage-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.tpl-manage-copy strong,
.tpl-manage-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tpl-manage-copy small {
    color: var(--text-muted);
}
.tpl-manage-empty {
    padding: 18px;
    text-align: center;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: 10px;
}
.tpl-editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.tpl-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: .85rem;
    font-weight: 500;
}
.tpl-field-full {
    grid-column: 1 / -1;
}
@media (max-width: 900px) {
    .tpl-manage-layout {
        grid-template-columns: 1fr;
    }
}

/* ─── ABTEILUNGS-CHOOSER ──────────────────────────────────────────── */
.dept-chooser-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
    max-width: 900px;
}
.dept-card {
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 28px 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.dept-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--dept-color, var(--accent));
}
.dept-card-icon {
    width: 54px; height: 54px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--dept-color, var(--accent)) 15%, transparent);
    color: var(--dept-color, var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.dept-card-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
    text-align: center;
}

/* ─── DIENSTPLAN-GRID (transponiert: Personen oben, Tage links) ────── */
.week-grid-t {
    display: grid;
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-width: max-content;
}
.wgt-corner {
    background: var(--bg-subtle);
    min-height: 60px;
}
.wgt-person {
    background: var(--bg-subtle);
    padding: 10px 12px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
}
.wgt-pos {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}
.wgt-day {
    background: var(--card);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 80px;
}
.wgt-dayname {
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--text);
    display: block;
}
.wgt-daynum {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}
.wgt-cell {
    background: var(--card);
    padding: 8px;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.wgt-weekend.wgt-day,
.wgt-weekend.wgt-cell {
    background: #fafbff;
}
.wgt-weekend .wgt-dayname { color: var(--text-secondary); }

/* ─── MESSENGER ───────────────────────────────────────────────────── */
.chat-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
    height: calc(100vh - var(--topbar-height) - 48px);
}
.channel-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    padding: 8px;
}
.channel-item {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-bottom: 2px;
    font-size: 0.92rem;
}
.channel-item:hover { background: var(--bg-subtle); }
.channel-item.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.channel-item .last {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.unread-badge {
    display: inline-block;
    background: #dc2626;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 999px;
    text-align: center;
    padding: 0 5px;
    margin-left: auto;
    flex-shrink: 0;
}

.chat-window {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.chat-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.msg {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    font-size: 0.92rem;
    line-height: 1.4;
}
.msg .author {
    display: block;
    font-size: 0.74rem;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 2px;
}
.msg.mine {
    align-self: flex-end;
    background: var(--accent);
    color: var(--on-accent);
}
.msg.mine .author { color: rgba(255,255,255,0.8); }
.msg .time {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
}
.chat-input {
    border-top: 1px solid var(--border);
    padding: 12px;
    display: flex;
    gap: 8px;
}
.chat-input input { flex: 1; }

/* ─── TODOS ──────────────────────────────────────────────────────── */
.todo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.todo-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-xs);
}
.todo-list .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.todo-list h3 { font-size: 0.98rem; margin: 0; font-weight: 700; }
.todo-list .scope-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
}
.todo-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border-light);
    font-size: 0.92rem;
}
.todo-item:first-of-type { border-top: 0; }
.todo-item input[type=checkbox] { width: auto; }
.todo-item.done { color: var(--text-muted); text-decoration: line-through; }
.todo-item .del {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
}
.todo-item:hover .del { opacity: 1; }
.add-item {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}
.add-item input { font-size: 0.85rem; padding: 6px 10px; }

/* ─── WIKI ──────────────────────────────────────────────────────── */
.wiki-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
}
.wiki-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    max-height: calc(100vh - var(--topbar-height) - 100px);
    overflow-y: auto;
}
.wiki-article {
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
}
.wiki-article:hover { background: var(--bg-subtle); }
.wiki-article.active { background: var(--accent-light); }
.wiki-article h4 { margin: 0; font-size: 0.92rem; }
.wiki-article p { margin: 4px 0 0; font-size: 0.78rem; color: var(--text-muted); }
.wiki-article .depts {
    display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px;
}
.wiki-detail {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    overflow-y: auto;
    max-height: calc(100vh - var(--topbar-height) - 100px);
}
.wiki-detail h2 { margin-top: 0; }
.wiki-detail .meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}
.wiki-empty { color: var(--text-muted); padding: 40px; text-align: center; }

/* ─── LOGIN ──────────────────────────────────────────────────────── */
.staff-auth-body {
    color-scheme: dark;
    --bg: var(--primary);
    --card: color-mix(in srgb, var(--primary) 92%, var(--on-primary));
    --bg-subtle: color-mix(in srgb, var(--primary) 86%, var(--on-primary));
    --text: var(--on-primary);
    --text-secondary: color-mix(in srgb, var(--on-primary) 85%, var(--primary));
    --text-muted: color-mix(in srgb, var(--on-primary) 70%, var(--primary));
    --border: color-mix(in srgb, var(--primary) 55%, var(--on-primary));
    --focus-ring: var(--on-primary);
    --success: color-mix(in srgb, #26734d 40%, var(--on-primary));
    --danger: color-mix(in srgb, #b42336 40%, var(--on-primary));
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text);
    background: var(--bg);
}
.staff-auth-body .ehms-topbar,
.staff-auth-body .ehms-brand-mark,
.staff-auth-body .login-card,
.staff-auth-body .pw-card {
    border-color: color-mix(in srgb, var(--primary) 80%, var(--on-primary));
}
.staff-auth-body .ehms-security i,
.staff-auth-body .ehms-benefit i,
.staff-auth-body .login-card .card-mark { color: var(--text); }
.staff-auth-body :is(.login-card, .pw-card) input { background: var(--bg); }
.staff-auth-body :is(.login-card, .pw-card) input:focus { border-color: var(--focus-ring); }
.staff-auth-body input::placeholder { color: var(--text-muted); opacity: 1; }

.login-shell {
    height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    background: var(--card);
    padding: 36px 32px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 360px;
    text-align: center;
}
.login-card .logo {
    width: 60px; height: 60px;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: #fff;
    margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
}
.login-card h1 { font-size: 1.2rem; margin: 0 0 4px; }
.login-card .sub { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 24px; }
.pin-display {
    font-size: 2rem;
    letter-spacing: 12px;
    font-weight: 700;
    margin: 16px 0;
    color: var(--primary);
    min-height: 50px;
}
.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.pin-pad button {
    padding: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
}
.pin-pad button:hover { background: var(--border); }
.pin-pad .pin-ok { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pin-pad .pin-clear { background: var(--bg); }
.pin-error { color: var(--danger); font-size: 0.85rem; margin-top: 12px; min-height: 18px; }

.empty {
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
    font-size: 0.92rem;
}

/* ─── MODALS ──────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modalSlideUp {
    from { transform: translateY(16px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-card {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow:
        0 24px 48px -12px rgba(0, 0, 0, 0.18),
        0 8px 16px -8px rgba(0, 0, 0, 0.10);
    width: min(520px, 96vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideUp 0.25s ease;
}
.modal-header {
    padding: 20px 24px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.modal-close:hover {
    background: var(--border);
    color: var(--text);
}
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--bg-subtle);
}
.modal-footer .btn.primary {
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.modal-footer .btn.primary:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

/* ─── FORM ROW (used in modals) ──────────────────────────────────── */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.form-row label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-row input:disabled {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    cursor: not-allowed;
}
.form-row textarea {
    resize: vertical;
    min-height: 60px;
}
.form-row input[type=checkbox] {
    width: auto;
    accent-color: var(--accent);
}

@media (max-width: 600px) {
    .modal-card { width: 100%; max-height: 95vh; border-radius: var(--radius-lg); }
    .modal-body { padding: 16px; }
    .modal-header { padding: 16px; }
    .modal-footer { padding: 12px 16px; }
}

/* ─── DIENSTPLAN SIDEBAR-LAYOUT ───────────────────────────────────── */
.dp-layout {
    display: flex;
    gap: 0;
    min-height: calc(100vh - 140px);
    align-items: flex-start;
}
.dp-sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-right: 16px;
    position: sticky;
    top: 80px;
}
.dp-sidebar-title {
    padding: 12px 14px 8px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}
.dp-dept-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    cursor: pointer;
    font-size: .88rem;
    color: var(--text);
    transition: background .12s;
    border-left: 3px solid transparent;
    user-select: none;
}
.dp-dept-item:hover { background: var(--bg-subtle); }
.dp-dept-item.active {
    background: var(--accent-light);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}
.dp-dept-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    color: #fff;
    flex-shrink: 0;
}
.dp-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dp-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 40px;
}
@media (max-width: 768px) {
    .dp-layout { flex-direction: column; }
    .dp-sidebar { width: 100%; position: static; margin-right: 0; margin-bottom: 12px; }
    .dp-sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
    .dp-dept-item { border-radius: 8px; border-left: none; border-bottom: 3px solid transparent; padding: 7px 10px; }
    .dp-dept-item.active { border-bottom-color: var(--accent); }
}
.staff-connection-status {
    --staff-status-color: #f59e0b;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: min(260px, 34vw);
    min-height: 30px;
    padding: 5px 10px;
    border: 1px solid color-mix(in srgb, var(--staff-status-color) 55%, transparent);
    border-radius: 999px;
    background: color-mix(in srgb, var(--staff-status-color) 10%, white);
    color: var(--text, #17202a);
    font-size: .72rem;
    font-weight: 750;
    line-height: 1.15;
}
.staff-connection-status[data-state="synchronized"] { --staff-status-color: #16a34a; }
.staff-connection-status[data-state="synchronizing"] { --staff-status-color: #0284c7; }
.staff-connection-status[data-state="offline"] { --staff-status-color: #64748b; }
.staff-connection-status[data-state="connection_impaired"] { --staff-status-color: #d97706; }
.staff-connection-status[data-state="never_synchronized"] { --staff-status-color: #64748b; }
.staff-connection-status__icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--staff-status-color);
    font-size: .82rem;
    line-height: 1;
}
.staff-connection-status__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .staff-connection-status { max-width: 145px; padding-inline: 8px; }
    .staff-connection-status__label { font-size: .66rem; }
}
@media (max-width: 360px) {
    .staff-connection-status {
        width: 34px;
        min-width: 34px;
        max-width: 34px;
        min-height: 34px;
        padding: 0;
        justify-content: center;
        overflow: hidden;
    }
    .staff-connection-status__label { display: none; }
    .staff-connection-status__icon {
        width: 18px;
        height: 18px;
        flex-basis: 18px;
        font-size: .92rem;
    }
}
@media (max-width: 760px) {
    .staff-connection-status { display: none; }
}
