/* ============================================
   Lagertool Resys – Hauptstylesheet
   Mobile-First, Resys-Rot als Primärfarbe
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #d10911;
    --primary-hover: #b0070e;
    --primary-light: #fde8e9;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --sidebar-width: 220px;
}

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

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

body {
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
    min-height: 100vh;
}

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

a:hover {
    text-decoration: underline;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    gap: 6px;
    font-family: var(--font);
}

.btn:hover { text-decoration: none; }

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

.btn-outline {
    background: #fff;
    border-color: var(--gray-300);
    color: var(--gray-700);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

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

.btn-block { width: 100%; }

.btn-sm {
    padding: 5px 12px;
    font-size: 0.85rem;
}

.btn-entnahme {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}
.btn-entnahme.active, .btn-entnahme:hover {
    background: var(--danger);
    color: #fff;
}

.btn-einlagerung {
    background: var(--success-light);
    color: var(--success);
    border-color: var(--success);
}
.btn-einlagerung.active, .btn-einlagerung:hover {
    background: var(--success);
    color: #fff;
}

.btn-inventur {
    background: var(--warning-light);
    color: #92400e;
    border-color: var(--warning);
}
.btn-inventur.active, .btn-inventur:hover {
    background: var(--warning);
    color: #fff;
}

.btn-book {
    font-size: 1.2rem;
    padding: 14px 20px;
    margin-top: 8px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color 0.15s;
    background: #fff;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
    display: flex;
    gap: 12px;
}
.form-row .form-group { flex: 1; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
}

.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid var(--warning);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #8a060b 100%);
    padding: 20px;
}

.login-container {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-img {
    max-width: 180px;
    height: auto;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 1.5rem;
    color: var(--gray-800);
}

/* ============================================
   SCAN PAGE (Mitarbeiter)
   ============================================ */
.scan-page {
    background: var(--gray-50);
    min-height: 100vh;
}

.scan-header {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scan-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.scan-user {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-link {
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
}
.logout-link:hover { color: #fff; }

.scan-main {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

.scan-home {
    text-align: center;
    padding-top: 60px;
}

.logo-home {
    max-width: 160px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.scan-home h2 {
    margin-bottom: 8px;
    color: var(--gray-800);
}

.scan-hint {
    color: var(--gray-500);
    margin-bottom: 40px;
    font-size: 1.05rem;
}

.scan-instructions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 280px;
    margin: 0 auto;
}

.instruction-step {
    display: flex;
    align-items: center;
    gap: 16px;
    text-align: left;
}

.step-number {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.step-text {
    font-size: 1rem;
    color: var(--gray-700);
}

/* Location Info */
.location-info {
    margin-bottom: 16px;
}

.location-code {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.location-label {
    color: var(--gray-500);
    font-size: 0.95rem;
}

/* Article Card */
.article-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.article-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

.article-number {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.stock-display {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 8px 0;
}

.stock-label {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--gray-500);
}

.stock-ok .stock-value { color: var(--gray-900); }
.stock-low .stock-value { color: var(--warning); }
.stock-empty .stock-value { color: var(--danger); }

.stock-warning {
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: var(--radius);
    margin-top: 8px;
    font-weight: 600;
}

.stock-warning-low {
    background: var(--warning-light);
    color: #92400e;
}

.stock-warning-empty {
    background: var(--danger-light);
    color: var(--danger);
}

/* Booking Section */
.booking-section {
    margin-bottom: 16px;
}

.booking-type-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.booking-type-buttons .btn {
    flex: 1;
    padding: 12px 8px;
    font-size: 0.95rem;
}

.booking-form #quantity {
    font-size: 1.5rem;
    text-align: center;
    padding: 14px;
    font-weight: 700;
}

.note-group {
    margin-top: 8px;
}

.note-group input {
    font-size: 0.9rem;
}

/* Booking Result */
.booking-result {
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 600;
    text-align: center;
    font-size: 1.05rem;
}

.booking-result.result-success {
    background: var(--success-light);
    color: var(--success);
    border: 2px solid var(--success);
}

.booking-result.result-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 2px solid var(--warning);
}

.booking-result.result-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 2px solid var(--danger);
}

.last-booking {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.85rem;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}

/* No Article */
.no-article {
    text-align: center;
    padding: 40px 20px;
}

.no-article-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.no-article p {
    color: var(--gray-500);
    margin-bottom: 8px;
}

/* ============================================
   ADMIN PAGE
   ============================================ */
.admin-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 20px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--gray-700);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--gray-800);
}
.admin-brand:hover { text-decoration: none; }

