@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;
    --primary-light: #6366f1;
    --primary-dark: #4338ca;
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #4f46e5;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    --sidebar-width: 250px;
    --sidebar-collapsed: 70px;
    --header-bg: #ffffff;
    --body-bg: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===================== LAYOUT ===================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===================== SIDEBAR ===================== */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: var(--transition-slow);
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
}

.sidebar-logo img {
    flex-shrink: 0;
}

.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
}

.sidebar-logo .logo-text {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
    min-width: 0;
}

.sidebar-logo .logo-sub {
    font-size: 11px;
    color: var(--sidebar-text);
    font-weight: 400;
}

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

.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--sidebar-text);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 6px;
    opacity: 0.6;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.nav-item .nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

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

.sync-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.sync-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

.sync-btn:active {
    transform: translateY(0);
}

.sync-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sync-btn .spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.sync-btn.loading .spinner { display: block; }
.sync-btn.loading .sync-icon { display: none; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

.sync-status {
    font-size: 11px;
    margin-top: 8px;
    text-align: center;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    display: none;
}

.sync-status.show { display: block; }
.sync-status.success { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.sync-status.error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.sync-status.loading { background: rgba(251, 191, 36, 0.15); color: #fcd34d; }

.install-btn {
    width: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.install-btn:hover {
    background: rgba(255,255,255,0.12);
    color: white;
    border-color: rgba(255,255,255,0.25);
}

.install-btn .install-icon { font-size: 15px; }

/* ===================== MAIN CONTENT ===================== */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Flex items default to min-width:auto, so a wide table stretches the whole
       page instead of scrolling inside .table-wrapper. */
    min-width: 0;
    max-width: 100%;
}

/* ===================== TOP BAR ===================== */

.topbar {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.9);
}

.topbar-title h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-content {
    padding: 24px 32px;
    flex: 1;
    animation: fadeInUp 0.3s ease;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== CONTROLS BAR ===================== */

/* ===================== CONTROLS SECTION ===================== */

.controls-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.94));
    padding: 20px;
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.controls-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.control-item label {
    font-weight: 700;
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-item input[type="date"],
.control-item input[type="month"],
.control-item input[type="number"],
.control-item input[type="search"],
.control-item select {
    padding: 11px 12px;
    border: 1.5px solid rgba(148, 163, 184, 0.35);
    border-radius: 12px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 600;
    outline: none;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.92);
    color: var(--text-primary);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

.control-item input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
}

.control-item input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.control-item input[type="date"]:hover,
.control-item input[type="month"]:hover,
.control-item input[type="search"]:hover,
.control-item select:hover {
    border-color: rgba(79, 70, 229, 0.45);
    background: rgba(79, 70, 229, 0.03);
}

.control-item input[type="date"]:focus,
.control-item input[type="month"]:focus,
.control-item input[type="number"]:focus,
.control-item input[type="search"]:focus,
.control-item select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
    background: white;
}

.controls-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
}

.controls-actions .btn {
    flex: 0 1 auto;
}

.export-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* Keep old controls style for backwards compatibility */
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    border: 1px solid var(--border);
}

.controls label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}

.controls input[type="date"],
.controls input[type="month"],
.controls input[type="number"],
.controls select {
    padding: 9px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: var(--transition);
    background: white;
    color: var(--text-primary);
}

.controls #employeeFilter {
    width: min(100%, 280px);
    min-width: 0;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.controls input:focus,
.controls select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.export-btns {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

/* ===================== BUTTONS ===================== */

.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 10px 20px rgba(79,70,229,0.24); }

.btn-secondary {
    background: var(--primary);
    color: white;
}
.btn-secondary:hover { background: var(--primary-dark); box-shadow: 0 10px 20px rgba(79,70,229,0.24); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

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

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}
.btn-outline:hover { background: var(--body-bg); border-color: var(--text-muted); }

