/*
 * Terminbuchung Admin – gemeinsames Design
 * Helles Layout mit kräftigen Akzentfarben, Sidebar-Navigation, View Transitions.
 */

@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/plus-jakarta-sans-latin-ext.woff2?v=1') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/plus-jakarta-sans-latin.woff2?v=1') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f9fbfd;
    --border: #e3e7ee;
    --border-strong: #d5dbe3;
    --line: #eef1f5;

    --text: #1b2430;
    --text-2: #3a4553;
    --muted: #5b6573;
    --faint: #8a94a3;

    --primary: #0078d4;
    --primary-hover: #0067b8;
    --primary-text: #0063b1;
    --primary-soft: #e6f1fb;
    --primary-soft-2: #f0f7fe;
    --primary-border: #cfe3f7;

    --success: #2e7d32;
    --success-text: #1e6b25;
    --success-soft: #e7f5e8;

    --warning: #e8590c;
    --warning-text: #7a3300;
    --warning-soft: #fff4e5;
    --warning-border: #ffd8a8;

    --danger: #d13438;
    --danger-hover: #b02a2e;
    --danger-text: #a4262c;
    --danger-soft: #fdecec;
    --danger-border: #f5c2c3;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow-pop: 0 12px 32px rgba(16, 24, 40, 0.10);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);

    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: ui-monospace, 'JetBrains Mono', 'SFMono-Regular', Menlo, Consolas, monospace;

    --sidebar-w: 264px;
}

/* ---------- Grundlagen ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
}

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

a:hover {
    color: #004a85;
}

h1,
h2,
h3,
h4,
p {
    margin: 0;
}

img {
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Seitenübergänge (View Transitions) ----------
 * Zwei Wege, eine Optik:
 *   - same-document (admin.js tauscht den Inhalt per fetch aus): Chrome und Firefox
 *   - cross-document (transitions.js, nur Chrome): bei Formular-Absendungen und als Rückfall
 * Die Art steht als Klasse am html-Element, weil Firefox keine View-Transition-Typen kennt:
 *   vt-page-change  anderer Pfad: Inhalt blendet aus und gleitet 10 px von unten ein
 *   vt-same-page    nur die Query ändert sich: Inhalt bleibt stehen, nur das Panel wechselt
 * Sidebar und Topbar bleiben stehen, der Menü-Pill gleitet zum neuen Punkt.
 * Ohne Unterstützung (oder bei reduzierter Bewegung) ist es ein sofortiger Austausch. */

@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }
}

.sidebar {
    view-transition-name: sidebar;
}

.topbar {
    view-transition-name: topbar;
}

.page {
    view-transition-name: page;
}

.panel {
    view-transition-name: panel;
}

/* Hintergrund des Hintergrunds bewegt sich nie */
::view-transition-group(root) {
    animation: none;
}

::view-transition-old(root) {
    display: none;
}

::view-transition-new(root) {
    animation: none;
}

/* Sidebar und Topbar: nur der Zustand (aktiver Punkt, Titel) blendet kurz über */
::view-transition-group(sidebar),
::view-transition-group(topbar) {
    animation: none;
}

::view-transition-old(sidebar),
::view-transition-new(sidebar),
::view-transition-old(topbar),
::view-transition-new(topbar) {
    animation-duration: 140ms;
}

/* Menü-Pill: nur die Gruppe gleitet, der Text darunter bleibt lesbar (multiply) */
::view-transition-group(nav-pill) {
    animation-duration: 220ms;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
    mix-blend-mode: multiply;
}

::view-transition-old(nav-pill) {
    display: none;
}

::view-transition-new(nav-pill) {
    animation: none;
}

/* Gruppen von Inhalt und Panel springen auf die neue Größe, statt verzerrt zu skalieren */
::view-transition-group(page),
::view-transition-group(panel) {
    animation-duration: 1ms;
}

html.vt-page-change {
    &::view-transition-old(page),
    &::view-transition-old(panel) {
        animation: 100ms ease-out both vt-out;
    }

    &::view-transition-new(page),
    &::view-transition-new(panel) {
        animation: 220ms cubic-bezier(0.2, 0.8, 0.2, 1) both vt-in-up;
    }
}

