/* ── CSS Custom Properties ───────────────────────────────────────────────── */
:root {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-2: #293548;
    --color-border: #334155;
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-light: #818cf8;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-danger: #ef4444;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    --sidebar-width: 230px;
    --header-height: 56px;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
}

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

html, body {
    height: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--color-primary-light); text-decoration: none; }
a:hover { color: var(--color-primary); }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary-light);
}

.sidebar-logo svg { width: 24px; height: 24px; }

.nav-section {
    padding: 8px 0;
}

.nav-section-title {
    padding: 8px 16px 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    margin: 1px 8px;
    border-radius: var(--radius);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-size: 13.5px;
    text-decoration: none;
}

.nav-item:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
    text-decoration: none;
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--color-primary-light);
    font-weight: 600;
}

.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Main Area ─────────────────────────────────────────────────────────────── */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    background: var(--color-surface-2);
    border-radius: 20px;
    font-size: 12.5px;
    color: var(--color-text-muted);
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

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

/* ── Stat Cards ────────────────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-label { font-size: 12px; color: var(--color-text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-text); }
.stat-sub   { font-size: 11px; color: var(--color-text-muted); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    line-height: 1.4;
}

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

.btn-primary   { background: var(--color-primary);     color: #fff; }
.btn-primary:hover   { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-surface-2);   color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-danger    { background: var(--color-danger);      color: #fff; }
.btn-danger:hover    { background: #dc2626; }
.btn-success   { background: var(--color-success);     color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

/* Inline-Positions-Formular (Einkaufsbestellung-Detail: Position hinzufügen/bearbeiten) —
   eigene Klasse statt Inline-Style, damit die Mobile-Breakpoints unten greifen können. */
.pos-form-grid {
    display: grid;
    grid-template-columns: 1fr 90px 110px 140px auto;
    gap: 8px;
    align-items: end;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 13.5px;
    transition: border-color 0.15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

select.form-control option { background: var(--color-surface-2); }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

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

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

.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    color: var(--color-text);
    font-size: 13.5px;
}

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

.data-table tr:hover td { background: rgba(99, 102, 241, 0.05); }

.data-table .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 200px;
    max-width: 360px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 7px 12px 7px 34px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 13.5px;
    outline: none;
}

.search-box input:focus { border-color: var(--color-primary); }

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    width: 15px;
    height: 15px;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-primary  { background: rgba(99,102,241,0.2); color: var(--color-primary-light); }
.badge-success  { background: rgba(34,197,94,0.2);  color: #4ade80; }
.badge-warning  { background: rgba(245,158,11,0.2); color: #fbbf24; }
.badge-danger   { background: rgba(239,68,68,0.2);  color: #f87171; }
.badge-info     { background: rgba(59,130,246,0.2); color: #93c5fd; }
.badge-muted    { background: rgba(148,163,184,0.15); color: var(--color-text-muted); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
    width: min(560px, 95vw);
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 700; }

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

/* ── Alert ─────────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 13px;
}

.alert-danger  { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }
.alert-error   { background: rgba(239,68,68,0.15);  border: 1px solid rgba(239,68,68,0.3);  color: #f87171; }
.alert-success { background: rgba(34,197,94,0.15);  border: 1px solid rgba(34,197,94,0.3);  color: #4ade80; }
.alert-info    { background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }
.alert-warning { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); color: #fbbf24; }

/* ── Login Page ────────────────────────────────────────────────────────────── */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.login-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 40px;
    width: min(400px, 95vw);
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary-light);
}

/* ══════════════════════════════════════════════════════════════════════════════
   MOBILE & PWA — Responsive, Touch, Navigation
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Touch Targets (Phase 11) ──────────────────────────────────────────────── */
.btn {
    min-height: 44px;
    padding: 10px 16px;
}
.btn-sm {
    min-height: 36px;
    padding: 6px 12px;
}
.btn-icon {
    min-height: 44px;
    width: 44px;
    height: 44px;
    padding: 0;
}
.form-control {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 16px; /* verhindert Auto-Zoom auf iOS */
}
select.form-control { min-height: 44px; }

.nav-item {
    min-height: 44px;
    padding: 12px 16px;
}

/* ── Hamburger Button ──────────────────────────────────────────────────────── */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    min-height: 44px;
    min-width: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    color: var(--color-text);
    flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--color-surface-2); }

.hamburger-icon {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 22px;
}
.hamburger-icon span {
    display: block;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.25s, opacity 0.25s;
    transform-origin: center;
}
.hamburger-icon.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-icon.open span:nth-child(2) { opacity: 0; }
.hamburger-icon.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Topbar Left Group ─────────────────────────────────────────────────────── */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-brand {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-primary-light);
    display: none; /* Desktop: Sidebar zeigt Brand */
}

/* ── Sidebar Overlay (Mobile) ──────────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 199;
    backdrop-filter: blur(2px);
}

/* ── Page Content Padding mobile ───────────────────────────────────────────── */
/* bereits gut, ggf. auf Handy reduzieren */

/* ── Toolbar Mobile ────────────────────────────────────────────────────────── */
.toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
}
.search-box {
    min-width: 160px;
}

