/* Import de la police Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
    /* Palette Tesla Light Mode */
    --bg: #ffffff;
    --bg-sidebar: #e0e2e4;
    --bg-panel: #e0e2e4;
    --bg-panel-raised: #d2d5d8;
    --border: #cdd0d4;
    /* Typographie */
    --text: #171a20;
    --text-dim: #5c5e62;
    --text-faint: #8e9094;
    /* Couleurs de statut */
    --red: #E82127;
    --red-soft: rgba(232, 33, 39, 0.15);
    --accent: #3E6AE1;
    --accent-soft: rgba(62, 106, 225, 0.15);
    --cyan: #5c5e62;
    --cyan-soft: rgba(92, 94, 98, 0.15);
    --green: #34a853;
    --green-soft: rgba(52, 168, 83, 0.15);
    --amber: #f2a900;
    --amber-soft: rgba(242, 169, 0, 0.15);
    --radius: 4px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.mono {
    font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    letter-spacing: 0.5px;
}

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

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

/* ---------- Sidebar ---------- */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 30px 24px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 32px; height: 32px;
    background: var(--red);
    color: #ffffff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    letter-spacing: 1px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 14px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase;}
.brand-text span { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 20px 10px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all .2s ease;
}
.sidebar-nav a:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.sidebar-nav a.active {
    color: var(--text);
    background: rgba(0,0,0,0.05);
    border-left: 3px solid var(--red);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.nav-icon { width: 18px; text-align: center; font-size: 14px; opacity: 0.9; }

.sidebar-footer { padding: 20px; border-top: 1px solid var(--border); }
.centre-chip { display: flex; align-items: center; gap: 12px; }
.centre-chip strong { display: block; font-size: 13px; font-weight: 600; }
.centre-chip span { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px;}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-live { background: var(--green); box-shadow: 0 0 0 2px var(--green-soft); }
.dot-down { background: var(--red); box-shadow: 0 0 0 2px var(--red-soft); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; padding: 40px 50px 60px; }

.flash {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.flash-success { background: var(--green-soft); color: #1e7e34; border: 1px solid rgba(52,168,83,0.2); }
.flash-error { background: var(--red-soft); color: var(--red); border: 1px solid rgba(232,33,39,0.2); }
.flash-info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,106,225,0.2); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; flex-wrap: wrap; gap: 15px; }
.page-head h1 { font-size: 26px; font-weight: 500; letter-spacing: 0.5px; margin: 0 0 8px; }
.page-head p { margin: 0; color: var(--text-dim); font-size: 13px; letter-spacing: 0.5px; }
.page-head-actions { display: flex; gap: 12px; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 35px; }
.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card:hover { border-color: var(--text-dim); box-shadow: 0 4px 8px rgba(0,0,0,0.05); }
.kpi-card .kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 12px; font-weight: 700; }
.kpi-card .kpi-value { font-size: 32px; font-weight: 400; line-height: 1; color: var(--text); }
.kpi-card .kpi-value small { font-size: 14px; color: var(--text-faint); font-weight: 500; }
.kpi-card .kpi-sub { margin-top: 12px; font-size: 11px; color: var(--text-dim); letter-spacing: 0.5px;}
.kpi-card.kpi-alert .kpi-value { color: var(--red); }
.kpi-card.kpi-warn .kpi-value { color: var(--accent); }
.kpi-card.kpi-good .kpi-value { color: #1e7e34; }

/* ---------- Panels & tables ---------- */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    width: 100%;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid var(--border); background: var(--bg-panel-raised); gap: 12px; flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin: 0; }
.panel-head .link { font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; transition: color 0.2s; }
.panel-head .link:hover { color: #2A4DB0; }
.panel-body { padding: 0; }
.panel-body.padded { padding: 24px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left; padding: 14px 24px; font-size: 10px; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-dim); font-weight: 700; border-bottom: 1px solid var(--border);
    background: var(--bg-panel-raised);
}
tbody td { padding: 16px 24px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background 0.15s ease; }
tbody tr.clickable:hover { background: var(--bg-panel-raised); }

/* ---------- Barre "Voir plus" ---------- */
.load-more-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-panel-raised);
    border-top: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}
.load-more-info { font-size: 11.5px; color: var(--text-dim); letter-spacing: 0.3px; }
.load-more-info strong { color: var(--text); font-weight: 700; }
.load-more-actions { display: flex; gap: 8px; align-items: center; }

