/* ============================================================
   JIT • Bierkowo Biogas SCADA — control-room theme
   Built on JIT Engineering design tokens (tokens.css)
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root { height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--fg-on-dark);
  background: var(--navy-950);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  --hud-bg:        #060f1f;
  --hud-panel:     #0c1b35;
  --hud-panel-2:   #102544;
  --hud-line:      rgba(122,160,209,0.16);
  --hud-line-soft: rgba(122,160,209,0.09);
  --hud-text:      #dfeaf7;
  --hud-text-2:    #9db2cc;
  --hud-text-3:    #647a98;
}
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--orange-500); color: #2a1800; }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #1c3358; border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #2a4a78; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.eyebrow { font-family: var(--font-body); font-weight: 700; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--hud-text-3); }

/* ===== App shell ============================================ */
.app { display: grid; grid-template-rows: 56px 30px 1fr 34px; grid-template-columns: 232px 1fr;
  grid-template-areas: "top top" "alarmbar alarmbar" "side main" "side foot"; height: 100vh; min-width: 1180px; }
.topbar  { grid-area: top; }
.alarmbar{ grid-area: alarmbar; }
.sidebar { grid-area: side; }
.main    { grid-area: main; overflow: hidden; position: relative; }
.footbar { grid-area: foot; }

/* ===== Top bar ============================================== */
.topbar { display: flex; align-items: center; gap: 18px; padding: 0 16px 0 14px;
  background: linear-gradient(180deg,#0a1730,#081225); border-bottom: 1px solid var(--hud-line);
  box-shadow: 0 1px 0 rgba(0,0,0,.4); z-index: 40; }
.tb-logo { height: 26px; object-fit: contain; }
.tb-divider { width: 1px; height: 26px; background: var(--hud-line); }
.tb-title { display: flex; flex-direction: column; line-height: 1.1; }
.tb-title b { font-size: 14px; font-weight: 700; color: #fff; letter-spacing: .01em; }
.tb-title span { font-size: 10.5px; color: var(--hud-text-3); font-family: var(--font-mono); letter-spacing: .04em; }
.tb-spacer { flex: 1; }
.tb-item { display: flex; align-items: center; gap: 8px; padding: 0 10px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid transparent; }
.tb-clock { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--hud-text); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.tb-clock .d { font-size: 10.5px; color: var(--hud-text-3); font-weight: 500; }
.tb-conn { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 11.5px; color: var(--hud-text-2); }
.tb-conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--status-run); box-shadow: 0 0 0 0 rgba(30,158,90,.6); animation: livepulse 2.4s infinite; }
@keyframes livepulse { 0%{ box-shadow: 0 0 0 0 rgba(30,158,90,.5);} 70%{ box-shadow: 0 0 0 6px rgba(30,158,90,0);} 100%{ box-shadow: 0 0 0 0 rgba(30,158,90,0);} }

/* language switch */
.lang { display: flex; border: 1px solid var(--hud-line); border-radius: var(--r-sm); overflow: hidden; }
.lang button { background: transparent; border: 0; color: var(--hud-text-3); font-family: var(--font-mono); font-weight: 600;
  font-size: 11px; letter-spacing: .06em; padding: 6px 9px; transition: all .12s; }
.lang button:hover { color: var(--hud-text); background: rgba(122,160,209,.07); }
.lang button.on { background: var(--orange-500); color: #2a1800; }

/* user chip */
.tb-user { display: flex; align-items: center; gap: 9px; padding: 4px 6px 4px 10px; }
.tb-user .av { width: 30px; height: 30px; border-radius: var(--r-sm); background: var(--navy-600); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; font-family: var(--font-mono); }
.tb-user .nm { line-height: 1.15; }
.tb-user .nm b { font-size: 12.5px; color: var(--hud-text); display: block; }
.tb-user .nm span { font-size: 10px; color: var(--hud-text-3); }

.iconbtn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm);
  border: 1px solid var(--hud-line); background: rgba(122,160,209,.04); color: var(--hud-text-2); transition: all .12s; position: relative; }