html.vt-same-page {
    &::view-transition-old(page) {
        animation: 120ms linear both vt-out;
    }

    &::view-transition-new(page) {
        animation: 120ms linear both vt-in;
    }

    &::view-transition-old(panel) {
        animation: 90ms ease-out both vt-out;
    }

    &::view-transition-new(panel) {
        animation: 200ms cubic-bezier(0.2, 0.8, 0.2, 1) both vt-in-right;
    }
}

@keyframes vt-out {
    to {
        opacity: 0;
    }
}

@keyframes vt-in {
    from {
        opacity: 0;
    }
}

@keyframes vt-in-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

@keyframes vt-in-right {
    from {
        opacity: 0;
        transform: translateX(8px);
    }
}

/* ---------- Ladebalken bei langsamer Navigation ---------- */

.nav-progress {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 200;
    height: 3px;
    background: var(--primary);
    transform-origin: left;
    pointer-events: none;
    animation: nav-progress 10s cubic-bezier(0.1, 0.6, 0.2, 1) both;
}

@keyframes nav-progress {
    from {
        transform: scaleX(0.04);
    }

    to {
        transform: scaleX(0.92);
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-progress {
        animation: none;
        transform: scaleX(0.6);
    }
}

/* ---------- App-Rahmen ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    flex: none;
    width: var(--sidebar-w);
    height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 28px 36px 56px;
}

.page {
    max-width: 1240px;
}

.page.is-wide {
    max-width: none;
}

.page.is-narrow {
    max-width: 920px;
}

.topbar {
    display: none;
}

/* Marke oben in der Sidebar */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 18px;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-tenant {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Navigation */
.nav-group {
    margin: 20px 12px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6b7684;
}

.nav-item {
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover:not(.is-active) {
    background: #f1f4f8;
    color: var(--text);
}

.nav-item.is-active {
    color: var(--primary-text);
    font-weight: 600;
}

/* Hintergrund des aktiven Punkts; eigener Name, damit er beim Seitenwechsel gleiten kann */
.nav-pill {
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: var(--primary-soft);
    view-transition-name: nav-pill;
}

.nav-item svg {
    flex: none;
}

.nav-label {
    flex: 1;
    min-width: 0;
}

.nav-badge {
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--primary);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.nav-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: var(--warning);
    flex: none;
}

.sidebar-user {
    margin-top: auto;
    padding: 14px 8px 0;
    border-top: 1px solid #e6eaf0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-spacer {
    min-height: 24px;
}

.sidebar-user-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--muted);
}

.nav-backdrop {
    display: none;
}

/* ---------- Seitenkopf ---------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
    padding-right: 52px; /* Platz für die Glocke oben rechts */
}

.page-head-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 720px;
}