.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--border); border: 1px solid #c0c0c0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: var(--text); margin-right: 12px; flex-shrink: 0;
    letter-spacing: 1px;
}
.cell-person { display: flex; align-items: center; }
.cell-person .name { font-weight: 600; letter-spacing: 0.5px; }
.cell-person .sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 4px 10px; border-radius: 2px;
    font-size: 10px; font-weight: 700; white-space: nowrap; text-transform: uppercase; letter-spacing: 1px;
}
.badge-info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,106,225,0.2); }
.badge-warn { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,106,225,0.2); }
.badge-progress { background: #f0f0f0; color: var(--text); border: 1px solid var(--border); }
.badge-ready { background: var(--green-soft); color: #1e7e34; border: 1px solid rgba(52,168,83,0.2); }
.badge-done { background: #fafafa; color: var(--text-dim); border: 1px solid var(--border); }
.badge-muted { background: transparent; color: var(--text-faint); border: 1px dashed var(--border); }
.badge-danger { background: var(--red-soft); color: var(--red); border: 1px solid rgba(232,33,39,0.2); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px;
    border: 1px solid transparent; cursor: pointer; font-family: inherit;
    transition: all 0.2s ease;
}
.btn-primary { background: var(--red); color: #ffffff; }
.btn-primary:hover { background: #CC1D22; }
.btn-secondary { background: var(--bg-panel); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-panel-raised); border-color: #a0a0a0; }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: rgba(232,33,39,0.2); }
.btn-danger:hover { background: rgba(232,33,39,0.15); }
.btn-ghost { background: transparent; color: var(--text-dim); padding: 10px 8px; }
.btn-ghost:hover { color: var(--text); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 8px 14px; font-size: 10px; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 20px; }
.form-row label {
    display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-dim); margin-bottom: 8px;
}
input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], input[type="search"], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
}
textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; gap: 12px; margin-top: 10px; }

/* ---------- Timeline ---------- */
.timeline {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 45px;
    position: relative;
}
.timeline-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}
.timeline-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.timeline-step.done:not(:last-child)::after { background: var(--red); }
.timeline-dot {
    width: 28px; height: 28px; border-radius: 50%; background: var(--bg); border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; position: relative; z-index: 1;
    font-size: 11px; font-weight: 700; color: var(--text-faint);
}
.timeline-step.done .timeline-dot { background: var(--red); border-color: var(--red); color: #ffffff; }
.timeline-step.current .timeline-dot { border-color: var(--text); color: var(--text); }
.timeline-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); text-align: center; }
.timeline-step.done .timeline-label, .timeline-step.current .timeline-label { color: var(--text); font-weight: 700; }

/* ---------- Grids & Non-stretched Rich Charts ---------- */
.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; align-items: start; width: 100%; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; align-items: start; width: 100%; }

.chart-wrap { padding: 16px 20px 14px; }
.rich-chart-block { width: 100%; }
.chart-svg {
    width: 100%;
    height: auto;
    max-height: 280px;
    display: block;
}

.chart-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    align-items: center;
}
.chart-stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--text-dim);
}
.chart-stat-chip strong {
    color: var(--text);
    font-weight: 700;
}
.chart-stat-chip small {
    font-weight: 500;
    color: var(--text-faint);
}
.lg-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    display: inline-block;
}

.stat-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 12.5px; }
.stat-bar-row:last-child { margin-bottom: 0; }
.stat-label { width: 130px; flex-shrink: 0; color: var(--text-dim); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-track { flex: 1; height: 8px; background: var(--bg-panel-raised); border-radius: 2px; overflow: hidden; }
.stat-track > span { display: block; height: 100%; background: var(--red); border-radius: 2px; }
.stat-count { width: 38px; text-align: right; font-weight: 700; font-size: 12px; }

.funnel-row { margin-bottom: 16px; }
.funnel-row:last-child { margin-bottom: 0; }
.funnel-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; color: var(--text-dim); }
.funnel-head strong { color: var(--text); }

/* ---------- Donut & Tabs DA ---------- */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut-legend { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 10px; }
.donut-legend-item { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.donut-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.donut-legend-label { flex: 1; color: var(--text-dim); }
.donut-legend-val { font-weight: 700; color: var(--text); }
.donut-legend-val small { font-weight: 500; color: var(--text-faint); }

.da-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.da-tab {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 12px 18px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: all 0.2s ease;
}
.da-tab:hover { color: var(--text); background: var(--bg-panel-raised); }
.da-tab.active {
    background: var(--text);
    color: #ffffff;
    border-color: var(--text);
}
.da-tab-content { display: none; }
.da-tab-content.active { display: block; }

/* ---------- Misc ---------- */
.info-list { display: flex; flex-direction: column; gap: 14px; }
.info-list .row { display: flex; justify-content: space-between; font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 10px; gap: 10px; }
.info-list .row:last-child { border-bottom: none; padding-bottom: 0; }
.info-list .row .k { color: var(--text-dim); }
.info-list .row .v { font-weight: 600; text-align: right; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-dim); }
.empty-state h2 { color: var(--text); font-size: 18px; font-weight: 500; margin-bottom: 10px; letter-spacing: 0.5px; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--bg-panel-raised); border: 1px solid var(--border); padding: 4px 10px; border-radius: 2px; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); font-weight: 600; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.slot-grid form { display: contents; }
.slot-btn {
    padding: 12px 10px; text-align: center; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--bg); font-size: 13px; cursor: pointer; color: var(--text); font-family: inherit; font-weight: 500;
    width: 100%; transition: all 0.2s;
}
.slot-btn:hover { border-color: var(--accent); color: var(--accent); }
.slot-btn.full { opacity: 0.4; cursor: not-allowed; text-decoration: line-through; }
.slot-day { margin-bottom: 24px; }
.slot-day h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin: 0 0 12px; font-weight: 700; }

.progress-bar { height: 4px; border-radius: 0; background: var(--border); overflow: hidden; margin-top: 10px; }
.progress-bar > span { display: block; height: 100%; background: var(--text); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .main { padding: 20px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}