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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f4f6f8;
    color: #333;
}

/* ─── HEADER ─────────────────────────────────────────── */
.header {
    background: #dff0e8;
    color: white;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-ministere {
    height: 52px;
    object-fit: contain;
}
.logo-tanwir {
    height: 46px;
    object-fit: contain;
}
.logo-divider {
    width: 1px;
    height: 44px;
    background: #8ab89a;
    flex-shrink: 0;
}
.header .subtitle {
    font-size: 16px;
    font-weight: 700;
    color: #1b6b3a;
    text-transform: uppercase;
    margin-top: 2px;
}
.header .nav-tabs {
    display: flex;
    gap: 6px;
}
.header .nav-tabs a {
    color: #1b6b3a;
    text-decoration: none;
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s;
}
.header .nav-tabs a:hover,
.header .nav-tabs a.active {
    background: #1b6b3a;
    color: white;
    font-weight: 600;
}
.header-datetime {
    font-size: 17px;
    font-weight: 700;
    color: #1b6b3a;
    white-space: nowrap;
    margin-left: 20px;
    letter-spacing: 0.5px;
}

/* ─── DATETIME WIDGET (index.php) ─────────────────────── */
.datetime-widget {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding-left: 0;
    flex-shrink: 0;
    margin-left: 20px;
}
.dw-time {
    font-size: 24px;
    font-weight: 800;
    color: #111;
    letter-spacing: 3px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.dw-time .dw-colon {
    color: #111;
    animation: dw-blink 1s step-end infinite;
}
@keyframes dw-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}
.dw-date {
    font-size: 10.5px;
    font-weight: 500;
    color: #555;
    text-transform: capitalize;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

/* ─── FILTERS BAR ─────────────────────────────────────── */
.filters-bar {
    background: white;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border-bottom: 1px solid #e8edf2;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* Badge "Filtres" */
.filters-label {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #1b6b3a;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}
.filters-label i { font-size: 12px; }

/* Chip filter */
.filter-chip {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid #d8e2ee;
    border-radius: 8px;
    padding: 8px 14px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    min-width: 150px;
    user-select: none;
}
.filter-chip:focus-within,
.filter-chip.active {
    border-color: #1b6b3a;
    box-shadow: 0 0 0 3px rgba(27,107,58,0.10);
    background: white;
}
.chip-icon {
    font-size: 13px;
    color: #1b6b3a;
    flex-shrink: 0;
}
.chip-label {
    flex: 1;
    font-size: 13px;
    color: #6b7a8d;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}
.chip-label.selected {
    color: #1b6b3a;
    font-weight: 600;
}
.chip-arrow {
    font-size: 10px;
    color: #9aa5b4;
    flex-shrink: 0;
    pointer-events: none;
    transition: transform 0.2s;
}
.filter-chip:focus-within .chip-arrow {
    transform: rotate(180deg);
}

/* Select invisible par-dessus le chip */
.chip-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    background: transparent;
    z-index: 3;
    font-size: 13px;
}

/* Input date : caché, activé via showPicker() */
.chip-date-hidden {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    pointer-events: none;
    border: none;
    padding: 0;
}

/* Bouton reset */
.filters-bar .btn-reset {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #6b7a8d;
    border: 1.5px solid #d8e2ee;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.filters-bar .btn-reset:hover {
    border-color: #1b6b3a;
    color: #1b6b3a;
    background: #f0f7f2;
}
.btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: #c0392b;
    border: 1.5px solid #e8c4c0;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-pdf:hover {
    border-color: #c0392b;
    background: #fdf3f2;
}
.btn-pdf:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── MAIN CONTENT ────────────────────────────────────── */
.dashboard {
    padding: 20px 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ─── KPI CARDS ───────────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    border: 1px solid #e8eeea;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
}
.kpi-icon-wrap {
    background: #e2e6e9;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    flex-shrink: 0;
    min-width: 58px;
}
.kpi-icon {
    font-size: 24px;
    color: #1b6b3a;
    opacity: 0.85;
}
.kpi-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 14px 12px;
}
.kpi-value {
    font-size: 28px;
    font-weight: 800;
    color: #1a2340;
    line-height: 1;
}
.kpi-primary-label {
    font-size: 10px;
    font-weight: 700;
    color: #2d3a2e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 3px;
}
.kpi-secondary-label {
    font-size: 10px;
    color: #7aaa90;
    line-height: 1.3;
}

/* ─── CHARTS GRID ─────────────────────────────────────── */
.charts-row-1 {
    display: grid;
    grid-template-columns: 1fr 1fr 0.7fr;
    gap: 16px;
    margin-bottom: 16px;
}
.charts-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.chart-card {
    background: white;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.chart-card .chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.chart-card .chart-title {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-card .chart-title i {
    font-size: 15px;
    color: #1b6b3a;
    opacity: 0.85;
}
.chart-card .chart-badge {
    background: #e8f5ed;
    color: #1b6b3a;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}
.chart-card canvas {
    max-height: 260px;
}
.chart-card.donut-card canvas {
    max-height: 240px;
}
.donut-card .chart-header {
    flex-wrap: nowrap;
    gap: 8px;
}
.donut-card .chart-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex-shrink: 1;
    font-size: 13px;
}

/* ─── CHART-LEVEL FILTER CHIP ─────────────────────────── */
.chart-filter-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1.5px solid #d8e2ee;
    border-radius: 8px;
    padding: 5px 30px 5px 11px;
    background: #f8fafc;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    flex-shrink: 0;
}
.chart-filter-chip:focus-within {
    border-color: #1b6b3a;
    box-shadow: 0 0 0 3px rgba(27,107,58,0.10);
    background: white;
}
.chart-filter-chip .chip-icon {
    font-size: 12px;
    color: #1b6b3a;
    flex-shrink: 0;
}
.chart-filter-chip .chip-arrow {
    position: absolute;
    right: 10px;
    font-size: 10px;
    color: #9aa5b4;
    pointer-events: none;
    transition: transform 0.2s;
}
.chart-filter-chip:focus-within .chip-arrow {
    transform: rotate(180deg);
    color: #1b6b3a;
}
.chart-filter-select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    font-size: 12px;
    color: #1b6b3a;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-family: inherit;
    max-width: 170px;
}
.chart-filter-select option {
    color: #333;
    font-weight: 400;
}

/* ─── LOADING ─────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 13px;
}

/* ─── KPI CLIQUABLE ───────────────────────────────────── */
.kpi-clickable {
    cursor: pointer;
}
.kpi-clickable:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(27,107,58,0.15);
    border-color: #1b6b3a;
}

/* ─── CHART CLIQUABLE ─────────────────────────────────── */
.chart-clickable {
    cursor: pointer;
    transition: box-shadow .2s, transform .2s;
}
.chart-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(27,107,58,0.15);
}