.page-kicker {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.page-title:focus {
    outline: none;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-sub {
    font-size: 14px;
    line-height: 1.5;
    color: var(--muted);
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- Layout-Helfer ---------- */

.stack {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stack-sm {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.grow {
    flex: 1 1 auto;
    min-width: 0;
}

.columns {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}

.col-main {
    flex: 2 1 520px;
    min-width: 0;
}

.col-side {
    flex: 1 1 320px;
    min-width: 0;
}

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.split {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: flex-start;
    /* Für den Platzhalter des Panels: er verschwindet, sobald das Panel unter den Inhalt rutscht */
    container-type: inline-size;
}

.split-main {
    flex: 999 1 520px;
    min-width: 0;
}

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

.text-sm {
    font-size: 13px;
}

.text-xs {
    font-size: 12px;
}

.nums {
    font-variant-numeric: tabular-nums;
}

.mt-0 {
    margin-top: 0;
}

/* ---------- Karten ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card-pad {
    padding: 20px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 18px 20px;
}

.card-title {
    font-size: 17px;
    font-weight: 700;
}

.card-body {
    padding: 0 20px 20px;
}

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}

.card.is-selected {
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.card.is-muted {
    background: #f9fafb;
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Listenzeilen in Karten */
.list-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

/* Sortierbare Listen (admin.js: data-sortable) */
[data-sortable] {
    & > [data-sort-id]:first-child {
        border-top: 0;
    }

    & > [data-sort-id] {
        position: relative;
        background: var(--surface);
    }

    & > .is-dragging {
        z-index: 2;
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow-pop);
        border-color: transparent;
    }

    &.is-sorting {
        user-select: none;
        cursor: grabbing;
    }
}

.sort-handle {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 32px;
    margin-left: -8px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    cursor: grab;
    touch-action: none;

    &:hover,
    &:focus-visible {
        background: var(--primary-soft);
        color: var(--primary-text);
    }

    .is-sorting & {
        cursor: grabbing;
    }
}

/* Einstellungszeilen: Text links, Steuerung rechts */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

.setting-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 320px;
}

.setting-label {
    font-size: 14px;
    font-weight: 600;
}

.setting-hint {
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Kennzahlen ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.stat-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    font-size: 13px;
    color: var(--muted);
}

.stat-sub.is-up {
    color: var(--success-text);
    font-weight: 600;
}

.progress {
    height: 6px;
    border-radius: 3px;
    background: var(--line);
    overflow: hidden;
}

.progress > span {
    display: block;
    height: 6px;
    background: var(--primary);
}

.progress.is-success > span {
    background: var(--success);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:disabled,
.btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #ffffff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
}

.btn-ghost:hover {
    background: #f1f4f8;
    color: var(--text);
}

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

.btn-danger:hover {
    background: var(--danger-hover);
    color: #ffffff;
}

.btn-danger-ghost {
    background: transparent;
    color: var(--danger-text);
}

.btn-danger-ghost:hover {
    background: var(--danger-soft);
    color: var(--danger-text);
}

.btn-sm {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    min-height: 36px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
    min-height: 32px;
}

/* ---------- Formulare ---------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    min-width: 0;
}

.field-hint {
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.field-error {
    font-size: 12px;
    font-weight: 600;
    color: var(--danger-text);
}

.input,
.select,
.textarea,
.field input:not([type='checkbox']):not([type='radio']):not([type='file']):not([type='color']),
.field select,
.field textarea {
    width: 100%;
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 14px;
    font-weight: 400;
}

.textarea,
.field textarea {
    padding: 10px 12px;
    min-height: 88px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

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

input[type='checkbox'],
input[type='radio'] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex: none;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
}

/* Schalter: <label class="switch"><input type="checkbox"><span></span></label> */
.switch {
    position: relative;
    display: inline-flex;
    flex: none;
    width: 46px;
    height: 26px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.switch span {
    width: 100%;
    height: 100%;
    border-radius: 13px;
    background: #c3cbd6;
    transition: background-color 0.15s;
    pointer-events: none;
}

.switch span::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s;
}

.switch input:checked + span {
    background: var(--primary);
}

.switch input:checked + span::after {
    transform: translateX(20px);
}

.switch input:focus-visible + span {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Auswahlkarten (Radio als Karte) */
.option-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    cursor: pointer;
    position: relative;
}

.option-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.option-card:has(input:checked) {
    border: 2px solid var(--primary);
    padding: 17px;
    background: #f5faff;
}

.option-card:has(input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.option-head {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
}

.option-radio {
    width: 18px;
    height: 18px;
    border-radius: 9px;
    border: 2px solid #a7b0bc;
    flex: none;
}

.option-card:has(input:checked) .option-radio {
    border: 6px solid var(--primary);
}

.option-text {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-2);
}

/* Dropzone für Uploads */
.dropzone {
    flex: 1;
    min-height: 72px;
    border-radius: 10px;
    border: 1.5px dashed #c3cbd6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 12px;
    text-align: center;
    cursor: pointer;
    position: relative;
}

.dropzone:hover,
.dropzone.is-over {
    border-color: var(--primary);
    background: var(--primary-soft-2);
}

.dropzone input[type='file'] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ---------- Segmentierte Auswahl, Chips, Tags ---------- */

.seg {
    display: inline-flex;
    padding: 3px;
    background: #eef1f5;
    border-radius: var(--radius-sm);
    gap: 2px;
    flex-wrap: wrap;
}

.seg a,
.seg button,
.seg label {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
}

.seg .is-active,
.seg label:has(input:checked) {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.seg label input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.chip.has-avatar {
    padding-left: 6px;
}

.chip:hover {
    border-color: #b9c2ce;
    color: var(--text);
}

.chip.is-active {
    background: var(--text);
    border-color: var(--text);
    color: #ffffff;
}

/* Umschaltbare Chips (Checkbox als Chip) */
.toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 17px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    position: relative;
}

.toggle-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-chip:has(input:checked) {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-text);
}

.toggle-chip:has(input:focus-visible) {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.toggle-chip .tick {
    display: none;
}

.toggle-chip:has(input:checked) .tick {
    display: inline;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    background: #eef1f5;
    color: var(--text-2);
}

.tag-blue,
.tg-0 {
    background: var(--primary-soft);
    color: var(--primary-text);
}

.tag-orange,
.tg-1 {
    background: #fff1e0;
    color: #8f4300;
}

.tag-green,
.tg-2 {
    background: var(--success-soft);
    color: var(--success-text);
}

.tag-purple,
.tg-3 {
    background: #f0ebff;
    color: #5b34c7;
}

.tag-pink,
.tg-4 {
    background: #fdeaf3;
    color: #9d174d;
}

.tag-teal,
.tg-5 {
    background: #e2f4f2;
    color: #0b6560;
}

.tag-red {
    background: var(--danger-soft);
    color: var(--danger-text);
}

.tag-solid {
    background: var(--primary);
    color: #ffffff;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    flex: none;
    background: #a7b0bc;
}

.dot-green {
    background: var(--success);
}

.dot-orange {
    background: var(--warning);
}

.dot-red {
    background: var(--danger);
}

.meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-2);
}

.meta svg {
    flex: none;
    color: var(--muted);
}

/* ---------- Avatare ---------- */

.av {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--primary);
}

