:root {
  --bg: #050807;
  --bg-soft: #09100f;
  --panel: #0d1514;
  --panel-2: #111b19;
  --panel-3: #172220;
  --line: rgba(154, 174, 165, 0.22);
  --line-strong: rgba(154, 174, 165, 0.42);
  --text: #eef5f1;
  --muted: #93a39d;
  --green: #21d48b;
  --green-dim: #0f7652;
  --cyan: #26bdd2;
  --blue: #4d8dff;
  --yellow: #f2c230;
  --orange: #ff8b2f;
  --red: #ff4f5b;
  --purple: #9b72ff;
  --steel-1: #edf0ec;
  --steel-2: #c6cfca;
  --steel-3: #8e9b95;
  --dark-steel: #273431;
  --radius: 8px;
  --shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.ts-app-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(18, 32, 30, 0.92), rgba(5, 8, 7, 0.98) 340px),
    var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 0 max(12px, calc((100vw - 1880px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(5, 8, 7, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #052016;
  background: linear-gradient(145deg, var(--green), var(--cyan));
}

.brand strong {
  color: var(--green);
}

.header-status {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(150px, 0.95fr) minmax(238px, 1.5fr) 76px 112px 88px 126px 82px;
  align-items: stretch;
  gap: 5px;
}

.header-status > div {
  min-width: 0;
  border-left: 1px solid rgba(154, 174, 165, 0.18);
  padding-left: 8px;
}

.header-status span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

.header-status strong {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  min-width: 0;
  overflow: hidden;
  color: #f7fffb;
  font-size: 11px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status strong[data-tone]::before,
.source-pill[data-tone]::before,
.kpi-card[data-tone]::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #87918d;
  box-shadow: 0 0 0 2px rgba(135, 145, 141, 0.12);
}

.header-status strong[data-tone="normal"]::before,
.source-pill[data-tone="normal"]::before,
.kpi-card[data-tone="normal"]::before {
  background: var(--green);
  box-shadow: 0 0 0 2px rgba(33, 212, 139, 0.12);
}

.header-status strong[data-tone="warning"]::before,
.source-pill[data-tone="warning"]::before,
.kpi-card[data-tone="warning"]::before {
  background: var(--yellow);
  box-shadow: 0 0 0 2px rgba(242, 194, 48, 0.14);
}

.header-status strong[data-tone="alarm"]::before,
.source-pill[data-tone="alarm"]::before,
.kpi-card[data-tone="alarm"]::before {
  background: var(--red);
  box-shadow: 0 0 0 2px rgba(255, 79, 91, 0.14);
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.module-nav {
  position: sticky;
  top: 46px;
  z-index: 25;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 max(12px, calc((100vw - 1880px) / 2));
  overflow-x: auto;
  border-bottom: 1px solid rgba(154, 174, 165, 0.16);
  background: rgba(8, 14, 13, 0.92);
  scrollbar-width: none;
}

.module-nav::-webkit-scrollbar {
  display: none;
}

.module-nav a {
  height: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.module-nav a:hover,
.module-nav a.active {
  color: var(--green);
  border-bottom-color: var(--green);
  background: rgba(33, 212, 139, 0.07);
}

.industrial-page,
.page {
  width: min(100% - 18px, 1880px);
  margin: 0 auto;
  padding: 6px 0 24px;
}

.plant-strip {
  display: grid;
  grid-template-columns: minmax(270px, 0.72fr) minmax(0, 1.9fr);
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.plant-title,
.kpi-card,
.scada-panel,
.operation-panel,
.ops-block,
.bottom-console,
.card,
.metric,
.side-panel,
.panel-block,
.variable-card,
.tank-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 27, 25, 0.96), rgba(9, 16, 15, 0.96));
  box-shadow: var(--shadow);
}

.plant-title {
  min-height: 58px;
  padding: 8px 12px;
  box-shadow: none;
}

.eyebrow {
  display: block;
  margin: 0 0 4px;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  color: #f7fffb;
  letter-spacing: 0;
}

h1 {
  font-size: 19px;
  line-height: 1.1;
}

h2 {
  font-size: 14px;
  line-height: 1.25;
}

h3 {
  font-size: 13px;
  line-height: 1.2;
}

.page-subtitle {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
}

.kpi-card {
  position: relative;
  min-width: 0;
  min-height: 58px;
  padding: 7px 9px 7px 20px;
  box-shadow: none;
}

.kpi-card[data-tone]::before {
  position: absolute;
  left: 8px;
  top: 12px;
}

.kpi-card span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.kpi-card strong,
.metric strong {
  display: block;
  min-width: 0;
  margin-top: 4px;
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-card small,
.metric small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.operation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 326px;
  gap: 8px;
  align-items: stretch;
}

.scada-panel {
  min-width: 0;
  overflow: hidden;
  box-shadow: none;
}

.panel-heading,
.console-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.panel-heading {
  min-height: 42px;
  padding: 6px 10px 6px;
  border-bottom: 1px solid rgba(154, 174, 165, 0.14);
}

.panel-heading > div:first-child,
.console-head > div:first-child,
.section-head > div:first-child {
  min-width: 0;
}

.panel-heading h2 {
  overflow: hidden;
  color: #eaf5ef;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.mode-pill,
.source-pill,
.status-badge,
.data-source,
.quality-badge,
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(13, 21, 20, 0.78);
  color: #cbd9d4;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.refresh-state {
  min-width: 72px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  text-align: right;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-pill.monitor {
  border-color: rgba(242, 194, 48, 0.38);
  color: var(--yellow);
  background: rgba(242, 194, 48, 0.1);
}

.scada-focusbar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 10px;
  overflow-x: auto;
  border-bottom: 1px solid rgba(154, 174, 165, 0.12);
  scrollbar-width: thin;
}

.scada-focusbar button {
  flex: 0 0 auto;
  min-height: 22px;
  border: 1px solid rgba(154, 174, 165, 0.24);
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(7, 16, 14, 0.86);
  color: #cfe2da;
  cursor: pointer;
  font-size: 9px;
  font-weight: 900;
  text-transform: uppercase;
}

.scada-focusbar button.active,
.scada-focusbar button:hover {
  border-color: rgba(33, 212, 139, 0.72);
  background: rgba(33, 212, 139, 0.12);
  color: var(--green);
}

.icon-button,
.text-button,
.series-toggle,
.tab-button,
.ack-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17, 27, 25, 0.88);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
}

.icon-button.is-refreshing i {
  animation: spinRefresh 0.8s linear infinite;
}

@keyframes spinRefresh {
  to {
    transform: rotate(360deg);
  }
}

.icon-button:hover,
.text-button:hover,
.series-toggle:hover,
.tab-button:hover {
  border-color: var(--line-strong);
  background: rgba(33, 212, 139, 0.08);
}

.scada-stage {
  position: relative;
  height: clamp(665px, calc(100vh - 314px), 760px);
  min-height: 665px;
  margin: 0 8px 8px;
  overflow: hidden;
  border: 1px solid rgba(154, 174, 165, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(82, 104, 99, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(82, 104, 99, 0.09) 1px, transparent 1px),
    linear-gradient(180deg, #f5f2e8 0, #eeeae0 47%, #e5e2d8 100%);
  background-size: 30px 30px, 30px 30px, auto;
}

.scada-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.scada-frame-outline {
  fill: rgba(33, 212, 139, 0.025);
  stroke: rgba(33, 212, 139, 0.38);
  stroke-width: 3;
  stroke-dasharray: 16 12;
}

.svg-label {
  fill: #10201c;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0;
  pointer-events: none;
  text-transform: uppercase;
}

.svg-small {
  fill: #34413c;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: none;
  text-transform: uppercase;
}

.svg-value {
  fill: #08211b;
  font-family: Consolas, "Courier New", monospace;
  font-size: 20px;
  font-weight: 900;
  pointer-events: none;
}

.svg-value.dark {
  fill: #0d1a17;
}

.svg-tag {
  fill: #f6fbff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  font-weight: 900;
  pointer-events: none;
}

.pipe {
  fill: none;
  stroke: #c33a3d;
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: miter;
}

.pipe.product,
.pipe.beer {
  stroke: #1f9a77;
}

.pipe.wort,
.pipe.mosto {
  stroke: #c33a3d;
}

.pipe.cip,
.pipe.cip-supply,
.pipe.cip-return,
.pipe.caustic,
.pipe.acid {
  stroke: #39b7a6;
  stroke-width: 4.5;
}

.pipe.drain,
.pipe.process-drain,
.pipe.cip-drain,
.pipe.trub-drain,
.pipe.yeast-drain,
.pipe.wastewater,
.pipe.spent-grain,
.pipe.trub {
  stroke: #a9a342;
  stroke-width: 4.5;
}

.pipe.offgas,
.pipe.off-gas,
.pipe.co2,
.pipe.co2-supply {
  stroke: #1aa7b7;
  stroke-width: 4.5;
}

.pipe.utility,
.pipe.water,
.pipe.hot-water,
.pipe.cold-water,
.pipe.glycol,
.pipe.glycol-supply,
.pipe.glycol-return,
.pipe.steam,
.pipe.condensate,
.pipe.air,
.pipe.oxygen {
  stroke: #d69626;
  stroke-width: 4.5;
}

.pipe-bg {
  fill: none;
  stroke: #aeb8b2;
  stroke-width: 8;
  opacity: 0.28;
  stroke-linecap: round;
  stroke-linejoin: miter;
}

.pipe-bg.thin {
  stroke-width: 9;
}

.pipe.flow-active {
  stroke-dasharray: 22 16;
  animation: pipeFlow 1.2s linear infinite;
}

@keyframes pipeFlow {
  to {
    stroke-dashoffset: -76;
  }
}

.flow-arrow-shape {
  fill: #ffffff;
  stroke: #52615c;
  stroke-width: 1.2;
}

.scada-panel-box,
.readout-box,
.instrument-box {
  fill: rgba(249, 248, 239, 0.96);
  stroke: rgba(83, 98, 93, 0.72);
  stroke-width: 1.5;
  rx: 6;
}

.tag-box {
  fill: #0b4874;
  stroke: #043653;
  stroke-width: 1.4;
  rx: 4;
}

.readout-title {
  fill: #29536b;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.readout-value {
  fill: #111d1a;
  font-family: Consolas, "Courier New", monospace;
  font-size: 20px;
  font-weight: 900;
}

.readout .readout-title {
  font-size: 10px;
}

.readout .readout-value {
  font-size: 16px;
}

.readout .readout-unit {
  font-size: 10px;
}

.readout-unit {
  fill: #4d5d58;
  font-family: Inter, Segoe UI, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
}

.equipment-2d {
  color: #22312c;
}

.equipment-outline,
.technical-box {
  fill: rgba(247, 246, 237, 0.38);
  stroke: #344641;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.equipment-outline.horizontal,
.equipment-outline.open-vessel {
  fill: rgba(247, 246, 237, 0.28);
}

.equipment-outline.fermenter {
  fill: rgba(247, 246, 237, 0.22);
}

.equipment-topline,
.equipment-centerline,
.equipment-port-line,
.technical-line,
.technical-plate {
  fill: none;
  stroke: #56645f;
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
}

.technical-port {
  fill: #f6f5ec;
  stroke: #344641;
  stroke-width: 1.5;
}

.equipment-liquid {
  fill: rgba(64, 150, 209, 0.28);
}

.equipment-liquid.wort {
  fill: rgba(198, 146, 45, 0.24);
}

.equipment-liquid.beer {
  fill: rgba(33, 212, 139, 0.20);
}

.equipment-liquid-line {
  fill: none;
  stroke: rgba(36, 111, 157, 0.72);
  stroke-width: 1.7;
  vector-effect: non-scaling-stroke;
}

.equipment-tag,
.equipment-name,
.equipment-status,
.instrument-tag,
.instrument-value {
  font-family: Consolas, "Courier New", monospace;
  text-anchor: middle;
  pointer-events: none;
  text-transform: uppercase;
}

.equipment-tag {
  fill: #0d1b17;
  font-size: 14px;
  font-weight: 900;
}

.equipment-name {
  fill: #34413c;
  font-size: 10px;
  font-weight: 800;
}

.equipment-status {
  fill: #4f5c57;
  font-size: 10px;
  font-weight: 900;
}

.state-alarm .equipment-outline,
.state-bad .equipment-outline,
.state-offline .equipment-outline,
.state-alarm .technical-box,
.state-bad .technical-box,
.state-offline .technical-box {
  stroke: var(--red);
}

.state-warning .equipment-outline,
.state-degraded .equipment-outline,
.state-warning .technical-box,
.state-degraded .technical-box {
  stroke: var(--yellow);
}

.state-normal .equipment-outline,
.state-running .equipment-outline,
.state-normal .technical-box,
.state-running .technical-box {
  stroke: #258260;
}

.equipment-metal,
.equipment-shadow,
.liquid {
  display: none;
}

.agitator-line {
  stroke: #606e69;
  stroke-width: 5;
  stroke-linecap: round;
}

.agitator-blade {
  fill: #65736d;
  transform-box: fill-box;
  transform-origin: center;
}

.agitator-active .agitator-blade {
  animation: agitatorSpin 1.1s linear infinite;
}

@keyframes agitatorSpin {
  to {
    transform: rotate(360deg);
  }
}

.motor-box,
.pump-body,
.valve-body {
  fill: rgba(247, 246, 237, 0.78);
  stroke: #344641;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.motor-shaft {
  stroke: #53625c;
  stroke-width: 4;
  stroke-linecap: round;
}

.motor-terminal {
  fill: #c43d3a;
  stroke: #742320;
  stroke-width: 1.2;
}

.motor-label {
  fill: #15231e;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  font-weight: 900;
}

.motor-run .motor-box {
  fill: #e5fff5;
  stroke: #0d9f6e;
}

.motor-stop .motor-box {
  fill: #eef1ed;
  stroke: #5e6a65;
}

.hmi-background {
  fill: transparent;
}

.hmi-source-card {
  fill: rgba(249, 248, 239, 0.95);
  stroke: #9aa39d;
  stroke-width: 1.2;
}

.hmi-source-head {
  fill: #0d5b8f;
  stroke: #073d63;
  stroke-width: 1;
}

.hmi-source-title {
  fill: #ffffff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.hmi-source-value {
  fill: #14231f;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  font-weight: 900;
}

.hmi-button {
  fill: #064e80;
  stroke: #052f50;
  stroke-width: 1.4;
}

.hmi-button.warning {
  fill: #9e3b24;
  stroke: #6c2617;
}

.hmi-button-text {
  fill: #fff7b0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11px;
  font-weight: 900;
  text-anchor: middle;
  text-transform: uppercase;
}

.hmi-control {
  fill: rgba(238, 236, 225, 0.96);
  stroke: #8b9690;
  stroke-width: 1.1;
}

.hmi-control-label {
  fill: #202b28;
  font-family: Consolas, "Courier New", monospace;
  font-size: 10px;
  font-weight: 900;
  text-anchor: middle;
}

.hmi-led {
  fill: #6b7370;
  stroke: #47504c;
  stroke-width: 1;
}

.hmi-led.run {
  fill: var(--green);
}

.hmi-led.warn {
  fill: var(--yellow);
}

.valve-actuator {
  fill: none;
  stroke: #344641;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.hmi-mini-valve .valve-body {
  stroke-width: 1.7;
}

.valve-stub,
.pump-stub {
  stroke: #344641;
  stroke-width: 2.1;
  stroke-linecap: square;
  vector-effect: non-scaling-stroke;
}

.valve-disc {
  stroke: #344641;
  stroke-width: 2.2;
  vector-effect: non-scaling-stroke;
}

.valve-tag,
.pump-tag {
  text-anchor: middle;
}

.pump-impeller {
  fill: #344641;
  transform-box: fill-box;
  transform-origin: center;
}

.pump-run .pump-impeller {
  fill: var(--green-dim);
  animation: agitatorSpin 1.3s linear infinite;
  transform-origin: center;
}

.pump-stop .pump-impeller {
  fill: #6e7b75;
}

.valve-open .valve-disc {
  stroke: var(--green);
}

.valve-closed .valve-disc {
  stroke: var(--red);
}

.valve-transition .valve-disc {
  stroke: var(--yellow);
}

.valve-fault .valve-disc {
  stroke: var(--red);
}

.valve-unknown .valve-disc {
  stroke: #58645f;
}

.instrument-node {
  fill: rgba(247, 246, 237, 0.82);
  stroke: #344641;
  stroke-width: 1.7;
  vector-effect: non-scaling-stroke;
}

.instrument-lead {
  stroke: #344641;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
}

.instrument-tag {
  fill: #0d1b17;
  font-size: 8.5px;
  font-weight: 900;
}

.instrument-value {
  fill: #4f5c57;
  font-size: 9px;
  font-weight: 900;
}

.instrument-warning .instrument-node {
  stroke: var(--yellow);
}

.instrument-bad .instrument-node,
.instrument-no-data .instrument-node,
.instrument-unknown .instrument-node {
  stroke: var(--red);
}

.connection-line {
  stroke: rgba(12, 21, 20, 0.72);
  stroke-width: 2;
  stroke-dasharray: 5 5;
}

.area-title {
  fill: rgba(6, 12, 11, 0.72);
  font-size: 13px;
  font-weight: 900;
}

.source-stamp {
  fill: #283631;
  font-size: 10px;
  font-weight: 900;
}

g.clickable {
  cursor: pointer;
}

g.clickable:hover .equipment-metal,
g.clickable:hover .equipment-outline,
g.clickable:hover .technical-box,
g.clickable:hover .scada-panel-box,
g.clickable:hover .instrument-node,
g.clickable:hover .valve-body,
g.clickable:hover .pump-body {
  stroke: var(--green);
}

.state-normal .state-light,
.state-fermenting .state-light,
.state-running .state-light {
  fill: var(--green);
}

.state-attention .state-light,
.state-cleaning .state-light,
.state-maintenance .state-light {
  fill: var(--yellow);
}

.state-alarm .state-light,
.state-fault .state-light {
  fill: var(--red);
}

.state-stopped .state-light,
.state-offline .state-light,
.state-no-data .state-light,
.state-unknown .state-light {
  fill: #87918d;
}

.state-fermenting .fermentation-glow {
  fill: rgba(33, 184, 199, 0.2);
  animation: pulseGlow 1.8s ease-in-out infinite;
}

@keyframes pulseGlow {
  50% {
    fill: rgba(33, 212, 139, 0.26);
  }
}

.scada-popup {
  position: absolute;
  z-index: 9;
  width: min(330px, calc(100% - 24px));
  border: 1px solid rgba(154, 174, 165, 0.48);
  border-radius: var(--radius);
  padding: 12px;
  background: rgba(7, 13, 12, 0.97);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
}

.scada-popup h3 {
  margin: 0 0 9px;
  font-size: 15px;
}

.scada-popup .popup-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
}

.popup-grid {
  display: grid;
  gap: 6px;
}

.popup-row,
.kv-row,
.reading-row,
.event-row,
.recipe-row,
.instrument-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 7px 0;
  border-bottom: 1px solid rgba(154, 174, 165, 0.12);
  font-size: 12px;
}

.popup-row:last-child,
.kv-row:last-child,
.reading-row:last-child,
.event-row:last-child,
.recipe-row:last-child,
.instrument-row:last-child {
  border-bottom: 0;
}

.popup-row span,
.kv-row span,
.reading-row span,
.event-row span,
.recipe-row span,
.instrument-row span {
  color: var(--muted);
}

.popup-row strong,
.kv-row strong,
.reading-row strong,
.event-row strong,
.recipe-row strong,
.instrument-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.operation-panel {
  display: grid;
  gap: 8px;
  min-width: 0;
  max-height: calc(clamp(520px, 52vh, 610px) + 63px);
  padding: 8px;
  overflow: auto;
  align-self: stretch;
  box-shadow: none;
}

.ops-block {
  min-width: 0;
  padding: 10px;
  box-shadow: none;
}

.ops-block h2 {
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
}

.ops-stack,
.instrument-list,
.current-readings,
.event-list,
.recipe-panel,
.detail-summary {
  display: grid;
  gap: 6px;
}

.status-badge.normal {
  border-color: rgba(33, 212, 139, 0.38);
  color: var(--green);
  background: rgba(33, 212, 139, 0.09);
}

.status-badge.attention,
.status-badge.warning,
.status-badge.active {
  border-color: rgba(242, 194, 48, 0.42);
  color: var(--yellow);
  background: rgba(242, 194, 48, 0.1);
}

.status-badge.alarm,
.status-badge.high,
.status-badge.critical {
  border-color: rgba(255, 79, 91, 0.46);
  color: var(--red);
  background: rgba(255, 79, 91, 0.12);
}

.status-badge.fermenting {
  border-color: rgba(33, 184, 199, 0.44);
  color: var(--cyan);
  background: rgba(33, 184, 199, 0.11);
}

.status-badge.ending,
.status-badge.cleaning,
.status-badge.maintenance {
  border-color: rgba(242, 194, 48, 0.42);
  color: var(--yellow);
  background: rgba(242, 194, 48, 0.1);
}

.status-badge.offline,
.status-badge.stopped,
.status-badge.acked,
.status-badge.info,
.status-badge.complete {
  color: #c5ccc9;
  background: rgba(119, 130, 127, 0.14);
}

.data-source.manual,
.data-source.api {
  color: var(--yellow);
  background: rgba(242, 194, 48, 0.1);
}

.data-source.no-data,
.data-source.not-configured {
  color: #c5ccc9;
  background: rgba(119, 130, 127, 0.14);
}

.data-source.sensor {
  color: var(--green);
  background: rgba(33, 212, 139, 0.09);
}

.data-source.plc,
.data-source.edge {
  color: var(--green);
  background: rgba(33, 212, 139, 0.09);
}

.data-source.calculated,
.data-source.estimated,
.data-source.real {
  color: var(--cyan);
  background: rgba(33, 184, 199, 0.1);
}

.quality-badge.good {
  color: var(--green);
  background: rgba(33, 212, 139, 0.09);
}

.quality-badge.uncertain,
.quality-badge.stale {
  color: var(--yellow);
  background: rgba(242, 194, 48, 0.1);
}

.quality-badge.no-data,
.quality-badge.unknown {
  color: #c5ccc9;
  background: rgba(119, 130, 127, 0.14);
}

.quality-badge.bad,
.quality-badge.offline {
  color: var(--red);
  background: rgba(255, 79, 91, 0.1);
}

.status-badge.no-data,
.status-badge.unknown {
  color: #c5ccc9;
  background: rgba(119, 130, 127, 0.14);
}

.trend-badge.rising {
  color: var(--green);
}

.trend-badge.falling {
  color: var(--orange);
}

.trend-badge.stable {
  color: var(--cyan);
}

.event-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.event-row i {
  color: var(--yellow);
}

.event-row small,
.instrument-row small,
.operational-action small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.event-list.compact {
  max-height: 136px;
  overflow: auto;
}

.alarm-state,
.instrument-state,
.variable-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.ack-button {
  min-height: 26px;
  padding: 0 9px;
  border-color: rgba(33, 212, 139, 0.4);
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-panel {
  display: grid;
  gap: 5px;
  min-height: 60px;
  border: 1px dashed rgba(154, 174, 165, 0.26);
  border-radius: var(--radius);
  padding: 9px;
  color: var(--muted);
  font-size: 12px;
}

.ai-panel strong {
  color: #f2faf5;
}

.bottom-console {
  margin-top: 10px;
  overflow: hidden;
  box-shadow: none;
}

.tabbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 42px;
  padding: 6px 8px 0;
  overflow-x: auto;
  border-bottom: 1px solid rgba(154, 174, 165, 0.16);
  scrollbar-width: none;
}

.tabbar::-webkit-scrollbar {
  display: none;
}

.tab-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.tab-button.active {
  border-color: rgba(33, 212, 139, 0.48);
  color: var(--green);
  background: rgba(33, 212, 139, 0.09);
}

.tab-panel {
  display: none;
  min-height: 236px;
  padding: 10px;
}

.tab-panel.active {
  display: block;
}

.console-head {
  margin-bottom: 8px;
}

.series-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.series-toggle {
  min-height: 28px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.series-toggle.active {
  color: #041712;
  border-color: transparent;
  background: var(--green);
}

.chart-box {
  position: relative;
  height: 190px;
  min-height: 190px;
}

.chart-box[data-empty="true"]::after {
  content: "SEM HISTORICO";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  pointer-events: none;
}

.chart-box.tall {
  height: 360px;
}

.chart-box canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: 100% !important;
}

.batch-table-wrap,
.instrument-table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.data-table th,
.data-table td {
  padding: 8px 7px;
  border-bottom: 1px solid rgba(154, 174, 165, 0.12);
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.event-grid,
.quality-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.55fr);
  gap: 10px;
}

.tank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.tank-card {
  display: grid;
  gap: 8px;
  min-height: 126px;
  padding: 11px;
  box-shadow: none;
}

.tank-card:hover {
  border-color: var(--line-strong);
  background: rgba(33, 212, 139, 0.06);
}

.tank-card header,
.variable-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.tank-mini {
  position: relative;
  height: 44px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(11, 19, 18, 0.72);
}

.tank-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(33, 212, 139, 0.46), rgba(33, 184, 199, 0.32));
}

