[hidden] { display: none !important; }
:root {
  --bg: #f3f4f6; --surface: #fff; --surface-2: #f0f2f5; --border: #dde1e7; --text: #1a1e24; --muted: #5d6775;
  --accent: #d6331f; --accent-soft: #fbe7e3; --blue: #1f6fd1; --green: #1d9a55; --amber: #c27a00; --red: #c9302c; --violet: #7a4cc2;
  --grid: rgba(60,70,85,.12); --shadow: 0 1px 2px rgba(0,0,0,.05), 0 3px 12px rgba(0,0,0,.04); --radius: 10px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1115; --surface: #161a20; --surface-2: #1d222a; --border: #2a313b; --text: #e5e8ed; --muted: #97a1ae;
    --accent: #ff5a3c; --accent-soft: #3a1e19; --blue: #5aa6ff; --green: #3ecf7a; --amber: #f0a531; --red: #ff6b61; --violet: #b28cff;
    --grid: rgba(200,210,225,.1); --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1115; --surface: #161a20; --surface-2: #1d222a; --border: #2a313b; --text: #e5e8ed; --muted: #97a1ae;
  --accent: #ff5a3c; --accent-soft: #3a1e19; --blue: #5aa6ff; --green: #3ecf7a; --amber: #f0a531; --red: #ff6b61; --violet: #b28cff;
  --grid: rgba(200,210,225,.1); --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 20px; } h2 { font-size: 15px; font-weight: 650; } h3 { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.kerb { height: 4px; background: repeating-linear-gradient(90deg, var(--accent) 0 18px, #fff 18px 36px); }

/* connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.login .in { padding: 24px; display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; letter-spacing: .01em; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }

/* structure */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { padding: 16px 16px 14px; }
.nav { display: grid; gap: 2px; padding: 6px 10px; flex: 1; overflow: auto; align-content: start; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); font-weight: 520; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side .foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top h1 { flex: 1; }
.top .burger { display: none; }
.page { padding: 20px 24px 40px; display: grid; gap: 16px; max-width: 1500px; }

/* blocs */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card > .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card > .hd h2 { flex: 1; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .g12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .l { color: var(--muted); font-size: 12px; font-weight: 550; }
.kpi .v { font-size: 24px; font-weight: 720; letter-spacing: -.01em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.warn .v { color: var(--amber); } .kpi.bad .v { color: var(--red); } .kpi.good .v { color: var(--green); }
.up { color: var(--green); } .down { color: var(--red); } .muted { color: var(--muted); } .small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .grow { flex: 1; }
.stack { display: grid; gap: 10px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* tableaux */
.tw { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover td { background: var(--surface-2); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.scroll { max-height: 420px; overflow: auto; }

/* pastilles */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid transparent; }
.b-green { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.b-red { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.b-amber { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.b-blue { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.b-violet { background: color-mix(in srgb, var(--violet) 15%, transparent); color: var(--violet); }
.b-accent { background: var(--accent); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--green); } .dot.ko { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 25%, transparent); } .dot.mid { background: var(--amber); }

/* formulaires */
label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 560; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
textarea { resize: vertical; min-height: 90px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 0; border-color: var(--blue); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
label.chk { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 13.5px; }
.btn { font: inherit; font-weight: 600; font-size: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.pri:hover { filter: brightness(1.06); }
.btn.sm { padding: 4px 9px; font-size: 12px; } .btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 12.5px; font-weight: 600; border: 0; background: var(--surface); color: var(--muted); padding: 6px 11px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; } .seg button.on { background: var(--accent-soft); color: var(--accent); }
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: end; }
.form .wide { grid-column: 1 / -1; }
.err { color: var(--red); font-size: 13px; } .ok-msg { color: var(--green); font-size: 13px; }

/* graphiques */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.chart .gl { stroke: var(--grid); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bars .r { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 4px 0; font-size: 13px; }
.bars .r .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .r .b { grid-column: 1 / -1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bars .r .b i { display: block; height: 100%; background: var(--blue); border-radius: 3px; }
.meter { height: 9px; background: var(--surface-2); border-radius: 5px; overflow: hidden; } .meter i { display: block; height: 100%; background: var(--green); border-radius: 5px; }
.meter.warn i { background: var(--amber); } .meter.bad i { background: var(--red); }
.bins { display: grid; grid-template-columns: repeat(48, 1fr); gap: 2px; height: 22px; }
.bins i { border-radius: 2px; background: var(--green); } .bins i.n { background: var(--surface-2); } .bins i.k { background: var(--red); } .bins i.m { background: var(--amber); }
.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; align-items: end; height: 70px; }
.hours i { background: var(--blue); border-radius: 2px 2px 0 0; min-height: 2px; }

/* SAV */
.sav { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
.tlist { display: grid; }
.titem { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: grid; gap: 3px; }
.titem:hover { background: var(--surface-2); } .titem.on { background: var(--accent-soft); }
.titem .l1 { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.titem .s { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs { display: grid; gap: 10px; }
.msg { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; max-width: 92%; }
.msg.in { background: var(--surface); justify-self: start; }
.msg.out { background: color-mix(in srgb, var(--blue) 8%, var(--surface)); border-color: color-mix(in srgb, var(--blue) 30%, var(--border)); justify-self: end; }
.msg.note { background: color-mix(in srgb, var(--amber) 10%, var(--surface)); border-style: dashed; justify-self: stretch; max-width: none; }
.msg .h { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; }
.msg .b { white-space: pre-wrap; word-wrap: break-word; }
.ctx { display: grid; gap: 6px; font-size: 13px; }

/* fenêtre */
.modal { position: fixed; inset: 0; background: rgba(10,12,16,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal .box { background: var(--surface); border-radius: 14px; border: 1px solid var(--border); width: 100%; max-width: 860px; max-height: 90vh; overflow: auto; padding: 18px; display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 9px; font-weight: 600; z-index: 60; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--red); color: #fff; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: s .8s linear infinite; } @keyframes s { to { transform: rotate(360deg); } }
.note-box { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.pre { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; max-height: 220px; overflow: auto; }

@media (max-width: 1100px) { .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g21, .g12 { grid-template-columns: 1fr; } .sav { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .top { padding: 12px 16px; } .top .burger { display: inline-flex; }
  .page { padding: 14px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 20px; }
}
@media print { .side, .top .btn, .noprint { display: none !important; } .app { display: block; } .card { box-shadow: none; break-inside: avoid; } }