.iconbtn:hover { color: #fff; border-color: var(--navy-400); background: rgba(122,160,209,.1); }
.iconbtn .badge { position: absolute; top: -6px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--status-alarm); color: #fff; font-size: 10px; font-weight: 700; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center; border: 1.5px solid #081225; }

/* ===== Alarm ticker bar ==================================== */
.alarmbar { display: flex; align-items: center; gap: 0; background: #1a0f0d; border-bottom: 1px solid rgba(211,58,44,.4); overflow: hidden; }
.alarmbar.ok { background: #0a1626; border-bottom-color: var(--hud-line); }
.ab-tag { display: flex; align-items: center; gap: 7px; padding: 0 12px; height: 100%; font-size: 10.5px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: #fff; background: var(--status-alarm); flex-shrink: 0; }
.alarmbar.ok .ab-tag { background: #143055; color: var(--hud-text-2); }
.ab-tag svg { width: 13px; height: 13px; }
.ab-track { flex: 1; overflow: hidden; height: 100%; position: relative; }
.ab-move { display: flex; align-items: center; gap: 40px; height: 100%; white-space: nowrap; position: absolute; left: 0;
  animation: abscroll 38s linear infinite; will-change: transform; }
.alarmbar:hover .ab-move { animation-play-state: paused; }
@keyframes abscroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ab-it { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-mono); font-size: 11.5px; color: #f6c9c4; }
.ab-it .t { color: var(--hud-text-3); font-size: 10.5px; }
.ab-it .pri { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ab-it.ack { color: var(--hud-text-3); }
.ab-clk { padding: 0 14px; font-family: var(--font-mono); font-size: 11px; color: var(--hud-text-2); flex-shrink: 0; border-left: 1px solid var(--hud-line); height: 100%; display: flex; align-items: center; gap: 7px; }

/* ===== Sidebar ============================================= */
.sidebar { background: linear-gradient(180deg,#0a1830,#070f20); border-right: 1px solid var(--hud-line);
  display: flex; flex-direction: column; overflow-y: auto; z-index: 30; }
.nav-group { padding: 12px 10px 4px; }
.nav-group .gl { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--hud-text-3); font-weight: 700; padding: 4px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 8.5px 11px; border-radius: var(--r-sm); color: var(--hud-text-2);
  font-size: 13px; font-weight: 600; transition: all .12s; position: relative; border: 1px solid transparent; }
.nav-item:hover { background: rgba(122,160,209,.07); color: var(--hud-text); }
.nav-item.on { background: linear-gradient(90deg, rgba(242,148,31,.14), rgba(242,148,31,.03)); color: #fff; border-color: rgba(242,148,31,.25); }
.nav-item.on::before { content:''; position:absolute; left:0; top:6px; bottom:6px; width:3px; border-radius:2px; background: var(--orange-500); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .ni-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 10px; font-weight: 700;
  font-family: var(--font-mono); display: flex; align-items: center; justify-content: center; }
.nav-item .ni-badge.al { background: var(--status-alarm); color: #fff; }
.nav-item .ni-badge.wn { background: var(--status-warn); color: #2a1c00; }
.nav-sep { height: 1px; background: var(--hud-line-soft); margin: 8px 16px; }
.sb-foot { margin-top: auto; padding: 12px 16px 14px; border-top: 1px solid var(--hud-line-soft); }
.sb-foot .row { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10.5px; color: var(--hud-text-3); padding: 2px 0; }
.sb-foot .row b { color: var(--hud-text-2); font-weight: 600; }

/* ===== Footer status bar ================================== */
.footbar { display: flex; align-items: center; gap: 0; background: #081225; border-top: 1px solid var(--hud-line); padding: 0; z-index: 30; }
.fb-cell { display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 100%; border-right: 1px solid var(--hud-line-soft); }
.fb-cell .lbl { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--hud-text-3); font-weight: 700; }
.fb-cell .val { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--hud-text); }
.fb-cell .val .u { font-size: 10px; color: var(--hud-text-3); margin-left: 2px; }
.fb-cell .dot { width: 8px; height: 8px; border-radius: 50%; }
.fb-spacer { flex: 1; }
.fb-mode { padding: 0 14px; font-family: var(--font-mono); font-size: 11px; color: var(--hud-text-2); display: flex; align-items: center; gap: 8px; }

/* ===== Page scaffolding ==================================== */
.page { position: absolute; inset: 0; overflow: auto; padding: 18px 22px 26px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head .ph-t { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.page-head h1 { font-family: var(--font-display); font-weight: 700; font-size: 23px; line-height: 1.15; color: #fff; letter-spacing: -.01em; }
.page-head .sub { font-size: 12.5px; color: var(--hud-text-2); }
.page-head .ph-tag { font-family: var(--font-mono); font-size: 11px; color: var(--orange-400); border: 1px solid rgba(242,148,31,.3);
  padding: 3px 9px; border-radius: var(--r-sm); white-space: nowrap; margin-top: 4px; }
.ph-actions { margin-left: auto; display: flex; gap: 8px; }

/* ===== Panels ============================================== */
.panel { background: linear-gradient(180deg,#0c1c38,#0a1730); border: 1px solid var(--hud-line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); }
.panel-h { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-bottom: 1px solid var(--hud-line-soft); }
.panel-h .pt { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--hud-text); }
.panel-h .pt small { font-family: var(--font-mono); font-weight: 500; color: var(--hud-text-3); letter-spacing: 0; text-transform: none; margin-left: 6px; }
.panel-h svg { width: 15px; height: 15px; color: var(--orange-400); }
.panel-h .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-b { padding: 14px; }

/* ===== Buttons ============================================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 600; font-size: 13px;
  border: 1px solid var(--hud-line); border-radius: var(--r-sm); padding: 8px 14px; background: rgba(122,160,209,.05);
  color: var(--hud-text); transition: all .12s cubic-bezier(.2,0,0,1); white-space: nowrap; }
.btn:hover { border-color: var(--navy-400); background: rgba(122,160,209,.12); }
.btn:active { transform: scale(.98); }
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary { background: var(--navy-600); border-color: var(--navy-500); color: #fff; }
.btn-primary:hover { background: var(--navy-500); }
.btn-accent { background: var(--orange-500); border-color: var(--orange-500); color: #2a1800; }
.btn-accent:hover { background: var(--orange-400); }
.btn-run { background: var(--status-run); border-color: var(--status-run); color: #fff; }
.btn-run:hover { filter: brightness(1.1); }
.btn-stop { background: var(--status-alarm); border-color: var(--status-alarm); color: #fff; }
.btn-stop:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ===== Status chip / pills ================================= */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; letter-spacing: .04em; font-family: var(--font-mono); text-transform: uppercase; }
.chip .d { width: 7px; height: 7px; border-radius: 50%; }
.chip.run  { background: rgba(30,158,90,.15);  color: #5fd99a; }
.chip.run .d  { background: var(--status-run); box-shadow: 0 0 6px rgba(30,158,90,.8); }
.chip.warn { background: rgba(232,163,23,.15); color: #f3c45a; }
.chip.warn .d { background: var(--status-warn); }
.chip.alarm{ background: rgba(211,58,44,.18); color: #f08478; }
.chip.alarm .d{ background: var(--status-alarm); animation: blink 1s steps(2,end) infinite; }
.chip.idle { background: rgba(117,130,143,.15); color: #a6b6c6; }
.chip.idle .d { background: var(--status-idle); }
.chip.info { background: rgba(46,82,134,.25); color: #8fb4e6; }
.chip.info .d { background: var(--status-info); }
@keyframes blink { 50% { opacity: .25; } }

/* ===== Device readouts on synoptic ======================== */
.dev { position: absolute; transform: translate(-50%,-50%); }
.tag-badge { display: inline-flex; flex-direction: column; align-items: center; cursor: pointer; user-select: none; }

/* live value pill */
.lv { display: inline-flex; align-items: baseline; gap: 3px; font-family: var(--font-mono); font-weight: 600;
  background: rgba(6,15,31,.85); border: 1px solid var(--hud-line); border-radius: var(--r-sm); padding: 2px 7px; }
.lv .n { color: var(--hud-text); font-size: 12.5px; }
.lv .u { color: var(--hud-text-3); font-size: 9.5px; }
.lv.hi .n { color: #f3c45a; } .lv.hi { border-color: rgba(232,163,23,.5); }
.lv.al .n { color: #f08478; } .lv.al { border-color: rgba(211,58,44,.5); }

/* ===== KPI cards =========================================== */
.kpi { background: linear-gradient(180deg,#0d1f3c,#0a1830); border: 1px solid var(--hud-line); border-radius: var(--r-lg); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi .k-l { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--hud-text-3); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.kpi .k-l svg { width: 13px; height: 13px; color: var(--orange-400); }
.kpi .k-v { font-family: var(--font-mono); font-weight: 700; font-size: 28px; color: #fff; margin-top: 8px; letter-spacing: -.01em; line-height: 1; }
.kpi .k-v .u { font-size: 13px; color: var(--hud-text-3); font-weight: 500; margin-left: 4px; }
.kpi .k-d { margin-top: 7px; font-size: 11px; color: var(--hud-text-2); display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); }
.kpi .k-spark { position: absolute; right: 0; bottom: 0; left: 0; height: 30px; opacity: .55; }
.kpi.accent { border-color: rgba(242,148,31,.35); }
.kpi.accent .k-v { color: var(--orange-400); }

/* ===== Tables ============================================== */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--hud-text-3);
  font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--hud-line); position: sticky; top: 0; background: #0b1a33; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--hud-line-soft); color: var(--hud-text); }
.tbl tr:hover td { background: rgba(122,160,209,.05); }
.tbl .mono { color: var(--hud-text); }
.tbl .clickrow { cursor: pointer; }
.tbl .dim { color: var(--hud-text-3); }

/* ===== Modal / Popup ====================================== */
.scrim { position: fixed; inset: 0; background: rgba(3,8,18,.6); backdrop-filter: blur(3px); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 30px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: linear-gradient(180deg,#0e2244,#0a1830); border: 1px solid var(--navy-500); border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.6); width: 460px; max-width: 100%; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
  animation: pop .16s cubic-bezier(.2,0,0,1); }
.modal.wide { width: 560px; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } }
.m-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--hud-line);
  background: linear-gradient(180deg,#0f2a52,#0c2246); }
.m-ic { width: 38px; height: 38px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: rgba(122,160,209,.12); border: 1px solid var(--hud-line); color: var(--orange-400); }
.m-ic svg { width: 20px; height: 20px; }
.m-ttl { flex: 1; line-height: 1.2; }
.m-ttl .tag { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: #fff; letter-spacing: .02em; }
.m-ttl .desc { font-size: 11.5px; color: var(--hud-text-2); margin-top: 2px; }
.m-x { width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--hud-line); background: transparent; color: var(--hud-text-2);
  display: flex; align-items: center; justify-content: center; transition: all .12s; }
.m-x:hover { background: rgba(211,58,44,.15); color: #f08478; border-color: rgba(211,58,44,.4); }
.m-body { padding: 16px; overflow-y: auto; }
.m-foot { padding: 12px 16px; border-top: 1px solid var(--hud-line); display: flex; gap: 9px; align-items: center; background: rgba(6,15,31,.4); }

/* mode toggle */
.modetog { display: flex; border: 1px solid var(--hud-line); border-radius: var(--r-sm); overflow: hidden; }
.modetog button { background: transparent; border: 0; color: var(--hud-text-3); font-family: var(--font-mono); font-weight: 600;
  font-size: 11.5px; letter-spacing: .04em; padding: 7px 14px; transition: all .12s; }
.modetog button:hover { color: var(--hud-text); }
.modetog button.on.man { background: var(--orange-500); color: #2a1800; }
.modetog button.on.auto { background: var(--navy-500); color: #fff; }

/* state block in popup */
.statebox { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--hud-line);
  background: rgba(6,15,31,.5); margin-bottom: 14px; }
.statebox .big { font-family: var(--font-mono); font-weight: 700; font-size: 19px; }
.statebox.run { border-color: rgba(30,158,90,.4); } .statebox.run .big { color: #5fd99a; }
.statebox.alarm { border-color: rgba(211,58,44,.5); } .statebox.alarm .big { color: #f08478; }
.statebox.idle .big { color: #a6b6c6; }
.statebox.warn { border-color: rgba(232,163,23,.45); } .statebox.warn .big { color: #f3c45a; }

/* param grid */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--hud-line-soft); border: 1px solid var(--hud-line);
  border-radius: var(--r-md); overflow: hidden; }
.pgrid.three { grid-template-columns: 1fr 1fr 1fr; }
.pcell { background: #0a1830; padding: 10px 12px; }
.pcell .pl { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--hud-text-3); font-weight: 700; }
.pcell .pv { font-family: var(--font-mono); font-weight: 600; font-size: 16px; color: var(--hud-text); margin-top: 4px; }
.pcell .pv .u { font-size: 11px; color: var(--hud-text-3); margin-left: 3px; }
.pcell .pv.alm { color: #f08478; }
.pcell .pv.wrn { color: #f3c45a; }

/* interlock list */
.ilist { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--hud-line); border-radius: var(--r-md); overflow: hidden; }
.ilist .ir { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #0a1830; font-size: 12px; }
.ilist .ir .di { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ilist .ir .di.ok { background: var(--status-run); }
.ilist .ir .di.no { background: var(--status-alarm); }
.ilist .ir .nm { color: var(--hud-text-2); }
.ilist .ir .st { margin-left: auto; font-family: var(--font-mono); font-size: 11px; }
.ilist .ir .st.ok { color: #5fd99a; } .ilist .ir .st.no { color: #f08478; }

/* section subtitle */
.subhead { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--hud-text-3); margin: 4px 0 9px; display: flex; align-items: center; gap: 8px; }
.subhead::after { content:''; flex:1; height:1px; background: var(--hud-line-soft); }

/* gauge */
.gauge-wrap { display: flex; align-items: center; justify-content: center; }

/* legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--hud-text-2); font-family: var(--font-mono); }
.legend .lg .d { width: 9px; height: 9px; border-radius: 2px; }

/* toggle switch */
.tgl { width: 42px; height: 23px; border-radius: 12px; background: #1c2f50; border: 1px solid var(--hud-line); position: relative; transition: all .15s; flex-shrink: 0; }
.tgl.on { background: var(--status-run); border-color: var(--status-run); }
.tgl::after { content:''; position: absolute; top: 2px; left: 2px; width: 17px; height: 17px; border-radius: 50%; background: #fff; transition: all .15s; }
.tgl.on::after { left: 21px; }

/* setpoint slider */
.sp-row { display: flex; align-items: center; gap: 12px; }
input[type=range].sp { -webkit-appearance: none; appearance: none; flex: 1; height: 5px; border-radius: 3px; background: #1c2f50; outline: none; }
input[type=range].sp::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--orange-500); cursor: pointer; border: 2px solid #0a1830; }
input[type=range].sp::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--orange-500); cursor: pointer; border: 2px solid #0a1830; }

/* pipe + flow animation for synoptic */
.pipe { stroke-linecap: round; fill: none; }
.flow { stroke-dasharray: 5 9; animation: flowdash 1s linear infinite; }
.flow.gas { stroke-dasharray: 4 8; animation: flowdash 1.3s linear infinite; }
.flow.rev { animation-direction: reverse; }
@keyframes flowdash { to { stroke-dashoffset: -14; } }

/* equip box on mimic */
.eq { fill: #0d1f3c; }
.toast { position: fixed; bottom: 46px; left: 50%; transform: translateX(-50%); z-index: 300;
  background: #0e2244; border: 1px solid var(--navy-400); border-radius: var(--r-md); padding: 11px 16px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--hud-text);
  animation: toastin .2s; }
.toast .ti { width: 8px; height: 8px; border-radius: 50%; }
@keyframes toastin { from { opacity: 0; transform: translate(-50%,8px); } }

/* ===== Operion plant assistant ============================== */
.oa {
  position: fixed;
  right: 18px;
  bottom: 50px;
  z-index: 180;
  font-family: var(--font-body);
}

.oa-fab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 15px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(242,148,31,.45);
  background: linear-gradient(135deg, #f2941f, #d87500);
  color: #2a1800;
  box-shadow: 0 18px 42px rgba(0,0,0,.38), 0 0 0 1px rgba(255,255,255,.08) inset;
  font-weight: 800;
  letter-spacing: .02em;
}

.oa-fab span {
  color: #2a1800;
}

.oa-mini {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(42,24,0,.16);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 900;
}

.oa-fab b {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #2a1800;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11px;
}

.oa-panel {
  width: 410px;
  height: min(650px, calc(100dvh - 78px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  border: 1px solid rgba(122,160,209,.28);
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(13,31,60,.98), rgba(6,15,31,.98));
  box-shadow: 0 28px 80px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04) inset;
}

.oa-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 14px;
  border-bottom: 1px solid var(--hud-line);
  background: linear-gradient(180deg, #12305d, #0d2343);
}

.oa-ic {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(242,148,31,.16);
  color: var(--orange-400);
  border: 1px solid rgba(242,148,31,.28);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 900;
}

.oa-k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .16em;
  font-weight: 800;
  color: var(--orange-400);
}

.oa-t {
  margin-top: 2px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.oa-x {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 1px solid var(--hud-line);
  background: rgba(255,255,255,.04);
  color: var(--hud-text-2);
}

.oa-x:hover {
  color: #fff;
  border-color: rgba(242,148,31,.45);
}

.oa-live {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--hud-line-soft);
  background: rgba(6,15,31,.48);
}

.oa-live span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--hud-text-2);
}

.oa-msgs {
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.oa-msg {
  max-width: 94%;
  border-radius: 18px;
  padding: 12px 13px;
  border: 1px solid var(--hud-line-soft);
  background: rgba(255,255,255,.045);
}

.oa-msg.user {
  margin-left: auto;
  background: linear-gradient(135deg, #f2941f, #d87500);
  border-color: rgba(242,148,31,.55);
  color: #2a1800;
}

.oa-msg.assistant {
  margin-right: auto;
  background: rgba(14,34,68,.9);
}

.oa-role {
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--hud-text-3);
}

.oa-msg.user .oa-role {
  color: rgba(42,24,0,.68);
}

.oa-text {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.48;
  color: var(--hud-text);
}

.oa-msg.user .oa-text {
  color: #2a1800;
  font-weight: 650;
}

.oa-nav {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(242,148,31,.35);
  background: rgba(242,148,31,.10);
  color: var(--orange-400);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 800;
}

.oa-quick {
  display: flex;
  gap: 7px;
  padding: 10px 14px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.oa-quick::-webkit-scrollbar {
  display: none;
}

.oa-quick button {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--hud-line);
  background: rgba(122,160,209,.08);
  color: var(--hud-text-2);
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 750;
}

.oa-quick button:hover {
  color: #fff;
  border-color: rgba(242,148,31,.42);
}

.oa-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  padding: 12px 14px 8px;
}

.oa-form input {
  min-width: 0;
  border: 1px solid var(--hud-line);
  border-radius: 14px;
  background: rgba(3,8,18,.62);
  color: #fff;
  padding: 11px 12px;
  outline: none;
  font-size: 13px;
}

.oa-form input:focus {
  border-color: rgba(242,148,31,.65);
  box-shadow: 0 0 0 3px rgba(242,148,31,.12);
}

.oa-form button {
  border: 0;
  border-radius: 14px;
  background: var(--orange-500);
  color: #2a1800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.oa-note {
  padding: 0 14px 12px;
  color: var(--hud-text-3);
  font-size: 10.5px;
  line-height: 1.35;
}

/* Floating draggable assistant restyle */
.oa {
  touch-action: none;
  user-select: none;
}

.oa-fab {
  min-height: 54px;
  gap: 10px;
  padding: 0 14px 0 16px;
  background: linear-gradient(135deg, #f28c00, #ffb23f);
  border-color: rgba(255,255,255,.20);
  color: #061427;
  cursor: grab;
}

.oa-fab:active,
.oa-head:active {
  cursor: grabbing;
}

.oa-label {
  color: #061427;
  font-weight: 1000;
  letter-spacing: -.02em;
}

.oa-mini {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: #101827;
  display: grid;
  place-items: center;
}

.oa-mini::before {
  content: "";
  width: 15px;
  height: 12px;
  border-radius: 7px;
  background: #f8fafc;
  display: block;
}

.oa-mini::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: 3px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #2dd4bf;
  box-shadow: 0 0 0 2px #101827;
}

.oa-fab b {
  min-width: auto;
  height: auto;
  padding: 5px 9px;
  background: #061427;
  color: #fff;
  line-height: 1;
}

.oa-panel {
  width: min(410px, calc(100vw - 28px));
  height: min(690px, calc(100dvh - 38px));
  border-color: rgba(242,148,31,.65);
  border-radius: 18px;
  background: #0b1222;
}

.oa-head {
  cursor: grab;
  background: #171d2b;
}

.oa-ic {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #f28c00;
  border: 0;
}

.oa-ic::before {
  content: "";
  width: 17px;
  height: 14px;
  border-radius: 8px;
  background: #101827;
  display: block;
}

.oa-ic::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 5px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #2dd4bf;
  box-shadow: 0 0 0 2px #171d2b;
}

.oa-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.oa-status {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 999px;
  background: #2dd4bf;
}

.oa-drag,
.oa-x {
  border: 0;
  background: transparent;
  color: #7b8aa6;
  width: 30px;
  height: 30px;
  border-radius: 12px;
  font-size: 20px;
  cursor: grab;
}

.oa-x {
  cursor: pointer;
}

.oa-drag:hover,
.oa-x:hover {
  color: #fff;
  border-color: transparent;
}

@media (max-width: 560px) {
  .oa-fab {
    width: 58px;
    height: 58px;
    padding: 0;
    justify-content: center;
  }

  .oa-fab .oa-label,
  .oa-fab b {
    display: none;
  }

  .oa-panel {
    width: calc(100vw - 20px);
    height: calc(100dvh - 20px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ab-move, .flow, .chip.alarm .d, .tb-conn .dot { animation: none !important; }
}

/* ===== Responsive control-room shell ========================
   SCADA pages contain real P&ID coordinates, so on small screens the shell
   adapts while technical canvases remain scrollable instead of unreadable.
   ============================================================ */
@media (max-width: 1180px) {
  html, body, #root { width: 100%; min-width: 0; overflow: hidden; }
  .app {
    grid-template-rows: 52px 30px 104px minmax(0, 1fr) 34px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "alarmbar"
      "side"
      "main"
      "foot";
    min-width: 0;
    width: 100vw;
    height: 100dvh;
  }

  .topbar {
    gap: 10px;
    padding: 0 10px;
    min-width: 0;
  }

  .tb-logo { height: 22px; }
  .tb-title { min-width: 0; }
  .tb-title b {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tb-title span { display: none; }
  .tb-conn { display: none; }
  .tb-user .nm { display: none; }
  .tb-divider { height: 22px; }
  .tb-clock { font-size: 11.5px; }
  .tb-clock .d { display: none; }
  .iconbtn { width: 32px; height: 32px; }
  .lang button { padding: 5px 7px; }

  .sidebar {
    flex-direction: row;
    align-items: stretch;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--hud-line);
    scrollbar-width: thin;
  }

  .sidebar {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .sidebar::-webkit-scrollbar {
    display: none;
  }

  .main::-webkit-scrollbar,
  .page::-webkit-scrollbar,
  .footbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  .main::-webkit-scrollbar-track,
  .page::-webkit-scrollbar-track,
  .footbar::-webkit-scrollbar-track {
    background: rgba(8, 18, 37, .7);
  }

  .main::-webkit-scrollbar-thumb,
  .page::-webkit-scrollbar-thumb,
  .footbar::-webkit-scrollbar-thumb {
    background: rgba(122, 160, 209, .42);
    border-radius: 999px;
  }

  .main::-webkit-scrollbar-thumb:hover,
  .page::-webkit-scrollbar-thumb:hover,
  .footbar::-webkit-scrollbar-thumb:hover {
    background: rgba(242, 148, 31, .65);
  }

  .nav-group {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    padding: 8px 8px;
    border-right: 1px solid var(--hud-line-soft);
  }

  .nav-group .gl {
    align-self: center;
    padding: 0 6px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    opacity: .8;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: 142px;
    max-width: 180px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.18;
  }

  .nav-item.on::before {
    left: 6px;
    right: 6px;
    top: auto;
    bottom: 2px;
    width: auto;
    height: 3px;
  }

  .nav-sep,
  .sb-foot {
    display: none;
  }

  .main {
    min-width: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .page {
    position: relative;
    inset: auto;
    min-height: 100%;
    min-width: 980px;
    padding: 14px 16px 22px;
  }

  .page-head {
    gap: 10px;
    margin-bottom: 12px;
  }

  .page-head h1 {
    font-size: 21px;
  }

  .page-head .sub {
    font-size: 12px;
  }

  .kpi {
    padding: 12px 13px;
  }

  .kpi .k-l {
    font-size: 9.8px;
  }

  .kpi .k-v {
    font-size: 24px;
  }

  .panel-h {
    padding: 10px 12px;
  }

  .footbar {
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
  }

  .fb-cell,
  .fb-mode {
    flex: 0 0 auto;
    padding: 0 10px;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-rows: 50px 30px 86px minmax(0, 1fr) 34px;
  }

  .topbar {
    gap: 7px;
  }

  .tb-logo,
  .tb-divider,
  .tb-clock,
  .tb-user {
    display: none;
  }

  .tb-title b {
    max-width: 48vw;
    font-size: 12.5px;
  }

  .lang {
    margin-left: auto;
  }

  .lang button {
    font-size: 10px;
    padding: 5px 6px;
  }

  .ab-tag {
    max-width: 150px;
    padding: 0 9px;
    font-size: 9.5px;
    letter-spacing: .08em;
  }

  .ab-it {
    font-size: 10.5px;
  }

  .nav-group {
    gap: 5px;
    padding: 7px 6px;
  }

  .nav-group .gl {
    display: none;
  }

  .nav-item {
    min-width: 116px;
    max-width: 136px;
    gap: 7px;
    padding: 7px 8px;
    font-size: 11px;
  }

  .nav-item svg {
    width: 15px;
    height: 15px;
  }

  .page {
    min-width: 900px;
    padding: 12px;
  }

  .page-head h1 {
    font-size: 19px;
  }

  .page-head .ph-tag,
  .panel-h .pt small {
    display: none;
  }

  .btn {
    padding: 7px 10px;
    font-size: 12px;
  }

  .scrim {
    align-items: flex-end;
    padding: 10px;
  }

  .modal,
  .modal.wide {
    width: 100%;
    max-height: 86dvh;
    border-radius: 16px;
  }

  .oa {
    right: 10px;
    left: 10px;
    bottom: 44px;
  }

  .oa-fab {
    margin-left: auto;
    height: 40px;
    padding: 0 12px;
  }

  .oa-panel {
    width: 100%;
    height: min(620px, calc(100dvh - 64px));
    border-radius: 18px;
  }

  .oa-live {
    display: none;
  }

  .oa-msg {
    max-width: 100%;
  }

  .oa-quick {
    padding-top: 8px;
  }
}
