/* ==========================================================================
   Portail SNEL v4 — système visuel « console d'ingénierie »
   Thèmes clair / sombre par variables CSS. Aucune dépendance externe.
   ========================================================================== */

:root {
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

    --bg: #eef2f7;
    --bg-grid: rgba(15, 37, 68, .035);
    --panel: #ffffff;
    --panel-2: #f6f8fb;
    --panel-3: #eef2f7;
    --ink: #0e1a2b;
    --ink-2: #33445a;
    --muted: #64748b;
    --line: #dde4ed;
    --line-2: #c9d3df;

    --brand: #0b5fb4;
    --brand-2: #094c90;
    --brand-soft: #e6f0fb;
    --accent: #f5b800;
    --accent-soft: #fff6d6;
    --ok: #12895a;
    --ok-soft: #e3f5ec;
    --warn: #b7791f;
    --warn-soft: #fdf3e1;
    --bad: #c8372d;
    --bad-soft: #fdeceb;
    --info: #2563c9;
    --info-soft: #e8f0fd;

    --side-bg: #0a1628;
    --side-bg-2: #0f2038;
    --side-ink: #c4d1e3;
    --side-muted: #6f84a3;

    --observe: #0b8457;
    --observe-soft: #e7f6ef;
    --total-soft: #eaf2fc;
    --now: #fff4cc;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(14, 26, 43, .06), 0 1px 1px rgba(14, 26, 43, .04);
    --shadow-lg: 0 10px 30px rgba(14, 26, 43, .12);
    --side-w: 248px;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0b1320;
    --bg-grid: rgba(120, 160, 210, .045);
    --panel: #111c2d;
    --panel-2: #142236;
    --panel-3: #18283f;
    --ink: #e5edf7;
    --ink-2: #b9c7d9;
    --muted: #8193ab;
    --line: #22344d;
    --line-2: #2c4262;
    --brand: #4c9dff;
    --brand-2: #78b4ff;
    --brand-soft: #14304f;
    --accent: #ffc928;
    --accent-soft: #3a3010;
    --ok: #3fcf8e;
    --ok-soft: #0f3326;
    --warn: #f0b44c;
    --warn-soft: #3a2c10;
    --bad: #ff6b5f;
    --bad-soft: #3d1715;
    --info: #6aa6ff;
    --info-soft: #132c4d;
    --side-bg: #070f1c;
    --side-bg-2: #0c1829;
    --observe: #46d39a;
    --observe-soft: #0f2e24;
    --total-soft: #13283f;
    --now: #3a3313;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font: 14px/1.5 var(--font);
    color: var(--ink);
    background: var(--bg);
    font-feature-settings: "cv11", "ss01";
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0 0 .6em; }
p:last-child { margin-bottom: 0; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { padding: 1px 5px; border-radius: 4px; background: var(--panel-3); }
small { font-size: .8em; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 650; }
.ellipsis { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { white-space: normal; min-width: 260px; }

.icon { width: 18px; height: 18px; flex: none; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--side-w);
    display: flex; flex-direction: column;
    background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
    color: var(--side-ink);
    border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar-brand {
    display: flex; gap: 12px; align-items: center;
    padding: 18px 18px 16px;
    color: #fff; text-decoration: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-brand img { border-radius: 6px; background: #0b5fb4; padding: 3px; }
.sidebar-brand strong { display: block; font-size: 14.5px; letter-spacing: .01em; }
.sidebar-brand small { display: block; color: var(--side-muted); font-size: 11.5px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 10px 18px; }
.nav-section {
    margin: 16px 10px 6px; color: var(--side-muted);
    font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.nav-link {
    position: relative; display: flex; gap: 11px; align-items: center;
    padding: 8px 12px; margin: 1px 0; border-radius: 8px;
    color: var(--side-ink); font-weight: 500; text-decoration: none !important;
    transition: background .15s, color .15s;
}
.nav-link .icon { opacity: .8; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.is-active { background: rgba(76, 157, 255, .14); color: #fff; }
.nav-link.is-active::before {
    content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-link.is-active .icon { color: var(--accent); opacity: 1; }
.sidebar-foot {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 18px; font-size: 12px; color: var(--side-muted);
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 16px;
    min-height: 64px; padding: 10px 28px;
    background: color-mix(in srgb, var(--panel) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kicker {
    margin: 0 0 2px; color: var(--muted);
    font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.topbar-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.clock, .user-chip, .live-chip {
    display: inline-flex; align-items: center; gap: 7px;
    height: 34px; padding: 0 11px; border-radius: 8px;
    border: 1px solid var(--line); background: var(--panel-2);
    color: var(--ink-2); font-size: 12.5px; white-space: nowrap;
}
.clock span { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.clock .icon, .user-chip .icon { width: 15px; height: 15px; color: var(--muted); }
.icon-btn {
    display: inline-grid; place-items: center; width: 34px; height: 34px;
    border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
    color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-2); color: var(--ink); text-decoration: none; }
.icon-btn .icon { width: 16px; height: 16px; }
.nav-toggle { display: none; }
.content { flex: 1; padding: 22px 28px 40px; display: flex; flex-direction: column; gap: 18px;
    background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 24px 24px; }
.statusbar {
    display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
    padding: 7px 28px; font-size: 11.5px; color: var(--muted);
    border-top: 1px solid var(--line); background: var(--panel);
}
.statusbar span { display: inline-flex; align-items: center; gap: 6px; }
.statusbar .icon { width: 13px; height: 13px; color: var(--accent); }
.statusbar-right { margin-left: auto; }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.status-dot.pending { background: var(--warn); animation: pulse 1.4s infinite; }
.live-chip.is-ok .status-dot { background: var(--ok); animation: pulse-ok 2.4s infinite; }
.live-chip.is-bad .status-dot { background: var(--bad); }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes pulse-ok { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Grilles ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 18px; }
.grid-1-2 { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(0, 1.6fr); gap: 18px; }
.split { display: grid; grid-template-columns: minmax(330px, 420px) minmax(0, 1fr); gap: 18px; align-items: start; }
.split-detail { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.split-list { position: sticky; top: 82px; }

/* ---------- Panneaux ---------- */
.panel {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 15.5px; font-weight: 700; }
.panel-icon { width: 22px; height: 22px; color: var(--muted); }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }
.panel-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }
.panel-subhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel-2); }
.panel-subhead h3 { font-size: 13.5px; }
.legend-hint { color: var(--muted); font-size: 12px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi-grid.compact { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 14px; }
.kpi {
    position: relative; display: flex; flex-direction: column; gap: 3px;
    padding: 13px 15px 12px; background: var(--panel);
    border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2); }
.kpi-accent::before { background: var(--accent); }
.kpi-ok::before { background: var(--ok); }
.kpi-warn::before { background: var(--warn); }
.kpi-bad::before { background: var(--bad); }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.kpi-value { font-family: var(--mono); font-size: 23px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { margin-left: 5px; font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-grid.compact .kpi-value { font-size: 16px; }

/* ---------- Héros client ---------- */
.hero-grid { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 18px; }
.hero-now {
    padding: 18px 20px; display: flex; flex-direction: column; gap: 6px;
    background: linear-gradient(135deg, #0a1628 0%, #0f2a4d 60%, #0b5fb4 140%);
    color: #e9f1fb; border-color: transparent; position: relative; overflow: hidden;
}
.hero-now::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; border: 28px solid rgba(245, 184, 0, .08); }
.hero-now .kicker { color: #8fb3df; }
.hero-now-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hero-now-value { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; }
.hero-number { font-family: var(--mono); font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -.04em; color: #fff; font-variant-numeric: tabular-nums; }
.hero-unit { font-size: 20px; font-weight: 600; color: var(--accent); }
.hero-sub { color: #a9c0de; font-size: 13px; margin: 0; }
.hero-sub strong { color: #fff; font-family: var(--mono); }
.hero-next { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .12); color: #a9c0de; font-size: 13px; }
.hero-next strong { color: #fff; font-family: var(--mono); }
.hero-next-value strong { font-size: 18px; }
.hero-progress { height: 4px; margin-top: 10px; border-radius: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.hero-progress span { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
.hero-info { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.hero-info h2 { font-size: 19px; }
.message-box { padding: 12px 14px; border-radius: 8px; background: var(--panel-2); border: 1px dashed var(--line-2); color: var(--ink-2); font-size: 13.5px; white-space: normal; margin-top: 12px; }
.hero-info .message-box { margin-top: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 18px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.facts.inline { margin-bottom: 14px; }

/* ---------- Boutons & formulaires ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border-radius: 8px;
    border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13.5px;
    cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 0 rgba(255, 255, 255, .15) inset, 0 1px 2px rgba(11, 95, 180, .3); }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: var(--panel); color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-block { width: 100%; height: 42px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn-xs { height: 26px; padding: 0 7px; font-size: 12px; }
.btn-xs .icon { width: 14px; height: 14px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.is-busy { pointer-events: none; opacity: .85; }
.btn.is-busy::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

input, select, textarea {
    font: inherit; color: var(--ink); background: var(--panel);
    border: 1px solid var(--line-2); border-radius: 7px; padding: 7px 10px; min-height: 36px; width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
input[disabled] { background: var(--panel-2); color: var(--muted); }
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span:first-child { color: var(--ink-2); font-size: 12px; font-weight: 650; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span:first-child { white-space: nowrap; }
.field.inline select, .field.inline input { width: auto; min-height: 32px; padding: 4px 8px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-content: start; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.span-2 { grid-column: 1 / -1; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { border-radius: 7px 0 0 7px; font-family: var(--mono); }
.input-unit em { display: grid; place-items: center; padding: 0 10px; font-style: normal; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-2); border-left: 0; border-radius: 0 7px 7px 0; }
.input-unit.sm input { width: 80px; min-height: 32px; padding: 4px 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.check input { margin-top: 2px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 10px; background: var(--line-2); position: relative; border: 0; padding: 0; transition: background .15s; cursor: pointer; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(14px); }
.search { position: relative; display: inline-flex; align-items: center; }
.search .icon { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--muted); }
.search input { padding-left: 30px; min-height: 30px; width: 220px; }
.panel-tools select { width: auto; min-height: 30px; padding: 3px 8px; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.client-picker select { width: min(340px, 40vw); }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-bar .field { width: 170px; }
.filter-actions { display: flex; gap: 8px; margin-left: auto; }
.note { padding: 12px 14px; border-radius: 8px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 13px; color: var(--ink-2); }
.checklist { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.checklist li { margin: 3px 0; }

/* ---------- Dépôt de fichier ---------- */
.dropzone {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
    padding: 26px 18px; border: 2px dashed var(--line-2); border-radius: var(--radius);
    background: var(--panel-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.dz-icon { width: 30px; height: 30px; color: var(--brand); }
.dropzone span { color: var(--muted); font-size: 12.5px; }

/* ---------- Alertes, badges, puces ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 13.5px; }
.alert .icon { margin-top: 1px; }
.alert strong { display: block; margin-bottom: 2px; }
.alert p { margin: 0; }
.alert.compact { padding: 9px 12px; font-size: 12.5px; }
.alert-success { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ink); }
.alert-success .icon { color: var(--ok); }
.alert-error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.alert-error .icon { color: var(--bad); }
.alert-warning { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.alert-warning .icon { color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.alert-info .icon { color: var(--info); }
ul.tight { margin: 6px 0 0; padding-left: 18px; }
ul.tight li { margin: 2px 0; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-bad { color: var(--bad); background: var(--bad-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-neutral { color: var(--muted); background: var(--panel-3); }
.hero-now .badge { background: rgba(255, 255, 255, .1); }
.hero-now .badge-ok { color: #6ee7b0; }
.hero-now .badge-warn { color: #ffd27a; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink-2); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip.is-active { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.chip-ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.chip-warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.chip-bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag { display: inline-flex; gap: 6px; align-items: center; padding: 3px 9px; border-radius: 6px; background: var(--panel-3); color: var(--ink-2); font-size: 12px; }
.tag .mono { color: var(--muted); }

.disclosure { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; background: var(--panel-2); }
.disclosure summary { cursor: pointer; padding: 9px 0; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.disclosure[open] { padding-bottom: 10px; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-state .icon { width: 34px; height: 34px; color: var(--line-2); }
.empty-state h3 { color: var(--ink-2); font-size: 15px; }

/* ---------- Tableaux de données ---------- */
.table-scroll { overflow: auto; max-width: 100%; }
.table-scroll.tall { max-height: 560px; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.data-table th, .data-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
.data-table thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--panel-2); color: var(--muted);
    font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    border-bottom: 1px solid var(--line-2);
}
.data-table thead th small { display: block; font-size: 10px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.data-table tbody tr:hover > * { background: color-mix(in srgb, var(--brand) 5%, var(--panel)); }
.data-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.data-table thead .num { font-family: var(--font); }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table .row-actions { text-align: right; display: flex; gap: 4px; justify-content: flex-end; }
.data-table tr.is-selected > * { background: var(--brand-soft); }
.data-table tr.needs-action > * { background: var(--warn-soft); }
.data-table tr[data-href] { cursor: pointer; }
.sortable thead th[data-sort] { cursor: pointer; user-select: none; }
.sortable thead th[data-sort]::after { content: "↕"; margin-left: 5px; opacity: .3; font-size: 10px; }
.sortable thead th.sort-asc::after { content: "↑"; opacity: 1; color: var(--brand); }
.sortable thead th.sort-desc::after { content: "↓"; opacity: 1; color: var(--brand); }
.src-dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c); vertical-align: 0; }

/* Programme horaire */
.consigne-table .col-hour, .grid-table .col-hour {
    position: sticky; left: 0; z-index: 1; background: var(--panel); font-family: var(--mono); font-weight: 650; color: var(--ink-2);
    border-right: 1px solid var(--line);
}
.consigne-table thead .col-hour, .grid-table thead .col-hour { z-index: 3; background: var(--panel-2); }
.consigne-table td.is-zero { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.consigne-table .col-total, .grid-table .col-total { background: var(--total-soft); font-weight: 700; color: var(--brand); }
.consigne-table .col-observe, .grid-table .col-observe { background: var(--observe-soft); font-weight: 750; color: var(--observe); }
.consigne-table .col-obs { min-width: 140px; color: var(--muted); }
.consigne-table tr.is-now > *, .grid-table tr.is-now > * { background: var(--now) !important; }
.consigne-table tr.is-now .col-hour::before { content: "▶ "; color: var(--accent); }
.summary-row > * { background: var(--panel-2); font-weight: 700; border-top: 1px solid var(--line-2); }
.summary-row:first-child > * { border-top: 2px solid var(--line-2); }
.summary-max .col-hour { color: var(--bad); }
.summary-low .col-hour { color: var(--info); }
.hide-idle .is-idle { display: none; }

/* Grille de saisie */
.grid-scroll { max-height: calc(100vh - 230px); }
.grid-table td { padding: 0; }
.grid-table td.num:not(.col-total):not(.col-observe) { min-width: 82px; }
.grid-table td.col-total, .grid-table td.col-observe { padding: 6px 10px; }
.grid-table input {
    width: 100%; min-height: 32px; border: 0; border-radius: 0; padding: 6px 10px; background: transparent;
    font-family: var(--mono); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums;
}
.grid-table .col-obs input { text-align: left; font-family: var(--font); min-width: 160px; }
.grid-table input:focus { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-soft); }
.grid-table input.is-invalid { background: var(--bad-soft); box-shadow: inset 0 0 0 2px var(--bad); }
.grid-table input.is-changed { color: var(--brand); font-weight: 700; }
.grid-table input.is-zero { color: var(--muted); }
.grid-table td + td { border-left: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.grid-table tfoot td, .grid-table tfoot th { position: sticky; bottom: 0; }
.grid-table tfoot tr.summary-total > * { bottom: 99px; }
.grid-table tfoot tr.summary-max > * { bottom: 66px; }
.grid-table tfoot tr.summary-average > * { bottom: 33px; }
.grid-table tfoot tr.summary-low > * { bottom: 0; }
.grid-table tfoot td { padding: 7px 10px; height: 33px; }
.range-tool { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 18px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.range-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px; color: var(--ink-2); }
.range-title .icon { color: var(--accent); width: 16px; height: 16px; }
.range-hint { color: var(--muted); font-size: 12px; margin-left: auto; }

.publish-bar {
    position: sticky; bottom: 12px; z-index: 20;
    display: flex; align-items: center; gap: 16px;
    padding: 12px 16px; border-radius: var(--radius);
    background: var(--side-bg); color: #dbe6f4; box-shadow: var(--shadow-lg);
}
.publish-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.publish-info strong { color: #fff; }
.publish-info span { font-size: 12.5px; color: #93a9c6; }
.publish-bar.is-dirty .publish-info span { color: var(--accent); }
.publish-check { font-size: 12.5px; color: #93a9c6; }
.publish-check.is-bad { color: #ff9b93; }

/* ---------- Graphiques ---------- */
.chart { position: relative; width: 100%; height: var(--chart-h, 280px); }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; font-family: var(--font); }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--mono); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .zero-line { stroke: var(--line-2); }
.chart .ref-line { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--bad); font-size: 11px; font-weight: 700; }
.chart .obs-line { fill: none; stroke: var(--observe); stroke-width: 2.25; }
.chart .obs-dot { fill: var(--panel); stroke: var(--observe); stroke-width: 2; }
.chart .now-band { fill: var(--accent); opacity: .18; }
.chart .now-label { fill: var(--warn); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; }
.chart .hover-band { fill: var(--ink); opacity: 0; }
.chart .hover-band.is-on { opacity: .05; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-legend i.line { height: 3px; border-radius: 2px; }
.chart-tip {
    position: absolute; z-index: 5; pointer-events: none; min-width: 180px;
    padding: 9px 11px; border-radius: 8px; background: var(--side-bg); color: #e6eef8;
    font-size: 12px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px); transition: opacity .1s;
}
.chart-tip.is-on { opacity: 1; transform: none; }
.chart-tip b { display: block; margin-bottom: 4px; font-family: var(--mono); color: var(--accent); }
.chart-tip div { display: flex; justify-content: space-between; gap: 14px; }
.chart-tip div span:last-child { font-family: var(--mono); }
.chart-tip hr { border: 0; border-top: 1px solid rgba(255, 255, 255, .15); margin: 5px 0; }
.chart-empty { display: grid; place-items: center; height: 100%; color: var(--muted); border: 1px dashed var(--line-2); border-radius: 8px; }
.sparkline .sparkline-line { fill: none; stroke: var(--brand); stroke-width: 1.5; }
.sparkline .sparkline-area { fill: var(--brand); opacity: .1; }

.mix-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.mix-list li { display: grid; grid-template-columns: 140px 1fr; grid-template-rows: auto auto; gap: 2px 10px; align-items: center; font-size: 12.5px; }
.mix-name { font-weight: 650; grid-row: span 2; }
.mix-bar { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.mix-bar span { display: block; height: 100%; border-radius: 4px; }
.mix-val { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.activity { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.activity-bars { display: flex; align-items: flex-end; gap: 4px; height: 56px; margin-top: 8px; }
.activity-bars span { flex: 1; border-radius: 3px 3px 0 0; background: color-mix(in srgb, var(--brand) 55%, transparent); min-height: 3px; }
.activity-bars span.is-today { background: var(--accent); }
.activity-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* Carte thermique */
.heat-scroll { max-height: 560px; }
.heatmap { border-collapse: separate; border-spacing: 2px; font-size: 11px; font-family: var(--mono); width: 100%; padding: 6px 10px 10px; }
.heatmap th { position: sticky; top: 0; z-index: 2; background: var(--panel); color: var(--muted); font-weight: 600; padding: 4px 2px; }
.heatmap th.is-now { color: var(--warn); }
.heatmap .heat-name { position: sticky; left: 0; z-index: 3; text-align: left; background: var(--panel); font-family: var(--font); font-size: 12px; padding-right: 10px; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.heatmap .heat-name a { color: var(--ink-2); }
.heatmap td {
    min-width: 34px; height: 24px; text-align: center; border-radius: 3px;
    background: color-mix(in srgb, var(--brand) calc(var(--h) * 92%), var(--panel-3));
    color: color-mix(in srgb, #fff calc(var(--h) * 140%), var(--ink-2));
}
.heatmap td.num { background: none; color: var(--ink); text-align: right; padding-left: 8px; }
.heat-legend { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.heat-legend i { width: 90px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--panel-3), var(--brand)); }

/* Bilan Excel */
.stepper { display: flex; gap: 0; margin: 0; padding: 0; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-weight: 600; font-size: 13px; color: var(--muted); border-right: 1px solid var(--line); }
.stepper li:last-child { border-right: 0; }
.stepper li span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--panel-3); font-size: 12px; font-family: var(--mono); }
.stepper li.is-done span { background: var(--ok); color: #fff; }
.stepper li.is-active { color: var(--ink); background: var(--brand-soft); }
.stepper li.is-active span { background: var(--brand); color: #fff; }
.meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; margin: 16px 0 6px; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 12.5px; color: var(--ink-2); }
.meter-bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; order: 3; }
.meter-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--ok)); border-radius: 4px; }
.meter strong { font-family: var(--mono); }
.report .kpi-grid { margin-bottom: 4px; }
.report .alert { margin-top: 12px; }

/* ---------- Authentification ---------- */
.auth { min-height: 100vh; background: var(--bg); }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, 1fr); min-height: 100vh; }
.auth-brand {
    position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 30px;
    padding: 40px 48px; color: #dbe6f4; overflow: hidden;
    background: radial-gradient(1200px 500px at -10% 110%, rgba(11, 95, 180, .55), transparent 60%), linear-gradient(160deg, #081222 0%, #0c1d36 55%, #0d2a50 100%);
}
.auth-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(124, 183, 255, .07) 1px, transparent 1px), linear-gradient(90deg, rgba(124, 183, 255, .07) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); }
.auth-brand > * { position: relative; }
.auth-brand-top { display: flex; gap: 14px; align-items: center; }
.auth-brand-top img { background: #0b5fb4; border-radius: 8px; padding: 4px; }
.auth-brand-top strong { display: block; color: #fff; font-size: 15px; }
.auth-brand-top span { color: #8fb3df; font-size: 13px; }
.auth-brand-body { max-width: 560px; }
.auth-brand-body .kicker { color: var(--accent); }
.auth-brand-body h1 { color: #fff; font-size: 38px; font-weight: 750; letter-spacing: -.025em; margin: 6px 0 14px; }
.auth-brand-body p { color: #a9c0de; font-size: 15px; }
.auth-facts { display: grid; grid-template-columns: repeat(3, auto); gap: 18px 32px; margin: 30px 0 0; justify-content: start; }
.auth-facts dt { color: #6f8db3; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.auth-facts dd { margin: 3px 0 0; color: #fff; font-family: var(--mono); font-size: 15px; }
.auth-brand-foot { color: #5f7899; font-size: 12px; }
.auth-panel { display: grid; place-items: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h2 { font-size: 26px; font-weight: 750; }
.auth-alt { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.auth-alt a { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.auth-alt .icon { width: 16px; height: 16px; }

.sidebar-backdrop { display: none; }

/* ---------- Adaptatif ---------- */
@media (max-width: 1280px) {
    .grid-2-1, .grid-1-2 { grid-template-columns: minmax(0, 1fr); }
    .split { grid-template-columns: minmax(0, 1fr); }
    .split-list { position: static; }
}
@media (max-width: 980px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; }
    .app.nav-open .sidebar { transform: none; }
    .app.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5, 12, 24, .5); }
    .main { margin-left: 0; }
    .nav-toggle { display: inline-grid; }
    .topbar { padding: 10px 16px; flex-wrap: wrap; }
    .content { padding: 16px; }
    .grid-2, .hero-grid, .meters { grid-template-columns: minmax(0, 1fr); }
    .auth-shell { grid-template-columns: minmax(0, 1fr); }
    .auth-brand { padding: 28px; }
    .auth-brand-body h1 { font-size: 28px; }
    .clock, .user-chip { display: none; }
    .range-hint { margin-left: 0; }
}
@media (max-width: 600px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .hero-number { font-size: 52px; }
    .filter-bar .field { width: 100%; }
    .stepper { flex-direction: column; }
    .stepper li { border-right: 0; border-bottom: 1px solid var(--line); }
    .auth-facts { grid-template-columns: repeat(2, auto); }
}

/* ---------- Impression ---------- */
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    :root, [data-theme="dark"] { --bg: #fff; --panel: #fff; --panel-2: #f3f5f8; --ink: #000; --line: #c9d1db; --now: #fff; }
    .sidebar, .topbar-tools, .nav-toggle, .statusbar, .panel-tools, .publish-bar, .range-tool, .filter-bar, .stepper, .hero-progress, .split-list { display: none !important; }
    .main { margin: 0; }
    .topbar { position: static; border: 0; padding: 0 0 8px; }
    .content { padding: 0; background: none; gap: 10px; }
    .panel, .kpi { box-shadow: none; break-inside: avoid; }
    .hero-now { background: #fff !important; color: #000; border: 1px solid #c9d1db; }
    .hero-now *, .hero-sub, .hero-next { color: #000 !important; }
    .table-scroll { overflow: visible; max-height: none !important; }
    .data-table { font-size: 9px; }
    .data-table th, .data-table td { padding: 3px 5px; }
    .data-table thead th { position: static; }
    .hide-idle .is-idle { display: none; }
    a { color: inherit; }
}

/* Ajustements */
.editor { display: flex; flex-direction: column; gap: 18px; }
.chart .ref-label, .chart .now-label { paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.alert p strong { display: inline; margin: 0; }
[data-live-client] { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 600px) {
    .topbar-title { flex: 1 1 calc(100% - 60px); }
    .topbar-tools { width: 100%; justify-content: flex-start; }
    .client-picker select { width: 100%; }
    .client-picker { flex: 1; }
}
.convert-form { justify-content: flex-start; align-items: center; flex-wrap: wrap; }
.convert-form input[type="file"] { width: auto; min-height: 30px; padding: 3px; flex: 1; min-width: 200px; }

/* Zone sensible (désactivation / suppression) */
.danger-zone { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.danger-zone .panel-head { background: color-mix(in srgb, var(--bad-soft) 60%, var(--panel)); border-radius: var(--radius) var(--radius) 0 0; }
.danger-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.danger-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2); }
.danger-card h3 { font-size: 14.5px; }
.danger-card.is-critical { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad-soft) 45%, var(--panel)); }
.danger-card .btn { align-self: flex-start; }
.btn-warn { background: var(--warn); color: #fff; }
.badge-inactive { color: var(--muted); background: var(--panel-3); text-decoration: line-through; }
tr.is-inactive > * { opacity: .6; }
@media (max-width: 980px) { .danger-grid { grid-template-columns: minmax(0, 1fr); } }
