/* ============================================================
   MAINTENANCE FLOTTE YUTONG — Design System
   Thème moderne : indigo/violet, surfaces douces, ombres subtiles
   ============================================================ */

:root {
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-200: #c7d2fe;
    --brand-300: #a5b4fc;
    --brand-400: #818cf8;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;
    --violet-500: #8b5cf6;
    --violet-600: #7c3aed;

    --ink-900: #0f172a;
    --ink-800: #1e293b;
    --ink-700: #334155;
    --ink-600: #475569;
    --ink-500: #64748b;
    --ink-400: #94a3b8;
    --ink-300: #cbd5e1;
    --ink-200: #e2e8f0;
    --ink-100: #f1f5f9;
    --ink-50:  #f8fafc;

    --success: #10b981;
    --success-soft: #d1fae5;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --danger:  #ef4444;
    --danger-soft: #fee2e2;
    --info:    #0ea5e9;
    --info-soft: #e0f2fe;

    --bg: #f4f6fb;
    --surface: #ffffff;
    --sidebar-from: #111827;
    --sidebar-to: #1e1b4b;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 4px 16px rgba(15, 23, 42, .07);
    --shadow-md: 0 10px 28px rgba(15, 23, 42, .10);
    --shadow-lg: 0 22px 48px rgba(15, 23, 42, .14);

    --sidebar-w: 268px;
    --chart-h: 236px;
    --ease: cubic-bezier(.4, 0, .2, 1);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Inter', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink-800);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(170deg, var(--sidebar-from) 0%, var(--sidebar-to) 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: transform .3s var(--ease);
}

.sidebar::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(560px 220px at -10% 0%, rgba(99, 102, 241, .28), transparent 60%),
        radial-gradient(420px 240px at 110% 100%, rgba(139, 92, 246, .22), transparent 60%);
    pointer-events: none;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 24px 22px 20px;
    position: relative;
    z-index: 1;
}

.brand-mark {
    width: 44px; height: 44px;
    flex: 0 0 44px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--brand-500), var(--violet-600));
    display: grid; place-items: center;
    font-size: 22px;
    box-shadow: 0 8px 20px rgba(99, 102, 241, .45);
}

.brand-text h1 { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .2px; }
.brand-text span { font-size: 11.5px; color: #94a3b8; letter-spacing: .4px; text-transform: uppercase; }

.sidebar__section {
    padding: 6px 16px 8px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #64748b;
    position: relative; z-index: 1;
}

.sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 14px 20px;
    position: relative; z-index: 1;
}

.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .28); border-radius: 99px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    position: relative;
    transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}

.nav-item svg { width: 19px; height: 19px; flex: 0 0 19px; opacity: .8; transition: opacity .18s var(--ease); }

.nav-item:hover { background: rgba(148, 163, 184, .12); color: #fff; transform: translateX(2px); }
.nav-item:hover svg { opacity: 1; }

.nav-item.is-active {
    background: linear-gradient(90deg, rgba(99, 102, 241, .95), rgba(139, 92, 246, .85));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 22px rgba(79, 70, 229, .38);
}
.nav-item.is-active svg { opacity: 1; }

.nav-item__badge {
    margin-left: auto;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
}
.nav-item.is-active .nav-item__badge { background: rgba(255, 255, 255, .3); }

.sidebar__footer {
    position: relative; z-index: 1;
    padding: 14px;
    margin: 0 14px 18px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .08);
    display: flex; align-items: center; gap: 11px;
}

.avatar {
    width: 38px; height: 38px; flex: 0 0 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-400), var(--violet-500));
    display: grid; place-items: center;
    font-weight: 700; font-size: 14px; color: #fff;
}

