/* SHUAA Doser V2 - area visual de OPERACAO na pagina do Gateway (Cloud). Identidade da Guition: grafite-azulado,
   verde-agua da marca, cores fortes so' nos produtos, numeros condensados. O painel e' escuro nos dois temas do app,
   como a tela fisica (cores pintadas explicitamente aqui). Animacao so' com operacao real (ver doser-v2-stage.js). */
.v2s {
  --s-bg: #080c11; --s-panel: #0f151d; --s-card: #141c26; --s-card2: #1a2431; --s-line: #243140;
  --s-text: #eef2f6; --s-muted: #8fa0b3; --s-dim: #5d6c7e;
  --s-brand: #2fb6c9; --s-brand-d: #16808f;
  --s-ok: #35c98a; --s-warn: #f0a93a; --s-crit: #e5484d;
  --s-disp: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "sans-serif-condensed", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(47, 182, 201, .10), transparent 60%),
    linear-gradient(180deg, #0b1118, var(--s-bg));
  color: var(--s-text);
  border: 1px solid var(--s-line);
  border-radius: 20px;
  padding: clamp(14px, 2vw, 22px);
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  overflow: hidden;
}
.v2s-num { font-family: var(--s-disp); font-variant-numeric: tabular-nums; letter-spacing: .3px; }
.v2s-h {
  font: 600 12.5px/1 var(--s-disp); letter-spacing: 1.6px; text-transform: uppercase; color: var(--s-muted);
  margin: 4px 0 10px;
}
.v2s-empty { color: var(--s-muted); font-size: 14px; margin: 0; padding: 18px; border: 1px dashed var(--s-line); border-radius: 14px; text-align: center; }

/* barra superior: como o cabecalho da Guition */
.v2s-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-bottom: 14px; border-bottom: 1px solid var(--s-line); }
.v2s-brand { display: flex; align-items: center; gap: 10px; font: 600 20px var(--s-disp); letter-spacing: 3px; }
.v2s-drop { width: 20px; height: 20px; border-radius: 50% 50% 50% 6px; transform: rotate(-45deg); background: var(--s-brand); flex: none; }
.v2s-site { font: 400 14px system-ui, sans-serif; letter-spacing: 0; color: var(--s-muted); padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--s-line); }
.v2s-pills { display: flex; flex-wrap: wrap; gap: 8px 16px; flex: 1 1 auto; }
.v2s-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--s-muted); white-space: nowrap; }
.v2s-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--s-dim); flex: none; }
.v2s-dot.v2s-ok { background: var(--s-ok); box-shadow: 0 0 0 3px rgba(53, 201, 138, .15); }
.v2s-dot.v2s-warn { background: var(--s-warn); } .v2s-dot.v2s-crit { background: var(--s-crit); }
.v2s-fresh { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; margin-left: auto; }
.v2s-fresh small { color: var(--s-dim); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.v2s-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: 12px;
  font-size: 12px; font-weight: 600; letter-spacing: .3px; background: var(--s-card2); color: var(--s-muted); max-width: 100%;
}
.v2s-chip.v2s-ok { background: rgba(53, 201, 138, .14); color: var(--s-ok); }
.v2s-chip.v2s-run { background: rgba(47, 182, 201, .16); color: var(--s-brand); }
.v2s-chip.v2s-wait, .v2s-chip.v2s-idle { background: var(--s-card2); color: var(--s-text); }
.v2s-chip.v2s-warn { background: rgba(240, 169, 58, .15); color: var(--s-warn); }
.v2s-chip.v2s-crit { background: rgba(229, 72, 77, .16); color: #ff7477; }
.v2s-chip.v2s-off { background: var(--s-card2); color: var(--s-dim); }
.v2s.is-live .v2s-fresh .v2s-chip.v2s-ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: v2s-pulse 2s ease-in-out infinite; }