.btn-export {
    background: #475569;
    color: white;
}
.btn-export:hover { background: #334155; }

.btn-export.excel {
    background: #16a34a;
}
.btn-export.excel:hover { background: #15803d; }

.btn-export.pdf {
    background: var(--danger);
}
.btn-export.pdf:hover { background: #dc2626; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-sm.approve { background: var(--success); color: white; }
.btn-sm.approve:hover { background: #059669; }
.btn-sm.reject { background: var(--danger); color: white; }
.btn-sm.reject:hover { background: #dc2626; }

/* ===================== STATS CARDS ===================== */

.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,252,0.96));
    padding: 18px 20px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary);
    border-radius: 4px 0 0 4px;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.stat-card.stat-late::before { background: var(--danger); }
.stat-card.stat-ontime::before { background: var(--success); }
.stat-card.stat-absent::before { background: var(--danger); }
.stat-card.stat-warning::before { background: var(--warning); }
.stat-card.stat-info::before { background: var(--info); }

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-late .stat-value { color: var(--danger); }
.stat-ontime .stat-value { color: var(--success); }
.stat-absent .stat-value { color: #64748b; }
.stat-warning .stat-value { color: var(--warning); }
.stat-info .stat-value { color: var(--info); }

.stat-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 6px;
}

/* ===================== TABLE ===================== */

.table-wrapper {
    background: var(--card-bg);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
    border: 1px solid rgba(148, 163, 184, 0.2);
    overflow: hidden;
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
}

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

thead {
    background: linear-gradient(180deg, rgba(248,250,252,0.92), rgba(241,245,249,0.96));
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background: rgba(79,70,229,0.04);
}

tbody tr.late-row {
    background: #fef2f2;
    border-left: 3px solid var(--danger);
}

tbody tr.late-row:hover {
    background: #fee2e2;
}

/* Absences are a real finding, not missing data: show them clearly. */
tbody tr.absent-row {
    background: #fef2f2;
    color: #7f1d1d;
    box-shadow: inset 3px 0 0 #dc2626;
}

tbody tr.absent-row:hover {
    background: #fee2e2;
}

tbody tr.absent-row td {
    color: #7f1d1d;
}

/* Absence is the exception, so fade everything else back a touch. */
tbody tr.ontime-row,
tbody tr.late-row {
    color: var(--text-secondary);
}

.no-data {
    text-align: center;
    padding: 48px 16px !important;
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

/* ===================== WEEKLY REPORT CELLS ===================== */

.weekly-present-cell {
    background: #f0fdf4 !important;
    padding: 8px 10px !important;
    text-align: center;
    vertical-align: middle;
    min-width: 85px;
}

.weekly-late-cell {
    background: #fff8f0 !important;
    padding: 8px 10px !important;
    text-align: center;
    vertical-align: middle;
    border-left: 2px solid var(--warning) !important;
    min-width: 85px;
}

.weekly-absent-cell {
    background: #fef2f2 !important;
    padding: 8px 10px !important;
    text-align: center;
    vertical-align: middle;
    min-width: 85px;
    box-shadow: inset 2px 0 0 #dc2626;
}

.weekly-time-in {
    font-size: 12px;
    font-weight: 600;
    color: #047857;
    line-height: 1.4;
    margin-bottom: 3px;
    white-space: nowrap;
}

.weekly-time-out {
    font-size: 11px;
    color: #065f46;
    line-height: 1.3;
    white-space: nowrap;
}

.weekly-time-missing {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.3;
}

.weekly-total-cell {
    background: var(--primary-50) !important;
    font-weight: 700 !important;
    color: var(--primary) !important;
    text-align: center;
    min-width: 90px;
    font-size: 14px !important;
}

.weekly-absent-cell .status-badge {
    font-size: 10px;
    padding: 3px 8px;
}

.weekly-absent-note {
    font-size: 9px;
    color: #b91c1c;
    opacity: 0.75;
    margin-top: 2px;
    line-height: 1.2;
}

/* Weekly table specific styles */
#weeklyTable th {
    padding: 12px 10px;
    font-size: 11px;
}

#weeklyTable td {
    padding: 10px 12px;
    font-size: 13px;
}

/* Make employee info columns wider, day columns balanced */
#weeklyTable th:nth-child(1) { width: 50px; } /* # */
#weeklyTable th:nth-child(2) { width: 120px; } /* Employee ID */
#weeklyTable th:nth-child(3) { min-width: 150px; max-width: 220px; } /* Name */
#weeklyTable th:nth-child(4) { width: 120px; } /* Department */
#weeklyTable th:nth-child(5) { width: 80px; } /* Absent count */
#weeklyTable th:nth-child(n+6):nth-child(-n+12) { width: 95px; } /* Day columns */
#weeklyTable th:nth-child(13) { width: 100px; } /* Total */

.weekly-absent-count-cell {
    text-align: center;
    vertical-align: middle;
    background: #fff7f7;
}

/* ===================== STATUS BADGES ===================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    gap: 3px;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-late { background: #fef3f2; color: #b91c1c; }
.status-late::before { background: #b91c1c; }
.status-ontime { background: #f0fdf4; color: #047857; }
.status-ontime::before { background: #047857; }
.status-absent { background: #fee2e2; color: #991b1b; }
.status-absent::before { background: #dc2626; }
.status-upcoming { background: #f1f5f9; color: #64748b; }
.status-upcoming::before { background: #94a3b8; }
.status-missing-in { background: #fef3f2; color: #dc2626; }
.status-missing-in::before { background: #dc2626; }
.status-missing-out { background: #fff7ed; color: #ea580c; }
.status-missing-out::before { background: #ea580c; }
.status-holiday { background: #fef3c7; color: #92400e; }
.status-holiday::before { background: #92400e; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-pending::before { background: #92400e; }

/* ===================== MODALS ===================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 28px;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 520px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-content h3 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

/* ===================== CALENDAR ===================== */

.calendar-grid {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.cal-header-cell {
    text-align: center;
    font-weight: 700;
    font-size: 11px;
    color: var(--text-muted);
    padding: 10px;
    background: var(--body-bg);
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-cell {
    min-height: 72px;
    padding: 8px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    background: white;
}

.cal-cell:hover {
    border-color: var(--primary);
    background: var(--primary-50);
    transform: scale(1.02);
}

.cal-cell.empty {
    border: none;
    cursor: default;
    background: transparent;
}

.cal-cell.empty:hover {
    background: transparent;
    transform: none;
}

.cal-cell .cal-date {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.cal-cell .cal-shift {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 500;
}

.cal-cell.rest-day {
    background: #fef2f2;
    border-color: #fecaca;
}

.cal-cell.rest-day .cal-shift {
    color: #b91c1c;
    font-weight: 700;
}

.cal-cell.has-shift {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.cal-cell.has-shift .cal-shift {
    color: #047857;
    font-weight: 700;
}

.roster-info {
    background: var(--card-bg);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===================== TABS (sub-navigation) ===================== */

.sub-tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--body-bg);
    padding: 4px 0 12px;
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    background: var(--card-bg);
    padding: 4px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    width: 100%;
}

.sub-tabs .tab {
    flex: 0 0 150px;
    text-align: center;
    padding: 11px 20px;
    text-decoration: none;
    color: var(--text-muted);
    background: transparent;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    border: none;
    transition: var(--transition);
    cursor: pointer;
    font-family: inherit;
}

.sub-tabs .tab:hover {
    color: var(--text-primary);
    background: var(--body-bg);
}

.sub-tabs .tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}

/* ===================== LEGACY TABS (for backward compat) ===================== */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab {
    padding: 8px 16px;
    text-decoration: none;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--border);
    transition: var(--transition);
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.tab:hover { color: var(--text-primary); background: var(--body-bg); }
.tab.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 6px rgba(79,70,229,0.3); }

/* ===================== EMPTY STATES ===================== */

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

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
    max-width: 300px;
    margin: 0 auto;
}

/* ===================== TOAST NOTIFICATIONS ===================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: white;
    border-radius: var(--radius);
    padding: 12px 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease;
    max-width: 360px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* ===================== REPORTS TABS ===================== */

.reports-tabs-container {
    background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.96));
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
    padding: 0;
    position: sticky;
    top: 64px;
    z-index: 40;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.reports-tabs {
    display: flex;
    align-items: stretch;
    gap: 10px;
    max-width: 1400px;
    padding: 12px 32px 0;
    margin: 0;
}