.tank-mini.no-data .tank-fill {
  background: rgba(154, 174, 165, 0.18);
}

.tank-meta,
.variable-meta {
  color: var(--muted);
  font-size: 11px;
}

.index-panel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.index-score {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--green) 0 96%, rgba(154, 174, 165, 0.18) 96% 100%);
}

.index-score span {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-soft);
  font-size: 28px;
  font-weight: 900;
}

.index-copy {
  display: grid;
  gap: 6px;
}

.config-page {
  display: grid;
  gap: 10px;
}

.config-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 10px;
  min-height: calc(100vh - 210px);
}

.config-left,
.config-main {
  min-width: 0;
  border: 1px solid rgba(154, 174, 165, 0.16);
  background: rgba(7, 13, 12, 0.72);
}

.config-left {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.config-tabs {
  flex-wrap: wrap;
  align-items: stretch;
  padding: 8px;
  border-bottom: 1px solid rgba(154, 174, 165, 0.16);
}

.config-tabs .tab-button {
  flex: 1 1 108px;
  justify-content: center;
}

.config-list {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
  overflow: auto;
}

.config-new,
.config-list-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
}

.config-new {
  grid-auto-flow: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--green);
}

.config-list-item.active {
  border-color: rgba(33, 212, 139, 0.52);
  background: rgba(33, 212, 139, 0.09);
}