/* galoes */
.v2s-tanks {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0;
  background: rgba(20, 28, 38, .55); border: 1px solid var(--s-line); border-radius: 16px; padding: 14px 6px 10px;
}
.v2s-tank { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 10px 8px; border-right: 1px solid var(--s-line); min-width: 0; text-align: center; }
.v2s-tank:last-child { border-right: 0; }
.v2s-tank-name { display: flex; align-items: center; gap: 7px; font: 500 16px var(--s-disp); letter-spacing: .5px; }
.v2s-tank-name small { font: 400 12px system-ui, sans-serif; color: var(--s-dim); }
.v2s-sw { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }
.v2s-dose { min-height: 22px; font-size: 12px; color: var(--s-muted); }
.v2s-dose b { font-size: 19px; color: var(--s-text); }
.v2s-tank-art { width: clamp(96px, 11vw, 140px); }
.v2s-tank-svg { display: block; width: 100%; height: auto; overflow: visible; }
.v2s-tank-val b { font-size: clamp(22px, 2.3vw, 28px); line-height: 1; }
.v2s-tank-val small { color: var(--s-muted); font-size: 12px; }
.v2s-tank-st { font-size: 13px; color: var(--s-muted); min-height: 18px; }
.v2s-st-run { color: var(--s-ok); font-weight: 600; }
.v2s-st-warn { color: var(--s-warn); font-weight: 600; }
.v2s-st-crit { color: #ff7477; font-weight: 600; }
.v2s-tank-src { font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--s-dim); }
.v2s-tank.is-stale .v2s-tank-src { color: var(--s-warn); }
.v2s-note { margin: -8px 0 0; text-align: center; font-size: 11.5px; color: var(--s-dim); display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 8px; }
.v2s-key { width: 14px; height: 10px; border-radius: 2px; display: inline-block; background: #2f80ed; }
.v2s-key-hatch { background: repeating-linear-gradient(45deg, #2f80ed 0 3px, #0b1118 3px 6px); opacity: .6; outline: 1px dashed var(--s-muted); outline-offset: 1px; }

.v2s-liq { transition: transform 1.2s cubic-bezier(.2, .7, .2, 1); }
.v2s-wave { animation: v2s-drift 9s linear infinite; }
.v2s-wave-b { animation-duration: 14s; animation-direction: reverse; }
.v2s-tank.is-run .v2s-wave { animation-duration: 2.2s; }
.v2s-tank.is-run .v2s-wave-b { animation-duration: 3.4s; }
.v2s-halo { fill: none; stroke-width: 6; opacity: 0; filter: blur(4px); transition: opacity .4s; }
.v2s-tank.is-run .v2s-halo { animation: v2s-breathe 1.8s ease-in-out infinite; }
.v2s-tick { stroke: #fff; stroke-opacity: .28; stroke-width: 1; }
.v2s-mark-warn { stroke: var(--s-warn); stroke-width: 1; stroke-dasharray: 4 3; opacity: .75; }
.v2s-mark-crit { stroke: var(--s-crit); stroke-width: 1; stroke-dasharray: 2 3; opacity: .8; }
.v2s-outline { fill: none; stroke: #3a4b5f; stroke-width: 1.5; }
.v2s-tank.is-run .v2s-outline { stroke: var(--c); stroke-width: 2.5; }
.v2s-tank.is-warn .v2s-outline { stroke: var(--s-warn); }
.v2s-tank.is-crit .v2s-outline { stroke: var(--s-crit); }
.v2s-hatch { opacity: 0; transition: opacity .4s; }
.v2s-tank.is-stale .v2s-hatch { opacity: 1; }
.v2s-tank.is-stale .v2s-wave { filter: saturate(.5); opacity: .78; }
.v2s-tank.is-stale .v2s-hatch { opacity: .8; }
.v2s-tank.is-stale .v2s-outline { stroke-dasharray: 6 4; }
.v2s-bubbles circle { fill: #fff; opacity: 0; }
.v2s-tank.is-run .v2s-bubbles circle { animation: v2s-bubble 2.4s ease-in infinite; }

/* colunas: dosadores | maquinas, alertas, eventos */
.v2s-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 18px; align-items: start; }
.v2s-col { min-width: 0; }
.v2s-nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.v2s-node { container-type: inline-size; background: var(--s-card); border: 1px solid var(--s-line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.v2s-node.is-off { border-color: rgba(229, 72, 77, .45); }
.v2s-node.is-stale { border-color: rgba(240, 169, 58, .35); }
.v2s-node-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.v2s-node-head h4 { margin: 0; font: 500 18px var(--s-disp); letter-spacing: .4px; }
.v2s-node-head small { color: var(--s-dim); font-size: 11.5px; overflow-wrap: anywhere; }
.v2s-node-net { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: 12.5px; color: var(--s-muted); }
.v2s-seen { color: var(--s-dim); }
.v2s-node-mach { font-size: 12.5px; color: var(--s-muted); }
.v2s-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.v2s-bars i { width: 4px; border-radius: 1px; background: var(--s-line); }
.v2s-bars i:nth-child(1) { height: 4px; } .v2s-bars i:nth-child(2) { height: 7px; } .v2s-bars i:nth-child(3) { height: 10px; } .v2s-bars i:nth-child(4) { height: 14px; }
.v2s-bars[data-l="1"] i:nth-child(-n+1), .v2s-bars[data-l="2"] i:nth-child(-n+2), .v2s-bars[data-l="3"] i:nth-child(-n+3), .v2s-bars[data-l="4"] i { background: var(--s-ok); }
.v2s-bars[data-l="1"] i:nth-child(-n+1) { background: var(--s-warn); }
.v2s-node.is-off .v2s-bars i, .v2s-node.is-stale .v2s-bars i { background: var(--s-line); }

/* comunicacao Gateway -> dosador */
.v2s-link { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--s-dim); }
.v2s-link-end { flex: none; }
.v2s-link-node { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2s-wire { position: relative; flex: 1; height: 4px; border-radius: 2px; background: var(--s-line); overflow: hidden; }
.v2s-wire i { position: absolute; top: 0; width: 18px; height: 4px; border-radius: 2px; background: var(--s-brand); opacity: 0; }
.v2s-node.is-on .v2s-wire { background: rgba(47, 182, 201, .22); }
.v2s-node.is-on .v2s-wire i { animation: v2s-run 2.4s linear infinite; }
.v2s-node.is-on .v2s-wire i:nth-child(2) { animation-delay: .8s; } .v2s-node.is-on .v2s-wire i:nth-child(3) { animation-delay: 1.6s; }
.v2s-node.is-stale .v2s-wire { background: repeating-linear-gradient(90deg, var(--s-dim) 0 6px, transparent 6px 11px); }
.v2s-node.is-off .v2s-wire { background: repeating-linear-gradient(90deg, rgba(229, 72, 77, .7) 0 8px, transparent 8px 14px); }
.v2s-node.is-off .v2s-link { color: #ff7477; }

/* entradas (sinal das maquinas) */
.v2s-inputs { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--s-muted); }
.v2s-in { display: inline-flex; align-items: center; gap: 6px; }
.v2s-in i { width: 9px; height: 9px; border-radius: 50%; background: var(--s-card2); border: 1px solid var(--s-line); }
.v2s-in.is-on { color: var(--s-text); }
.v2s-in.is-on i { background: var(--s-ok); border-color: var(--s-ok); box-shadow: 0 0 8px rgba(53, 201, 138, .7); }

/* bombas (saidas) */
.v2s-pumps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.v2s-pump {
  display: grid; grid-template-columns: 36px minmax(0, 1.2fr) minmax(40px, 1fr) minmax(0, 1.5fr); align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 12px; background: var(--s-card2); border: 1px solid transparent;
}
.v2s-pump.is-run { border-color: color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 10%, var(--s-card2)); }
.v2s-pump.is-free { opacity: .55; }
.v2s-pump-svg { width: 36px; height: 36px; display: block; }
.v2s-pump-body { fill: #0f151d; stroke: var(--c); stroke-width: 2; }
.v2s-rotor path { fill: var(--c); opacity: .85; }
.v2s-pump-hub { fill: #0f151d; stroke: var(--c); stroke-width: 1.5; }
.v2s-rotor { transform-box: view-box; transform-origin: 20px 20px; }
.v2s-pump.is-run .v2s-rotor { animation: v2s-spin .9s linear infinite; }
.v2s-pump-id { display: flex; flex-direction: column; min-width: 0; }
.v2s-pump-id b { font: 500 15px var(--s-disp); letter-spacing: .3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2s-pump-id small { color: var(--s-dim); font-size: 11px; }
.v2s-pump-st { font-size: 12.5px; color: var(--s-muted); text-align: right; }
.v2s-pump.is-run .v2s-pump-st { color: var(--s-text); font-weight: 600; }
.v2s-flow { position: relative; height: 6px; border-radius: 3px; background: var(--s-card); overflow: hidden; }
.v2s-flow i { position: absolute; top: 1px; width: 14px; height: 4px; border-radius: 2px; background: var(--c, var(--s-brand)); opacity: 0; }
.v2s-pump.is-run .v2s-flow i, .v2s-mach.is-run .v2s-flow i { animation: v2s-run 1.4s linear infinite; }
.v2s-pump.is-run .v2s-flow i:nth-child(2), .v2s-mach.is-run .v2s-flow i:nth-child(2) { animation-delay: .35s; }
.v2s-pump.is-run .v2s-flow i:nth-child(3), .v2s-mach.is-run .v2s-flow i:nth-child(3) { animation-delay: .7s; }
.v2s-pump.is-run .v2s-flow i:nth-child(4), .v2s-mach.is-run .v2s-flow i:nth-child(4) { animation-delay: 1.05s; }

/* maquinas, alertas, eventos */
.v2s-side { display: flex; flex-direction: column; gap: 6px; }
.v2s-block { min-width: 0; }
.v2s-machs, .v2s-alerts, .v2s-events { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.v2s-mach { display: grid; grid-template-columns: minmax(0, 1fr) 54px auto; grid-template-areas: "id flow chip" "today today today"; align-items: center; gap: 4px 10px; padding: 10px 12px; border-radius: 12px; background: var(--s-card); border: 1px solid var(--s-line); }
.v2s-mach-id { grid-area: id; display: flex; flex-direction: column; min-width: 0; }
.v2s-mach-id b { font: 500 16px var(--s-disp); }
.v2s-mach-id small, .v2s-mach-today { color: var(--s-dim); font-size: 11.5px; }
.v2s-mach .v2s-flow { grid-area: flow; --c: var(--s-brand); }
.v2s-mach .v2s-chip { grid-area: chip; justify-self: end; }
.v2s-mach-today { grid-area: today; }
.v2s-al { padding: 10px 12px; border-radius: 12px; background: var(--s-card); border: 1px solid var(--s-line); border-left: 3px solid var(--s-dim); display: flex; flex-direction: column; gap: 3px; }
.v2s-al b { font-size: 13.5px; font-weight: 600; }
.v2s-al small { color: var(--s-muted); font-size: 12px; }
.v2s-al-warn { border-left-color: var(--s-warn); } .v2s-al-crit { border-left-color: var(--s-crit); } .v2s-al-info { border-left-color: var(--s-brand); }
.v2s-events li { display: grid; grid-template-columns: 44px 10px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 13px; color: var(--s-muted); padding: 5px 0; border-bottom: 1px solid var(--s-line); }
.v2s-events li:last-child { border-bottom: 0; }
.v2s-events time { font-family: var(--s-disp); color: var(--s-dim); font-variant-numeric: tabular-nums; }
.v2s-events b { color: var(--s-text); font-weight: 600; }
.v2s-ev-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }

/* sem dado ao vivo: nada se move */
.v2s.is-frozen .v2s-wave, .v2s.is-frozen .v2s-rotor, .v2s.is-frozen .v2s-flow i, .v2s.is-frozen .v2s-wire i, .v2s.is-frozen .v2s-bubbles circle, .v2s.is-frozen .v2s-halo { animation-play-state: paused; }

@keyframes v2s-drift { from { transform: translateX(0); } to { transform: translateX(-120px); } }
@keyframes v2s-breathe { 0%, 100% { opacity: .35; } 50% { opacity: .95; } }
@keyframes v2s-spin { to { transform: rotate(360deg); } }
@keyframes v2s-run { 0% { left: -18px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
@keyframes v2s-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes v2s-bubble { 0% { opacity: 0; transform: translateY(0); } 20% { opacity: .55; } 100% { opacity: 0; transform: translateY(-70px); } }

@media (max-width: 1100px) {
  .v2s-cols { grid-template-columns: minmax(0, 1fr); }
  .v2s-side { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 6px 16px; align-items: start; }
}
@media (max-width: 760px) {
  .v2s-tanks { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
  .v2s-tank:nth-child(2n) { border-right: 0; }
  .v2s-fresh { align-items: flex-start; margin-left: 0; width: 100%; }
  .v2s-pump { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: "ico id" "ico st" "ico flow"; row-gap: 4px; }
  .v2s-pump-st { text-align: left; }
  .v2s-pump:not(.is-run) .v2s-flow { display: none; }
  .v2s-pump-svg { grid-area: ico; width: 32px; height: 32px; }
  .v2s-pump-id { grid-area: id; } .v2s-pump .v2s-flow { grid-area: flow; } .v2s-pump-st { grid-area: st; }
}
@media (max-width: 420px) {
  .v2s { border-radius: 16px; padding: 12px; }
  .v2s-tank { padding: 4px 4px 8px; }
  .v2s-tank-name { font-size: 14.5px; }
  .v2s-brand { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .v2s * { animation: none !important; transition: none !important; }
}

/* o cartao do dosador se reorganiza pela PROPRIA largura (dentro do app, com menu lateral, ele fica estreito) */
@container (max-width: 420px) {
  .v2s-pump { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: "ico id" "ico st" "ico flow"; row-gap: 4px; }
  .v2s-pump-svg { grid-area: ico; width: 32px; height: 32px; }
  .v2s-pump-id { grid-area: id; } .v2s-pump .v2s-flow { grid-area: flow; } .v2s-pump-st { grid-area: st; text-align: left; }
  .v2s-pump:not(.is-run) .v2s-flow { display: none; }
}