.sidebar__footer .who { min-width: 0; }
.sidebar__footer .who strong { display: block; font-size: 13px; color: #fff; }
.sidebar__footer .who span { font-size: 11.5px; color: #94a3b8; }

/* ---------- Main ---------- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--ink-200);
    padding: 15px 30px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.topbar__burger {
    display: none;
    width: 42px; height: 42px;
    border-radius: 12px;
    border: 1px solid var(--ink-200);
    background: #fff;
    cursor: pointer;
    font-size: 18px;
    color: var(--ink-700);
}

.topbar__heading { min-width: 0; }
.breadcrumb { font-size: 12px; color: var(--ink-400); display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.breadcrumb strong { color: var(--brand-600); font-weight: 600; }
.topbar__heading h2 { font-size: 20px; font-weight: 700; color: var(--ink-900); letter-spacing: -.3px; }

.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.search-box {
    display: flex; align-items: center; gap: 9px;
    background: var(--ink-100);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 9px 14px;
    width: 260px;
    transition: border-color .18s var(--ease), background .18s var(--ease);
}
.search-box:focus-within { background: #fff; border-color: var(--brand-300); box-shadow: 0 0 0 4px var(--brand-50); }
.search-box input { border: none; background: transparent; outline: none; font-size: 13.5px; width: 100%; color: var(--ink-800); }
.search-box svg { width: 17px; height: 17px; color: var(--ink-400); flex: 0 0 17px; }

.icon-btn {
    width: 42px; height: 42px;
    border-radius: 12px;
    border: 1px solid var(--ink-200);
    background: #fff;
    display: grid; place-items: center;
    cursor: pointer;
    position: relative;
    color: var(--ink-600);
    transition: all .18s var(--ease);
}
.icon-btn:hover { color: var(--brand-600); border-color: var(--brand-200); box-shadow: var(--shadow-sm); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot {
    position: absolute; top: 9px; right: 10px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px #fff;
}

.content { padding: 26px 30px 46px; flex: 1 1 auto; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .22s var(--ease), transform .22s var(--ease), border-color .22s var(--ease);
}
.card--pad { padding: 22px; }
.card--hover:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: var(--brand-200); }

.card__head {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--ink-100);
}
.card__head h3 { font-size: 15.5px; font-weight: 700; color: var(--ink-900); }
.card__head p { font-size: 12.5px; color: var(--ink-500); }
.card__head .spacer { margin-left: auto; }

.card__body { padding: 20px 22px; }

/* ============================================================
   GRIDS
   ============================================================ */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(232px, 1fr)); }
/* Variante compacte : simples compteurs (pages de liste) affichés 2 par ligne sur mobile */
.grid-kpi--compact { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.stack-18 { display: grid; gap: 18px; }
.mb-18 { margin-bottom: 18px; }
.mb-26 { margin-bottom: 26px; }

.dash-layout {
    display: grid;
    grid-template-columns: 1.55fr 1fr;
    gap: 18px;
}

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi {
    position: relative;
    overflow: hidden;
    padding: 20px 20px 18px;
    background: var(--surface);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--brand-200); }

.kpi::before {
    content: '';
    position: absolute;
    top: -46px; right: -46px;
    width: 128px; height: 128px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-100), transparent 70%);
    opacity: .75;
    transition: transform .35s var(--ease);
}
.kpi:hover::before { transform: scale(1.18); }

.kpi__top { display: flex; align-items: flex-start; gap: 12px; position: relative; z-index: 1; }

