:root {
    --primary-color: #0056b3;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --active-color: #28a745;
    --inactive-color: #6c757d;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    font-size: 15px;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1, h2, h3 {
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-controls select, .header-controls button {
    padding: 8px 12px;
    border-radius: 5px;
    border: none;
    font-size: 14px;
    cursor: pointer;
}

.role-switch {
    background-color: #e9ecef;
    color: #333;
    font-weight: bold;
    border: 2px solid #fff !important;
}

.header-controls button.admin-btn {
    background-color: #ffc107;
    color: #333;
    font-weight: bold;
}

.header-controls button.admin-btn:hover {
    background-color: #e0a800;
}

.header-controls button.db-btn {
    background-color: #17a2b8;
    color: white;
    font-weight: bold;
}

.header-controls button.db-btn:hover {
    background-color: #138496;
}

/* Kachelsystem */
#main-dashboard, #dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.kachel {
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    position: relative;
}

.kachel:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.kachel h2 {
    font-size: 24px;
    margin-bottom: 10px;
}

.kachel p {
    margin: 5px 0;
    color: #666;
}

.kachel.aktiv { border-color: var(--active-color); }
.kachel.aktiv h2 { color: var(--active-color); }
.kachel.aktiv .status-badge { background-color: var(--active-color); color: white; padding: 3px 8px; border-radius: 12px; font-size: 12px; display: inline-block; margin-top: 10px; }

.kachel.inaktiv { border-color: var(--border-color); background-color: #f8f9fa; }
.kachel.inaktiv h2 { color: var(--inactive-color); }
.kachel.inaktiv .status-badge { background-color: var(--inactive-color); color: white; padding: 3px 8px; border-radius: 12px; font-size: 12px; display: inline-block; margin-top: 10px; }

/* Ansichten */
#bereich-dashboard, #detail-view, #admin-view, #database-view, #excel-view {
    display: none;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.back-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 20px;
    font-size: 14px;
}