.config-list-item strong {
  color: var(--text);
  font-size: 12px;
}

.config-list-item span {
  color: var(--muted);
  font-size: 11px;
}

.config-editor {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.config-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(154, 174, 165, 0.16);
}

.config-editor-head h2 {
  margin: 2px 0 0;
}

.config-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.config-form label {
  display: grid;
  gap: 5px;
}

.config-form label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.config-form input {
  min-width: 0;
  min-height: 34px;
  border: 1px solid rgba(154, 174, 165, 0.24);
  border-radius: 4px;
  padding: 0 9px;
  color: var(--text);
  background: rgba(4, 11, 10, 0.82);
}

.config-save-state {
  min-height: 22px;
  color: var(--yellow);
  font-size: 12px;
}

.instrument-row {
  grid-template-columns: minmax(120px, 1fr) minmax(80px, auto);
}

.instrument-row > div:first-child {
  min-width: 0;
}

.instrument-row > div:first-child strong {
  display: inline-block;
  text-align: left;
  white-space: nowrap;
}

.instrument-state {
  max-width: 112px;
}

.loading,
.empty,
.error {
  min-height: 86px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  padding: 14px;
}

.error {
  color: var(--red);
}

.action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.action-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.action-list li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  color: #dce8e3;
  font-size: 12px;
}