.kpi__icon {
    width: 46px; height: 46px; flex: 0 0 46px;
    border-radius: 14px;
    display: grid; place-items: center;
    background: var(--brand-50);
    color: var(--brand-600);
}
.kpi__icon svg { width: 22px; height: 22px; }
.kpi__icon.green  { background: var(--success-soft); color: #047857; }
.kpi__icon.amber  { background: var(--warning-soft); color: #b45309; }
.kpi__icon.red    { background: var(--danger-soft);  color: #b91c1c; }
.kpi__icon.sky    { background: var(--info-soft);    color: #0369a1; }
.kpi__icon.violet { background: #ede9fe;             color: #6d28d9; }

.kpi__label { font-size: 12.5px; font-weight: 600; color: var(--ink-500); text-transform: uppercase; letter-spacing: .5px; }

.kpi__value {
    font-size: 30px;
    font-weight: 800;
    color: var(--ink-900);
    letter-spacing: -1px;
    line-height: 1.15;
    margin-top: 6px;
    position: relative; z-index: 1;
    display: flex; align-items: baseline; gap: 4px;
}
.kpi__value small { font-size: 15px; font-weight: 600; color: var(--ink-400); letter-spacing: 0; }

.kpi__foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; position: relative; z-index: 1; }
.kpi__hint { font-size: 12px; color: var(--ink-400); }

.trend {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 12px; font-weight: 700;
    padding: 3px 8px; border-radius: 99px;
}
.trend.up   { background: var(--success-soft); color: #047857; }
.trend.down { background: var(--danger-soft);  color: #b91c1c; }
.trend.flat { background: var(--ink-100);      color: var(--ink-500); }

/* ============================================================
   GAUGE / DONUT
   ============================================================ */
.donut-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }

.donut {
    --pct: 0;
    width: 178px; height: 178px; flex: 0 0 178px;
    border-radius: 50%;
    position: relative;
    background: conic-gradient(var(--ink-200) 0deg, var(--ink-200) 360deg);
    transition: background .8s var(--ease);
}
.donut::after {
    content: '';
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: inset 0 2px 8px rgba(15, 23, 42, .06);
}
.donut__center {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    text-align: center;
    z-index: 1;
}
.donut__center b { display: block; font-size: 28px; font-weight: 800; color: var(--ink-900); letter-spacing: -1px; }
.donut__center span { font-size: 11.5px; color: var(--ink-500); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }

.legend { display: grid; gap: 11px; flex: 1 1 180px; min-width: 180px; }
.legend__row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend__dot { width: 11px; height: 11px; border-radius: 4px; flex: 0 0 11px; }
.legend__row .lbl { color: var(--ink-600); }
.legend__row .val { margin-left: auto; font-weight: 700; color: var(--ink-900); font-variant-numeric: tabular-nums; }

/* ---------- Radial gauge ---------- */
.gauge { display: grid; place-items: center; position: relative; }
.gauge svg { transform: rotate(-90deg); }
.gauge__track { fill: none; stroke: var(--ink-100); stroke-width: 14; }
.gauge__value {
    fill: none;
    stroke: url(#gaugeGradient);
    stroke-width: 14;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s var(--ease);
}
.gauge__center { position: absolute; text-align: center; }
.gauge__center b { font-size: 34px; font-weight: 800; color: var(--ink-900); letter-spacing: -1.5px; display: block; }
.gauge__center span { font-size: 12px; color: var(--ink-500); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }

/* ============================================================
   BARS
   ============================================================ */
.bars { display: grid; gap: 15px; }
.bar-row__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.bar-row__top .name { color: var(--ink-700); font-weight: 600; }
.bar-row__top .num { color: var(--ink-500); font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-track { height: 9px; border-radius: 99px; background: var(--ink-100); overflow: hidden; }
.bar-fill {
    height: 100%;
    border-radius: 99px;
    width: 0;
    background: linear-gradient(90deg, var(--brand-500), var(--violet-500));
    transition: width 1s var(--ease);
}
.bar-fill.green  { background: linear-gradient(90deg, #34d399, #10b981); }
.bar-fill.amber  { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-fill.red    { background: linear-gradient(90deg, #f87171, #ef4444); }
.bar-fill.sky    { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }

/* ============================================================
   AREA / LINE CHART
   Le graphique (SVG) ne contient que des tracés : les repères
   chiffrés sont en HTML, donc parfaitement nets quelle que soit
   la largeur de l'écran (aucune déformation du texte).
   ============================================================ */
.chart-row { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: stretch; }
.chart-scale { position: relative; height: var(--chart-h, 236px); }
.chart-scale span {
    position: absolute;
    right: 9px;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-400);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.chart-plot { position: relative; min-width: 0; }
.chart-area { width: 100%; height: var(--chart-h, 236px); display: block; overflow: visible; }
.chart-area .grid-line { stroke: var(--ink-100); stroke-width: 1; }
.chart-area .series-line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; transition: stroke-dashoffset 1.3s var(--ease); }
.chart-area .series-line.l1 { stroke: var(--brand-500); }
.chart-area .series-line.l2 { stroke: var(--success); }
.chart-area .series-dot { stroke: #fff; stroke-width: 2.5; }
.chart-area .series-area { opacity: .16; }

.chart-months {
    display: flex;
    justify-content: space-between;
    margin: 9px 2px 0 30px;
}
.chart-months span { font-size: 11.5px; font-weight: 700; color: var(--ink-400); }

.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.chart-legend .li { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-600); font-weight: 600; }
.chart-legend .sw { width: 14px; height: 4px; border-radius: 99px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    position: relative;
}
.table-wrap::-webkit-scrollbar { height: 9px; }
.table-wrap::-webkit-scrollbar-track { background: var(--ink-100); border-radius: 99px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 99px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

.table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-500);
    background: var(--ink-50);
    padding: 12px 16px;
    border-bottom: 1px solid var(--ink-200);
    white-space: nowrap;
}
.table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--ink-100); color: var(--ink-700); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .16s var(--ease); }
.table tbody tr:hover { background: var(--ink-50); }
.table .strong { font-weight: 700; color: var(--ink-900); }
.table .muted { color: var(--ink-400); font-size: 12.5px; }

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 11px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: .2px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge--plain::before { display: none; }

.badge.green   { background: var(--success-soft); color: #047857; }
.badge.amber   { background: var(--warning-soft); color: #b45309; }
.badge.red     { background: var(--danger-soft);  color: #b91c1c; }
.badge.sky     { background: var(--info-soft);    color: #0369a1; }
.badge.violet  { background: #ede9fe;             color: #6d28d9; }
.badge.slate   { background: var(--ink-100);      color: var(--ink-600); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 20px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .18s var(--ease);
    white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }

.btn--primary {
    background: linear-gradient(135deg, var(--brand-600), var(--violet-600));
    color: #fff;
    box-shadow: 0 8px 18px rgba(79, 70, 229, .3);
}
.btn--primary:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(79, 70, 229, .42); }

.btn--ghost { background: #fff; border-color: var(--ink-200); color: var(--ink-700); }
.btn--ghost:hover { border-color: var(--brand-300); color: var(--brand-600); box-shadow: var(--shadow-sm); }

.btn--sm { padding: 8px 14px; font-size: 12.5px; border-radius: 10px; }
.btn--icon { padding: 8px; width: 34px; height: 34px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Action links in tables ---------- */
.act { display: inline-flex; gap: 6px; }
.act a {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--ink-100);
    color: var(--ink-600);
    transition: all .16s var(--ease);
}
.act a:hover { background: var(--brand-600); color: #fff; transform: translateY(-2px); }
.act a svg { width: 15px; height: 15px; }

/* ============================================================
   ALERTS / FEED
   ============================================================ */
.feed { display: grid; gap: 12px; }
.feed__item {
    display: flex; gap: 13px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--ink-50);
    border: 1px solid var(--ink-100);
    border-left: 3px solid var(--ink-300);
    transition: all .18s var(--ease);
}
.feed__item:hover { background: #fff; box-shadow: var(--shadow-sm); }
.feed__item.warn { border-left-color: var(--warning); background: #fffbeb; }
.feed__item.crit { border-left-color: var(--danger);  background: #fef2f2; }
.feed__item.ok   { border-left-color: var(--success); background: #f0fdf4; }
.feed__item.info { border-left-color: var(--info);    background: #f0f9ff; }

.feed__icon {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: #fff;
    font-size: 17px;
    box-shadow: var(--shadow-xs);
}
.feed__body { min-width: 0; }
.feed__body strong { display: block; font-size: 13.5px; color: var(--ink-900); font-weight: 700; }
.feed__body p { font-size: 12.5px; color: var(--ink-500); }
.feed__time { margin-left: auto; font-size: 11.5px; color: var(--ink-400); white-space: nowrap; font-weight: 600; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty { text-align: center; padding: 54px 24px; }
.empty__icon {
    width: 74px; height: 74px;
    margin: 0 auto 16px;
    border-radius: 22px;
    background: var(--brand-50);
    display: grid; place-items: center;
    font-size: 32px;
}
.empty h3 { font-size: 16.5px; color: var(--ink-800); margin-bottom: 5px; }
.empty p { font-size: 13.5px; color: var(--ink-500); margin-bottom: 18px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-head {
    display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
    margin-bottom: 22px;
}
.page-head h1 { font-size: 24px; font-weight: 800; color: var(--ink-900); letter-spacing: -.5px; }
.page-head p { font-size: 13.5px; color: var(--ink-500); margin-top: 3px; }
.page-head .spacer { margin-left: auto; }

/* ============================================================
   MISC
   ============================================================ */
.avatar-chip { display: flex; align-items: center; gap: 9px; }
.avatar-chip .av {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-400), var(--violet-500));
    color: #fff; display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}

.meter { display: flex; align-items: center; gap: 10px; }
.meter .bar-track { flex: 1 1 auto; }

.divider { height: 1px; background: var(--ink-100); margin: 18px 0; }

.text-muted { color: var(--ink-500); }
.text-tiny { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.anim { animation: fadeUp .5s var(--ease) both; }
.d1 { animation-delay: .04s; }
.d2 { animation-delay: .08s; }
.d3 { animation-delay: .12s; }
.d4 { animation-delay: .16s; }
.d5 { animation-delay: .20s; }
.d6 { animation-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
    .anim, .kpi, .card, .module, .bar-fill, .gauge__value, .chart-area .series-line {
        animation: none !important;
        transition: none !important;
    }
}

.sidebar-scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 35;
    backdrop-filter: blur(2px);
    animation: fadeIn .2s var(--ease) both;
}
.sidebar-scrim.show { display: block; }

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

/* Empêche le défilement de l'arrière-plan quand le menu est ouvert */
body.nav-open { overflow: hidden; }

/* Confort tactile et anti-débordement horizontal */
img, svg { max-width: 100%; }
.table-wrap, .chart-plot, .feed__body { min-width: 0; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }

.field { display: grid; gap: 6px; }
.field > label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-700);
    letter-spacing: .2px;
}
.field > label .req { color: var(--danger); }

.input, .select, .textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--ink-200);
    border-radius: 11px;
    background: #fff;
    font-size: 13.8px;
    font-family: inherit;
    color: var(--ink-800);
    transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 17px; padding-right: 38px; }

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 4px var(--brand-50);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }

.field .hint { font-size: 11.5px; color: var(--ink-400); }
.field .error { font-size: 12px; color: var(--danger); font-weight: 600; }

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 20px;
    margin-top: 4px;
    border-top: 1px solid var(--ink-100);
}
.form-actions .spacer { margin-left: auto; }

.alert-error {
    background: var(--danger-soft);
    border: 1px solid #fecaca;
    border-left: 3px solid var(--danger);
    color: #991b1b;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 18px;
    font-size: 13px;
}
.alert-error ul { margin: 6px 0 0 18px; }

/* ---------- Fiche détail ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; }
.detail { display: grid; gap: 3px; }
.detail dt, .detail .k {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-400);
}
.detail dd, .detail .v { font-size: 14.5px; font-weight: 600; color: var(--ink-900); }

.reading { font-size: 14px; color: var(--ink-700); line-height: 1.7; }

/* ============================================================
   ICONES FONT AWESOME
   Les icônes héritent de la couleur du conteneur (currentColor)
   et de sa taille de police ; seuls quelques ajustements sont
   nécessaires pour garder les proportions d'origine.
   ============================================================ */
.kpi__icon { font-size: 20px; }
.kpi__icon i { line-height: 1; }

/* Les pastilles d'état colorées donnent du sens aux icônes des flux */
.feed__item.ok .feed__icon   { color: #047857; }
.feed__item.warn .feed__icon { color: #b45309; }
.feed__item.crit .feed__icon { color: #b91c1c; }
.feed__item.info .feed__icon { color: #0369a1; }

/* Icônes dans les boutons et les liens d'action */
.btn > i { font-size: 14px; line-height: 1; }
.btn--sm > i { font-size: 13px; }
.act a > i { font-size: 14px; }

/* Balisage sémantique : les icônes purement décoratives sont ignorées
   par les lecteurs d'écran, le texte du bouton porte le sens. */
.brand-mark i, .module__icon i, .empty__icon i, .feed__icon i, .kpi__icon i {
    pointer-events: none;
}

/* ============================================================
   SECTION TECHNIQUE — fiche de contrôle « MAINTENANCE SYSTEMATIQUE »
   ============================================================ */
.checklist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.checklist thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--ink-50);
    padding: 11px 14px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-500);
    border-bottom: 1px solid var(--ink-200);
    text-align: left;
}
.checklist th.col-status,
.checklist td.col-status { width: 148px; }
.checklist th.col-comment,
.checklist td.col-comment { width: 30%; }

/* En-tête de catégorie (I-, II-, III-…) */
.checklist tr.cat td {
    background: linear-gradient(90deg, var(--brand-600), var(--violet-600));
    color: #fff;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .3px;
    padding: 10px 14px;
    border-bottom: none;
}
/* Sous-rubrique (MECANIQUE, ELECTRICITE…) */
.checklist tr.sub td {
    background: var(--brand-50);
    color: var(--brand-700);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .7px;
    padding: 7px 14px 7px 30px;
    border-bottom: 1px solid var(--brand-100);
}
.checklist tbody td.item { padding: 7px 14px; border-bottom: 1px solid var(--ink-100); vertical-align: middle; }
.checklist tbody tr:hover td.item { background: var(--ink-50); }
.checklist .lbl { color: var(--ink-700); }
.checklist .num { color: var(--ink-400); font-size: 11.5px; font-weight: 700; margin-right: 7px; font-variant-numeric: tabular-nums; }

/* Choix OK / N OK */
.choice { display: inline-flex; gap: 6px; }
.choice label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 6px 10px;
    border: 1px solid var(--ink-200);
    border-radius: 9px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-500);
    cursor: pointer;
    transition: all .15s var(--ease);
    user-select: none;
}
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice label:hover { border-color: var(--brand-300); color: var(--brand-600); }
.choice label.ok:has(input:checked) {
    background: var(--success-soft);
    border-color: #6ee7b7;
    color: #047857;
}
.choice label.nok:has(input:checked) {
    background: var(--danger-soft);
    border-color: #fca5a5;
    color: #b91c1c;
}
.choice input:focus-visible + span { outline: 2px solid var(--brand-400); outline-offset: 2px; border-radius: 6px; }

.comment-input {
    width: 100%;
    padding: 7px 11px;
    border: 1px solid var(--ink-200);
    border-radius: 9px;
    font-size: 12.8px;
    font-family: inherit;
    color: var(--ink-800);
    background: #fff;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.comment-input:focus {
    outline: none;
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px var(--brand-50);
}
.comment-input.is-nok { border-color: #fca5a5; background: #fff7f7; }

/* Bandeau de progression collant */
.checklist-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 20px;
    margin-top: 18px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .93);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border: 1px solid var(--ink-200);
    box-shadow: 0 -6px 22px rgba(15, 23, 42, .09);
}
.checklist-bar .count { font-size: 13.5px; font-weight: 700; color: var(--ink-700); }
.checklist-bar .count b { font-variant-numeric: tabular-nums; }
.counter-ok { color: #047857; }
.counter-nok { color: #b91c1c; }

/* Repli par catégorie sur la fiche d'intervention */
.tsum {
    border: 1px solid var(--ink-200);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    background: #fff;
}
.tsum > summary {
    cursor: pointer;
    padding: 11px 14px;
    background: var(--ink-50);
    font-weight: 700;
    font-size: 13.5px;
    color: var(--ink-800);
    display: flex;
    align-items: center;
    gap: 10px;
    list-style: none;
    transition: background .16s var(--ease);
}
.tsum > summary::-webkit-details-marker { display: none; }
.tsum > summary:hover { background: var(--ink-100); }
.tsum > summary .sign { margin-left: auto; color: var(--ink-400); font-size: 12px; }
.tsum[open] > summary { border-bottom: 1px solid var(--ink-200); }
.tsum__body { padding: 2px 0; }
.tsum__sub {
    padding: 6px 14px 6px 22px;
    background: var(--brand-50);
    color: var(--brand-700);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .7px;
}
.tsum__row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border-bottom: 1px solid var(--ink-100);
    font-size: 13px;
}
.tsum__row:last-child { border-bottom: none; }
.tsum__row.is-nok { background: #fef2f2; }
.tsum__row .num { color: var(--ink-400); font-size: 11px; font-weight: 700; min-width: 22px; font-variant-numeric: tabular-nums; }
.tsum__row .lbl { flex: 1 1 auto; color: var(--ink-700); }
.tsum__row .cmt { color: var(--ink-500); font-size: 12px; font-style: italic; }

@media (max-width: 780px) {
    .checklist th.col-comment, .checklist td.col-comment { display: none; }
    .checklist th.col-status, .checklist td.col-status { width: 118px; }
    .choice label { min-width: 44px; padding: 6px 8px; }
    .tsum__row { flex-wrap: wrap; }
}

/* ============================================================
   RESPONSIVE
   Points de rupture : 1280 → 1080 → 900 → 780 → 640 → 480 → 380
   ============================================================ */

/* ---------- Grands écrans ---------- */
@media (min-width: 1600px) {
    .content { padding: 30px 40px 56px; }
    .grid-kpi { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ---------- Écrans intermédiaires ---------- */
@media (max-width: 1280px) {
    :root { --chart-h: 230px; }
    .dash-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Tablettes ---------- */
@media (max-width: 900px) {
    /* Menu latéral en tiroir */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: min(84vw, 300px);
        flex-basis: auto;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        transition: transform .28s var(--ease);
    }
    .sidebar.open { transform: translateX(0); }
    .topbar__burger { display: grid; place-items: center; flex: 0 0 42px; }

    /* Barre supérieure sur deux lignes : titre puis actions */
    .topbar { flex-wrap: wrap; row-gap: 12px; padding: 13px 18px; }
    .topbar__heading { flex: 1 1 auto; }
    .topbar__actions {
        order: 2;
        flex: 1 1 100%;
        margin-left: 0;
        gap: 8px;
    }
    .search-box { flex: 1 1 auto; width: auto; min-width: 0; }

    .content { padding: 20px 18px 44px; }

    /* Ombres de défilement : signalent qu'il reste des colonnes à découvrir.
       Technique « scroll shadows » 100 % CSS (aucun JS). Les dégradés
       « local » suivent le contenu et disparaissent une fois le bord atteint. */
    .table-wrap {
        background:
            linear-gradient(to right, var(--surface) 45%, rgba(255, 255, 255, 0)) left center,
            linear-gradient(to left, var(--surface) 45%, rgba(255, 255, 255, 0)) right center,
            radial-gradient(farthest-side at 0 50%, rgba(15, 23, 42, .18), rgba(15, 23, 42, 0)) left center,
            radial-gradient(farthest-side at 100% 50%, rgba(15, 23, 42, .18), rgba(15, 23, 42, 0)) right center;
        background-repeat: no-repeat;
        background-size: 26px 100%, 26px 100%, 14px 100%, 14px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    /* Colonne d'identification figée pour garder le contexte */
    .table-wrap .table th:first-child,
    .table-wrap .table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: var(--surface);
        box-shadow: 1px 0 0 var(--ink-100);
    }
    .table-wrap .table thead th:first-child { background: var(--ink-50); z-index: 3; }
    .table-wrap .table tbody tr:hover td:first-child { background: var(--ink-50); }
}

/* ---------- Petites tablettes / grandes mobiles ---------- */
@media (max-width: 780px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }

    .card--pad, .card__body { padding: 16px; }
    .card__head { padding: 15px 16px; }

    .page-head { align-items: flex-start; }
    .page-head h1 { font-size: 19px; }
    .page-head p { font-size: 12.5px; }

    .donut-wrap { justify-content: center; gap: 20px; }
    .donut { width: 150px; height: 150px; flex-basis: 150px; }
    .donut::after { inset: 19px; }
    .donut__center b { font-size: 23px; }

    .gauge svg { width: 128px; height: 128px; }
    .gauge__center b { font-size: 27px; }

    .feed__item { padding: 12px; gap: 11px; }
    .feed__time { font-size: 11px; }

    .form-actions { flex-direction: column-reverse; align-items: stretch; }
    .form-actions .spacer { display: none; }
    .form-actions .btn { width: 100%; }
}

/* ---------- Mobiles ---------- */
@media (max-width: 640px) {
    body { font-size: 14.5px; }

    .content { padding: 16px 14px 40px; }
    .topbar { padding: 11px 14px; }
    .topbar__heading h2 { font-size: 16.5px; }
    .breadcrumb { font-size: 11.5px; }

    /* Empêche le zoom automatique de Safari iOS lors du focus d'un champ
       (déclenché dès que la taille de police est inférieure à 16 px). */
    .input, .select, .textarea { font-size: 16px; }

    /* Cibles tactiles confortables : 40 px minimum recommandé */
    .act a { width: 38px; height: 38px; }
    .act a svg { width: 17px; height: 17px; }
    .icon-btn { width: 42px; height: 42px; }
    .btn--sm { padding: 11px 16px; }
    .nav-item { padding: 13px 13px; }

    .grid-4 { grid-template-columns: 1fr; }

    .kpi { padding: 16px; }
    .kpi__value { font-size: 24px; }
    .kpi__icon { width: 40px; height: 40px; flex-basis: 40px; border-radius: 12px; }
    .kpi__icon svg { width: 19px; height: 19px; }
    .kpi__label { font-size: 11.5px; }

    /* Compteurs simples : deux par ligne pour limiter le défilement */
    .grid-kpi--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .grid-kpi--compact .kpi { padding: 13px; }
    .grid-kpi--compact .kpi__top { gap: 9px; }
    .grid-kpi--compact .kpi__icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; }
    .grid-kpi--compact .kpi__value { font-size: 20px; }
    .grid-kpi--compact .kpi__value small { font-size: 12px; }
    .grid-kpi--compact .kpi__label { font-size: 10.5px; letter-spacing: .3px; }
    .grid-kpi--compact .kpi__foot { margin-top: 7px; }
    .grid-kpi--compact .kpi__hint { display: none; }

    .card { border-radius: 14px; }
    .card__head h3 { font-size: 14.5px; }
    .card__head p { font-size: 12px; }

    /* Graphique : repères réduits, points masqués (évite toute déformation) */
    .chart-row { grid-template-columns: 24px minmax(0, 1fr); }
    .chart-scale span { font-size: 10px; right: 7px; }
    .chart-months { margin-left: 24px; }
    .chart-months span { font-size: 10.5px; }
    .chart-area .series-dot { display: none; }

    /* Tableaux : défilement horizontal fluide */
    .table { min-width: 600px; font-size: 13px; }
    .table tbody td, .table thead th { padding: 11px 12px; }

    .btn-row { width: 100%; }
    .btn-row .btn { flex: 1 1 auto; }

    .badge { font-size: 11px; padding: 3px 9px; }
}

/* ---------- Très petits mobiles ---------- */
@media (max-width: 480px) {
    .content { padding: 14px 12px 36px; }

    .kpi__value { font-size: 22px; }
    .kpi__top { gap: 10px; }
    .kpi__icon { width: 36px; height: 36px; flex-basis: 36px; }
    .kpi__foot { flex-wrap: wrap; gap: 6px; }

    .table { min-width: 540px; }
    .table tbody td, .table thead th { padding: 10px 10px; }

    .page-head h1 { font-size: 17.5px; }
    .page-head .btn-row { width: 100%; }
    .page-head .btn { width: 100%; }

    .donut { width: 132px; height: 132px; flex-basis: 132px; }
    .donut__center b { font-size: 20px; }
    .donut__center span { font-size: 10px; }
    .legend__row { font-size: 12.5px; }

    .topbar__heading h2 { font-size: 15px; }
    .icon-btn { width: 38px; height: 38px; }
    .avatar-chip { display: none; }

    .feed__icon { width: 32px; height: 32px; flex-basis: 32px; font-size: 15px; }
}

/* ---------- Ultra compact ---------- */
@media (max-width: 380px) {
    .sidebar { width: 88vw; }
    .chart-months span { font-size: 9.5px; }
    .table { min-width: 500px; }
}

/* ---------- Hauteur réduite (paysage mobile) ---------- */
@media (max-height: 520px) and (max-width: 900px) {
    .sidebar__footer { display: none; }
}

/* ---------- Impression ---------- */
@media print {
    .sidebar, .topbar, .sidebar-scrim, .btn, .act, .chart-months { display: none !important; }
    .content { padding: 0; }
    .app-shell { display: block; }
    .card { box-shadow: none; border-color: #ddd; break-inside: avoid; }
    .kpi { box-shadow: none; border-color: #ddd; break-inside: avoid; }
    .chart-area { --chart-h: 200px; }
}