.back-btn:hover { background-color: #5a6268; }

.excel-main-btn {
    background-color: #0056b3;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-bottom: 20px;
    margin-left: 10px;
    font-size: 15px;
    font-weight: bold;
}
.excel-main-btn:hover { background-color: #004494; }

.copy-btn { background-color: #6c757d; color: white; border: none; padding: 4px 10px; font-size: 11px; border-radius: 4px; cursor: pointer; font-weight: bold; transition: background-color 0.2s; }
.copy-btn:hover { background-color: #5a6268; }

.btn-release { background-color: #28a745; color: white; border: none; padding: 6px 12px; border-radius: 5px; cursor: pointer; font-weight: bold; margin-left: 15px; font-size: 14px; }
.btn-release:hover { background-color: #218838; }

.timeline-container { border-left: 4px solid var(--primary-color); padding-left: 20px; margin-bottom: 30px; position: relative; }
.timeline-container::before { content: ''; position: absolute; left: -12px; top: 0; width: 20px; height: 20px; background-color: var(--primary-color); border-radius: 50%; }

.current-production { background-color: #e9f2ff; border: 1px solid #b8d4fe; padding: 15px; border-radius: 5px; }
.current-production h3 { color: var(--primary-color); margin-bottom: 10px; }

.details-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.details-grid span { font-weight: bold; }

/* Tabellen allgemein */
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { border: 1px solid var(--border-color); padding: 12px; text-align: left; }
th { background-color: #f8f9fa; color: #333; font-weight: bold; font-size: 15px; }
tr:nth-child(even) { background-color: #fafafa; }
tr.holiday-row { background-color: #e9ecef !important; color: #adb5bd; }

th[draggable=true] { transition: background-color 0.2s; }
.drag-over-col { background-color: #e9f2ff !important; border-left: 3px dashed var(--primary-color) !important; }

/* Schichten & Personal */
.shift-mini-table { width: auto; margin: 0; border-collapse: collapse; text-align: center; background: transparent; font-size: 13px; }
.shift-mini-table th, .shift-mini-table td { border: 1px solid #6c757d; padding: 3px 10px; text-align: center; width: 35px; height: 24px; }
.shift-mini-table th.shift-active { background-color: #28a745; color: white; font-weight: bold; }
.shift-mini-table th.shift-inactive { background-color: #e9ecef; }
.shift-mini-table td.shift-active-val { background-color: #fff; color: #000; font-weight: bold; }
.shift-mini-table td.shift-inactive-val { background-color: #e9ecef; }

/* EXCEL DETAILED VIEW STYLES */
.excel-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 13px; 
    background: #fff; 
    border: 2px solid #000; 
    table-layout: fixed; 
}
.excel-table th, .excel-table td { 
    border: 1px solid #000; 
    padding: 6px; 
    text-align: center; 
    vertical-align: middle; 
    word-wrap: break-word; 
}
.excel-table th { font-size: 14px; color: #000; }
.excel-table .excel-header-kw { background-color: #d9e1f2; font-weight: bold; font-size: 15px; text-align: left; padding-left: 15px; border-bottom: 2px solid #000; }
.excel-table .excel-header-day { background-color: #e2efda; border-bottom: 2px solid #000; padding: 8px; }

/* Kompakte, schmale Breiten für die ersten zwei Info-Spalten */
.excel-kst { 
    background-color: #bdd7ee; 
    width: 85px; 
    text-align: center; 
    border-right: 2px solid #000 !important; 
}
.excel-kst strong { font-size: 18px; display: block; margin-bottom: 4px; color: #000; }
.excel-kst small { font-size: 13px; font-weight: normal; color: #333; display: block; line-height: 1.2; }

.excel-label { 
    background-color: #e9ecef; 
    width: 115px; 
    text-align: left !important; 
    font-weight: bold; 
    font-size: 11px; 
    padding-left: 8px !important;
    white-space: nowrap; 
}

/* FA und Tagesmenge: Schön mittig, nicht zu eng, nicht zu weit */
.excel-fa-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px; 
    width: 100%;
}
.fa-left { font-weight: bold; font-size: 13px; }
.fa-mid { color: #555; font-weight: bold; }
.fa-right { font-weight: normal; font-size: 13px; }

.excel-shift-box { display: flex; justify-content: space-between; border: 1px solid #000; background: #fff; width: 90px; margin: 0 auto; }
.excel-shift-box span { flex: 1; border-right: 1px solid #000; padding: 2px 0; font-size: 12px; }
.excel-shift-box span:last-child { border-right: none; }
.excel-shift-box span.active { font-weight: bold; background-color: #c6e0b4; } 
.excel-spacer td { border: none !important; border-top: 2px solid #000 !important; border-bottom: 2px solid #000 !important; height: 15px; background: #f4f7f6; }

/* Farbliche Hervorhebung für Zeilen in der Excel */
.excel-bg-umbau { background-color: #fd7e14 !important; color: #fff !important; }
.excel-bg-variant { background-color: #0dcaf0 !important; color: #000 !important; }
.excel-bg-fa { background-color: #ffc107 !important; color: #000 !important; }
.excel-bg-empty { background-color: #e2e6ea !important; } 

/* Farbliche Hervorhebung für die Auftragsmenge in Excel */
.excel-auftrag-badge {
    background-color: #f3e5f5; 
    color: #7b1fa2;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 13px;
    display: inline-block;
    border: 1px solid #d1c4e9;
}

/* Fußzeile Personal */
.excel-footer-header { background-color: #d9e1f2; font-weight: bold; }
.excel-footer-val { background-color: #fff; font-weight: bold; font-size: 14px; }

/* Badges Detailansicht */
.muster-badge { background-color: #dc3545; color: white; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; display: inline-block; margin-bottom: 5px; }
.reinigung-badge { background-color: #20c997; color: white; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; display: inline-block; margin-bottom: 5px; }
.umbau-badge { background-color: #fd7e14; color: white; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; display: inline-block; margin-bottom: 5px; }
.varianten-badge { background-color: #0dcaf0; color: #000; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; display: inline-block; margin-bottom: 5px; }
.fa-badge { background-color: #ffc107; color: #000; padding: 4px 8px; border-radius: 4px; font-weight: bold; font-size: 12px; display: inline-block; margin-bottom: 5px; }

/* Datenbank-Buttons */
.db-action-btn { padding: 6px 12px; margin: 2px; border: 1px solid #ccc; border-radius: 4px; background-color: #f8f9fa; cursor: pointer; font-size: 13px; font-weight: bold; box-shadow: 0 1px 2px rgba(0,0,0,0.1); transition: all 0.2s; }
.db-action-btn:hover { background-color: #e2e6ea; border-color: #adb5bd; }
.btn-edit { color: #0056b3; }
.btn-delete { color: #dc3545; }

/* Layouts & Grids */
.admin-list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 1px solid #ddd; margin-bottom: 5px; border-radius: 5px; background: #fdfdfd; transition: background-color 0.2s; }
.admin-list-item.drag-over { border: 2px dashed var(--primary-color); background: #e9f2ff; }
.drag-handle { cursor: grab; font-size: 24px; color: #999; }
.admin-actions button { padding: 6px 12px; margin-left: 5px; cursor: pointer; font-size: 13px; }
.admin-form-group { margin-bottom: 15px; }
.admin-form-group label { display: block; margin-bottom: 5px; font-weight: bold; font-size: 13px; line-height: 1.2; white-space: normal; word-wrap: break-word; }
.admin-form-group input[type="text"], .admin-form-group select { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; }
.admin-edit-area { border: 1px solid var(--primary-color); padding: 20px; border-radius: 8px; background: #f8faff; display: none; }

.week-edit-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; border-bottom: 1px solid #ccc; padding-bottom: 15px; align-items: end; }
.shift-checkboxes { display: flex; gap: 15px; align-items: center; margin-top: 5px; }
.save-btn { background-color: var(--active-color); color: white; border: none; padding: 12px 25px; font-size: 16px; border-radius: 5px; cursor: pointer; }
.db-form-container { background: #f8f9fa; padding: 20px; border: 1px solid #ddd; border-radius: 8px; margin-bottom: 20px; }

/* Modals / Popups */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 9999; }
.modal-box { background: var(--card-bg); padding: 25px 30px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); max-width: 400px; width: 90%; text-align: center; border-top: 5px solid var(--primary-color); }
.modal-box h3 { margin-bottom: 15px; color: var(--primary-color); font-size: 20px; }
.modal-box p { margin-bottom: 20px; font-size: 16px; color: #333; word-wrap: break-word; line-height: 1.4; }
.modal-box input { width: 100%; padding: 12px; margin-bottom: 20px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; text-align: center; font-size: 16px; }
.modal-buttons { display: flex; justify-content: center; gap: 15px; }
.modal-btn { padding: 10px 25px; border: none; border-radius: 5px; cursor: pointer; font-weight: bold; font-size: 15px; }
.modal-btn-ok { background-color: var(--primary-color); color: white; }
.modal-btn-ok:hover { background-color: #004494; }
.modal-btn-cancel { background-color: #6c757d; color: white; }
.modal-btn-cancel:hover { background-color: #5a6268; }

/* --- DRUCK-LAYOUT (A4 Querformat) --- */
@media print {
    body { padding: 0; background: #fff; font-size: 11px; }
    header, .header-controls, .back-btn, .excel-main-btn, .db-btn, .admin-btn { display: none !important; }
    #main-dashboard, #bereich-dashboard, #detail-view, #admin-view, #database-view { display: none !important; }
    
    #excel-view { display: block !important; padding: 0; box-shadow: none; border: none; }
    
    @page { size: A4 landscape; margin: 8mm; }
    
    .excel-table { border: 2px solid #000; width: 100%; table-layout: fixed; }
    .excel-table th, .excel-table td { padding: 4px; }
    
    tbody { page-break-inside: avoid; }
    tr { page-break-inside: avoid; }
    
    .excel-spacer td { height: 10px; }
}