.av img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.av-xs {
    width: 20px;
    height: 20px;
    font-size: 9px;
}

.av-sm {
    width: 28px;
    height: 28px;
    font-size: 11px;
}

.av-lg {
    width: 56px;
    height: 56px;
    font-size: 18px;
}

.av-xl {
    width: 72px;
    height: 72px;
    font-size: 22px;
}

.av-c0 {
    background: #0078d4;
}

.av-c1 {
    background: #7048e8;
}

.av-c2 {
    background: #0b7a75;
}

.av-c3 {
    background: #c2410c;
}

.av-c4 {
    background: #be185d;
}

.av-c5 {
    background: #4d7c0f;
}

.av-muted {
    background: #8a94a3;
}

.av-stack {
    display: inline-flex;
    align-items: center;
}

.av-stack .av {
    border: 2px solid var(--surface);
    margin-right: -6px;
}

/* ---------- Hinweise ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 18px;
}

.alert svg {
    flex: none;
    margin-top: 1px;
}

.alert-body {
    flex: 1 1 320px;
}

.alert .actions {
    margin-left: auto;
}

.alert-success {
    background: var(--success-soft);
    border-color: #bfe3c2;
    color: var(--success-text);
}

.alert-error {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.alert-warning {
    background: var(--warning-soft);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.alert-info {
    background: var(--primary-soft-2);
    border-color: var(--primary-border);
    color: #0b4f86;
}

.note {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 14px;
    flex-wrap: wrap;
}

/* ---------- Tabellen ---------- */

.table-wrap {
    position: relative; /* clippt auch absolut positionierte Inhalte wie .sr-only */
    overflow-x: auto;
}

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

.table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: 0;
}

.table tbody tr:hover td {
    background: #fafbfd;
}

/* ---------- Seitenpanel (Bearbeiten, Ausfüllhilfe) ---------- */

.panel {
    flex: 1 1 380px;
    min-width: 0;
    max-width: 460px;
    position: sticky;
    top: 68px; /* unter der Glocke (fest oben rechts) */
    max-height: calc(100vh - 92px);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
}

