* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1a1a2e; min-height: 100vh; }

.app-footer { text-align: center; color: #666; padding: 1.5rem 1rem; margin-top: 2rem; }

/* Nav */
nav { background: #1a1a2e; color: white; padding: 0 2rem; display: flex; align-items: center; justify-content: space-between; height: 60px; box-shadow: 0 2px 10px rgba(0,0,0,0.15); }
nav .brand { font-weight: 700; font-size: 1.2rem; }
nav .nav-links { display: flex; gap: 0.25rem; }
nav .nav-links a, nav .user-info a { color: white; text-decoration: none; padding: 0.5rem 0.9rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; transition: background 0.2s; }
nav .nav-links a:hover, nav .user-info a:hover { background: rgba(255,255,255,0.12); }
nav .nav-links a.active { background: rgba(255,255,255,0.18); }
nav .user-info { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: #aab; }
nav .user-info a.nav-shutdown { background: rgba(220, 38, 38, 0.18); color: #fecaca; }
nav .user-info a.nav-shutdown:hover { background: rgba(220, 38, 38, 0.35); color: #fff; }

/* Layout */
.container { max-width: 1200px; margin: 2rem auto; padding: 0 1.5rem; }
.card { background: white; border-radius: 12px; padding: 1.5rem 2rem; margin-bottom: 1.5rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); }
h1 { font-size: 1.7rem; margin-bottom: 0.5rem; color: #1a1a2e; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; color: #1a1a2e; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; gap: 0.5rem; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: white; border-radius: 12px; padding: 1.3rem; box-shadow: 0 1px 4px rgba(0,0,0,0.07); text-align: center; }
.stat-card .number { font-size: 2.4rem; font-weight: 700; color: #2563eb; }
.stat-card .label { color: #666; margin-top: 0.2rem; font-size: 0.88rem; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 0.8rem; text-align: left; border-bottom: 1px solid #eee; }
th { font-weight: 600; color: #666; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover { background: #f8f9fa; }
.empty-row td { text-align: center; color: #999; padding: 2rem; font-style: italic; }

/* Buttons */
.btn { display: inline-block; padding: 0.5rem 1.1rem; border-radius: 8px; border: none; cursor: pointer; font-size: 0.88rem; font-weight: 500; text-decoration: none; transition: all 0.2s; font-family: inherit; }
.btn-primary { background: #2563eb; color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; }
.btn-success { background: #22c55e; color: white; }
.btn-success:hover { background: #16a34a; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-weight: 500; color: #444; font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.55rem 0.8rem; border: 1.5px solid #ddd; border-radius: 8px;
    font-size: 0.92rem; transition: border-color 0.2s; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1.2rem; }

/* Alerts */
.alert { padding: 0.8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* Badges */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-azubi { background: #e0e7ff; color: #3730a3; }
.badge-typ-X { background: #dcfce7; color: #166534; }
.badge-typ-G { background: #dbeafe; color: #1e40af; }
.badge-typ-K { background: #ffedd5; color: #9a3412; }
.badge-typ-SU { background: #f3e8ff; color: #6b21a8; }
.badge-typ-BS { background: #e0f2fe; color: #075985; }

/* Mitarbeiter-Aktionen */
.ma-actions {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

/* Deaktivierte Mitarbeiter */
.ma-group-deaktiviert td {
    background: #f3f4f6;
    border-bottom: 2px solid #9ca3af;
    color: #6b7280;
}
.ma-deaktiviert td {
    color: #9ca3af;
    background: #f9fafb;
}
.ma-deaktiviert td strong {
    color: #9ca3af;
    font-weight: 500;
}

/* Drei-Punkte-Menü */
.ma-more-menu {
    position: relative;
}
.ma-more-btn {
    font-size: 1.2rem !important;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 0.3rem 0.6rem !important;
    line-height: 1;
}
.ma-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.3rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 180px;
    z-index: 50;
    overflow: hidden;
}
.ma-menu-dropdown.open {
    display: block;
}
.ma-menu-item {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.88rem;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.ma-menu-item:hover {
    background: #f3f4f6;
}
.ma-menu-item-warn {
    color: #d97706;
}
.ma-menu-item-warn:hover {
    background: #fffbeb;
}
.ma-menu-item-success {
    color: #16a34a;
}
.ma-menu-item-success:hover {
    background: #f0fdf4;
}
.ma-menu-item-danger {
    color: #dc2626;
}
.ma-menu-item-danger:hover {
    background: #fef2f2;
}

/* Mitarbeiter-Gruppen */
.ma-group-header td {
    background: #f0f4ff;
    border-bottom: 2px solid #818cf8;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    color: #312e81;
}
.ma-group-count {
    font-weight: 400;
    font-size: 0.8rem;
    color: #6366f1;
}

/* Rest-Urlaub */
.rest-ok { color: #16a34a; font-weight: 600; }
.rest-warn { color: #d97706; font-weight: 600; }
.rest-over { color: #dc2626; font-weight: 600; }

/* Mercedes-Stern */
.mercedes-star {
    width: 80px;
    height: 80px;
    object-fit: contain;
}
.login-logo {
    text-align: center;
    margin-bottom: 1rem;
}
.login-logo .mercedes-star {
    width: 90px;
    height: 90px;
}
.dashboard-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.2rem;
}
.dashboard-star {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

/* Login */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-card { background: white; padding: 2.5rem; border-radius: 16px; width: 100%; max-width: 400px; box-shadow: 0 25px 60px rgba(0,0,0,0.3); }
.login-card h1 { text-align: center; margin-bottom: 0.2rem; font-size: 1.5rem; }
.login-card .subtitle { text-align: center; color: #888; margin-bottom: 1.8rem; font-size: 0.9rem; }
.login-card .btn { width: 100%; padding: 0.75rem; font-size: 1rem; margin-top: 0.5rem; }

/* Confirm dialog */
.overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 100; display: flex; justify-content: center; align-items: center; }
.dialog { background: white; border-radius: 12px; padding: 2rem; max-width: 480px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.dialog h2 { margin-bottom: 0.7rem; }
.dialog p { color: #555; margin-bottom: 1.2rem; line-height: 1.5; }
.dialog .form-actions { margin-top: 0.5rem; }

/* Filter bar */
.filter-bar { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.filter-bar .form-group { margin-bottom: 0; min-width: 180px; }

/* Hide pages */
.page { display: none; }
.page.active { display: block; }

/* ─── Calendar Grid ─── */
.calendar-nav { display: flex; align-items: center; gap: 0.3rem; }

.calendar-grid-container { overflow-x: auto; }

.calendar-grid {
    display: grid;
    gap: 0;
    font-size: 0.75rem;
    min-width: 800px;
}

.calendar-grid .cal-header {
    background: #f3f4f6;
    font-weight: 600;
    text-align: center;
    padding: 0.4rem 0.2rem;
    border: 1px solid #e5e7eb;
    font-size: 0.7rem;
    color: #555;
}

.calendar-grid .cal-header.weekend {
    background: #e5e7eb;
    color: #999;
}

.calendar-grid .cal-header.holiday {
    background: #fde8e8;
    color: #b91c1c;
}

.calendar-grid .cal-cell.holiday {
    background: #fde8e8;
}

.calendar-grid .cal-name {
    background: #f9fafb;
    padding: 0.4rem 0.5rem;
    border: 1px solid #e5e7eb;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.78rem;
}

.calendar-grid .cal-cell {
    border: 1px solid #e5e7eb;
    padding: 0.2rem;
    min-height: 24px;
    text-align: center;
}

.calendar-grid .cal-cell.weekend {
    background: #f3f4f6;
}

.calendar-grid .cal-cell.vacation-genehmigt {
    background: #bbf7d0;
}

.calendar-grid .cal-cell.vacation-beantragt {
    background: #fef08a;
}

.calendar-grid .cal-cell.vacation-abgelehnt {
    background: #fecaca;
    text-decoration: line-through;
}

.calendar-grid .cal-cell.type-G {
    background: #dbeafe;
}

.calendar-grid .cal-cell.type-K {
    background: #ffedd5;
}

.calendar-grid .cal-cell.type-SU {
    background: #f3e8ff;
}

.calendar-grid .cal-cell.type-BS {
    background: #e0f2fe;
}

.calendar-grid .cal-cell.conflict {
    outline: 2px solid #ef4444;
    outline-offset: -2px;
    position: relative;
}

.calendar-grid .cal-cell.conflict::after {
    content: "!";
    position: absolute;
    top: -2px;
    right: 1px;
    font-size: 0.6rem;
    color: #ef4444;
    font-weight: 700;
}

.calendar-grid .cal-cell.today {
    border-bottom: 2px solid #2563eb;
}

.calendar-grid .cal-group-header {
    background: #f0f4ff;
    border-bottom: 2px solid #818cf8;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #312e81;
}
.cal-group-count {
    font-weight: 400;
    font-size: 0.72rem;
    color: #6366f1;
}

/* Gruppen-Reihenfolge UI */
.group-order-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    font-size: 0.8rem;
}
.group-order-list::before {
    content: 'Reihenfolge:';
    font-weight: 600;
    color: #555;
    margin-right: 0.3rem;
}
.group-order-item {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
}
.group-order-name {
    font-weight: 500;
    color: #374151;
}
.group-order-btns {
    display: flex;
    gap: 0.15rem;
}
.group-order-btns .btn {
    padding: 0.1rem 0.3rem;
    font-size: 0.7rem;
    line-height: 1;
    min-width: unset;
}

/* ─── Jahresuebersicht (12-Monats-Kalender) ─── */
.ju-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.ju-month {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    background: #fafafa;
}

.ju-month-title {
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    padding: 0.3rem 0;
    margin-bottom: 0.3rem;
    color: #374151;
}

.ju-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.ju-day-header {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 600;
    color: #9ca3af;
    padding: 0.15rem 0;
}

.ju-day {
    text-align: center;
    font-size: 0.7rem;
    padding: 0.2rem 0.1rem;
    border-radius: 3px;
    cursor: default;
    min-height: 20px;
    line-height: 1.3;
}

.ju-day.empty {
    background: transparent;
}

.ju-day.ju-weekend {
    background: #f3f4f6;
    color: #9ca3af;
}

.ju-day.ju-holiday {
    background: #fde8e8;
    color: #b91c1c;
    font-weight: 600;
}

.ju-day.ju-today {
    outline: 2px solid #2563eb;
    outline-offset: -1px;
    font-weight: 700;
}

/* Urlaubstypen in Jahresuebersicht (nutzt bestehende Klassen) */
.ju-day.vacation-genehmigt { background: #bbf7d0; color: #166534; font-weight: 600; }
.ju-day.vacation-beantragt { background: #fef08a; color: #854d0e; font-weight: 600; }
.ju-day.vacation-abgelehnt { background: #fecaca; color: #991b1b; text-decoration: line-through; }
.ju-day.type-G { background: #dbeafe; color: #1e40af; font-weight: 600; }
.ju-day.type-K { background: #ffedd5; color: #9a3412; font-weight: 600; }
.ju-day.type-SU { background: #f3e8ff; color: #6b21a8; font-weight: 600; }
.ju-day.type-BS { background: #e0f2fe; color: #075985; font-weight: 600; }

/* Legende */
.ju-legende {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    font-size: 0.8rem;
}

.ju-legende-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.ju-legende-box {
    display: inline-block;
    width: 22px;
    height: 18px;
    border-radius: 3px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 18px;
    border: 1px solid #e5e7eb;
}

.ju-legende-box.ju-holiday { background: #fde8e8; }
.ju-legende-box.ju-weekend { background: #f3f4f6; }
.ju-legende-box.ja-legende-today { background: #fff; border-bottom: 2px solid #2563eb; }
/* Farben für Legende-Boxen ohne Wrapper-Selektor */
.ju-legende-box.vacation-genehmigt { background: #bbf7d0; color: #166534; }
.ju-legende-box.vacation-beantragt { background: #fef08a; color: #854d0e; }
.ju-legende-box.vacation-abgelehnt { background: #fecaca; color: #991b1b; text-decoration: line-through; }
.ju-legende-box.type-G { background: #dbeafe; color: #1e40af; }
.ju-legende-box.type-K { background: #ffedd5; color: #9a3412; }
.ju-legende-box.type-SU { background: #f3e8ff; color: #6b21a8; }
.ju-legende-box.type-BS { background: #e0f2fe; color: #075985; }

/* ─── Jahresansicht (12 Monatsblöcke untereinander) ─── */
.ja-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.8rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.85rem;
}
.ja-group-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    user-select: none;
}
.ja-group-filter input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.ja-month-block {
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed #e2e8f0;
}
.ja-month-block:last-of-type {
    border-bottom: none;
    margin-bottom: 0.5rem;
}
.ja-month-title {
    margin: 0 0 0.5rem 0;
    padding: 0.4rem 0.8rem;
    background: linear-gradient(90deg, #1a1a2e 0%, #2d2d44 100%);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

/* Adjustment-Item im MA-Form */
.adjustment-item {
    font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    nav { padding: 0 0.8rem; }
    nav .nav-links a { padding: 0.4rem 0.5rem; font-size: 0.8rem; }
    nav .brand { font-size: 1rem; }
    .container { padding: 0 0.8rem; margin: 1rem auto; }
    .card { padding: 1rem 1.2rem; }
    nav .user-info span.user-detail { display: none; }
    table { font-size: 0.85rem; }
    th, td { padding: 0.5rem 0.4rem; }
    .calendar-nav { flex-wrap: wrap; }
    .ju-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .stats { grid-template-columns: 1fr; }
    .ju-grid { grid-template-columns: 1fr; }
}