.tab-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: 12px 12px 0 0;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    cursor: pointer;
    outline: none;
    background: transparent;
}

.tab-item:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
    border-color: rgba(79, 70, 229, 0.08);
    transform: translateY(-1px);
}

.tab-item:focus {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    color: var(--primary);
}

.tab-item:focus:not(:focus-visible) {
    outline: none;
}

.tab-item:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    color: var(--primary);
}

.tab-item.active {
    color: var(--primary);
    border-color: rgba(79, 70, 229, 0.08);
    border-bottom-color: var(--primary);
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.08), rgba(79, 70, 229, 0.02));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 12px;
    right: 12px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px 3px 0 0;
}

.tab-icon {
    font-size: 18px;
    display: inline-flex;
    transition: transform 0.2s ease;
}

.tab-label {
    display: inline;
}

@keyframes tabSlide {
    0% { opacity: 0; transform: translateY(3px); }
    100% { opacity: 1; transform: translateY(0); }
}

.tab-item.active::after {
    animation: tabSlide 0.25s ease;
}

.tab-item:hover .tab-icon {
    transform: scale(1.1);
}

/* ===================== WEEKLY REPORT TABLE FIT ===================== */

#weeklyTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

#weeklyTable th,
#weeklyTable td {
    padding: 6px 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
    font-size: 11.5px;
    line-height: 1.3;
}

