:root {
    --primary-color: #d32f2f;
    /* Red to match logo */
    --primary-dark: #b71c1c;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-bg: #fff5f5;
    /* Light red tint */
    --dark-text: #212529;
    --white: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --font-family: 'Cairo', 'Segoe UI', sans-serif;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: var(--dark-text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Links */
a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

/* Navbar */
.main-nav {
    background: linear-gradient(90deg, #d32f2f, #b71c1c);
    color: white;
    padding: 0.5rem 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.2rem;
}

.nav-logo {
    height: 40px;
    background: white;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.nav-item.active {
    background: var(--white);
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-logout {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-logout:hover {
    background: rgba(0, 0, 0, 0.4);
}

/* Mobile Toggle */
.menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Base Responsive */
@media (max-width: 992px) {
    .menu-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        padding: 10px 0;
        gap: 5px;
        background: rgba(183, 28, 28, 0.98);
        /* Solid secondary red for menu */
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        padding: 20px;
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        z-index: 1000;
        animation: slideDown 0.3s ease-out;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .nav-links.show {
        display: flex;
    }

    .nav-item {
        width: 100%;
        border-radius: 8px;
        padding: 12px 20px;
    }

    .nav-actions {
        width: 100%;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 10px;
    }
}

@media (max-width: 600px) {
    .main-content {
        padding: 1rem;
    }

    .card {
        padding: 15px;
        border-radius: 12px;
    }

    .nav-brand .brand-text {
        font-size: 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .menu-item {
        padding: 20px;
    }

    .menu-item span.icon {
        font-size: 2.5rem;
    }
}

/* Cards */
.card {
    background: var(--glass-bg);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-title {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid #eef2f7;
    padding-bottom: 10px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Forms */
input,
select,
textarea {
    width: 100%;
    padding: 6px 10px;
    margin: 4px 0;
    border: 1px solid #ced4da;
    border-radius: 8px;
    box-sizing: border-box;
    font-family: var(--font-family);
    font-size: 0.85rem;
    transition: 0.2s;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

/* Buttons */
button,
.btn {
    cursor: pointer;
    font-family: var(--font-family);
    transition: all 0.2s;
    border: none;
    outline: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--dark-text);
    color: white;
}

/* Keep danger buttons distinct but neutral or use specific red */
.btn-danger:hover {
    opacity: 0.9;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead th {
    background: var(--primary-color);
    color: white;
    padding: 6px 8px;
    text-align: right;
}

tbody td {
    padding: 4px 6px;
    border-bottom: 1px solid #f2f2f2;
    color: #333;
}

tbody tr:hover {
    background-color: #fff8f8;
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 20px;
    color: #6c757d;
    font-size: 0.9rem;
    margin-top: auto;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-danger {
    color: var(--danger-color);
}

.text-success {
    color: var(--success-color);
}

.text-primary {
    color: var(--primary-color);
}

.w-100 {
    width: 100%;
}

.m-0 {
    margin: 0;
}

.mt-2 {
    margin-top: 10px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    padding: 20px 0;
}

.menu-item {
    background: white;
    padding: 30px;
    border-radius: 16px;
    color: var(--dark-text);
    text-decoration: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    text-align: center;
    border: 2px solid transparent;
}

.menu-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(211, 47, 47, 0.1);
    border-color: var(--primary-color);
}

.menu-item span.icon {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
}

/* Login Page */
.login-body {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.login-card img {
    width: 120px;
    margin-bottom: 20px;
}

/* Advance Search */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input {
    width: 100% !important;
    padding: 12px 45px 12px 15px !important;
    border-radius: 10px;
    border: 2px solid var(--primary-color);
    outline: none;
    font-size: 15px;
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 18px;
    color: var(--primary-color);
    font-size: 18px;
}

.emp-adv-card {
    background: #fff;
    border: 1px solid #ddd;
    border-top: 3px solid var(--primary-color);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
}

.emp-adv-header {
    padding: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.emp-name {
    font-weight: bold;
    color: var(--primary-color);
}

.emp-total {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.adv-list {
    padding: 15px;
    display: none;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    flex-direction: column;
    gap: 8px;
}

.active-card .adv-list {
    display: flex;
}

.adv-row {
    background: #fff;
    border: 1px solid #eee;
    padding: 10px 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-amt {
    width: 80px !important;
    padding: 5px !important;
    margin: 0 !important;
    text-align: center;
    font-weight: bold;
}

/* Logs */
.log-list {
    padding: 15px;
    display: none;
    background: #fafafa;
    border-top: 1px solid #eee;
    flex-wrap: wrap;
    gap: 8px;
}

.active-card .log-list {
    display: flex;
}

.log-item {
    background: #fff;
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    border: 1px solid #ffcdd2;
    display: inline-block;
}

/* --- GLOBAL REPORT STYLES (Used in display, overwritten in print) --- */
.page-container {
    width: 210mm;
    min-height: 297mm;
    /* Standard A4 */
    padding: 10mm;
    margin: 20px auto;
    background: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    page-break-after: always;
}

.report-header {
    text-align: center;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 5px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-header h1 {
    color: var(--primary-color);
    margin: 0;
    font-size: 24px;
    font-weight: 900;
}

.logo-img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-left: 15px;
}

.header-info {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    border: 1.5px solid #000;
    padding: 8px;
    margin-bottom: 10px;
    font-size: 11px;
    background: #fdfdfd;
    gap: 5px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}

.report-table th,
.report-table td {
    border: 1px solid #000;
    padding: 4px;
    text-align: center;
    font-size: 11px;
}

.report-table th {
    background: #f2f2f2;
    font-weight: bold;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: auto;
    padding-top: 15px;
}

.summary-box-item {
    border: 1.5px solid #000;
    padding: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
}

.full-width-item {
    grid-column: span 3;
    background: #000 !important;
    color: #fff !important;
    font-size: 16px;
    padding: 8px;
    text-align: center;
    margin-top: 5px;
    font-weight: bold;
}

.signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-bottom: 20px;
}

.sig-box {
    width: 40%;
    text-align: center;
    font-size: 12px;
    font-weight: bold;
    border-top: 2px solid #000;
    padding-top: 5px;
}

.admin-name {
    display: block;
    margin-top: 5px;
    color: var(--primary-color);
    font-size: 14px;
}

/* --- PRINT OVERRIDES (Aggressive Compaction) --- */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    .main-nav,
    .no-print,
    .btn,
    .search-container,
    footer {
        display: none !important;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        width: 100%;
    }

    .page-container {
        width: 100% !important;
        max-width: 210mm;
        margin: 0 auto !important;
        padding: 2mm !important;
        border: none !important;
        box-shadow: none !important;
        page-break-inside: avoid !important;
        min-height: auto !important;
        height: auto !important;
        display: block !important;
        zoom: 0.95;
        /* Increased from 0.90 */
    }

    .report-table th,
    .report-table td {
        font-size: 11px !important;
        /* Increased from 9px */
        font-weight: bold !important;
        /* Added for visibility */
        padding: 1px 2px !important;
        line-height: 1.2 !important;
        border: 1px solid #000 !important;
    }

    .report-table th {
        background-color: #d0d0d0 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .header-info {
        font-size: 11px !important;
        padding: 2px !important;
        margin-bottom: 5px !important;
    }

    .report-header {
        padding-bottom: 2px !important;
        margin-bottom: 5px !important;
        border-bottom-width: 2px !important;
    }

    .report-header h1 {
        font-size: 18px !important;
        margin-bottom: 2px !important;
    }

    .logo-img {
        width: 45px !important;
        height: 45px !important;
    }

    .summary-grid {
        margin-top: 5px !important;
        gap: 2px !important;
    }

    .summary-box-item {
        font-size: 10px !important;
        padding: 2px !important;
    }

    .full-width-item {
        font-size: 14px !important;
        padding: 4px !important;
        margin-top: 2px !important;
    }

    .signatures {
        margin-top: 15px !important;
        padding-bottom: 0 !important;
    }

    .sig-box {
        font-size: 11px !important;
        padding-top: 2px !important;
    }
}

/* --- Employee Interactive Cards (Manager View) --- */
.employee-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.employee-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.employee-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.employee-card.inactive {
    opacity: 0.7;
    filter: grayscale(0.5);
    border-right: 5px solid var(--danger-color);
}

.employee-card.active {
    border-right: 5px solid var(--success-color);
}

.card-header-main {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.card-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark-text);
}

.card-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    gap: 10px;
}

.card-toggle-icon {
    font-size: 1.2rem;
    color: var(--primary-color);
    transition: transform 0.3s;
}

.employee-card.open .card-toggle-icon {
    transform: rotate(180deg);
}

.card-details {
    display: none;
    padding: 20px;
    background: #fcfcfc;
    border-top: 1px solid #f0f0f0;
}

.employee-card.open .card-details {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.detail-item {
    font-size: 0.9rem;
}

.detail-label {
    display: block;
    color: #888;
    margin-bottom: 4px;
}

.detail-value {
    font-weight: 600;
}

.card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.card-actions .btn {
    flex: 1;
    min-width: 120px;
}