/* ======================
   VEREINSPORTAL - Premium Design System
   Apple-like, clean, minimalistisch
   ====================== */

/* ===== Design Tokens ===== */
:root {
    /* Primärfarben */
    --color-primary: #1d4ed8;
    --color-primary-light: #3b82f6;
    --color-primary-lighter: #dbeafe;
    --color-primary-dark: #1e40af;

    /* Neutralfarben */
    --color-bg: #f8f9fa;
    --color-bg-secondary: #f1f3f5;
    --color-surface: #ffffff;
    --color-surface-hover: #f8f9fa;
    --color-border: #e5e7eb;
    --color-border-light: #f3f4f6;

    /* Textfarben */
    --color-text: #111827;
    --color-text-secondary: #6b7280;
    --color-text-tertiary: #9ca3af;
    --color-text-inverse: #ffffff;

    /* Status-Farben */
    --color-success: #059669;
    --color-success-bg: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-danger: #dc2626;
    --color-danger-bg: #fef2f2;
    --color-info: #2563eb;
    --color-info-bg: #eff6ff;

    /* Schatten (Apple-like, sehr subtil) */
    --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.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Font */
    --font-sans: 'Albert Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-bg: rgba(249, 250, 251, 0.85);
    --sidebar-border: #e5e7eb;
}

/* Keyframes muessen ausserhalb von @layer stehen */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes gs-spin {
    to { transform: rotate(360deg); }
}

/*
 * Alle Component-Styles in @layer components,
 * damit Tailwind @layer utilities hoehere Prioritaet hat
 * und Utility-Klassen die Component-Defaults ueberschreiben koennen.
 *
 * Kaskade-Reihenfolge:
 *   @layer base (Tailwind Preflight) < @layer components (Design System) < @layer utilities (Tailwind Utilities)
 */
@layer components {

/* ===== Base ===== */
body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--color-text);
    background: var(--color-bg);
}

/* ===== Scrollbar (Apple-like, duenn) ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-overlay p {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* ===== Cards ===== */
.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-interactive:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-border);
}

.btn-success {
    background: var(--color-success);
    color: var(--color-text-inverse);
}

.btn-success:hover:not(:disabled) {
    background: #047857;
}

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

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
}

.badge-primary {
    background: var(--color-primary-lighter);
    color: var(--color-primary);
}

.badge-success {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.badge-warning {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.badge-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-neutral {
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
}

/* ===== Form Inputs ===== */
.input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    outline: none;
}

.input:focus {
    border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.input::placeholder {
    color: var(--color-text-tertiary);
}

.input-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

/* ===== Modal ===== */

/* Legacy: modal-backdrop (some older views use this) */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal-backdrop.show {
    display: flex;
    opacity: 1;
}

.modal-backdrop.show .modal-content {
    transform: scale(1);
}

/* Standard: modal-overlay (events, etc.) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-border-light);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    color: var(--color-text-secondary);
    font-size: 20px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--color-border);
    color: var(--color-text);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border-light);
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border-light);
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
    max-width: 380px;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-info); }

.toast-success { border-left: 3px solid var(--color-success); }
.toast-error { border-left: 3px solid var(--color-danger); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info { border-left: 3px solid var(--color-info); }

.toast-close {
    margin-left: auto;
    padding: 2px;
    background: none;
    border: none;
    color: var(--color-text-tertiary);
    cursor: pointer;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--color-text-secondary);
}

/* ===== Tables ===== */
.table-container {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-container table {
    width: 100%;
    border-collapse: collapse;
}

.table-container th {
    padding: 10px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.table-container td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--color-border-light);
}

.table-container tbody tr:hover {
    background: var(--color-surface-hover);
}

.table-container tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border-light);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
    transition: box-shadow var(--transition-base);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    margin-top: 4px;
    letter-spacing: -0.025em;
}