#weeklyTable th:nth-child(1),
#weeklyTable td:nth-child(1) { width: 36px; padding-left: 4px; padding-right: 4px; }
#weeklyTable th:nth-child(2),
#weeklyTable td:nth-child(2) { width: 90px; }
#weeklyTable th:nth-child(3),
#weeklyTable td:nth-child(3) { width: auto; text-align: left; white-space: normal; }
#weeklyTable th:nth-child(4),
#weeklyTable td:nth-child(4) { width: 100px; }
#weeklyTable th:nth-child(12),
#weeklyTable td:nth-child(12) { width: 56px; font-weight: 700; padding-left: 10px; padding-right: 10px; }

#weeklyTable th:nth-child(n+5):nth-child(-n+11),
#weeklyTable td:nth-child(n+5):nth-child(-n+11) {
    width: calc((100% - 380px) / 7);
    min-width: 72px;
    padding: 6px 10px;
    border-left: 1px solid var(--border-light, #f0f0f0);
}

#weeklyTable th:nth-child(5) {
    border-left: none;
}

#weeklyTable td:nth-child(n+5):nth-child(-n+11) {
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 10px;
    letter-spacing: -0.3px;
}

#weeklyTable thead tr:first-child th {
    font-size: 10.5px;
    padding: 6px 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#weeklyTable thead tr:last-child th {
    font-size: 10.5px;
    padding: 6px 10px;
    font-weight: 500;
}

/* Reports tabs overflow fix */
.reports-tabs-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.reports-tabs-container::-webkit-scrollbar {
    height: 2px;
}

.reports-tabs-container::-webkit-scrollbar-track {
    background: transparent;
}

.reports-tabs-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 2px;
}

.tab-item.active .tab-icon {
    transform: scale(1.15);
}

