/* ============================================================
   EllioFREQ — thème & mise en page
   Même socle que les autres démonstrateurs Ellio (clair + sombre),
   accent orange « signal » propre à l'analyse fréquentielle.
   ============================================================ */
:root {
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --series-3: #eda100;
  --series-5: #4a3aa7;
  --status-good: #0ca30c;
  --status-warning: #d99400;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --accent: #e8611c;
  --accent-soft: rgba(232, 97, 28, .12);
  --shadow: 0 1px 3px rgba(0, 0, 0, .07);
}
[data-theme="dark"] {
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #242423;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #199e70;
  --series-3: #e0a020;
  --series-5: #9085e9;
  --status-warning: #fab219;
  --accent: #ff8c42;
  --accent-soft: rgba(255, 140, 66, .14);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--page);
}
a { color: var(--accent); }

/* ---------------- structure ---------------- */
#app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #ff8c42, #c8401c);
  display: grid; place-items: center; color: #fff;
}
.brand-logo svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand b { font-size: 16px; letter-spacing: .2px; }
.brand span { display: block; font-size: 11px; color: var(--text-muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--text-secondary); text-decoration: none;
  font-weight: 500; transition: background .12s, color .12s;
}
.nav-item svg { width: 17px; height: 17px; flex: none; stroke-width: 1.9; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--surface-2); color: var(--accent); }
.nav-item .pill {
  margin-left: auto; background: var(--status-critical); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 99px;
  min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 5px;
}
.sidebar-foot { margin-top: auto; padding: 10px 12px; font-size: 11px; color: var(--text-muted); line-height: 1.5; }

