/* ========================================
   HAIX Projects - Modern Template
   ======================================== */

:root {
    --primary-color: #1a365d;
    --primary-dark: #0f2544;
    --accent-color: #10b981;
    --accent-hover: #059669;
    --sidebar-bg: #1a365d;
    --sidebar-width: 260px;
    --content-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --hover-bg: #f1f5f9;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--content-bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   Layout
   ======================================== */

.app-container {
    display: flex;
    min-height: 100vh;
    overflow-x: clip;
}

/* ========================================
   Sidebar
   ======================================== */

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: white;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    width: 80px;
    height: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 24px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    padding: 0 24px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-left: 3px solid var(--accent-color);
    padding-left: 21px;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    opacity: 0.8;
}

.nav-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* ========================================
   Main Content
   ======================================== */

.main-content {
    flex: 1;
    /* Wichtig: Flex-Kinder haben min-width: auto und wachsen sonst auf die
       Breite ihres breitesten Inhalts (z. B. der Projekttabelle). Dann scrollt
       die ganze Seite statt nur der Tabellen-Container. */
    min-width: 0;
    max-width: 100%;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: none;
}

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

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

.btn-success {
    background-color: var(--accent-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--accent-hover);
}

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

.btn-outline:hover {
    background: var(--content-bg);
    border-color: var(--text-light);
    color: var(--text-primary);
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-icon {
    padding: 8px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--content-bg);
    color: var(--primary-color);
}

.btn-icon.danger:hover {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* ========================================
   Cards
   ======================================== */

.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* ========================================
   Status Badges
   ======================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-lead {
    background: #e0e7ff;
    color: #3730a3;
}

.status-rfi {
    background: #dbeafe;
    color: #1e40af;
}

.status-rfp {
    background: #cffafe;
    color: #0e7490;
}

.status-angebot,
.status-angebotabgegeben {
    background: #fef3c7;
    color: #92400e;
}

.status-zusage {
    background: #d1fae5;
    color: #065f46;
}

.status-bestellung,
.status-bestellungerhalten {
    background: #bbf7d0;
    color: #166534;
}

.status-abgeschlossen,
.status-auftragabgeschlossen {
    background: #f0fdf4;
    color: #15803d;
}

.status-verloren {
    background: #fee2e2;
    color: #991b1b;
}

.status-abgesagt,
.status-projektwurdeabgesagt {
    background: #f1f5f9;
    color: #475569;
}

/* ========================================
   Tables
   ======================================== */

.table-container {
    overflow-x: auto;
}

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

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--content-bg);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    user-select: none;
}

tbody td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--content-bg);
}

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

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

/* ========================================
   Sortable Table Headers
   ======================================== */

th.sortable {
    cursor: pointer;
    transition: background 0.15s ease;
}

th.sortable:hover {
    background: #eef2f6;
}

.sort-icons {
    display: inline-flex;
    flex-direction: column;
    margin-left: 6px;
    vertical-align: middle;
    gap: 2px;
}

.sort-icons svg {
    opacity: 0.3;
    transition: opacity 0.15s ease;
}

th.sortable.sort-asc .sort-icons .sort-asc,
th.sortable.sort-desc .sort-icons .sort-desc {
    opacity: 1;
    color: var(--primary-color);
}

th.sortable:hover .sort-icons svg {
    opacity: 0.5;
}

/* ========================================
   Probability Bar
   ======================================== */