/* ===================== RESPONSIVE ===================== */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        padding: 12px 16px;
    }

    .page-content {
        padding: 16px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 90;
    }

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

    .menu-toggle {
        display: flex !important;
    }

    .reports-tabs {
        padding: 0 16px;
    }

    .tab-item {
        padding: 14px 16px;
        font-size: 13px;
        gap: 6px;
    }

    .tab-icon {
        font-size: 16px;
    }

    .controls-group {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 12px;
    }

    .controls-container {
        padding: 16px;
    }

    .controls-actions {
        gap: 10px;
    }

    .export-btns {
        gap: 6px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-container {
        padding: 14px;
        gap: 12px;
    }

    .controls-group {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .control-item input,
    .control-item select {
        width: 100%;
    }

    .controls-actions {
        flex-direction: column;
        gap: 10px;
    }

    .controls-actions .btn {
        width: 100%;
    }

    .export-btns {
        width: 100%;
        flex-direction: column;
    }

    .export-btns .btn {
        width: 100%;
        justify-content: center;
    }

    .export-btns {
        margin-left: 0;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 8px 10px;
    }

    .reports-tabs {
        padding: 0 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .reports-tabs::-webkit-scrollbar {
        height: 3px;
    }

    .reports-tabs::-webkit-scrollbar-track {
        background: transparent;
    }

    .reports-tabs::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 2px;
    }

    .tab-item {
        padding: 12px 14px;
        font-size: 12px;
        gap: 4px;
    }

    .tab-icon {
        font-size: 14px;
    }

    .tab-label {
        display: none;
    }

    .tab-item:hover .tab-label,
    .tab-item.active .tab-label {
        display: inline;
    }
}

/* Smaller phones */
@media (max-width: 480px) {
    .page-content {
        padding: 12px;
    }

    .topbar {
        padding: 10px 12px;
    }

    .topbar-title h2 {
        font-size: 16px;
    }

    .topbar-title p {
        font-size: 11px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 68vw;
    }

    .sidebar {
        width: min(82vw, 270px);
    }

    .sidebar-footer {
        padding: 12px 14px;
        padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    }

    .main-content {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .reports-tabs .tab-item,
    .company-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .dash-date-picker {
        width: 100%;
        justify-content: space-between;
    }

    .dash-date-picker input[type="date"] {
        flex: 1;
        font-size: 13px;
    }

    .controls-container,
    .reports-tabs-container {
        border-radius: var(--radius);
    }

    .table-wrapper {
        border-radius: var(--radius);
    }

    th, td {
        padding: 8px;
        font-size: 12px;
    }
}

/* iOS standalone (PWA) safe areas */
@supports (padding: max(0px)) {
    .main-content {
        padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
    }

    .topbar {
        padding-top: max(16px, env(safe-area-inset-top, 0px));
    }
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    font-size: 18px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.menu-toggle:hover {
    background: var(--body-bg);
}

/* ===================== SKELETON LOADING ===================== */

.skeleton {
    background: linear-gradient(90deg, var(--border-light) 25%, var(--border) 50%, var(--border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ===================== CHECKBOX ===================== */

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 6px;
    accent-color: var(--primary);
}

/* ===================== DASHBOARD ===================== */

/* Hero Section */
.dash-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 32px 36px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #a855f7 100%);
    border-radius: var(--radius-xl);
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.3);
}

.dash-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.dash-hero::after {
    content: '';
    position: absolute;
    bottom: -60%;
    left: 10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.dash-hero-left { position: relative; z-index: 1; }

.dash-greeting {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}

.dash-date-display {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.85;
}

.dash-hero-right { position: relative; z-index: 1; }

.dash-date-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px 14px;
    border-radius: var(--radius-lg);
}

.dash-dp-icon { font-size: 18px; opacity: 0.9; }

.dash-date-picker input[type="date"] {
    padding: 6px 10px;
    border: 1.5px solid rgba(255,255,255,0.25);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    background: rgba(255,255,255,0.12);
    color: white;
    outline: none;
    transition: var(--transition);
}

.dash-date-picker input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.dash-date-picker input[type="date"]:focus {
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.2);
}

.dash-date-picker .btn-primary {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 6px 16px;
    font-size: 12px;
}

.dash-date-picker .btn-primary:hover {
    background: rgba(255,255,255,0.3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Company Tabs */
.company-tabs-wrapper {
    margin-bottom: 24px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.company-tabs {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.company-tabs::-webkit-scrollbar { height: 0; }

.company-tab {
    flex: 0 0 auto;
    padding: 9px 20px;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50px;
    white-space: nowrap;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.company-tab .tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.company-tab:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-50);
}

.company-tab:hover .tab-dot { background: var(--primary); }

.company-tab.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

.company-tab.active .tab-dot { background: rgba(255,255,255,0.7); }

/* Stat Cards */
.dash-stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    min-height: 120px;
}

.dash-stat-card {
    background: var(--card-bg);
    padding: 22px 20px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.dash-stat-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    opacity: 0.9;
}

.dash-stat-card-total .dash-stat-glow { background: linear-gradient(90deg, var(--primary), #7c3aed); }
.dash-stat-card-present .dash-stat-glow { background: linear-gradient(90deg, #10b981, #34d399); }
.dash-stat-card-ontime .dash-stat-glow { background: linear-gradient(90deg, #059669, #10b981); }
.dash-stat-card-late .dash-stat-glow { background: linear-gradient(90deg, #ef4444, #f87171); }
.dash-stat-card-absent .dash-stat-glow { background: linear-gradient(90deg, #64748b, #94a3b8); }

.dash-stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.dash-stat-icon-wrap {
    display: flex;
}

.dash-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dash-stat-icon svg { width: 22px; height: 22px; }

.dash-stat-total { background: var(--primary-100); color: var(--primary); }
.dash-stat-present { background: var(--success-light); color: var(--success); }
.dash-stat-ontime { background: #d1fae5; color: #059669; }
.dash-stat-late { background: var(--danger-light); color: var(--danger); }
.dash-stat-absent { background: #f1f5f9; color: #64748b; }

.dash-stat-info { display: flex; flex-direction: column; }

.dash-stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.dash-stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 4px;
    line-height: 1.3;
    word-wrap: break-word;
}

.dash-stat-trend {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.dash-stat-trend.positive { color: var(--success); }
.dash-stat-trend.negative { color: var(--danger); }

/* Chart Cards */
.dash-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr;
    gap: 16px;
    margin-bottom: 16px;
}

.dash-charts-row:last-child {
    grid-template-columns: 1fr 1fr;
}

.dash-chart-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 24px;
    transition: all 0.3s ease;
}

.dash-chart-card:hover {
    box-shadow: var(--shadow-md);
}

.dash-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-light);
}

.dash-chart-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.dash-chart-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--success);
    background: var(--success-light);
    padding: 3px 10px;
    border-radius: 20px;
}

/* Donut Chart */
.dash-donut-card {
    display: flex;
    flex-direction: column;
}

.dash-donut-wrap {
    position: relative;
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donut-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}

.donut-center-value {
    display: block;
    font-size: 32px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
}

.donut-center-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Donut Legend */
.donut-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 12px 16px 4px;
    flex-wrap: wrap;
}
.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
}
.donut-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.donut-legend-item strong {
    font-weight: 700;
    color: var(--text-primary, #1e293b);
}

/* Trend Chart */
.dash-trend-card .dash-chart-wrap {
    height: 280px;
}

.dash-chart-wrap {
    position: relative;
    height: 280px;
}

/* Responsive */
@media (max-width: 1200px) {
    .dash-stats-row { grid-template-columns: repeat(3, 1fr); }
    .dash-charts-row { grid-template-columns: 1fr; }
    .dash-charts-row:last-child { grid-template-columns: 1fr 1fr; }
    .dash-stat-label { font-size: 12px; }
}

@media (max-width: 768px) {
    .dash-stats-row { grid-template-columns: repeat(2, 1fr); }
    .dash-hero {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 24px;
    }
    .dash-greeting { font-size: 20px; }
    .dash-chart-wrap { height: 220px; }
    .dash-stat-card { padding: 18px 16px; }
    .dash-stat-label { font-size: 11px; line-height: 1.4; }
    .dash-stat-value { font-size: 24px; }
    .dash-stat-icon { width: 40px; height: 40px; border-radius: 10px; }
    .dash-stat-icon svg { width: 18px; height: 18px; }
    .donut-center-value { font-size: 24px; }
    .dash-charts-row { grid-template-columns: 1fr; }
    .dash-charts-row:last-child { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .dash-stats-row { grid-template-columns: 1fr; }
    .company-tab { padding: 7px 14px; font-size: 12px; }
}
/* Gender Chart Styles */
.chart-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1.5rem 0;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.chart-container h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
}

.chart-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

#genderChart {
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

.legend-color.male {
    background-color: #3B82F6;
}

.legend-color.female {
    background-color: #EC4899;
}

.legend-text {
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .chart-wrapper {
        flex-direction: column;
        gap: 1rem;
    }
    
    #genderChart {
        width: 250px !important;
        height: 250px !important;
    }
    
    .chart-legend {
        align-items: center;
    }
}
/* ============================================================
   Roster import screens
   ============================================================ */

.rm-intro {
    margin-bottom: 22px;
}
.rm-intro h3 {
    margin: 0 0 6px;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}
.rm-intro p {
    margin: 0;
    max-width: 68ch;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}
.rm-intro .rm-backlink {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}
.rm-intro .rm-backlink:hover { text-decoration: underline; }

/* Two column layout on wide screens, single column on narrow */
.rm-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.rm-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}
.rm-card + .rm-card { margin-top: 20px; }

.rm-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}
.rm-card-sub {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
}

/* Numbered step marker */
.rm-step-num {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
}

/* Alerts: readable contrast on a light card surface */
.rm-alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 13px 15px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 600;
    margin-bottom: 20px;
}
.rm-alert strong { display: block; margin-bottom: 2px; }
.rm-alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.rm-alert-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.rm-alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.rm-alert-icon { flex: 0 0 auto; font-weight: 800; }

/* Drop zone */
.rm-dropzone {
    position: relative;
    display: grid;
    place-items: center;
    gap: 6px;
    padding: 30px 20px;
    text-align: center;
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--border-light);
    cursor: pointer;
    transition: var(--transition);
}
.rm-dropzone:hover,
.rm-dropzone:focus-within {
    border-color: var(--primary);
    background: #eef2ff;
    outline: none;
}
.rm-dropzone.is-over {
    border-color: var(--primary);
    background: #e0e7ff;
}
.rm-dropzone.has-file {
    border-style: solid;
    border-color: var(--success);
    background: #ecfdf5;
}
.rm-dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.rm-dz-icon { font-size: 26px; line-height: 1; }
.rm-dz-title { font-size: 14px; font-weight: 800; color: var(--text-primary); }
.rm-dz-title span { color: var(--primary); text-decoration: underline; }
.rm-dz-hint { font-size: 12px; color: var(--text-muted); }
.rm-dz-name {
    display: none;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #065f46;
    word-break: break-all;
}
.rm-dropzone.has-file .rm-dz-name { display: block; }
.rm-dropzone.has-file .rm-dz-hint { display: none; }

/* Shift reference chips */
.rm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.rm-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    padding: 7px 11px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.rm-chip-time {
    font-weight: 600;
    font-size: 11px;
    opacity: .85;
}
.rm-chip-rest {
    background: var(--danger);
}

/* Code sample with copy button */
.rm-code-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.rm-code {
    margin: 0;
    padding: 14px 16px;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    line-height: 1.65;
    overflow-x: auto;
}

.rm-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}
.rm-btn-row .btn { margin-left: 0; }

.rm-help {
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 9px;
}
.rm-help li {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}
.rm-help li::before {
    content: "";
    flex: 0 0 5px;
    width: 5px;
    height: 5px;
    margin-top: 7px;
    border-radius: 999px;
    background: var(--primary);
}
.rm-monthform .control-item { max-width: 240px; }
.rm-monthform .control-item label { margin-bottom: 2px; }

.rm-help code,
.rm-code-inline {
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--border-light);
    border: 1px solid var(--border);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--text-primary);
}

@media (max-width: 1000px) {
    .rm-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   Report tables: legend, absent/future states
   ============================================================ */

/* Legend is an accurate key: each swatch reproduces the exact cell tint and
   border it describes, so the mapping is verifiable at a glance. A bordered
   tile stays legible where a pale flat dot on white would disappear. */
.table-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 0;
    margin: 0 0 12px;
    padding: 0 2px;
    background: none;
    border: 0;
    box-shadow: none;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 4px;
}
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}
.legend-item + .legend-item {
    padding-left: 14px;
    border-left: 1px solid var(--border);
}
.legend-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex: 0 0 auto;
    border: 1px solid rgba(148, 163, 184, 0.35);
}
.swatch-ontime  { background: #f0fdf4; border-color: #86efac; }
.swatch-late    { background: #fff8f0; border-color: #fdba74; }
.swatch-absent  { background: #fef2f2; border-color: #fca5a5; }
.swatch-holiday { background: #fef3c7; border-color: #fcd34d; }
.swatch-future  { background: #ffffff; border-color: #e2e8f0; }

.day-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

/* Days later than today are not absences - render them invisible-quiet */
.weekly-future-cell {
    background: #ffffff !important;
    padding: 8px 10px !important;
    text-align: center;
    vertical-align: middle;
    min-width: 85px;
}
.weekly-future-dash {
    color: #e2e8f0;
    font-weight: 700;
    font-size: 13px;
}

/* Resignation: candidates are only a suggestion, and confirming is deliberate. */
.resignation-panel {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #b45309;
    border-radius: 6px;
    padding: 12px 14px;
    margin: 0 0 14px 0;
}
.resignation-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 8px;
}
.resignation-head strong { font-size: 13px; color: #1f2937; }
.resignation-hint { font-size: 11px; color: #64748b; }
.resignation-list { display: flex; flex-direction: column; gap: 6px; }
.resignation-empty { font-size: 12px; color: #94a3b8; }
.resignation-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border: 1px solid #f1f5f9;
    border-radius: 4px;
    background: #fffbeb;
}
.resignation-name { font-size: 12px; font-weight: 600; color: #1f2937; }
.resignation-meta { font-size: 11px; color: #64748b; }
.btn-resign {
    border: 1px solid #b45309;
    background: #ffffff;
    color: #b45309;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-resign:hover { background: #b45309; color: #ffffff; }
.btn-resign-undo { border-color: #15803d; color: #15803d; }
.btn-resign-undo:hover { background: #15803d; color: #ffffff; }
.resign-reason { font-size: 10px; color: #64748b; width: 100%; }
.status-resigned { background: #fef2f2; color: #b91c1c; }
.status-resigned::before { background: #b91c1c; }
.status-protected { background: #e0e7ff; color: #3730a3; }
.status-protected::before { background: #4f46e5; }
#customTable th:nth-child(13),
#customTable td:nth-child(13) { white-space: nowrap; }
