/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #10b981;
    --purple-color: #8b5cf6;
    --orange-color: #f59e0b;
    --danger-color: #ef4444;
    --dark-bg: #1e293b;
    --sidebar-bg: #0f172a;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --hover-bg: #f1f5f9;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8fafc;
    color: var(--text-primary);
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo i {
    font-size: 32px;
    color: var(--primary-color);
}

.logo h2 {
    font-size: 20px;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 30px;
    width: calc(100% - 260px);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.header-left h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.date-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

/* Logout button in header */
.btn-logout {
    display: inline-flex; align-items: center;
    font-size: .85rem; color: #64748b;
    text-decoration: none; padding: 8px 12px;
    border: 1px solid #334155; border-radius: 6px; transition: all .2s;
}

/* CSS tooltip for icon-only header buttons */
.hdr-btn {
    position: relative;
}
.hdr-btn[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #334155;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 100;
}
.hdr-btn[data-tip]:hover::after {
    opacity: 1;
}

.btn-refresh:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary-color);
}

.stat-icon.purple {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple-color);
}

.stat-icon.orange {
    background: rgba(245, 158, 11, 0.1);
    color: var(--orange-color);
}

.stat-content h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Gender Card Styles */
.gender-card {
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
}

.stat-card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    text-align: center;
}

.gender-chart-container {
    width: 100%;
    height: 140px;
    position: relative;
    margin: 0 auto;
}

.gender-chart-container canvas {
    max-height: 140px;
}

.gender-legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.female-color {
    background-color: rgba(139, 92, 246, 0.8);
}

.male-color {
    background-color: rgba(37, 99, 235, 0.8);
}

.legend-text {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-text i {
    font-size: 14px;
}

.legend-text strong {
    color: var(--text-primary);
    margin-left: 2px;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Turnover 2-col grid — collapses on mobile */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 768px) {
    .charts-grid { grid-template-columns: 1fr; }
}

.chart-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* Prevent any inner canvas from bleeding outside */
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.chart-card h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 18px;
}

/* All canvas inside a chart-card — never exceed card width */
.chart-card canvas {
    max-width: 100% !important;
    box-sizing: border-box;
}

/* canvas direct child (no .chart-container wrapper) — cap height */
.chart-card > canvas {
    max-height: 300px;
}

.chart-container {
    position: relative;
    height: 280px;
    overflow: hidden;   /* prevent canvas bleed */
    max-width: 100%;
}

/* Tables */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
}

.table-container h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 18px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--hover-bg);
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 14px;
}

.data-table tbody tr:hover {
    background: var(--hover-bg);
}

/* Table Controls */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.search-input {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    width: 300px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Alert Box */
.alert-box {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.alert-box.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--orange-color);
    color: #92400e;
}

.alert-box i {
    font-size: 20px;
}

/* ── Enhanced Employees Section ──────────────────────────────────── */
.emp-stat-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.emp-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.emp-stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.emp-stat-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.emp-stat-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }

/* Filter bar */
.emp-filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.emp-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
}
.emp-search-icon {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    color: var(--text-secondary); font-size: 13px; pointer-events: none;
}
.emp-search-input {
    width: 100%; padding: 8px 12px 8px 32px;
    border: 1px solid var(--border-color); border-radius: 8px;
    font-size: 13px; background: var(--hover-bg); color: var(--text-primary);
    transition: border-color .2s;
}
.emp-search-input:focus { outline: none; border-color: var(--primary-color); background: white; }
.emp-select {
    padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 8px;
    font-size: 13px; background: var(--hover-bg); color: var(--text-primary);
    cursor: pointer; min-width: 130px;
}
.emp-select:focus { outline: none; border-color: var(--primary-color); }
.emp-clear-btn {
    padding: 8px 14px; border: 1.5px solid var(--danger-color); border-radius: 8px;
    background: transparent; color: var(--danger-color); font-size: 12px; font-weight: 600;
    cursor: pointer; white-space: nowrap; transition: all .2s;
}
.emp-clear-btn:hover { background: rgba(239,68,68,.08); }
.emp-export-btn {
    padding: 8px 14px; border: 1.5px solid var(--secondary-color); border-radius: 8px;
    background: rgba(16,185,129,.08); color: var(--secondary-color); font-size: 12px; font-weight: 600;
    cursor: pointer; white-space: nowrap; transition: all .2s; display: flex; align-items: center; gap: 6px;
}
.emp-export-btn:hover { background: rgba(16,185,129,.16); }