/* ── Modal Mobile (Phase 4) ────────────────────────────────────────────────── */
.modal {
    width: min(580px, 96vw);
    max-height: 92vh;
    padding: 20px;
}
.modal-footer {
    flex-wrap: wrap;
    gap: 8px;
}
.modal-footer .btn {
    flex: 1;
    min-width: 100px;
    justify-content: center;
}

/* ── Tabellen: Mobile Card View (Phase 2) ──────────────────────────────────── */
/* Tabellen bleiben horizontal scrollbar; Card-View per data-card-view Attribut */
.table-wrapper {
    -webkit-overflow-scrolling: touch;
}

/* ── Form Grid: immer einzeln auf schmalem Screen ──────────────────────────── */
/* Wird in media query überschrieben */

/* ── Stat Grid ─────────────────────────────────────────────────────────────── */
.stat-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ── User Badge ────────────────────────────────────────────────────────────── */
.user-badge-role {
    margin-left: 4px;
    font-size: 0.7rem;
    opacity: 0.7;
}


/* ══════════════════════════════════════════════════════════════════════════════
   BREAKPOINT: Tablet (≤ 960px)
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 960px) {
    :root { --sidebar-width: 260px; }

    /* Hamburger sichtbar */
    .hamburger-btn   { display: flex; }
    .topbar-brand    { display: block; }

    /* Sidebar: seitlich einschieben */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
        box-shadow: none;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.45);
    }
    .sidebar-overlay { display: block; }

    /* Page padding reduzieren */
    .page-content { padding: 16px; }

    /* Toolbar strecken */
    .search-box { max-width: 100%; width: 100%; }
    .toolbar > .btn { margin-left: auto; }
}


/* ══════════════════════════════════════════════════════════════════════════════
   BREAKPOINT: Mobile (≤ 640px)
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    /* Stat-Raster: 2 Spalten */
    .stat-grid { grid-template-columns: 1fr 1fr; }

    /* Page Padding weiter reduzieren */
    .page-content { padding: 12px; }

    /* Topbar schmaler */
    .topbar { padding: 0 12px; }
    .user-badge-name { display: none; }

    /* Modals: fast Fullscreen */
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 88vh;
        border-radius: 16px 16px 0 0;
        padding: 20px 16px;
        position: fixed;
        bottom: 0;
        margin: 0;
    }
    .modal-overlay {
        align-items: flex-end;
    }

    /* Formulare: immer 1 Spalte */
    .modal [style*="grid-template-columns:1fr 1fr"],
    .modal [style*="grid-template-columns: 1fr 1fr"],
    .modal [style*="grid-template-columns:120px 1fr"],
    .modal [style*="grid-template-columns: 120px 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Inline-Positions-Formular (Einkaufsbestellung-Detail) auf sehr schmalen Screens stapeln */
    .pos-form-grid {
        grid-template-columns: 1fr;
    }

    /* Toolbar: Stack */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .toolbar > * { width: 100%; }
    .toolbar > .btn { width: auto; align-self: flex-start; }

    /* Actions in Tabellen: Column */
    .data-table .actions { flex-wrap: wrap; justify-content: flex-start; }

    /* Card statt Tabelle — tabellenzeilen werden zu Cards */
    .table-card-mode table,
    .table-card-mode thead,
    .table-card-mode tbody,
    .table-card-mode th,
    .table-card-mode td,
    .table-card-mode tr { display: block; }

    .table-card-mode thead { display: none; }

    .table-card-mode tbody tr {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        margin-bottom: 10px;
        padding: 12px;
    }

    .table-card-mode tbody td {
        padding: 4px 0;
        border: none;
        display: flex;
        gap: 8px;
        font-size: 13px;
    }
    .table-card-mode tbody td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--color-text-muted);
        min-width: 90px;
        flex-shrink: 0;
        padding-top: 2px;
    }
    .table-card-mode tbody td:last-child {
        padding-top: 10px;
        margin-top: 6px;
        border-top: 1px solid var(--color-border);
    }
    .table-card-mode .table-wrapper {
        border: none;
        background: transparent;
        overflow: visible;
    }

    /* Dashboard Cards: 1 Spalte auf sehr kleinen Screens */
    .db-stat-grid  { grid-template-columns: 1fr 1fr; }
    .db-quick-grid { grid-template-columns: 1fr 1fr; }
    .db-bar-row    { grid-template-columns: 70px 1fr 28px; }

    /* Login */
    .login-box { padding: 28px 20px; border-radius: 12px; }
}


/* ══════════════════════════════════════════════════════════════════════════════
   BREAKPOINT: Sehr klein (≤ 380px)
   ══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
    .db-stat-grid  { grid-template-columns: 1fr; }
    .db-quick-grid { grid-template-columns: 1fr; }
    .page-content  { padding: 8px; }
}


/* ── Hover nur auf Pointer-Geräten (Phase 11) ──────────────────────────────── */
@media (hover: none) {
    .btn:hover,
    .nav-item:hover,
    .db-stat-link:hover,
    .db-quick-btn:hover,
    .data-table tr:hover td {
        background: unset;
        color: unset;
        border-color: unset;
        text-decoration: none;
    }
    /* Aktive Zustände für Touch */
    .btn:active         { opacity: 0.75; }
    .nav-item:active    { background: var(--color-surface-2); }
    .db-quick-btn:active { background: rgba(99,102,241,0.15); }
}


