/* ============================================================
   GMAO Atelier — feuille de style
   ============================================================ */
:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --ink: #16202a;
  --ink-2: #4b5966;
  --ink-3: #7a8894;
  --line: #d5dce2;
  --line-2: #e6ebef;
  --accent: #0e6e7c;
  --accent-ink: #ffffff;
  --accent-soft: #dcefF1;
  --rail: #1b2833;
  --rail-ink: #c4d0da;
  --rail-active: #2a3b48;
  --ok: #2e7d4f;       --ok-soft: #e3f2e8;
  --warn: #b7791f;     --warn-soft: #fbf0db;
  --bad: #c0392b;      --bad-soft: #fbe6e3;
  --info: #3a6ea5;     --info-soft: #e3edf7;
  --s-correctif: #d9822b;
  --s-preventif: #0e6e7c;
  --s-amelioration: #8b98a4;
  --shadow: 0 1px 2px rgba(22,32,42,.06), 0 4px 16px rgba(22,32,42,.06);
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f161c; --surface: #17212a; --surface-2: #1c2832; --ink: #e3e9ee; --ink-2: #aab7c2; --ink-3: #7d8b97;
    --line: #2b3a46; --line-2: #22303b; --accent: #3fb6c4; --accent-ink: #06222a; --accent-soft: #163a41;
    --rail: #0b1116; --rail-ink: #9fb0bd; --rail-active: #1a2731;
    --ok: #5cc48a; --ok-soft: #173326; --warn: #e5b04e; --warn-soft: #3a2f16; --bad: #ef7466; --bad-soft: #3c1d1a;
    --info: #7fb0e3; --info-soft: #1a2c40; --s-correctif: #e89a4c; --s-preventif: #3fb6c4; --s-amelioration: #74828e;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f161c; --surface: #17212a; --surface-2: #1c2832; --ink: #e3e9ee; --ink-2: #aab7c2; --ink-3: #7d8b97;
  --line: #2b3a46; --line-2: #22303b; --accent: #3fb6c4; --accent-ink: #06222a; --accent-soft: #163a41;
  --rail: #0b1116; --rail-ink: #9fb0bd; --rail-active: #1a2731;
  --ok: #5cc48a; --ok-soft: #173326; --warn: #e5b04e; --warn-soft: #3a2f16; --bad: #ef7466; --bad-soft: #3c1d1a;
  --info: #7fb0e3; --info-soft: #1a2c40; --s-correctif: #e89a4c; --s-preventif: #3fb6c4; --s-amelioration: #74828e;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 600; letter-spacing: .01em; line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