/* Table meta row */
.emp-table-meta {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}

/* Sortable columns */
.emp-table thead th.emp-th-sort {
    cursor: pointer; user-select: none; white-space: nowrap; position: relative;
}
.emp-table thead th.emp-th-sort:hover { background: rgba(37,99,235,.06); }
.emp-table thead th.sort-asc .sort-icon::after  { content: ' ▲'; font-size: 10px; color: var(--primary-color); }
.emp-table thead th.sort-desc .sort-icon::after { content: ' ▼'; font-size: 10px; color: var(--primary-color); }
.emp-table th.sort-asc .sort-icon, .emp-table th.sort-desc .sort-icon { color: var(--primary-color); font-weight: 700; }
.sort-icon { font-size: 10px; color: #cbd5e1; margin-left: 3px; }

/* Avatar initials */
.emp-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    flex-shrink: 0; margin-right: 8px; vertical-align: middle;
    text-transform: uppercase;
}
.emp-name-cell { display: flex; align-items: center; }
.emp-name-main { font-weight: 600; color: var(--text-primary); line-height: 1.2; }
.emp-name-sub  { font-size: 11px; color: var(--text-secondary); }

/* Gender badge */
.badge-gender-f { background: rgba(236,72,153,.12); color: #db2777; border: 1px solid rgba(236,72,153,.25); padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-gender-m { background: rgba(37,99,235,.12); color: #2563eb; border: 1px solid rgba(37,99,235,.25); padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }

/* Level badge */
.badge-level {
    background: rgba(139,92,246,.12); color: #7c3aed;
    border: 1px solid rgba(139,92,246,.25);
    padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap;
}

/* Dept / BU stacked cell */
.emp-dept-main { font-weight: 500; color: var(--text-primary); }
.emp-dept-sub  { font-size: 11px; color: var(--text-secondary); }

/* Tenure pill */
.tenure-chip {
    display: inline-block; padding: 2px 8px; border-radius: 99px;
    font-size: 11px; font-weight: 600; background: rgba(16,185,129,.1); color: #059669;
}

/* Pagination */
.emp-pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.emp-pg-btn {
    min-width: 30px; height: 30px; padding: 0 8px;
    border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--card-bg); color: var(--text-secondary);
    font-size: 12px; font-weight: 600; cursor: pointer; transition: all .15s;
    display: inline-flex; align-items: center; justify-content: center;
}
.emp-pg-btn:hover:not(:disabled) { background: var(--hover-bg); color: var(--text-primary); border-color: var(--primary-color); }
.emp-pg-btn.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.emp-pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.emp-pg-ellipsis { padding: 0 4px; color: var(--text-secondary); font-size: 13px; }

@media (max-width: 1024px) {
    .emp-stat-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
    .emp-stat-row { grid-template-columns: repeat(2, 1fr); }
    .emp-filter-bar { gap: 8px; }
}

/* ── Contracts Section ────────────────────────────────────────────── */
.con-stat-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.con-stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.con-stat-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.con-stat-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.con-stat-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }

/* Expiry status badges */
.badge-con-critical   { background:#fef2f2; color:#dc2626; border:1px solid #fecaca;   padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; white-space:nowrap; display:inline-block; }
.badge-con-warning    { background:#fffbeb; color:#d97706; border:1px solid #fde68a;   padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; white-space:nowrap; display:inline-block; }
.badge-con-active     { background:#f0fdf4; color:#16a34a; border:1px solid #bbf7d0;   padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; white-space:nowrap; display:inline-block; }
.badge-con-indefinite { background:#eff6ff; color:#2563eb; border:1px solid #bfdbfe;   padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; white-space:nowrap; display:inline-block; }
.badge-con-expired    { background:#fdf4ff; color:#9333ea; border:1px solid #e9d5ff;   padding:3px 10px; border-radius:20px; font-size:12px; font-weight:600; white-space:nowrap; display:inline-block; }

@media (max-width: 1024px) { .con-stat-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .con-stat-row { grid-template-columns: repeat(2, 1fr); } }

/* AI Analysis Section */
.ai-container {
    max-width: 1200px;
    margin: 0 auto;
}

.ai-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, var(--primary-color), var(--purple-color));
    border-radius: 12px;
    color: white;
}

.ai-header i {
    font-size: 48px;
    margin-bottom: 15px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.ai-header h2 {
    font-size: 28px;
    margin-bottom: 10px;
}

.ai-header p {
    font-size: 16px;
    opacity: 0.9;
}

.ai-input-section {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.input-group {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

#ai-query {
    flex: 1;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

#ai-query:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-analyze {
    padding: 15px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    transition: all 0.3s;
}

.btn-analyze:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-analyze:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.ai-loading {
    text-align: center;
    padding: 50px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ai-loading p {
    color: var(--text-secondary);
    font-size: 16px;
}

.ai-results {
    display: grid;
    gap: 25px;
    margin-bottom: 25px;
}

.ai-insights {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-insights h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 20px;
}

.ai-insights h3 i {
    color: var(--orange-color);
}

#ai-insights-text {
    line-height: 1.8;
    color: var(--text-primary);
}

#ai-insights-text h3,
#ai-insights-text h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--orange-color);
    margin: 14px 0 6px;
}

#ai-insights-text strong {
    font-weight: 700;
    color: var(--text-primary);
}

#ai-insights-text p {
    margin-bottom: 12px;
}

#ai-insights-text ul,
#ai-insights-text ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

#ai-insights-text li {
    margin-bottom: 8px;
}

#ai-insights-text code {
    background: rgba(0,0,0,0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.88em;
}

.ai-chart-container {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-chart-container h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 20px;
}

.ai-chart-container h3 i {
    color: var(--secondary-color);
}

#aiChart {
    max-height: 400px;
}

.ai-examples {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.ai-examples h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 18px;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.example-chip {
    padding: 10px 20px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.example-chip:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
}

.mobile-menu-toggle:hover {
    background: #1d4ed8;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive Design */

/* Tablet View */
@media (max-width: 1024px) {
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .charts-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile View */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 80px 20px 20px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .header-right {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }
    
    .date-display,
    .btn-refresh {
        width: 100%;
        justify-content: center;
    }
    
    .stats-cards {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .charts-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .chart-card {
        /* Let height be driven by content, not a fixed value */
        height: auto;
        min-height: 280px;
    }

    .chart-container {
        height: 260px;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .btn-analyze {
        width: 100%;
        justify-content: center;
    }
    
    /* Table responsive */
    .table-container {
        overflow-x: auto;
    }
    
    .data-table {
        min-width: 600px;
    }
    
    /* Employee list responsive */
    .employee-grid {
        grid-template-columns: 1fr;
    }
}

/* Small Mobile View */
@media (max-width: 480px) {
    .main-content {
        padding: 70px 10px 10px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .subtitle {
        font-size: 12px;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .stat-card h3 {
        font-size: 20px;
    }
    
    .stat-card p {
        font-size: 12px;
    }
    
    .chart-card {
        padding: 15px;
        height: auto;
        min-height: 240px;
    }
    
    .chart-card h3 {
        font-size: 14px;
        margin-bottom: 10px;
    }
    
    .btn-refresh,
    .btn-analyze {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px;
    }
}
