* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

/* =============================================
   NAVIGATION
   ============================================= */
.navbar {
    background: #1a237e;
    color: white;
    padding: 0.5rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.nav-brand a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
}

.nav-brand img {
    height: 40px;
    width: auto;
    margin-right: 12px;
}

.nav-brand span {
    font-size: 1.2rem;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.nav-user {
    color: #90caf9;
    padding: 0 10px;
    font-size: 0.9rem;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
    transition: background 0.3s;
    font-size: 0.9rem;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
}

/* =============================================
   CONTAINER & CARDS
   ============================================= */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h3 {
    color: #1a237e;
    margin-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

/* =============================================
   DASHBOARD GRID
   ============================================= */
.dashboard-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
}

/* =============================================
   WIDGETS
   ============================================= */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.widget {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #1a237e;
    text-align: center;
}

.widget .number {
    font-size: 2rem;
    font-weight: 700;
    color: #1a237e;
}

.widget .label {
    font-size: 0.85rem;
    color: #666;
}

.widget.approval {
    border-left-color: #ff9800;
    cursor: pointer;
}

.widget.approval .number {
    color: #ff9800;
}

.widget.on-leave {
    border-left-color: #4caf50;
}

.widget.on-leave .number {
    color: #4caf50;
}

.widget.upcoming {
    border-left-color: #2196f3;
}

.widget.upcoming .number {
    color: #2196f3;
}

/* =============================================
   LEAVE BALANCES
   ============================================= */
.balance-item {
    padding: 12px 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #1a237e;
    transition: all 0.3s;
}

.balance-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.balance-item.accrued {
    border-left-color: #4caf50;
}

.balance-item.unlimited {
    border-left-color: #ff9800;
    background: #fff8e1;
}

.balance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.balance-label {
    font-weight: 600;
    font-size: 1rem;
    color: #333;
}

.balance-details {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}

.balance-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a237e;
}

.balance-item.accrued .balance-value {
    color: #4caf50;
}

.balance-total {
    font-size: 0.9rem;
    color: #666;
}

/* Balance Summary Details */
.balance-summary-details {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin: 8px 0 10px 0;
    padding: 8px 10px;
    background: white;
    border-radius: 6px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 5px;
}

.summary-label {
    font-size: 0.6rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
    margin-top: 2px;
}

.summary-item.highlight .summary-value {
    color: #1a237e;
    font-size: 1.2rem;
    font-weight: 700;
}

/* Balance Bars */
.balance-bar-track {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-top: 5px;
}

.balance-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.balance-bar-fill.used {
    z-index: 2;
    background: #f44336;
}

.balance-bar-fill.accrued {
    z-index: 1;
    opacity: 0.5;
    background: #4caf50;
}

.balance-bar-legend {
    display: flex;
    gap: 15px;
    margin-top: 5px;
    font-size: 0.7rem;
    color: #666;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

/* Badges */
.unlimited-badge {
    background: #fff3cd;
    color: #856404;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 5px;
    display: inline-block;
}

.accrual-badge {
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    display: inline-block;
    margin-left: 5px;
}

/* =============================================
   CALENDAR
   ============================================= */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.calendar-header h3 {
    margin: 0;
    border: none;
    padding: 0;
}

.calendar-nav {
    display: flex;
    gap: 10px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.calendar-header-cell {
    background: #f5f5f5;
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
}

.calendar-cell {
    background: white;
    padding: 8px 5px;
    min-height: 70px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.calendar-cell:hover:not(.disabled):not(.empty) {
    background: #e3f2fd;
}

.calendar-cell.empty {
    background: #fafafa;
    cursor: default;
}

.calendar-cell.disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.calendar-cell.disabled .calendar-day {
    color: #ccc;
}

.calendar-cell.past {
    background: #fafafa;
    color: #bbb;
}

.calendar-cell.past .calendar-day {
    color: #bbb;
}

.calendar-cell.has-leave {
    border: 2px solid #4caf50;
}

.calendar-cell.user-leave {
    background: #e8f5e9;
}

.calendar-day {
    font-weight: 500;
    font-size: 0.95rem;
    padding: 2px 0;
}

.leave-indicators {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
    margin-top: 3px;
}

.leave-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    cursor: help;
    transition: transform 0.2s;
}

.leave-dot:hover {
    transform: scale(1.3);
}

.holiday-label {
    font-size: 0.9rem;
    margin-top: 2px;
    cursor: help;
}

/* =============================================
   FORMS
   ============================================= */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 5px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1a237e;
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.form-group input:disabled,
.form-group select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.form-group small {
    display: block;
    margin-top: 5px;
    font-size: 0.8rem;
    color: #666;
}

/* Handover Section - One Line */
.handover-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 15px;
    width: 50%;
    margin-top: 10px;
    border-top: 1px solid #e0e0e0;
    padding-top: 10px;
}

.handover-section .form-group {
    margin-bottom: 0;
}

.handover-section select,
.handover-section textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.handover-section textarea {
    resize: vertical;
    min-height: 38px;
}

.handover-section small {
    display: block;
    margin-top: 3px;
    font-size: 0.7rem;
    color: #666;
}

/* Password Toggle */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    flex: 1;
    padding-right: 45px !important;
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    color: #666;
    transition: color 0.3s;
}