/* Breites Panel (adminPageStart 'panel' => 'wide'), z. B. Mitarbeiter-Bearbeitung.
 * Die Kacheln links dürfen dafür auf eine Spalte gehen (Basis 320 + 24 + 560 = 904 px). */
.page.has-wide-panel {
    & .split-main {
        flex-basis: 320px;
    }

    & .panel {
        flex-basis: 560px;
        max-width: 640px;
    }

    @container (width < 904px) {
        & .panel-empty {
            display: none;
        }
    }
}

/* Platzhalter, solange nichts ausgewählt ist: hält den Platz rechts frei, das Raster links
 * behält seine Breite. Unter dem Inhalt (Panel gewrappt: 520 + 24 + 380 = 924 px) entfällt er. */
.panel-empty {
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 280px;
    padding: 32px 24px;
    text-align: center;
    background: transparent;
    border: 1.5px dashed #c3cbd6;
    box-shadow: none;
    color: var(--muted);

    & .panel-empty-icon {
        display: grid;
        place-items: center;
        width: 48px;
        height: 48px;
        margin-bottom: 4px;
        border-radius: 50%;
        background: var(--surface);
        border: 1px solid var(--border);
        color: var(--faint);
    }

    & .panel-empty-title {
        font-size: 15px;
        font-weight: 700;
        color: var(--text);
    }

    & .panel-empty-text {
        max-width: 30ch;
        font-size: 14px;
        line-height: 1.5;
    }

    & .panel-empty-actions {
        margin-top: 8px;
    }
}

@container (width < 924px) {
    .page:not(.has-wide-panel) .panel-empty {
        display: none;
    }
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
}

.panel-title {
    font-size: 18px;
    font-weight: 700;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
}

.panel-section:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.panel-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

/* ---------- Code ---------- */

.code {
    margin: 0;
    padding: 14px 16px;
    border-radius: 10px;
    background: #0f1b2a;
    color: #d6e4f5;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-inline {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-2);
    background: var(--bg);
    border-radius: 6px;
    padding: 3px 8px;
}

/* ---------- Leere Zustände ---------- */

.empty {
    padding: 36px 20px;
    text-align: center;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.empty-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.add-tile {
    min-height: 160px;
    border-radius: var(--radius);
    border: 1.5px dashed #c3cbd6;
    background: transparent;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    text-decoration: none;
}

.add-tile:hover {
    border-color: var(--primary);
    color: var(--primary-text);
}

/* ---------- Tabs ---------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.tabs a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tabs a:hover {
    color: var(--text);
}

.tabs a.is-active {
    color: var(--primary-text);
    border-bottom-color: var(--primary);
}

/* ---------- Schritte (Einbinden) ---------- */

.step-num {
    width: 28px;
    height: 28px;
    border-radius: 14px;
    background: var(--text);
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

/* ---------- Toasts und Glocke ----------
 * Toasts liegen fest oben rechts unter der Glocke und verschieben nie den Inhalt.
 * Die Glocke sitzt auf dem Desktop fest in der rechten oberen Ecke, mobil in der Topbar (siehe Media Query). */

.bell {
    position: fixed;
    top: 14px;
    right: 20px;
    z-index: 85;
}

.bell-btn {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);

    &.is-pulse svg {
        animation: bell-ring 0.7s ease-out;
        transform-origin: 50% 20%;
    }

    &.is-pulse {
        animation: bell-pulse 0.7s ease-out;
    }
}

.bell-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger);
    border: 2px solid var(--surface);
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    box-sizing: border-box;
    font-variant-numeric: tabular-nums;
}

.bell-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(380px, calc(100vw - 24px));
    max-height: min(520px, calc(100vh - 90px));
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);

    &:focus {
        outline: none;
    }
}

.bell-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.bell-title {
    font-size: 14px;
    font-weight: 700;
}

.bell-clear {
    padding: 2px 4px;
    border: 0;
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-text);
    cursor: pointer;

    &:hover {
        text-decoration: underline;
    }

    &:disabled {
        color: var(--faint);
        cursor: default;
        text-decoration: none;
    }
}

.bell-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
}

.bell-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
}

