/* ==================================================================
   IHM DU MALAXEUR (simulation)
   L'écran garde son allure d'IHM industrielle (fond sombre) quel que
   soit le thème du site. Couleurs des courbes validées pour ce fond :
   vitesse #3987e5, température #d95926 (contraste, daltonisme).
   ================================================================== */
.hmi {
  --h-bg: #0f1513; --h-panel: #161e1b; --h-line: #27322d; --h-grid: #1f2925;
  --h-text: #e6ebe8; --h-muted: #8d9893; --h-v: #3987e5; --h-t: #d95926;
  --h-ok: #3cc274; --h-warn: #f5b700; --h-fault: #ff5a47;
  margin-top: .75rem; border-radius: 14px; overflow: hidden; color: var(--h-text);
  background: var(--h-bg); border: 1px solid #000; box-shadow: 0 0 0 6px #2a2f2d, 0 0 0 7px #000, 0 24px 50px -24px rgba(0,0,0,.6);
  font-variant-numeric: tabular-nums;
}
:root[data-theme="dark"] .hmi { box-shadow: 0 0 0 6px #232a27, 0 0 0 7px #000, 0 24px 50px -24px rgba(0,0,0,.8); }
.hmi-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 1rem; background: #1b2420; border-bottom: 1px solid var(--h-line); }
.hmi-title { font-weight: 750; font-stretch: 110%; font-size: var(--fs-sm); }
.hmi-title span { font-weight: 500; font-stretch: 100%; color: var(--h-muted); margin-left: .5rem; }
.hmi-state { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--fs-xs); font-weight: 600; padding: .2rem .6rem .2rem .25rem; border-radius: 6px; background: #0b100e; border: 1px solid var(--h-line); }
.hmi-state b { padding: .05rem .4rem; border-radius: 4px; background: var(--h-line); color: var(--h-text); font-size: .7rem; }
.hmi-state.run b { background: var(--h-ok); color: #06210f; }
.hmi-state.ready b { background: var(--h-warn); color: #1c2220; }
.hmi-state.fault b { background: var(--h-fault); color: #fff; }
@media (prefers-reduced-motion: no-preference) { .hmi-state.fault { animation: hmi-blink 1s steps(1) infinite; } @keyframes hmi-blink { 50% { border-color: var(--h-fault); } } }

.hmi-body { display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.hmi-side { padding: 1rem; border-right: 1px solid var(--h-line); display: grid; gap: 1.1rem; align-content: start; background: var(--h-panel); }
.hmi-group { display: grid; gap: .5rem; }
.hmi-label { font-size: .7rem; font-weight: 700; color: var(--h-muted); }
.hmi-recipes { display: grid; gap: .4rem; }
.hmi-recipe { text-align: left; padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--h-line); background: #0f1513; color: var(--h-text); font: inherit; font-weight: 700; font-size: var(--fs-sm); cursor: pointer; }
.hmi-recipe small { display: block; font-weight: 500; font-size: .72rem; color: var(--h-muted); }
.hmi-recipe[aria-checked="true"] { border-color: var(--h-warn); box-shadow: inset 3px 0 0 var(--h-warn); background: #1d2316; }
.hmi-recipe:disabled { opacity: .5; cursor: not-allowed; }
.hmi-cmds { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.hmi-btn { display: grid; justify-items: center; gap: .1rem; padding: .55rem .2rem; border-radius: 8px; border: 1px solid #3a4742; background: linear-gradient(180deg, #26302c, #1b2320); color: var(--h-text); font: inherit; font-weight: 800; font-size: var(--fs-sm); cursor: pointer; box-shadow: 0 2px 0 #0a0e0c; }
.hmi-btn small { font-size: .6rem; font-weight: 600; color: var(--h-muted); text-align: center; line-height: 1.15; }
.hmi-btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.hmi-btn:disabled { opacity: .4; cursor: not-allowed; }
.hmi-btn.go:not(:disabled) { border-color: var(--h-ok); box-shadow: 0 2px 0 #0a0e0c, 0 0 0 1px rgba(60,194,116,.25); }
.hmi-btn.pulse:not(:disabled) { animation: hmi-pulse 1.4s ease-in-out infinite; }
@keyframes hmi-pulse { 50% { box-shadow: 0 2px 0 #0a0e0c, 0 0 14px rgba(245,183,0,.55); border-color: var(--h-warn); } }
.hmi-btn.au { background: linear-gradient(180deg, #b3271a, #8c1b11); border-color: #d5392a; }
.hmi-btn.au small { color: #ffd2cc; }
.hmi-btn.au[aria-pressed="true"] { background: #5a130c; box-shadow: inset 0 2px 6px rgba(0,0,0,.6); }
@media (prefers-reduced-motion: reduce) { .hmi-btn.pulse:not(:disabled) { animation: none; border-color: var(--h-warn); } }
.hmi-safety { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .78rem; }
.hmi-safety li { display: flex; align-items: center; gap: .5rem; color: var(--h-muted); }
.hmi-safety i { width: 8px; height: 8px; border-radius: 50%; background: var(--h-ok); box-shadow: 0 0 6px var(--h-ok); }
.hmi-safety li.ko { color: var(--h-text); }
.hmi-safety li.ko i { background: var(--h-fault); box-shadow: 0 0 8px var(--h-fault); }

.hmi-main { padding: 1rem; display: grid; gap: .9rem; min-width: 0; }
.hmi-phases { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.hmi-phases li { padding: .45rem .5rem; border-radius: 6px; background: #121916; border: 1px solid var(--h-line); font-size: .7rem; color: var(--h-muted); line-height: 1.25; min-width: 0; }
.hmi-phases b { display: block; font-size: .8rem; color: var(--h-text); }
.hmi-phases li.done { border-color: #2b4a37; color: #9fb7a8; }
.hmi-phases li.done b::after { content: " ✓"; color: var(--h-ok); }
.hmi-phases li.on { border-color: var(--h-warn); background: #262612; color: var(--h-text); box-shadow: inset 0 -3px 0 var(--h-warn); }
.hmi-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.hmi-tile { padding: .55rem .7rem; border-radius: 8px; background: #121916; border: 1px solid var(--h-line); display: grid; }
.hmi-tile span { font-size: .68rem; color: var(--h-muted); font-weight: 600; }
.hmi-tile b { font-size: 1.45rem; font-weight: 700; line-height: 1.15; font-stretch: 105%; }
.hmi-tile small { font-size: .68rem; color: var(--h-muted); }
.hmi-tile b.km3-on { color: var(--h-warn); }

.hmi-charts { position: relative; display: grid; gap: .5rem; }
.hmi-chart { position: relative; border-radius: 8px; background: #0c1210; border: 1px solid var(--h-line); padding: .45rem .5rem .2rem; }
.hmi-chart-title { display: flex; align-items: center; gap: .4rem; font-size: .7rem; font-weight: 600; color: var(--h-muted); }
.hmi-chart-title i { width: 14px; height: 2px; border-radius: 1px; }
.sw-v { background: var(--h-v); } .sw-t { background: var(--h-t); }
.hmi-chart svg { display: block; width: 100%; height: 112px; overflow: visible; touch-action: pan-y; }
.hmi-chart .grid line { stroke: var(--h-grid); stroke-width: 1; }
.hmi-chart .axis text { fill: var(--h-muted); font-size: 10px; font-family: var(--font); }
.hmi-chart .phase-mark { stroke: #33403a; stroke-width: 1; stroke-dasharray: 2 3; }
.hmi-chart .phase-lbl { fill: #6f7b75; font-size: 9px; font-family: var(--font); }
.hmi-chart .band { fill: rgba(217,89,38,.08); }
.hmi-chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.hmi-chart .ln-v { stroke: var(--h-v); } .hmi-chart .ln-t { stroke: var(--h-t); }
.hmi-chart .xh { stroke: var(--h-text); stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; }
.hmi-chart .dot { stroke: #0c1210; stroke-width: 2; }
.hmi-chart .dot-v { fill: var(--h-v); } .hmi-chart .dot-t { fill: var(--h-t); }
.hmi-tip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 150px;
  padding: .5rem .65rem; border-radius: 8px; background: #e6ebe8; color: #1c2220; font-size: .74rem;
  box-shadow: 0 10px 24px -8px rgba(0,0,0,.6);
}
.hmi-tip[hidden] { display: none; }
.hmi-tip b { display: block; font-size: .72rem; color: #4d5752; margin-bottom: .2rem; }
.hmi-tip div { display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.hmi-tip div span { display: inline-flex; align-items: center; gap: .35rem; color: #4d5752; }
.hmi-tip i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.hmi-tip strong { font-weight: 700; }

.hmi-alarm { min-height: 2.2rem; display: flex; align-items: center; gap: .6rem; padding: .5rem 1rem; border-top: 1px solid var(--h-line); background: #0b100e; font-size: var(--fs-xs); color: var(--h-muted); }
.hmi-alarm.warn { color: #ffe08a; }
.hmi-alarm.fault { color: #ffc2bb; background: #2a0f0b; }
.hmi-alarm.ok { color: #a9e8c3; }
.hmi-alarm::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--h-muted); flex: none; }
.hmi-alarm.warn::before { background: var(--h-warn); } .hmi-alarm.fault::before { background: var(--h-fault); } .hmi-alarm.ok::before { background: var(--h-ok); }

@media (max-width: 860px) {
  .hmi-body { grid-template-columns: 1fr; }
  .hmi-side { border-right: 0; border-bottom: 1px solid var(--h-line); grid-template-columns: 1fr 1fr; }
  .hmi-side .hmi-group:nth-child(3) { grid-column: 1 / -1; }
  .hmi-safety { grid-template-columns: repeat(3, auto); justify-content: start; column-gap: 1rem; }
  .hmi-phases { grid-template-columns: repeat(3, 1fr); }
  .hmi-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .hmi-side { grid-template-columns: 1fr; }
  .hmi-safety { grid-template-columns: repeat(2, auto); }
  .hmi-bar { flex-wrap: wrap; }
}