.stat-card .stat-sub {
    font-size: 12px;
    color: var(--color-text-tertiary);
    margin-top: 4px;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.sidebar-brand h1 {
    font-size: 17px;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.sidebar-brand span {
    font-size: 12px;
    color: var(--color-text-tertiary);
    font-weight: 400;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.sidebar-section-title {
    padding: 16px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 450;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--color-text);
}

.sidebar-link.active {
    background: var(--color-primary-lighter);
    color: var(--color-primary);
    font-weight: 500;
}

.sidebar-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-link.active svg {
    opacity: 1;
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid var(--color-border-light);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-avatar {
    width: 36px;
    height: 36px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.sidebar-user-actions {
    display: flex;
    gap: 6px;
}

.sidebar-user-actions a,
.sidebar-user-actions button {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-user-actions a:hover,
.sidebar-user-actions button:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

/* ===== App Header ===== */
.app-header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border-light);
    padding: 0 28px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: visible;
}

.app-header-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

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

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

.header-avatar {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.header-avatar:hover {
    opacity: 0.85;
}

/* ===== User Dropdown ===== */
.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--color-border-light);
    min-width: 200px;
    padding: 6px;
    display: none;
    z-index: 100;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown a,
.user-dropdown button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 450;
    color: var(--color-text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.user-dropdown a:hover,
.user-dropdown button:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.user-dropdown svg {
    width: 16px;
    height: 16px;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: 4px 0;
}

/* ===== App Footer ===== */
.app-footer {
    padding: 12px 28px;
    border-top: 1px solid var(--color-border-light);
    background: var(--color-surface);
}

.app-footer p {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-tertiary);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Global Search ===== */
.app-header .global-search {
    position: relative;
    flex: 0 1 400px;
    min-width: 180px;
    margin: 0 4px;
}
.app-header .global-search .gs-input-wrap {
    position: relative;
    width: 100%;
    height: 36px;
}
.app-header .global-search .gs-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px !important;
    height: 16px !important;
    color: var(--color-text-tertiary);
    pointer-events: none;
    z-index: 1;
    display: block;
}
.app-header .global-search input[type="text"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0 70px 0 36px;
    margin: 0;
    border: 1px solid var(--color-border);
    border-style: solid;
    border-width: 1px;
    border-color: var(--color-border);
    border-radius: var(--radius-full, 9999px);
    background: var(--color-bg-secondary, #f1f3f5);
    font-size: 13px;
    color: var(--color-text, #111827);
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
.app-header .global-search input[type="text"]::placeholder {
    color: var(--color-text-tertiary);
}
.app-header .global-search input[type="text"]:focus {
    background: var(--color-surface, #ffffff);
    border-color: var(--color-primary-light, #3b82f6);
    border-width: 1px;
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.app-header .global-search .gs-kbd {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    padding: 2px 6px;
    margin: 0;
    font-size: 11px;
    font-family: inherit;
    color: var(--color-text-tertiary);
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border);
    border-style: solid;
    border-width: 1px;
    border-radius: 4px;
    line-height: 1.4;
    pointer-events: none;
    z-index: 1;
    display: inline-block;
}

/* Dropdown */
.global-search .gs-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 440px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border) !important;
    border-style: solid !important;
    border-width: 1px !important;
    border-radius: var(--radius-lg, 14px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.08);
    max-height: 420px;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.global-search .gs-dropdown.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Loading */
.gs-dropdown .gs-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-size: 13px;
    color: var(--color-text-secondary);
}
.gs-dropdown .gs-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border) !important;
    border-style: solid !important;
    border-width: 2px !important;
    border-top-color: var(--color-primary) !important;
    border-radius: 50%;
    animation: gs-spin 0.6s linear infinite;
    display: inline-block;
}

/* Empty */
.gs-dropdown .gs-empty {
    padding: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--color-text-tertiary);
}

/* Group Label */
.gs-dropdown .gs-group-label {
    padding: 10px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Result Items */
.gs-dropdown a.gs-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none !important;
    color: inherit;
    border: none;
}
.gs-dropdown a.gs-result:hover,
.gs-dropdown a.gs-result.active {
    background: var(--color-bg-secondary);
}
.gs-dropdown .gs-result-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm, 6px);
    background: var(--color-primary-lighter);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.gs-dropdown .gs-result-icon svg {
    width: 16px !important;
    height: 16px !important;
    display: inline-block;
}
.gs-dropdown .gs-result-text {
    min-width: 0;
    flex: 1;
}
.gs-dropdown .gs-result-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gs-dropdown .gs-result-label mark {
    background: rgba(59, 130, 246, 0.15);
    color: var(--color-primary-dark);
    border-radius: 2px;
    padding: 0 1px;
}
.gs-dropdown .gs-result-sublabel {
    font-size: 12px;
    color: var(--color-text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Notifications ===== */
.notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: var(--color-danger);
    border-radius: var(--radius-full);
}
.notif-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border) !important;
    border-style: solid !important;
    border-width: 1px !important;
    border-radius: var(--radius-lg, 14px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.15), 0 4px 12px rgba(0,0,0,0.08);
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.notif-panel.show {
    opacity: 1;
    transform: translateY(0);
}
.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
}
.notif-panel-action {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    border: none; background: none; color: var(--color-text-tertiary);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.notif-panel-action:hover { background: var(--color-bg-secondary); color: var(--color-primary); }
.notif-panel-list {
    max-height: 400px;
    overflow-y: auto;
}
.notif-panel-empty {
    padding: 32px 16px;
    text-align: center;
    font-size: 13px;
    color: var(--color-text-tertiary);
}
.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--color-border-light);
    text-decoration: none;
    color: inherit;
}
.notif-item:hover { background: var(--color-bg-secondary); }
.notif-item.unread { background: rgba(59, 130, 246, 0.04); }
.notif-item-icon {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 16px;
    background: var(--color-primary-lighter); color: var(--color-primary);
}
.notif-item-content { flex: 1; min-width: 0; }
.notif-item-title {
    font-size: 13px; font-weight: 500; color: var(--color-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notif-item-message {
    font-size: 12px; color: var(--color-text-secondary); margin-top: 2px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.notif-item-time {
    font-size: 11px; color: var(--color-text-tertiary); margin-top: 4px;
}
.notif-item-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-primary); flex-shrink: 0; margin-top: 4px;
}

/* ===== Responsive ===== */

/* --- Tablet & below: Sidebar overlay --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-slow);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0 !important;
    }

    .app-header {
        padding: 0 16px;
    }

    /* Hamburger sichtbar */
    .sidebar-hamburger {
        display: flex !important;
    }

    /* Touch targets minimum 44px */
    .sidebar-link {
        min-height: 44px;
        padding: 10px 12px;
    }

    .btn, .input, select {
        min-height: 44px;
    }

    .btn-sm {
        min-height: 36px;
    }

    /* Cards kompakter */
    .card {
        padding: 16px;
    }

    /* Tabellen horizontal scrollbar */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Modals fullwidth */
    .pd-modal, .modal-content {
        max-width: calc(100vw - 24px) !important;
        margin: 12px !important;
        max-height: 92vh !important;
    }

    /* Stat-Cards: 2 Spalten statt 4 */
    .stat-grid, [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Sidebar-User kompakter */
    .sidebar-user {
        padding: 12px 14px;
    }

    .sidebar-user-actions a,
    .sidebar-user-actions button {
        min-height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Header title truncate */
    .app-header-title {
        font-size: 15px;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Notifications - Mobile */
    .notif-panel {
        position: fixed;
        top: 56px;
        right: 8px;
        left: 8px;
        width: auto;
    }

    /* Global Search - Mobile */
    .app-header .global-search {
        flex: 1 1 auto;
        min-width: 100px;
        max-width: none;
    }
    .app-header .global-search .gs-input-wrap {
        height: 34px;
    }
    .app-header .global-search .gs-kbd {
        display: none !important;
    }
    .app-header .global-search input[type="text"] {
        padding-right: 12px;
    }
    .global-search .gs-dropdown {
        position: fixed;
        top: 56px;
        left: 8px;
        right: 8px;
        width: auto;
        min-width: 0;
        max-height: 70vh;
    }
}

/* Sidebar overlay (erscheint wenn Sidebar offen auf mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 49;
    opacity: 0;
    transition: opacity var(--transition-base);
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Hamburger Button (versteckt auf Desktop) */
.sidebar-hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    margin-right: 8px;
}
.sidebar-hamburger:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}
.sidebar-hamburger svg {
    width: 22px;
    height: 22px;
}

/* --- Small phones --- */
@media (max-width: 480px) {
    .card { padding: 12px; }
    h1 { font-size: 18px !important; }
    h2 { font-size: 16px !important; }

    .app-header {
        padding: 0 12px;
        height: 52px;
    }

    .app-header-title {
        font-size: 14px;
        max-width: 140px;
    }

    /* Single column for all grids */
    [style*="grid-template-columns: repeat(auto-fill"],
    [style*="grid-template-columns: repeat(2"],
    [style*="grid-template-columns: repeat(3"],
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: 1fr !important;
    }

    /* Buttons stack vertical */
    .app-header-actions {
        gap: 4px;
    }

    .app-header .global-search input[type="text"] {
        font-size: 16px; /* prevent zoom on iOS */
    }
}

/* --- PWA Standalone Mode --- */
@media (display-mode: standalone) {
    .sidebar {
        padding-top: env(safe-area-inset-top, 0);
    }

    .app-header {
        padding-top: env(safe-area-inset-top, 0);
    }

    .sidebar-user {
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0));
    }

    body {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

} /* Ende @layer components */

/* --- Safe area support (ausserhalb layer fuer @supports) --- */
@supports (padding: env(safe-area-inset-top)) {
    @media (display-mode: standalone) {
        .app-header {
            height: calc(56px + env(safe-area-inset-top, 0));
        }
    }
}