.main { padding: 20px 26px 46px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { font-size: 21px; font-weight: 650; letter-spacing: .2px; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-secondary);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 99px; padding: 6px 12px; white-space: nowrap;
}
.chip b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.chip i.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-good); animation: pulse 1.6s infinite; }
.chip.rec i.dot { background: var(--status-critical); animation: pulse .8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

/* ---------------- composants ---------------- */
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-5 { grid-template-columns: repeat(5, 1fr); }
.cols-side { grid-template-columns: 320px 1fr; }
.cols-13 { grid-template-columns: 1.15fr 1fr; }
@media (max-width: 1200px) { .cols-5 { grid-template-columns: repeat(3, 1fr); } .cols-4 { grid-template-columns: repeat(2, 1fr); } .cols-3 { grid-template-columns: 1fr 1fr; } .cols-side { grid-template-columns: 1fr; } .cols-13 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  #app { grid-template-columns: 64px 1fr; }
  .sidebar .label, .brand div, .sidebar-foot { display: none; }
  .cols-2, .cols-3, .cols-4, .cols-5 { grid-template-columns: 1fr; }
  .main { padding: 14px 12px 40px; }
}
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h3 {
  font-size: 12.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted); margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.card h3 .right { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card.accent-top { border-top: 3px solid var(--accent); }
.mt { margin-top: 14px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 14px; }
.muted { color: var(--text-muted); } .sec { color: var(--text-secondary); }
.small { font-size: 12px; } .tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
p.lead { font-size: 15px; line-height: 1.55; color: var(--text-secondary); max-width: 78ch; }
.prose { line-height: 1.6; color: var(--text-secondary); max-width: 80ch; }
.prose b, .prose strong { color: var(--text-primary); }
.prose p + p { margin-top: 8px; }
.prose ul { padding-left: 20px; margin-top: 6px; }
.prose li + li { margin-top: 3px; }

.kpi { display: flex; flex-direction: column; gap: 3px; }
.kpi .v { font-size: 26px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.kpi .l { font-size: 12px; color: var(--text-muted); }
.kpi .sub { font-size: 12px; color: var(--text-secondary); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; border-radius: 99px; padding: 3px 10px;
  background: var(--surface-2); color: var(--text-secondary); white-space: nowrap;
}
.badge.good { background: color-mix(in srgb, var(--status-good) 16%, transparent); color: var(--status-good); }
.badge.warn { background: color-mix(in srgb, var(--status-warning) 20%, transparent); color: color-mix(in srgb, var(--status-warning) 75%, var(--text-primary)); }
.badge.serious { background: color-mix(in srgb, var(--status-serious) 18%, transparent); color: var(--status-serious); }
.badge.crit { background: color-mix(in srgb, var(--status-critical) 16%, transparent); color: var(--status-critical); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.info { background: color-mix(in srgb, var(--series-1) 16%, transparent); color: var(--series-1); }
.badge.demo { background: color-mix(in srgb, var(--series-5) 16%, transparent); color: var(--series-5); letter-spacing: .5px; text-transform: uppercase; font-size: 10px; }

button, .btn {
  font: inherit; cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 14px; font-weight: 550;
  transition: filter .12s, background .12s;
  display: inline-flex; align-items: center; gap: 7px;
}
button:hover, .btn:hover { filter: brightness(1.06); }
button:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-danger { color: var(--status-critical); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { padding: 11px 20px; font-size: 15px; border-radius: 11px; }
.btn-icon { padding: 7px 9px; display: inline-grid; place-items: center; }
.btn-icon svg, .btn svg { width: 16px; height: 16px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 5px 12px; border-radius: 7px; color: var(--text-secondary); font-size: 13px; }
.seg button.on { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow); font-weight: 600; }

input, select, textarea {
  font: inherit; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 11px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="number"] { width: 100px; font-variant-numeric: tabular-nums; }
input[type="range"] { padding: 0; accent-color: var(--accent); width: 100%; }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
textarea { width: 100%; min-height: 70px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-muted); }
.field > b, .field > span.lbl { font-weight: 600; text-transform: uppercase; letter-spacing: .4px; font-size: 10.5px; }
.field input, .field select { width: 100%; }
.field .ro { padding: 7px 11px; border-radius: 9px; background: var(--surface-2); color: var(--text-primary); font-variant-numeric: tabular-nums; }
.fields { display: flex; flex-direction: column; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 14px; }

/* ---------------- tables ---------------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); font-weight: 600; padding: 8px 10px;
  border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--accent-soft); }
.tbl .num { text-align: right; }
.tbl th.num { text-align: right; }
.tbl th.lam { text-transform: none; }
.tbl td.dim { color: var(--text-muted); }
.tbl input { padding: 4px 8px; border-radius: 6px; }
.tbl input.w-s { width: 84px; } .tbl input.w-m { width: 150px; } .tbl input.w-l { width: 220px; }
.tbl .harm { color: var(--text-muted); font-size: 12px; }

/* ---------------- spécifique ---------------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; line-height: 1.45;
  background: color-mix(in srgb, var(--series-1) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--series-1) 35%, transparent);
}
.alert.warn { background: color-mix(in srgb, var(--status-warning) 12%, var(--surface-1)); border-color: color-mix(in srgb, var(--status-warning) 40%, transparent); }
.alert.crit { background: color-mix(in srgb, var(--status-critical) 12%, var(--surface-1)); border-color: color-mix(in srgb, var(--status-critical) 40%, transparent); }
.alert.good { background: color-mix(in srgb, var(--status-good) 10%, var(--surface-1)); border-color: color-mix(in srgb, var(--status-good) 35%, transparent); }

.sim { border-style: dashed; border-color: color-mix(in srgb, var(--series-5) 45%, transparent); background: color-mix(in srgb, var(--series-5) 4%, var(--surface-1)); }
.sim summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.sim summary::-webkit-details-marker { display: none; }
.sim summary .caret { margin-left: auto; transition: transform .15s; }
.sim details[open] summary .caret { transform: rotate(180deg); }
.sim-body { margin-top: 12px; display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 900px) { .sim-body { grid-template-columns: 1fr; } }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-list label { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; padding: 5px 8px; border-radius: 8px; }
.check-list label:hover { background: var(--surface-2); }
.check-list label small { color: var(--text-muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.counter { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.counter .c { background: var(--surface-2); border-radius: 10px; padding: 9px 12px; }
.counter .c .v { font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.counter .c .v small { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.counter .c .l { font-size: 11px; color: var(--text-muted); }

.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #ffb347); border-radius: 99px; transition: width .1s linear; }

.cand { display: flex; flex-direction: column; gap: 8px; }
.cand .c {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface-1);
}
.cand .c.best { border-color: color-mix(in srgb, var(--accent) 55%, transparent); background: color-mix(in srgb, var(--accent) 6%, var(--surface-1)); }
.cand .c.dim { opacity: .7; }
.cand .name { font-weight: 600; }
.cand .name small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11.5px; margin-top: 1px; }
.cand .score { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }
.cand .score small { display: block; font-weight: 400; color: var(--text-muted); font-size: 11px; }
.cand .bar { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.cand .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--series-3), var(--accent)); }
.cand .c.best .bar i { background: linear-gradient(90deg, var(--accent), var(--status-critical)); }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-secondary); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 9px solid var(--series-5); border-radius: 0; background: none; }
.legend i.dash { height: 0; border-top: 2px dashed var(--text-muted); border-radius: 0; background: none; }
.legend i.zone { background: var(--text-muted); opacity: .25; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: none; background: transparent; border-radius: 8px 8px 0 0; padding: 8px 14px; color: var(--text-secondary); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: -1px; }

.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; align-items: stretch; }
.pipeline .step { position: relative; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.pipeline .step .n { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .5px; text-transform: uppercase; }
.pipeline .step b { display: block; margin: 4px 0 4px; }
.pipeline .step p { font-size: 12px; color: var(--text-secondary); line-height: 1.45; }
.pipeline .step::after { content: '→'; position: absolute; right: -11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 16px; }
.pipeline .step:last-child::after { content: ''; }
@media (max-width: 1000px) { .pipeline { grid-template-columns: 1fr 1fr; } .pipeline .step::after { content: ''; } }

.formula { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; display: inline-block; font-size: 13px; }

/* synoptique machine (SVG) */
.syno { width: 100%; height: auto; display: block; }
.syno text { font-family: system-ui, "Segoe UI", sans-serif; font-size: 10px; fill: var(--text-muted); }
.syno .sheet { stroke: var(--accent); stroke-width: 2; fill: none; opacity: .75; }
.syno .el circle, .syno .el rect, .syno .el path { fill: var(--surface-2); stroke: var(--axis); stroke-width: 1.4; transition: stroke .15s, fill .15s; }
.syno .el.loop path { fill: none; stroke-dasharray: 3 3; }
.syno .el:hover circle, .syno .el:hover rect, .syno .el:hover path { stroke: var(--text-secondary); }
.syno .el.hl-sel circle, .syno .el.hl-sel rect, .syno .el.hl-sel path { stroke: var(--accent); stroke-width: 2.4; fill: var(--accent-soft); }
.syno .el.hl-warn circle, .syno .el.hl-warn rect, .syno .el.hl-warn path { stroke: var(--status-warning); stroke-width: 2.4; fill: color-mix(in srgb, var(--status-warning) 18%, transparent); }
.syno .el.hl-crit circle, .syno .el.hl-crit rect, .syno .el.hl-crit path { stroke: var(--status-critical); stroke-width: 2.6; fill: color-mix(in srgb, var(--status-critical) 20%, transparent); animation: syno-blink 1.2s ease-in-out infinite; }
@keyframes syno-blink { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.syno .sec-lbl { font-size: 9.5px; letter-spacing: .6px; text-transform: uppercase; fill: var(--text-muted); }

/* rapport */
.report { max-width: 980px; }
.report .rp-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--accent); padding-bottom: 12px; margin-bottom: 16px; }
.report .rp-head .brand-logo { width: 44px; height: 44px; }
.report .rp-head h2 { font-size: 20px; }
.report .rp-head .r { margin-left: auto; text-align: right; font-size: 12px; color: var(--text-muted); }
.report .meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 14px; font-size: 12.5px; }
.report .meta div b { display: block; color: var(--text-muted); font-weight: 600; font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; }
.report h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin: 18px 0 8px; }
.report .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 26px; font-size: 12px; color: var(--text-muted); }
.report .sign div { border-top: 1px solid var(--axis); padding-top: 6px; }
@media print {
  #app { grid-template-columns: 1fr; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}

/* modal & info-bulle */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; width: min(720px, 100%); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.modal h2 button { margin-left: auto; }
.chart-tip {
  position: absolute; z-index: 99; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25); color: var(--text-primary);
  display: none; max-width: 300px; line-height: 1.5;
}
.chart-tip .tt-head { color: var(--text-muted); font-size: 11.5px; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .4px; }
canvas { display: block; width: 100%; }
.empty { text-align: center; color: var(--text-muted); padding: 40px 0; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text-primary); color: var(--page); padding: 10px 18px; border-radius: 99px; font-weight: 600; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.3); animation: toast .25s ease-out; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- mobile ---------------- */
/* Socle mobile de la charte Ellio (references/mobile.css, 06/09/2026).
   À coller tel quel à la fin de app.css, après le bloc « spécifique ».
   Palier « téléphone » ≤ 640 px : rien ici ne s'applique au-dessus, le rendu PC
   reste identique au pixel. Le bloc (hover:none) and (pointer:coarse) ne vise que
   les écrans tactiles sans souris (téléphone, tablette) : un PC à écran tactile,
   dont le pointeur principal est la souris, n'y entre pas.
   Décision de la gamme : sous 640 px la barre latérale devient une barre
   d'onglets fixe en bas, défilante, icône + libellé — même HTML, CSS seul. */