/* ── Lager-Raster Mobile (Phase 6) ────────────────────────────────────────── */
.raster-scroll-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}
@media (max-width: 640px) {
    .raster-fach-detail { margin-top: 16px; }
}


/* ── PWA / iOS Meta Anpassungen ────────────────────────────────────────────── */
@media (display-mode: standalone) {
    /* Safe-area Insets für iPhone-Notch / Android-Cutout */
    .topbar {
        padding-top: env(safe-area-inset-top);
        height: calc(var(--header-height) + env(safe-area-inset-top));
    }
    .sidebar {
        padding-top: env(safe-area-inset-top);
    }
    .page-content {
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.text-muted   { color: var(--color-text-muted); }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-primary { color: var(--color-primary-light); }
.text-right   { text-align: right; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-2  { gap: 8px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-100  { width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Dashboard ─────────────────────────────────────────────────────────────── */
.db-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.db-title    { font-size: 22px; font-weight: 700; color: var(--color-text); }
.db-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.db-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 16px;
}

.db-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(99,102,241,0.25);
    color: var(--color-primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; flex-shrink: 0;
}

.db-user-name  { font-size: 13.5px; font-weight: 600; color: var(--color-text); }
.db-user-role  { font-size: 11px; color: var(--color-primary-light); font-weight: 500; margin-top: 1px; }
.db-user-login { font-size: 11px; color: var(--color-text-muted); margin-top: 1px; }

/* Stat-Karten */
.db-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.db-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.15s, background 0.15s;
}

.db-stat-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}
.db-stat-link:hover {
    border-color: var(--color-primary);
    background: var(--color-surface-2);
    color: inherit;
}

.db-stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.db-stat-value { font-size: 22px; font-weight: 700; color: var(--color-text); line-height: 1.2; }
.db-stat-label { font-size: 12px; font-weight: 600; color: var(--color-text); margin-top: 1px; }
.db-stat-sub   { font-size: 11px; color: var(--color-text-muted); margin-top: 1px; }

/* Hauptlayout */
.db-main-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    align-items: start;
}

.db-left-col, .db-right-col { display: flex; flex-direction: column; gap: 16px; }
.db-left-col  .card { margin-bottom: 0; }
.db-right-col .card { margin-bottom: 0; }

/* Leer-Zustand */
.db-empty {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-muted);
    font-size: 13px;
    padding: 8px 0 4px;
}

/* Aktivitätsliste */
.db-activity-list { display: flex; flex-direction: column; gap: 0; }

.db-activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(51,65,85,0.4);
}
.db-activity-item:last-child { border-bottom: none; }

.db-activity-time   { font-size: 12px; color: var(--color-primary-light); font-weight: 600; white-space: nowrap; min-width: 38px; }
.db-activity-action { font-size: 13px; color: var(--color-text); }
.db-activity-meta   { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }

/* Schnellzugriff */
.db-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.db-quick-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    cursor: pointer;
}
.db-quick-btn:hover {
    background: rgba(99,102,241,0.15);
    border-color: var(--color-primary);
    color: var(--color-primary-light);
}

/* Pie-Chart */
.db-chart-row { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

.db-pie {
    width: 120px; height: 120px;
    border-radius: 50%;
    flex-shrink: 0;
}

.db-legend        { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.db-legend-item   { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.db-legend-dot    { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.db-legend-label  { flex: 1; color: var(--color-text); }
.db-legend-count  { color: var(--color-text-muted); font-weight: 600; }

/* Bar-Chart */
.db-bar-chart { display: flex; flex-direction: column; gap: 8px; }

.db-bar-row {
    display: grid;
    grid-template-columns: 90px 1fr 32px;
    align-items: center;
    gap: 8px;
}

.db-bar-label  { font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.db-bar-track  { background: var(--color-surface-2); border-radius: 4px; height: 8px; }
.db-bar-fill   { height: 8px; border-radius: 4px; background: var(--color-primary); min-width: 4px; transition: width 0.3s; }
.db-bar-count  { font-size: 11.5px; color: var(--color-text-muted); text-align: right; }

/* Speicherplatz */
.db-storage-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    text-align: center;
}

.db-storage-item  { padding: 10px 4px; }
.db-storage-value { font-size: 16px; font-weight: 700; color: var(--color-text); }
.db-storage-label { font-size: 11px; color: var(--color-text-muted); margin-top: 3px; }

/* Systemstatus */
.db-status-list { display: flex; flex-direction: column; gap: 10px; }

.db-status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--color-text);
}

.db-status-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Dashboard Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .db-stat-grid  { grid-template-columns: repeat(2, 1fr); }
    .db-main-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .db-stat-grid  { grid-template-columns: 1fr 1fr; }
    .db-header     { flex-direction: column; }
    .db-user-card  { width: 100%; }
    .db-quick-grid { grid-template-columns: 1fr 1fr; }
}