.bell-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;

    &:hover {
        background: var(--surface-2);
        color: var(--text);
    }

    &.is-unread {
        background: var(--primary-soft-2);
    }

    & .bell-item-icon {
        flex: none;
        margin-top: 1px;
    }

    &.is-success .bell-item-icon {
        color: var(--success);
    }

    &.is-info .bell-item-icon {
        color: var(--primary);
    }

    &.is-warning .bell-item-icon {
        color: var(--warning);
    }

    & .bell-item-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    & .bell-item-msg {
        font-size: 13px;
        line-height: 1.4;
        overflow-wrap: anywhere;
    }

    & .bell-item-meta {
        font-size: 12px;
        color: var(--muted);
    }
}

.toast-region {
    position: fixed;
    top: 68px;
    right: 20px;
    z-index: 80;
    width: min(380px, calc(100vw - 24px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 10px 12px 14px;
    border-radius: var(--radius);
    border: 1px solid;
    box-shadow: var(--shadow-pop);
    font-size: 14px;
    line-height: 1.45;
    animation: toast-in 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;

    & .toast-icon {
        flex: none;
        margin-top: 1px;
    }

    & .toast-body {
        flex: 1;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    & .toast-close {
        flex: none;
        display: grid;
        place-items: center;
        width: 24px;
        height: 24px;
        margin-top: -2px;
        padding: 0;
        border: 0;
        border-radius: 6px;
        background: none;
        color: inherit;
        opacity: 0.7;
        cursor: pointer;

        &:hover {
            opacity: 1;
            background: rgba(16, 24, 40, 0.08);
        }
    }

    &.toast-success {
        background: var(--success-soft);
        border-color: #bfe3c2;
        color: var(--success-text);
    }

    &.toast-info {
        background: var(--primary-soft-2);
        border-color: var(--primary-border);
        color: #0b4f86;
    }

    &.toast-warning {
        background: var(--warning-soft);
        border-color: var(--warning-border);
        color: var(--warning-text);
    }

    /* Verschwinden: kleiner werden und zur Glocke fliegen (Ziel kommt per Script) */
    &.is-leaving {
        animation: none;
        pointer-events: none;
        opacity: 0;
        transform: translate(var(--fly-x, 0px), var(--fly-y, 0px)) scale(0.12);
        transition: transform 0.45s cubic-bezier(0.5, 0, 0.75, 0), opacity 0.45s ease-in;
    }

    &.is-dropped {
        animation: none;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
}

@keyframes bell-pulse {
    35% {
        box-shadow: 0 0 0 5px rgba(0, 120, 212, 0.25);
    }
}

@keyframes bell-ring {
    20% {
        transform: rotate(14deg);
    }

    45% {
        transform: rotate(-12deg);
    }

    70% {
        transform: rotate(6deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: toast-fade 0.2s ease-out backwards;

        &.is-leaving {
            transform: none;
            transition: opacity 0.2s;
        }
    }

    .bell-btn.is-pulse,
    .bell-btn.is-pulse svg {
        animation: none;
    }
}

@keyframes toast-fade {
    from {
        opacity: 0;
    }
}

/* ---------- Mobil ---------- */

@media (max-width: 960px) {
    .topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 56px;
        padding: 0 12px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }

    .topbar-title {
        font-size: 15px;
        font-weight: 700;
    }

    /* Glocke liegt in der Topbar rechts (fest, deckt sich mit der sticky Topbar) */
    .bell {
        top: 8px;
        right: 12px;
        z-index: 35;
    }

    .bell-btn {
        border-color: transparent;
        box-shadow: none;
    }

    .toast-region {
        top: 64px;
        right: 12px;
    }

    .page-head {
        padding-right: 0;
    }

    .app {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        height: auto;
        transform: translateX(-105%);
        transition: transform 0.2s ease-out;
        box-shadow: var(--shadow-pop);
    }

    body.nav-open .sidebar {
        transform: none;
    }

    body.nav-open .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(16, 24, 40, 0.35);
    }

    .main {
        padding: 20px 16px 48px;
    }

    .panel {
        position: static;
        max-width: none;
        max-height: none;
    }

    .page-title {
        font-size: 24px;
    }
}