@media (max-width: 640px) {
  :root { --tabbar-h: 60px; --sab: env(safe-area-inset-bottom, 0px); }
  html { -webkit-text-size-adjust: 100%; }

  /* -- coque : barre d'onglets en bas (la .sidebar sort du flux de la grille) -- */
  #app { grid-template-columns: 1fr; min-height: 100vh; min-height: 100dvh; }
  .sidebar {
    position: fixed; top: auto; right: 0; bottom: 0; left: 0; z-index: 40;
    height: auto; flex-direction: row; align-items: stretch; gap: 2px;
    padding: 4px 4px calc(4px + var(--sab));
    border-right: 0; border-top: 1px solid var(--border);
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain; scrollbar-width: none; scroll-snap-type: x proximity;
    box-shadow: 0 -2px 10px color-mix(in srgb, var(--text-primary) 8%, transparent);
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand, .sidebar-foot { display: none; }
  .nav-item {
    flex: 0 0 auto; flex-direction: column; justify-content: center; gap: 3px;
    min-width: 64px; min-height: 50px; padding: 5px 6px; border-radius: 9px;
    font-size: 10px; line-height: 1.1; text-align: center; position: relative;
    scroll-snap-align: center;
  }
  .nav-item svg { width: 21px; height: 21px; }
  .sidebar .nav-item .label { display: block; white-space: nowrap; } /* bat le repli 800 px (0,2,1 > 0,1,1) */
  .nav-item .pill { position: absolute; top: 2px; right: 6px; margin: 0;
                    min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }

  /* -- contenu : marges réduites, place dégagée sous la barre d'onglets -- */
  .main { padding: 12px 12px calc(var(--tabbar-h) + 16px + var(--sab)); }
  .topbar { flex-wrap: wrap; gap: 8px 10px; margin-bottom: 12px; }
  .topbar h1 { flex: 1 1 100%; font-size: 18px; line-height: 1.25; }  /* titre seul sur sa ligne */
  .topbar .spacer { flex: 1 1 0; }                                     /* indicateurs à droite, ligne 2 */
  .topbar .badge, .topbar .live-dot, .topbar .chip { white-space: normal; max-width: 100%; }
  .grid { gap: 10px; }
  /* minmax(0, 1fr) : une colonne 1fr ne descend jamais sous la largeur intrinsèque de son contenu
     (un <select>, un texte nowrap) et ferait déborder la page */
  .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); }
  .grid[style] { grid-template-columns: minmax(0, 1fr) !important; }  /* grilles posées en inline par le JS */
  .grid > *, .card { min-width: 0; }
  .card { padding: 12px; border-radius: 11px; }
  .card h3 { flex-wrap: wrap; row-gap: 6px; }
  .card h3 .right { flex-basis: 100%; max-width: 100%; min-width: 0; flex-wrap: wrap; }  /* commandes sous le titre */
  .card h3 .right select { flex: 1 1 100%; width: 100%; }
  .kpi .v { font-size: 24px; }
  .sensor-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .legend { gap: 6px 14px; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .empty { padding: 28px 0; }

  /* -- champs, filtres, segmentés, onglets -- */
  input, select, textarea { font-size: 16px; }   /* sous 16 px, iOS zoome à la prise de focus */
  select { max-width: 100%; }                     /* un <select> prend la largeur de sa plus longue option */
  input[type="number"] { width: 100px; }
  .filters { gap: 8px; }
  .filters .f { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .filters .f select, .filters .f input { width: 100%; min-width: 0; }
  .filters .f input[style], .filters .f select[style] { width: 100% !important; min-width: 0 !important; }
  .filters > button, .filters > .btn { flex: 1 1 100%; }
  .seg { flex-wrap: wrap; max-width: 100%; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; white-space: nowrap; }

  /* -- tableaux : ils défilent dans .tbl-wrap ; ombres de bord = indice de défilement
        (les deux calques « surface » suivent le contenu et découvrent l'ombre) -- */
  .tbl-wrap {
    -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
    background:
      linear-gradient(to right, var(--surface-1) 40%, transparent) left / 32px 100% no-repeat local,
      linear-gradient(to left,  var(--surface-1) 40%, transparent) right / 32px 100% no-repeat local,
      linear-gradient(to right, color-mix(in srgb, var(--text-primary) 16%, transparent), transparent) left / 12px 100% no-repeat scroll,
      linear-gradient(to left,  color-mix(in srgb, var(--text-primary) 16%, transparent), transparent) right / 12px 100% no-repeat scroll;
  }
  .tbl td { padding: 12px 10px; }   /* lignes cliquables ≈ 44 px */

  /* -- modales : feuille ancrée en bas, hauteur bornée par le viewport dynamique -- */
  .modal-back { padding: 0; align-items: end; }
  .modal, .modal.wide {
    width: 100%; max-height: 92vh; max-height: calc(100dvh - 24px);
    border-radius: 16px 16px 0 0; border-bottom: 0;
    padding: 14px 14px calc(16px + var(--sab));
  }
  .modal h2 { font-size: 16px; flex-wrap: wrap; }

  /* -- info-bulle, toast (au-dessus de la barre d'onglets) -- */
  .chart-tip { max-width: min(300px, calc(100vw - 24px)); }
  .toast { left: 12px; right: 12px; max-width: none; transform: none; animation: none;
           bottom: calc(var(--tabbar-h) + 14px + var(--sab)); }
}

@media (hover: none) and (pointer: coarse) {
  /* cibles tactiles ≥ 44 px ; 40 px pour les commandes compactes */
  button, .btn { min-height: 44px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
  .btn-sm, .seg button, .tabs button, .pager button { min-height: 40px; }
  .btn-sm { min-width: 40px; }
  .seg button { min-width: 40px; }
  a.btn, a.btn-sm { display: inline-flex; align-items: center; }   /* min-height sans effet sur un lien inline */
  a.badge { display: inline-flex; align-items: center; min-height: 40px; }
  input[type="color"] { min-width: 44px; min-height: 40px; }
  summary { min-height: 44px; }
  select, textarea,
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]) { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  input[type="range"] { min-height: 44px; }
  .nav-item { min-height: 50px; }
  /* pas de halo au toucher, retour visuel bref à l'appui */
  a, button, .nav-item, .tbl tbody tr, .sensor-tile { -webkit-tap-highlight-color: transparent; }
  button:active, .btn:active, .nav-item:active { filter: brightness(.9); }
  /* le survol « colle » après un toucher : on le neutralise */
  button:hover, .btn:hover { filter: none; }
  .nav-item:hover { background: transparent; color: var(--text-secondary); }
  .nav-item.active:hover { background: var(--surface-2); color: var(--accent); }
  .tbl tbody tr:hover { background: transparent; }
  .sensor-tile:hover { background: var(--surface-1); }
}

/* ---------------- mobile : spécifique EllioFreq ---------------- */
@media (max-width: 640px) {
  .cols-5, .cols-side, .cols-13 { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .pipeline .step::after { content: ''; }
  /* rapport : méta sur 2 colonnes, signatures empilées (le bloc @media print reste intact) */
  .report .rp-head { flex-wrap: wrap; }
  .report .rp-head .r { margin-left: 0; text-align: left; flex-basis: 100%; }
  .report .meta { grid-template-columns: 1fr 1fr; }
  .report .sign { grid-template-columns: 1fr; gap: 14px; }
  /* synoptique SVG (viewBox 1000 × 232) : garde une taille lisible et défile dans son cadre */
  #db-syno, #an-syno, #rp-syno { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .syno { min-width: 640px; }
  .tbl input.w-l { width: 160px; }
  /* plancher 11 px */
  .badge.demo, .field > b, .field > span.lbl, .report .meta div b { font-size: 11px; }
  .chart-tout { margin-top: 6px; }   /* bouton « Tout » créé par charts.js sous 640 px */
}
@media (hover: none) and (pointer: coarse) {
  .check-list label:hover { background: transparent; }
}