.logo-admin {
    height: 32px;
    width: auto;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-user {
    font-size: 0.9rem;
    color: var(--gray-600);
}

.admin-wrapper {
    display: flex;
    flex: 1;
}

/* Sidebar */
.admin-sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--gray-200);
    padding: 12px 0;
    flex-shrink: 0;
    min-height: calc(100vh - 56px);
}

.nav-group-label {
    padding: 16px 20px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gray-400);
}

.admin-nav-item.nav-grouped {
    padding-left: 28px;
    font-size: 0.9rem;
}

.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.1s;
}

.admin-nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
    text-decoration: none;
}

.admin-nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    border-right: 3px solid var(--primary);
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Main Content */
.admin-main {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

.admin-content {
    max-width: 1200px;
}

.admin-page-title {
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: var(--gray-900);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.kpi-card {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 2px solid transparent;
}

.kpi-card.kpi-warning {
    border-color: var(--danger);
    background: var(--danger-light);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.kpi-card.kpi-warning .kpi-value {
    color: var(--danger);
}

.kpi-label {
    font-size: 0.85rem;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Table Toolbar */
.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.table-toolbar h2 {
    font-size: 1.15rem;
    color: var(--gray-800);
}

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

.toolbar-search {
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    min-width: 200px;
    font-family: var(--font);
}

.toolbar-search:focus {
    outline: none;
    border-color: var(--primary);
}

.toolbar-select {
    padding: 8px 12px;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    background: #fff;
}

.toolbar-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--gray-600);
    cursor: pointer;
}

.toolbar-info {
    font-size: 0.85rem;
    color: var(--gray-500);
}

.toolbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Data Table */
.table-responsive {
    overflow-x: auto;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.data-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table .text-right { text-align: right; }
.data-table .text-center { text-align: center; }
.data-table .text-nowrap { white-space: nowrap; }

.text-muted { color: var(--gray-400); }

.table-link {
    font-weight: 600;
}

.action-cell {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.col-check {
    width: 40px;
    text-align: center;
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-ok { background: var(--success-light); color: var(--success); }
.status-low { background: var(--warning-light); color: #92400e; }
.status-critical { background: var(--danger-light); color: var(--danger); }
.status-empty { background: var(--gray-100); color: var(--gray-400); }

/* Booking Type Badges */
.booking-type-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.type-entnahme { background: var(--danger-light); color: var(--danger); }
.type-einlagerung { background: var(--success-light); color: var(--success); }
.type-inventur { background: var(--warning-light); color: #92400e; }

/* Role Badges */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.role-admin { background: var(--primary-light); color: var(--primary); }
.role-buero { background: var(--warning-light); color: #b45309; }
.role-mitarbeiter { background: var(--gray-100); color: var(--gray-600); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.page-info {
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.15rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }

.modal form {
    padding: 24px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

/* ============================================
   QR-CODE PRINT
   ============================================ */
.qr-print-area {
    margin-top: 24px;
}

.qr-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.qr-item {
    display: flex;
    align-items: stretch;
    gap: 20px;
    padding: 16px 20px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: #fff;
}

.qr-item-left {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.qr-item-left img {
    width: 120px;
    height: 120px;
}

.qr-item-right {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

.qr-item .qr-code-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.qr-item .qr-code-text {
    font-weight: 800;
    font-size: 1.3rem;
}

.qr-item .qr-label-text {
    font-size: 0.9rem;
    color: var(--gray-500);
    font-weight: 400;
}

.qr-item .qr-article-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
}

.qr-item .qr-article-nr {
    font-size: 0.8rem;
    color: var(--gray-400);
    font-family: monospace;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .admin-menu-toggle {
        display: block;
    }

    .admin-sidebar {
        position: fixed;
        top: 56px;
        left: -260px;
        width: 260px;
        height: calc(100vh - 56px);
        z-index: 99;
        transition: left 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    .admin-sidebar.open {
        left: 0;
    }

    .admin-main {
        padding: 16px;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .kpi-card {
        padding: 14px;
    }

    .kpi-value {
        font-size: 1.5rem;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-form {
        width: 100%;
    }

    .toolbar-search {
        min-width: 0;
        flex: 1;
    }

    .action-cell {
        flex-direction: column;
    }

}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .booking-type-buttons {
        flex-direction: column;
    }
}

/* ============================================
   AUFMASS-AUSWERTUNG
   ============================================ */
.aufmass-upload-zone {
    border: 3px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    margin-bottom: 16px;
}

.aufmass-upload-zone:hover,
.aufmass-upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.aufmass-upload-zone .upload-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.aufmass-upload-zone .upload-text strong {
    display: block;
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.aufmass-upload-zone .upload-text span {
    font-size: 0.9rem;
    color: var(--gray-500);
}

.aufmass-file-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    font-weight: 600;
    color: var(--gray-700);
}

.aufmass-actions {
    margin-bottom: 24px;
}

.aufmass-progress {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.spinner-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.progress-text {
    font-size: 0.9rem;
    color: var(--gray-600);
    text-align: center;
}

.aufmass-result {
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.result-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.result-header.result-success { color: var(--success); }
.result-header.result-warning { color: var(--warning); }
.result-header.result-error { color: var(--danger); }

.result-stats {
    color: var(--gray-600);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.8;
}

.result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.aufmass-preview {
    margin-bottom: 24px;
}

.aufmass-article-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    padding: 10px 16px;
    background: var(--primary-light);
    border-radius: var(--radius);
}

/* ============================================
   MATERIALBEDARF (Monatsübersicht)
   ============================================ */
.mb-month-block {
    background: #fff;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.mb-month-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s;
}

.mb-month-header:hover {
    background: var(--gray-50);
}

.mb-month-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mb-month-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.9rem;
}

.mb-stat {
    color: var(--gray-600);
}

.mb-pct {
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.mb-diff-green {
    color: #16a34a;
}

.mb-pct.mb-diff-green {
    background: #dcfce7;
    color: #16a34a;
}

.mb-diff-red {
    color: var(--danger, #d10911);
}

.mb-pct.mb-diff-red {
    background: #fde8e9;
    color: var(--danger, #d10911);
}

.mb-month-detail {
    border-top: 1px solid var(--gray-200);
    padding: 0 20px 16px;
}

/* ============================================
   ABGLEICH (Entnahme-Vergleich)
   ============================================ */
.abgleich-summary-row.clickable {
    cursor: pointer;
}

.abgleich-summary-row.clickable:hover {
    background: var(--gray-50);
}

.expand-icon {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.detail-cell {
    padding: 16px !important;
    background: var(--gray-50);
}

.detail-section {
    margin-bottom: 12px;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section > strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--gray-600);
}

.detail-table {
    font-size: 0.85rem;
}

.detail-table th,
.detail-table td {
    padding: 6px 10px !important;
}

.text-danger {
    color: var(--danger, #d10911);
}

.text-warning-color {
    color: var(--warning, #e67e22);
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    /* Auf der QR-Code-Seite wird ausschließlich der Etikettenbereich gedruckt.
       Die Regel ist bewusst auf .page-qrcodes begrenzt – vorher galt sie für
       jede Seite und hätte den Druck der Inventurliste leer gelassen. */
    .page-qrcodes body *,
    body.page-qrcodes * {
        visibility: hidden;
    }

    body.page-qrcodes .qr-print-area,
    body.page-qrcodes .qr-print-area * {
        visibility: visible;
    }

    body.page-qrcodes .qr-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .qr-grid {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .qr-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Nach je 6 Etiketten Seitenumbruch */
    .qr-item:nth-child(6n) {
        page-break-after: always;
    }

    .qr-item .qr-article-nr {
        font-size: 0.9rem;
    }
}

/* Dashboard Sections */
.dashboard-section {
    margin-bottom: 32px;
}
.dashboard-section .table-toolbar h2 {
    margin: 0;
    font-size: 1.15rem;
}

/* ============================================
   Lagerbestand – Status-Indikatoren
   ============================================ */
.kpi-card.kpi-danger {
    border-color: var(--danger);
    background: var(--danger-light);
}
.kpi-card.kpi-danger .kpi-value {
    color: var(--danger);
}

.lb-status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.lb-status-kritisch {
    background: var(--danger-light);
    color: var(--danger);
}
.lb-status-niedrig {
    background: var(--warning-light);
    color: #b45309;
}
.lb-status-ok {
    background: var(--success-light);
    color: var(--success);
}

.lb-row-kritisch {
    background: #fff5f5 !important;
}
.lb-row-kritisch:hover {
    background: #fee2e2 !important;
}
.lb-row-niedrig {
    background: #fffbeb !important;
}
.lb-row-niedrig:hover {
    background: #fef3c7 !important;
}

.lb-diff-negative {
    color: var(--danger);
    font-weight: 600;
}
.lb-diff-positive {
    color: var(--success);
    font-weight: 600;
}

/* ============================================
   PAGE INFO ("i" hinter der Überschrift)
   ============================================ */
.page-info {
    display: inline-block;
    position: relative;
    vertical-align: middle;
    margin-left: 8px;
    /* Unabhängig von der Schriftgröße der Überschrift */
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1;
    text-align: left;
    color: var(--gray-700);
}

.page-info-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid var(--gray-300);
    border-radius: 50%;
    background: #fff;
    color: var(--gray-500);
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

/* Standard-Dreieck von <summary> entfernen */
.page-info-toggle::-webkit-details-marker { display: none; }
.page-info-toggle::marker { content: ''; }

.page-info-toggle:hover,
.page-info[open] .page-info-toggle {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

.page-info-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 60;
    width: max-content;
    min-width: 260px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: normal;
    cursor: auto;
}

/* Für zentrierte Überschriften (Scan-Seiten) */
.page-info-center .page-info-panel {
    left: 50%;
    transform: translateX(-50%);
}

.page-info-section + .page-info-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.page-info-heading {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-400);
    margin-bottom: 4px;
}

.page-info-panel p {
    color: var(--gray-700);
}

.page-info-panel ul {
    margin: 0;
    padding-left: 18px;
    list-style: disc;
}

.page-info-panel li {
    color: var(--gray-700);
    margin-bottom: 3px;
}

.page-info-panel li:last-child { margin-bottom: 0; }

/* Technische Details (nur Hauptadmin) optisch abgesetzt */
.page-info-tech {
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-left: -6px;
    margin-right: -6px;
    padding: 10px 6px 8px;
}

.page-info-tech li {
    color: var(--gray-600);
    font-size: 0.8rem;
}

/* Mobil: als Sheet am unteren Bildschirmrand, damit nichts abgeschnitten wird */
@media (max-width: 600px) {
    .page-info-panel {
        position: fixed;
        top: auto;
        bottom: 16px;
        left: 16px;
        right: 16px;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: 60vh;
        overflow-y: auto;
        transform: none;
    }
    .page-info-center .page-info-panel {
        left: 16px;
        transform: none;
    }
}

/* ============================================
   BESTANDSSTATUS "NICHT EINGERICHTET"
   Artikel ohne Lagerplatz sind nicht kritisch,
   sondern schlicht noch nicht angelegt.
   ============================================ */
.lb-status-nicht_eingerichtet {
    background: var(--gray-100);
    color: var(--gray-600);
}

.lb-row-nicht_eingerichtet {
    background: var(--gray-50) !important;
}
.lb-row-nicht_eingerichtet:hover {
    background: var(--gray-100) !important;
}

.kpi-card.kpi-neutral {
    border-color: var(--gray-300);
}
.kpi-card.kpi-neutral .kpi-value {
    color: var(--gray-600);
}
a.kpi-card {
    text-decoration: none;
    color: inherit;
}
a.kpi-card:hover {
    box-shadow: var(--shadow-md);
}

.alert-info {
    background: var(--gray-50);
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
    font-weight: 400;
}
.alert-info a {
    font-weight: 500;
    white-space: nowrap;
}

.dashboard-hint {
    margin-bottom: 24px;
}

/* ============================================
   INVENTURLISTE
   ============================================ */
.print-header {
    display: none;
}

.inventur-count-col {
    width: 110px;
    min-width: 110px;
}

.inventur-table tbody .inventur-count-col {
    border-bottom: 1px solid var(--gray-400);
}

@media print {
    /* Allgemeines Druckbild für Listenseiten: Navigation und Bedienelemente
       verschwinden, der Inhalt bekommt die volle Seitenbreite. */
    .admin-header,
    .admin-sidebar,
    .no-print,
    .page-info {
        display: none !important;
    }

    .admin-wrapper,
    .admin-main,
    .admin-content {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
    }

    .admin-page-title {
        display: none;
    }

    .print-header {
        display: block;
        margin-bottom: 16px;
    }
    .print-header h2 {
        font-size: 1.3rem;
        margin-bottom: 4px;
    }
    .print-header p {
        font-size: 0.85rem;
        color: #000;
        margin-bottom: 4px;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .data-table {
        width: 100%;
        font-size: 0.8rem;
        border-collapse: collapse;
    }
    .data-table th,
    .data-table td {
        border: 1px solid #999;
        padding: 4px 6px;
    }
    .data-table thead {
        display: table-header-group; /* Kopfzeile auf jeder Seite wiederholen */
    }
    .data-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .inventur-count-col {
        width: 90px;
    }

    a[href]::after {
        content: none !important; /* keine URLs hinter Links ausdrucken */
    }
}

/* Stornierte Buchungen und Gegenbuchungen */
.booking-reversed td:not(.action-cell) {
    text-decoration: line-through;
    color: var(--gray-400);
}
.booking-storno {
    background: var(--gray-50);
}
.booking-storno td {
    font-style: italic;
}

/* ============================================
   ÄNDERUNGSPROTOKOLL
   ============================================ */
.audit-action {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}
.audit-action-create { background: var(--success-light); color: var(--success); }
.audit-action-update { background: var(--warning-light); color: #b45309; }
.audit-action-delete { background: var(--danger-light);  color: var(--danger); }

.audit-changes {
    margin: 0;
    padding-left: 16px;
    font-size: 0.85rem;
    list-style: disc;
}
.audit-changes li { margin-bottom: 2px; }
.audit-changes li:last-child { margin-bottom: 0; }

.audit-old {
    color: var(--gray-500);
    text-decoration: line-through;
}
.audit-new {
    color: var(--gray-800);
    font-weight: 500;
}

/* ============================================
   BENUTZERMENÜ IN DER ROTEN KOPFZEILE
   Klick auf den Namen öffnet Passwortwechsel und Abmelden.
   ============================================ */
.user-menu {
    position: relative;
    display: inline-block;
}

.user-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    white-space: nowrap;
}

.user-menu-toggle::-webkit-details-marker { display: none; }
.user-menu-toggle::marker { content: ''; }

/* Kleines Dreieck als Hinweis, dass sich etwas öffnen lässt */
.user-menu-toggle::after {
    content: '\25BE';
    font-size: 0.7rem;
    opacity: 0.8;
}

.user-menu-toggle:hover,
.user-menu[open] .user-menu-toggle {
    background: rgba(255, 255, 255, 0.18);
}

.user-menu-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 60;
    min-width: 190px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.user-menu-panel a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 0.95rem;
    text-decoration: none;
}

.user-menu-panel a:hover {
    background: var(--gray-50);
    color: var(--primary);
    text-decoration: none;
}