.probability-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.probability-bar {
    width: 60px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.probability-bar-fill {
    height: 100%;
    background: var(--accent-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.probability-text {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 35px;
}

/* ========================================
   Search Input
   ======================================== */

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper svg {
    position: absolute;
    left: 14px;
    color: var(--text-light);
    pointer-events: none;
}

.search-input {
    padding-left: 42px !important;
    min-width: 250px;
}

/* ========================================
   Filter Bar & Checkbox Dropdown
   ======================================== */

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.filter-bar .form-control {
    width: auto;
    min-width: 180px;
}

/* Custom Checkbox Dropdown */
.checkbox-dropdown {
    position: relative;
    display: inline-block;
}

.checkbox-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    min-width: 220px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkbox-dropdown-toggle:hover {
    border-color: var(--text-light);
}

.checkbox-dropdown-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.checkbox-dropdown.open .checkbox-dropdown-toggle {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.checkbox-dropdown.open .checkbox-dropdown-toggle svg {
    transform: rotate(180deg);
}

.checkbox-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.checkbox-dropdown.open .checkbox-dropdown-menu {
    display: block;
}

.checkbox-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.checkbox-dropdown-item:hover {
    background: var(--content-bg);
}

.checkbox-dropdown-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-dropdown-item label {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
}

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

/* ========================================
   Forms
   ======================================== */

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

.form-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.form-group {
    margin-bottom: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-label.required::after {
    content: ' *';
    color: var(--danger-color);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(26, 54, 93, 0.1);
}

.form-control::placeholder {
    color: var(--text-light);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Summary Bar
   ======================================== */

.summary-bar {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.summary-bar .count {
    color: var(--text-secondary);
    font-size: 14px;
}

.summary-bar .totals {
    display: flex;
    gap: 32px;
}

.summary-bar .total-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-bar .total-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.summary-bar .total-value {
    font-weight: 600;
    font-size: 14px;
}

.summary-bar .total-value.highlight {
    color: var(--accent-color);
}

/* ========================================
   Dashboard Stats
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stats-grid.cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* ========================================
   Charts
   ======================================== */

.chart-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

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

.chart-title {
    font-size: 16px;
    font-weight: 600;
}

#chart {
    max-height: 300px;
}

/* ========================================
   Dashboard Grid
   ======================================== */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* ========================================
   Article/Product Box
   ======================================== */

.article-box {
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.article-box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.article-box-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.remove-article-btn {
    color: var(--danger-color);
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
}

.remove-article-btn:hover {
    opacity: 0.7;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ========================================
   Project Value Display
   ======================================== */

.project-value-box {
    background: var(--content-bg);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-value-item .label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.project-value-item .value {
    font-size: 24px;
    font-weight: 700;
}

.project-value-item .value.highlight {
    color: var(--accent-color);
}

/* ========================================
   Dashboard Specifics
   ======================================== */

.full-width-on-grid {
    grid-column: span 2;
}

/* Chart Containers müssen sich anpassen */
.chart-container {
    min-width: 0; /* Wichtig für Grid-Items */
}

.chart-container canvas {
    width: 100% !important;
    height: auto !important;
}

/* Dashboard Search */
.search-wrapper {
    position: relative;
    min-width: 200px;
}

.dashboard-search {
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    width: 300px;
    max-width: 100%;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* ========================================
   Mobile Navigation Toggle
   ======================================== */

.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1000;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mobile-menu-toggle:hover {
    background: var(--primary-dark);
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
    display: block;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ========================================
   Table Optimizations
   ======================================== */

.table-container {
    -webkit-overflow-scrolling: touch;
}

/* Tabellen in scrollbaren Containern nicht unter eine lesbare Breite quetschen */
.table-container table {
    min-width: 640px;
}
.table-container table.table-wide {
    min-width: 1000px;
}
/* Projektübersicht: 12 Spalten. Kompakte, feste Spaltenbreiten, damit die
   Tabelle ab ca. 1120px Inhaltsbreite ohne horizontales Scrollen passt.
   Der Projektname ist die flexible Spalte und wird bei Platzmangel gekürzt. */
table.projects-table {
    table-layout: auto;
    min-width: 1080px;
}
.projects-table thead th {
    white-space: normal;      /* zweizeilige Spaltentitel erlaubt */
    line-height: 1.25;
    padding: 8px 8px;
    font-size: 11px;
    vertical-align: bottom;
}
.projects-table tbody td {
    padding: 10px 8px;
    font-size: 13px;
    white-space: nowrap;
}
.projects-table thead th:nth-child(1),  /* Hinzugefügt */
.projects-table thead th:nth-child(2) { /* Zuletzt geändert */
    width: 78px;
}
.projects-table thead th:nth-child(3) { /* Projektnr. */
    width: 64px;
}
.projects-table thead th:nth-child(4) { /* Projektname (flexibel) */
    width: auto;
    min-width: 150px;
}
.projects-table thead th:nth-child(5) { /* Salesmanager */
    width: 116px;
}
.projects-table thead th:nth-child(6),  /* Vergabedatum */
.projects-table thead th:nth-child(7) { /* Lieferdatum */
    width: 88px;
}
.projects-table thead th:nth-child(8) { /* Status */
    width: 116px;
}
.projects-table thead th:nth-child(9) { /* Wahrscheinlichkeit */
    width: 104px;
}
.projects-table thead th:nth-child(10), /* Pipeline */
.projects-table thead th:nth-child(11) { /* Opportunity */
    width: 96px;
    text-align: right;
}
.projects-table thead th:nth-child(12) { /* Aktionen */
    width: 44px;
}
/* Lange Texte abschneiden, voller Text per title-Attribut */
.projects-table tbody td:nth-child(4),
.projects-table tbody td:nth-child(5) {
    max-width: 0;             /* erzwingt Ellipsis bei table-layout: auto */
    overflow: hidden;
    text-overflow: ellipsis;
}
.projects-table tbody td:nth-child(4) { min-width: 150px; }
.projects-table tbody td:nth-child(5) { min-width: 116px; }
.projects-table tbody td:nth-child(4) a { display: block; overflow: hidden; text-overflow: ellipsis; }
.projects-table .status-badge {
    white-space: normal;
    line-height: 1.3;
    text-align: center;
}

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

/* Bis 1600px: schmalere Sidebar, damit die Projekttabelle ohne Scrollen passt */
@media (max-width: 1600px) {
    :root {
        --sidebar-width: 200px;
    }
    .sidebar-header,
    .nav-section-title,
    .nav-item,
    .sidebar-footer {
        padding-left: 16px;
        padding-right: 16px;
    }
    .nav-item.active {
        padding-left: 13px;
    }
    .main-content {
        padding: 24px;
    }
}

@media (max-width: 1200px) {
    .stats-grid,
    .stats-grid.cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 24px;
    }
    
    /* Tabelle kompakter machen */
    tbody td {
        padding: 12px;
        font-size: 13px;
    }
    
    thead th {
        padding: 10px 12px;
        font-size: 11px;
    }
}

@media (max-width: 992px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 72px 20px 20px 20px; /* Extra Platz oben für mobile Menü */
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-grid.cols-3,
    .form-grid.cols-4 {
        grid-template-columns: 1fr;
    }
    
    .summary-bar {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .summary-bar .totals {
        flex-direction: column;
        gap: 12px;
    }
    
    .page-title {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .stats-grid,
    .stats-grid.cols-3 {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }
    
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }
    
    .filter-bar {
        flex-direction: column;
    }
    
    .filter-bar .form-group {
        width: 100%;
        min-width: auto !important;
    }
    
    .filter-bar .form-control,
    .checkbox-dropdown,
    .search-input-wrapper {
        width: 100%;
    }
    
    .checkbox-dropdown-toggle,
    .search-input {
        width: 100%;
    }
    
    .card-body {
        padding: 16px;
    }
    
    /* Noch kompaktere Tabelle */
    tbody td {
        padding: 10px 8px;
        font-size: 12px;
    }
    
    thead th {
        padding: 8px;
        font-size: 10px;
    }
    
    /* Buttons kompakt, aber mit ausreichend großer Touch-Fläche */
    .btn-icon {
        padding: 6px;
        min-width: 36px;
        min-height: 36px;
    }
    
    .btn-icon svg {
        width: 16px;
        height: 16px;
    }
    
    /* Dashboard-spezifisch */
    .dashboard-search {
        width: 100%;
    }
    
    .search-wrapper {
        width: 100%;
        min-width: auto;
    }
    
    .full-width-on-grid {
        grid-column: span 1;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 64px 12px 12px 12px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    .page-subtitle {
        font-size: 13px;
    }
    
    /* Minimale Tabellendarstellung */
    table.projects-table {
        min-width: 960px;
    }
    
    .summary-bar {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .summary-bar .total-label {
        font-size: 12px;
    }
    
    .summary-bar .total-value {
        font-size: 13px;
    }
}
/* Range Slider */
input[type="range"].form-control {
    padding: 0;
    height: 38px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
}

.prob-value {
    font-weight: 600;
    color: var(--accent-color);
}

/* ========================================
   Projekt-Modal (index.php + dashboard.php)
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: white;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease-out;
}
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}
.project-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.project-info-item {
    padding: 12px;
    background: var(--content-bg);
    border-radius: 4px;
}
.project-info-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}
.project-info-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}
.project-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.summary-card {
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a3a5d 100%);
    color: white;
    border-radius: 6px;
}
.summary-label {
    font-size: 12px;
    opacity: 0.9;
    margin-bottom: 4px;
}
.summary-value {
    font-size: 24px;
    font-weight: 700;
}
.spinner {
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.modal-actions {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--content-bg);
}

@media (max-width: 768px) {
    .project-info-grid,
    .project-summary {
        grid-template-columns: 1fr;
    }
    .modal-content {
        width: 95%;
        max-height: 95vh;
        max-height: 95dvh;
    }
    .modal-body {
        padding: 16px;
    }
}

/* ========================================
   Utilities (ersetzen die bisherigen Inline-Styles)
   ======================================== */
.text-muted   { color: var(--text-secondary); }
.text-dark    { color: var(--text-primary); }
.text-accent  { color: var(--accent-color); }
.text-xxs     { font-size: 11px; }
.text-xs      { font-size: 12px; }
.text-sm      { font-size: 13px; }
.text-md      { font-size: 14px; }
.text-lg      { font-size: 16px; }
.fw-500       { font-weight: 500; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.text-center  { text-align: center; }
.nowrap       { white-space: nowrap; }
.inline       { display: inline; }
.block        { display: block; }
.relative     { position: relative; }
.overflow-visible { overflow: visible; }
.m-0   { margin: 0; }
.mb-0  { margin-bottom: 0; }
.mb-4  { margin-bottom: 4px; }
.mb-6  { margin-bottom: 6px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.ml-6  { margin-left: 6px; }
.ml-8  { margin-left: 8px; }
.p-16  { padding: 16px; }
.flush { padding: 0; }
.w-auto    { width: auto; }
.min-w-200 { min-width: 200px; }
.h-38      { height: 38px; }
.col-50    { width: 50px; }
.col-60    { width: 60px; }
.col-100   { width: 100px; }
.cell-clamp { max-width: 300px; }
.flex          { display: flex; }
.flex-wrap     { flex-wrap: wrap; }
.flex-1        { flex: 1; }
.items-center  { align-items: center; }
.items-end     { align-items: flex-end; }
.items-baseline{ align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-end   { justify-content: flex-end; }
.gap-4  { gap: 4px; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.bg-muted      { background: var(--content-bg); }
.bordered      { border: 1px solid var(--border-color); }
.border-top    { border-top: 1px solid var(--border-color); }
.border-bottom { border-bottom: 1px solid var(--border-color); }

/* Links im Fließtext / in Tabellen */
.text-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.text-link:hover { text-decoration: underline; }

/* Icons in Textzeilen */
.icon-inline { vertical-align: -3px; margin-right: 6px; }

/* ========================================
   Gemeinsame Komponenten
   ======================================== */

/* Abschnittsüberschriften innerhalb von Karten und Modals */
.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}
.form-section-title {
    margin: 32px 0 20px;
    font-size: 16px;
    color: var(--text-secondary);
}
.form-section-title.first { margin-top: 0; }

/* Kompakte Labels in Filterleisten */
.form-label-sm {
    font-size: 12px;
    margin-bottom: 4px;
}

/* Filter-Gruppen in der Filterleiste */
.filter-group {
    margin-bottom: 0;
    min-width: 150px;
}
.filter-group.w-120 { min-width: 120px; }
.filter-group.w-160 { min-width: 160px; }
.filter-group.w-180 { min-width: 180px; }
.filter-group.grow  { flex: 1; min-width: 200px; }
.filter-group.self-end { align-self: flex-end; }
.filter-group.dropdown-anchor { position: relative; z-index: 100; }

/* Leere Zustände */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}
.empty-state-sm { padding: 20px; }
.empty-state-icon { margin-bottom: 16px; opacity: 0.5; }

/* Dezente Infobox (Kommentare etc.) */
.subtle-box {
    background: var(--content-bg);
    padding: 12px;
    border-radius: 4px;
}

/* Kompakte Detail-Tabellen (Artikel im Modal, Auswertungen) */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.detail-table thead th {
    padding: 10px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    background: var(--content-bg);
    border-bottom: 1px solid var(--border-color);
}
.detail-table tbody td {
    padding: 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
}
.detail-table tfoot td {
    padding: 10px;
    font-weight: 600;
    background: var(--content-bg);
}
.table-total-row {
    font-weight: 700;
    background: var(--content-bg);
}

/* Pagination unter Listen */
.pagination-bar {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    background: var(--content-bg);
    font-size: 13px;
    color: var(--text-secondary);
}
.pagination-controls {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    min-height: 32px;
}
.pagination-btn:hover:not(:disabled) { background: var(--hover-bg); }
.pagination-btn:disabled { opacity: 0.5; cursor: default; }
.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Änderungsverlauf (Dashboard + Projekt-Historie) */
.change-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}
.change-item:last-child { border-bottom: none; }
.change-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.change-line {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 2px 0;
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}
.change-field {
    font-weight: 500;
    color: var(--text-primary);
    min-width: fit-content;
}
.change-old {
    text-decoration: line-through;
    color: var(--danger-color);
}
.change-new {
    color: var(--success-color);
    font-weight: 500;
}

/* Sortierbare Tabellenköpfe (Dashboard) */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}
.sortable:hover { background: var(--hover-bg); }
.sort-icon {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 4px;
}
.sortable.sort-asc .sort-icon::after  { content: ' ↑'; color: var(--primary-color); }
.sortable.sort-desc .sort-icon::after { content: ' ↓'; color: var(--primary-color); }
.th-sort-link {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Modal-Varianten */
.modal-content.modal-md { max-width: 1000px; }
.summary-card-indigo { background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); }
.summary-card-green  { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.chart-canvas { max-height: 280px; }

/* Kleine Buttons */
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Artikel-Box: Treffer aus dem Produktfeed */
.article-box.matched { background-color: #d1fae5; }

/* Sidebar-Footer */
.sidebar-footer .user-name {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    display: block;
    margin-bottom: 8px;
}
.error-logo { width: 80px; margin-bottom: 24px; }

/* ========================================
   Plausibilitätsprüfung: Schweregrade
   ======================================== */
.severity-critical-text { color: #dc2626; }
.severity-warning-text  { color: #f59e0b; }
.severity-info-text     { color: #3b82f6; }

a.stat-card {
    display: block;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s;
}
a.stat-card:hover { box-shadow: 0 0 0 2px var(--border-color); }
a.stat-card.active { box-shadow: 0 0 0 2px var(--primary-color); }
.stat-card.severity-critical { border-left: 4px solid #dc2626; }
.stat-card.severity-warning  { border-left: 4px solid #f59e0b; }
.stat-card.severity-critical.active { background: rgba(220, 38, 38, 0.05); }
.stat-card.severity-warning.active  { background: rgba(245, 158, 11, 0.05); }

.severity-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.severity-badge.severity-critical { background: #fef2f2; color: #dc2626; }
.severity-badge.severity-warning  { background: #fffbeb; color: #f59e0b; }
.severity-badge.severity-info     { background: #eff6ff; color: #3b82f6; }

/* Regel-Chips in der Übersicht nach Problemtyp */
.rule-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    text-decoration: none;
    background: var(--content-bg);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}
.rule-chip:hover { border-color: var(--text-light); }
.rule-chip-name { font-size: 13px; color: var(--text-primary); }
.rule-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--border-color);
    color: var(--text-secondary);
}
.rule-chip.has-count.severity-critical .rule-chip-count { background: #dc2626; color: #fff; }
.rule-chip.has-count.severity-warning  .rule-chip-count { background: #f59e0b; color: #fff; }
.rule-chip.has-count.severity-info     .rule-chip-count { background: #3b82f6; color: #fff; }
.rule-chip.active.severity-critical { background: #fef2f2; border-color: #dc2626; }
.rule-chip.active.severity-warning  { background: #fffbeb; border-color: #f59e0b; }
.rule-chip.active.severity-info     { background: #eff6ff; border-color: #3b82f6; }
.rule-chip.rule-chip-reset {
    gap: 6px;
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    font-size: 13px;
}

/* ========================================
   Benutzerverwaltung
   ======================================== */
.users-table { min-width: 720px; }
.users-table tbody tr.row-inactive td { color: var(--text-light); }
.users-table tbody tr.row-inactive .status-badge { opacity: 0.85; }
.btn-icon:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-icon:disabled:hover { background: transparent; color: inherit; }
.checkbox-inline {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    padding-top: 10px;
    cursor: pointer;
}
.checkbox-inline input { margin-top: 3px; }
.fw-normal { font-weight: 400; }
.mt-4 { margin-top: 4px; }

/* ========================================
   Dashboard: Drilldown aus den Diagrammen
   ======================================== */
.chart-header {
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}
.chart-hint {
    font-size: 12px;
    color: var(--text-light);
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 12px;
    border-radius: 999px;
    background: var(--primary-color);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
}
.filter-chip-clear {
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.filter-chip-clear:hover { background: rgba(255, 255, 255, 0.35); }