.action-list i {
  margin-top: 2px;
  color: var(--green);
}

/* Tank detail compatibility */
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.head-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  gap: 8px;
  min-width: min(660px, 54vw);
}

.metric,
.card {
  min-width: 0;
  padding: 12px;
}

.metric {
  min-height: 68px;
}

.section-head {
  margin-bottom: 10px;
}

.detail-page {
  max-width: 1640px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.detail-grid.wide-left {
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
}

.detail-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-summary .kv-row {
  min-height: 50px;
  border: 1px solid rgba(154, 174, 165, 0.12);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(10, 17, 21, 0.55);
}

.current-readings.detail {
  grid-template-columns: 1fr;
}

@media (max-width: 1520px) {
  .header-status {
    grid-template-columns: minmax(120px, 1fr) minmax(170px, 1.2fr) 72px 100px 82px 118px;
  }

  .header-status > div:last-child {
    display: none;
  }

  .kpi-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .operation-grid {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

@media (max-width: 1180px) {
  .topbar {
    height: auto;
    min-height: 46px;
    grid-template-columns: 1fr auto;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .header-status {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .module-nav {
    top: 86px;
  }

  .plant-strip,
  .operation-grid,
  .event-grid,
  .quality-grid,
  .detail-grid,
  .detail-grid.wide-left,
  .config-shell {
    grid-template-columns: 1fr;
  }

  .operation-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scada-stage {
    height: 560px;
    min-height: 560px;
  }

  .head-metrics {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .config-form {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 760px) {
  .industrial-page,
  .page {
    width: min(100% - 12px, 1880px);
    padding-top: 8px;
  }

  .brand-name {
    display: none;
  }

  .header-status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .header-status > div:nth-child(3) {
    display: none;
  }

  .module-nav {
    top: 118px;
  }

  h1 {
    font-size: 21px;
  }

  .kpi-strip,
  .operation-panel,
  .head-metrics,
  .detail-summary,
  .index-panel,
  .config-form {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .console-head,
  .page-head,
  .section-head {
    display: grid;
    align-items: start;
  }

  .mode-group,
  .series-controls {
    justify-content: start;
    flex-wrap: wrap;
  }

  .panel-heading h2 {
    white-space: normal;
  }

  .scada-stage {
    height: 560px;
    min-height: 560px;
  }

  .scada-popup {
    left: 8px !important;
    top: 8px !important;
  }

  .event-row,
  .popup-row,
  .kv-row,
  .reading-row,
  .recipe-row,
  .instrument-row {
    grid-template-columns: 1fr;
  }

  .popup-row strong,
  .kv-row strong,
  .reading-row strong,
  .event-row strong,
  .recipe-row strong,
  .instrument-row strong {
    text-align: left;
  }

  .alarm-state,
  .instrument-state {
    justify-content: flex-start;
    max-width: none;
  }

  .chart-box,
  .chart-box.tall {
    height: 260px;
  }
}

/* Banner de permissao (modo somente leitura) */
.config-perm-banner {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  border: 1px solid rgba(217, 165, 38, 0.55);
  border-radius: 9px;
  padding: 11px 14px;
  margin-bottom: 10px;
  color: #7a5b00;
  background: rgba(253, 243, 221, 0.85);
  font-size: 12.5px;
  line-height: 1.45;
}

.config-perm-banner i {
  margin-top: 2px;
  color: #b8860b;
  font-size: 16px;
}

.config-perm-banner strong {
  display: block;
  color: #6b4e00;
  font-size: 13px;
}

.config-editor-head button:disabled,
.config-new:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.config-save-state {
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 700;
}

/* ================= MODAL DE PIN (permissão via PIN) ================= */
.pin-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 7, 0.6);
  z-index: 120;
}

.pin-modal {
  width: 380px;
  max-width: calc(100vw - 32px);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 26px 30px 22px;
}

.pin-modal h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 750;
  color: var(--text);
}

.pin-modal h3 i {
  color: var(--green);
  margin-right: 6px;
}

.pin-modal p {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.pin-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 22px;
  letter-spacing: 0.45em;
  text-align: center;
  color: var(--text);
  background: var(--panel);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pin-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(33, 212, 139, 0.14);
}

.pin-error {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
}

.pin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.pin-btn {
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pin-btn:hover {
  border-color: var(--line-strong);
  background: var(--dark-steel);
}

.pin-ok {
  background: var(--green-dim);
  border-color: var(--green-dim);
}

.pin-ok:hover {
  background: var(--green);
  border-color: var(--green);
  color: #04120c;
}

/* ================= Botão Excluir (config editor) ================= */
.config-editor-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.config-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 79, 91, 0.45);
  background: rgba(255, 79, 91, 0.12);
  color: var(--red);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.config-delete-btn:hover {
  background: rgba(255, 79, 91, 0.22);
  border-color: var(--red);
}

.config-delete-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