/* ─── EXPORT EXCEL ────────────────────────────────────── */
.btn-export {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #1b6b3a;
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    opacity: .85;
    transition: opacity .15s;
    flex-shrink: 0;
}
.btn-export:hover { opacity: 1; }
.btn-export-chart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #1b6b3a;
    font-size: 14px;
    cursor: pointer;
    padding: 0 2px;
    opacity: .85;
    transition: opacity .15s;
}
.btn-export-chart:hover { opacity: 1; }

/* ─── MODAL ───────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-container {
    background: white;
    border-radius: 14px;
    width: 92%;
    max-width: 1080px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 70px rgba(0,0,0,0.25);
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid #e8edf2;
    flex-shrink: 0;
    gap: 16px;
}
.modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    color: #1a2340;
}
.modal-title i { color: #1b6b3a; font-size: 17px; }
.modal-count-badge {
    background: #e8f5ed;
    color: #1b6b3a;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
}
.modal-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.modal-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1.5px solid #d8e2ee;
    border-radius: 8px;
    padding: 6px 12px;
    background: #f8fafc;
    transition: border-color 0.2s;
}
.modal-search-wrap:focus-within {
    border-color: #1b6b3a;
    background: white;
    box-shadow: 0 0 0 3px rgba(27,107,58,0.08);
}
.modal-search-wrap i { color: #9aa5b4; font-size: 12px; }
.modal-search-input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: #333;
    outline: none;
    width: 200px;
    font-family: inherit;
}
.modal-close-btn {
    background: transparent;
    border: 1.5px solid #d8e2ee;
    border-radius: 8px;
    padding: 7px 11px;
    cursor: pointer;
    color: #6b7a8d;
    font-size: 13px;
    transition: all 0.2s;
}
.modal-close-btn:hover {
    border-color: #e05050;
    color: #e05050;
    background: #fff5f5;
}
.modal-body {
    overflow-y: auto;
    flex: 1;
}
.modal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.modal-table thead th {
    background: #f4f6f8;
    color: #1a2340;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 11px 16px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 2px solid #e8edf2;
    white-space: nowrap;
}
.modal-table tbody tr {
    border-bottom: 1px solid #f0f4f8;
    transition: background 0.12s;
}
.modal-table tbody tr:hover { background: #f8fafc; }
.modal-table tbody td {
    padding: 9px 16px;
    color: #444;
    vertical-align: middle;
}
.modal-table .td-matricule {
    font-family: monospace;
    font-size: 12px;
    color: #1b6b3a;
    font-weight: 600;
}
.modal-table .td-profile a {
    color: #1b6b3a;
    font-size: 15px;
    text-decoration: none;
    transition: color 0.2s;
}
.modal-table .td-profile a:hover { color: #f0c040; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 22px;
    border-top: 1px solid #e8edf2;
    flex-shrink: 0;
}
.modal-info {
    font-size: 12px;
    color: #6b7a8d;
}
.modal-pagination {
    display: flex;
    gap: 5px;
    align-items: center;
}
.modal-page-btn {
    border: 1.5px solid #d8e2ee;
    background: white;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #444;
    transition: all 0.15s;
    font-family: inherit;
}
.modal-page-btn:hover,
.modal-page-btn.active {
    border-color: #1b6b3a;
    color: #1b6b3a;
    background: #f0f7f2;
    font-weight: 700;
}
.modal-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ─── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 1200px) {
    .kpi-row { grid-template-columns: repeat(4, 1fr); }
    .charts-row-1 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .charts-row-1, .charts-row-2 { grid-template-columns: 1fr; }
    .header .nav-tabs { display: none; }
}