.mono { font-family: var(--f-mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.boot { padding: 40px 16px; color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Structure ---------- */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100%; }
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand svg { flex: none; }
.brand b { font-family: var(--f-display); font-size: 21px; font-weight: 700; letter-spacing: .03em; display: block; line-height: 1; }
.brand small { font-size: 11.5px; color: var(--rail-ink); letter-spacing: .04em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 5px; color: var(--rail-ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--rail-active); color: #fff; }
.nav a.on { background: var(--rail-active); color: #fff; box-shadow: inset 3px 0 0 #3fb6c4; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; background: #c0392b; color: #fff; font-size: 11px; font-weight: 600; border-radius: 9px; padding: 0 7px; line-height: 18px; }
.rail .sep { margin: 14px 10px 6px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #6f8291; }
.rail .me { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #2c3c49; font-size: 13px; }
.rail .me b { color: #fff; display: block; font-weight: 500; }
.rail .me button { background: none; border: 0; color: var(--rail-ink); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; margin-right: 12px; }

main.view { padding-block: 26px 60px; padding-inline: 32px; max-width: 1400px; width: 100%; min-width: 0; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 20px; }
.head .eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; margin-bottom: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Boutons & champs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 5px; padding: 7px 13px; font: 500 14px var(--f-body); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: 14px var(--f-body); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 7px 9px; width: 100%; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
label.f.chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.f.chk input { width: auto; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid-form .full { grid-column: 1 / -1; }
.grid-form.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { max-width: 260px; }
.filters select { width: auto; max-width: 240px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; font: 500 13px var(--f-body); color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ink); color: var(--surface); }

/* ---------- Panneaux ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line-2); }
.panel > header h2 { font-size: 18px; }
.panel .pad { padding: 14px 16px; }
.empty { padding: 26px 16px; text-align: center; color: var(--ink-3); }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 12px 14px; text-decoration: none; color: inherit; display: block; position: relative; }
a.kpi:hover { border-color: var(--ink-3); }
.kpi .l { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.kpi .v { font-family: var(--f-display); font-size: 34px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 17px; color: var(--ink-3); font-weight: 500; margin-left: 2px; }
.kpi .s { font-size: 12px; color: var(--ink-3); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.kpi.bad .v { color: var(--bad); }
.kpi.warn .v { color: var(--warn); }
.kpi-group { font-size: 11.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 4px 0 8px; }

.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.c-8 { grid-column: span 8; } .c-4 { grid-column: span 4; } .c-6 { grid-column: span 6; } .c-12 { grid-column: span 12; }

/* ---------- Tableaux ---------- */
.tbl-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.clic { cursor: pointer; }
.t tbody tr.clic:hover td { background: var(--surface-2); }
.t td.r, .t th.r { text-align: right; }
.t .sub { font-size: 12.5px; color: var(--ink-3); }
.t td.prio { padding: 0; width: 4px; min-width: 4px; }
.t td.mono, .t td .plate { white-space: nowrap; }
.t td.wide { min-width: 240px; }

/* ---------- Pastilles ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; line-height: 19px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.st-demande { background: var(--info-soft); color: var(--info); }
.st-planifie { background: var(--accent-soft); color: var(--accent); }
.st-en_cours { background: var(--warn-soft); color: var(--warn); }
.st-termine { background: var(--ok-soft); color: var(--ok); }
.st-annule { background: var(--line-2); color: var(--ink-3); }
.eq-en_service { background: var(--ok-soft); color: var(--ok); }
.eq-arret { background: var(--bad-soft); color: var(--bad); }
.eq-maintenance { background: var(--warn-soft); color: var(--warn); }
.eq-reforme { background: var(--line-2); color: var(--ink-3); }
.pr-urgente { color: var(--bad); } .pr-haute { color: var(--warn); } .pr-normale { color: var(--ink-2); } .pr-basse { color: var(--ink-3); }
.bar-urgente { background: var(--bad); } .bar-haute { background: var(--warn); } .bar-normale { background: var(--line); } .bar-basse { background: transparent; }
.type-tag { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.type-tag i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.crit { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 3px; font: 700 12px var(--f-mono); border: 1.5px solid currentColor; }
.crit-A { color: var(--bad); } .crit-B { color: var(--warn); } .crit-C { color: var(--ink-3); }
/* Plaque signalétique : code équipement */
.plate { font: 500 12.5px var(--f-mono); letter-spacing: .04em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; white-space: nowrap; color: var(--ink); }
.late { color: var(--bad); font-weight: 600; }
.soon { color: var(--warn); font-weight: 600; }

/* ---------- Graphique ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--ink-3); font: 11px var(--f-body); }
.chart .grid { stroke: var(--line-2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: 4px 12px; align-items: center; font-size: 13px; }
.hbar .track { height: 8px; background: var(--line-2); border-radius: 4px; overflow: hidden; grid-column: 1 / -1; margin-bottom: 8px; }
.hbar .track span { display: block; height: 100%; background: var(--s-correctif); border-radius: 4px; }

/* ---------- Liste compacte ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list li .grow { flex: 1; min-width: 0; }
.list li .grow b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li.clic { cursor: pointer; }
.list li.clic:hover { background: var(--surface-2); }

/* ---------- Fiche équipement ---------- */
.fiche { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; font-size: 13.5px; }
.specs dt { color: var(--ink-3); }
.specs dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }

/* ---------- Stock ---------- */
.gauge { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.gauge .g { flex: 1; height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.gauge .g span { display: block; height: 100%; background: var(--ok); }
.gauge.low .g span { background: var(--bad); }
.gauge.mid .g span { background: var(--warn); }

/* ---------- Modale ---------- */
dialog#modal { border: 1px solid var(--line); border-radius: 9px; padding: 0; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog#modal::backdrop { background: rgba(10, 18, 24, .5); }
.m-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.m-body { padding: 18px 20px; }
.m-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2); position: sticky; bottom: 0; }
.m-foot .left { margin-right: auto; }
.lines { display: grid; gap: 8px; }
.lines .line { display: grid; grid-template-columns: minmax(0, 1fr) 90px 34px; gap: 8px; }
.confirm { background: var(--bad-soft); border: 1px solid var(--bad); color: var(--ink); border-radius: 6px; padding: 10px 12px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.note { font-size: 12.5px; color: var(--ink-3); }
.cost { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; padding: 10px 12px; background: var(--surface-2); border-radius: 6px; }
.cost b { font-family: var(--f-display); font-size: 19px; font-weight: 600; }

/* ---------- Connexion ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--rail); background-image: repeating-linear-gradient(135deg, transparent 0 22px, rgba(255,255,255,.025) 22px 44px); }
.login form { width: min(380px, 100%); background: var(--surface); border-radius: 9px; padding: 28px; display: grid; gap: 14px; }
.login .brand { color: var(--ink); padding: 0 0 6px; }
.login .brand small { color: var(--ink-3); }
.err { color: var(--bad); font-size: 13px; }

/* ---------- Notifications ---------- */
#toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); font-size: 13.5px; max-width: 340px; }
.toast.bad { background: var(--bad); color: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .c-8, .c-4, .c-6 { grid-column: span 12; }
  .fiche { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px)); gap: 6px; z-index: 20; overflow-x: auto; }
  .brand { padding: 0 8px 0 0; }
  .brand small, .brand b, .rail .sep { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 7px 9px; white-space: nowrap; }
  .nav a span.lbl { display: none; }
  .nav a.on { box-shadow: inset 0 -3px 0 #3fb6c4; }
  .rail .me { margin: 0 0 0 auto; border: 0; padding: 0; white-space: nowrap; }
  .rail .me b { display: none; }
  main.view { padding-inline: 16px; padding-block: 18px 60px; }
  .grid-form, .grid-form.three { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
