*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --sidebar-w: 240px;
    --blue: #1d6fa4;
    --blue-dark: #154e74;
    --blue-light: #e8f4fd;
    --green: #22a06b;
    --orange: #d97706;
    --red: #dc2626;
    --red-light: #fef2f2;
    --yellow: #ca8a04;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-400: #94a3b8;
    --gray-600: #475569;
    --gray-800: #1e293b;
    --sidebar-bg: #0f1c2e;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, .07), 0 2px 4px rgba(0, 0, 0, .06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, .1), 0 4px 6px rgba(0, 0, 0, .05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
}

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.sidebar-logo .logo-icon svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.sidebar-logo h1 {
    color: white;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.2px;
}

.sidebar-logo p {
    color: rgba(255, 255, 255, .4);
    font-size: 11px;
    margin-top: 2px;
}

nav {
    padding: 12px 12px;
    flex: 1;
}

nav .nav-section {
    color: rgba(255, 255, 255, .3);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .8px;
    text-transform: uppercase;
    padding: 12px 8px 6px;
}

nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 7px;
    color: rgba(255, 255, 255, .6);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    margin-bottom: 2px;
}

nav a svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

nav a:hover {
    background: rgba(255, 255, 255, .07);
    color: white;
}

nav a.active {
    background: var(--blue);
    color: white;
}

nav a .badge {
    margin-left: auto;
    background: var(--red);
    color: white;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    color: rgba(255, 255, 255, .3);
    font-size: 11px;
}

/* ── Main ── */
#main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--gray-800);
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-primary {
    background: var(--blue);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .15s;
}

.btn-primary:hover {
    background: var(--blue-dark);
}

.btn-secondary {
    background: white;
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.content {
    padding: 28px;
    flex: 1;
}

/* ── Section visibility ── */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* ── Cards KPI ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border: 1px solid var(--gray-200);
    cursor: pointer;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg {
    width: 22px;
    height: 22px;
}

.kpi-icon.blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.kpi-icon.green {
    background: #dcfce7;
    color: var(--green);
}

.kpi-icon.orange {
    background: #fef3c7;
    color: var(--orange);
}

.kpi-icon.red {
    background: #fee2e2;
    color: var(--red);
}

.kpi-icon svg {
    fill: currentColor;
}

.kpi-data .kpi-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    color: var(--gray-800);
}

.kpi-data .kpi-label {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.kpi-data .kpi-sub {
    font-size: 12px;
    color: var(--gray-600);
    margin-top: 6px;
}

/* ── Dashboard grid ── */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Cards ── */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 0;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-400);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
    font-size: 13.5px;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--gray-50);
}

.actions {
    display: flex;
    gap: 6px;
}

.btn-icon {
    width: 30px;
    height: 30px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: all .15s;
}

.btn-icon:hover {
    background: var(--gray-100);
    border-color: var(--gray-400);
}

.btn-icon.danger:hover {
    background: var(--red-light);
    border-color: #fca5a5;
    color: var(--red);
}

.btn-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge.actif {
    background: #dcfce7;
    color: #16a34a;
}

.badge.maintenance {
    background: #fef3c7;
    color: #b45309;
}

.badge.hors_service {
    background: #fee2e2;
    color: #dc2626;
}

.badge.reserve {
    background: #f1f5f9;
    color: #475569;
}

.badge.ouvert {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.en_cours {
    background: #fef3c7;
    color: #b45309;
}

.badge.en_attente {
    background: #f3e8ff;
    color: #7c3aed;
}

.badge.termine {
    background: #dcfce7;
    color: #16a34a;
}

.badge.annule {
    background: #f1f5f9;
    color: #64748b;
}

.prio {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
}

.prio.urgente {
    color: #dc2626;
}

.prio.haute {
    color: #d97706;
}

.prio.normale {
    color: #2563eb;
}

.prio.basse {
    color: #64748b;
}

.prio-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.prio.urgente .prio-dot {
    background: #dc2626;
}

.prio.haute .prio-dot {
    background: #d97706;
}

.prio.normale .prio-dot {
    background: #2563eb;
}

.prio.basse .prio-dot {
    background: #94a3b8;
}

/* ── Filter bar ── */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    align-items: center;
}

.filter-bar input,
.filter-bar select {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 7px 12px;
    font-size: 13px;
    background: white;
    color: var(--gray-800);
    outline: none;
    transition: border .15s;
}

.filter-bar input:focus,
.filter-bar select:focus {
    border-color: var(--blue);
}

.filter-bar input {
    width: 220px;
}

/* ── Techniciens cards ── */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.tech-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.tech-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 12px;
}

.tech-card h4 {
    font-size: 14px;
    font-weight: 700;
}

.tech-card p {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 2px;
}

.tech-card .tech-info {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tech-card .tech-info span {
    font-size: 12px;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tech-card .tech-info svg {
    width: 12px;
    height: 12px;
    fill: var(--gray-400);
    flex-shrink: 0;
}

.tech-card .tech-actions {
    margin-top: 14px;
    display: flex;
    gap: 8px;
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal-box {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .18s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(.97);
    }
}

.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--gray-100);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    font-size: 16px;
    transition: background .15s;
}

.modal-close:hover {
    background: var(--gray-200);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Form ── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-grid .full {
    grid-column: 1/-1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
}

.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid var(--gray-200);
    border-radius: 7px;
    padding: 9px 11px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--gray-800);
    background: white;
    outline: none;
    transition: border .15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29, 111, 164, .1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* ── Toast ── */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-item {
    background: var(--gray-800);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn .2s ease;
    max-width: 320px;
}

.toast-item.success {
    background: #065f46;
}

.toast-item.error {
    background: #7f1d1d;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* ── Empty state ── */
.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-400);
}

.empty svg {
    width: 48px;
    height: 48px;
    fill: var(--gray-200);
    margin-bottom: 12px;
}

.empty p {
    font-size: 14px;
}

/* ── Planification upcoming ── */
.plan-soon {
    color: var(--red);
    font-weight: 600;
}

.plan-week {
    color: var(--orange);
    font-weight: 600;
}

.plan-ok {
    color: var(--green);
}

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--gray-800);
}

.page-header p {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 2px;
}