.password-toggle:hover {
    color: #1a237e;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-block;
    text-decoration: none;
}

.btn-primary {
    background: #1a237e;
    color: white;
}

.btn-primary:hover {
    background: #0d1457;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.9rem;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

/* =============================================
   ALERTS
   ============================================= */
.alert {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

/* =============================================
   LEAVE MESSAGE
   ============================================= */
#leaveMessage {
    margin-top: 20px;
    padding: 20px;
    background: #e8f5e9;
    border-radius: 4px;
    border-left: 4px solid #4caf50;
}

#leaveMessage h4 {
    color: #2e7d32;
    margin-bottom: 10px;
}

#messageText {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    background: white;
    border: 1px solid #c8e6c9;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 120px;
}

/* =============================================
   TABLES
   ============================================= */
.table-responsive {
    overflow-x: auto;
    margin: 10px 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th {
    background: #f5f5f5;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
}

.table tr:hover {
    background: #f8f9fa;
}

/* =============================================
   DEPARTMENT SUMMARY
   ============================================= */
.dept-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.dept-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #1a237e;
}

.dept-card .dept-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #1a237e;
    margin-bottom: 10px;
}

.dept-card .dept-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.dept-card .stat-item {
    font-size: 0.9rem;
    background: #f5f5f5;
    padding: 3px 10px;
    border-radius: 12px;
}

.dept-card .stat-item .num {
    font-weight: 700;
    color: #1a237e;
}

.dept-card .leave-types {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.dept-card .leave-type-badge {
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 12px;
    background: #e3f2fd;
    color: #1565c0;
}

.dept-card .employees-list {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
}

.dept-card .employees-list .emp {
    padding: 2px 0;
}

.dept-card .employees-list .emp .status-current {
    color: #4caf50;
}

.dept-card .employees-list .emp .status-upcoming {
    color: #2196f3;
}

/* =============================================
   LOGIN / REGISTER
   ============================================= */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    color: #1a237e;
    text-align: center;
    margin-bottom: 5px;
}

.login-box h2 {
    color: #333;
    text-align: center;
    margin-bottom: 25px;
    font-weight: 400;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.login-footer a {
    color: #1a237e;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* Login Logo */
.login-logo {
    text-align: center;
    margin-bottom: 25px;
}

.login-logo img {
    height: 70px;
    width: auto;
    display: block;
    margin: 0 auto 10px auto;
}

.login-logo h1 {
    color: #1a237e;
    margin: 5px 0 0 0;
    font-size: 1.8rem;
    font-weight: 700;
}

.login-logo .subtitle {
    color: #666;
    margin: 0;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

.login-logo .est {
    color: #999;
    font-size: 0.75rem;
    display: block;
    margin-top: 2px;
}

/* =============================================
   NO ALLOCATIONS
   ============================================= */
.no-allocations {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

.no-allocations .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 10px;
        padding: 10px 20px;
    }
    
    .nav-brand img {
        height: 30px;
    }
    
    .nav-brand span {
        font-size: 1rem;
    }
    
    .nav-menu {
        justify-content: center;
        width: 100%;
        gap: 8px;
    }
    
    .nav-link {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .nav-user {
        font-size: 0.8rem;
        width: 100%;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .handover-section {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .balance-summary-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
    }
    
    .calendar-cell {
        min-height: 50px;
        padding: 4px 2px;
    }
    
    .calendar-day {
        font-size: 0.75rem;
    }
    
    .calendar-header-cell {
        padding: 5px;
        font-size: 0.7rem;
    }
    
    .leave-dot {
        width: 6px;
        height: 6px;
    }
    
    .holiday-label {
        font-size: 0.7rem;
    }
    
    .card {
        padding: 15px;
    }
    
    .login-box {
        padding: 25px;
    }
    
    .balance-value {
        font-size: 1.2rem;
    }
    
    .dept-summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .nav-brand img {
        height: 25px;
    }
    
    .nav-brand span {
        font-size: 0.85rem;
    }
    
    .nav-link {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    
    .widget-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* =============================================
   UTILITY
   ============================================= */
.text-center {
    text-align: center;
}

.text-muted {
    color: #999;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* Admin specific */
.admin-user-select {
    max-width: 400px;
    margin-bottom: 20px;
}

.balances-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* Tooltip for leave dots */
.leave-dot[title] {
    position: relative;
}

.leave-dot[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 10;
}