:root {
  --bg: #f7f9fc;
  --panel: #ffffff;
  --panel-soft: #fbfdff;
  --line: #dce5ee;
  --line-strong: #c8d5e2;
  --text: #0d1b2f;
  --muted: #63728a;
  --blue: #0b84e9;
  --cyan: #17a7d7;
  --green: #109c38;
  --yellow: #d59b12;
  --red: #cf3f3f;
  --steel-1: #f7fafc;
  --steel-2: #dce3e9;
  --steel-3: #aebbc6;
  --steel-4: #6f7f8d;
  --liquid: #c98016;
  --shadow: 0 10px 28px rgba(34, 55, 83, 0.09);
  --shadow-soft: 0 4px 14px rgba(34, 55, 83, 0.07);
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  overflow-x: hidden;
}

button,
a {
  color: inherit;
  font: inherit;
}

a { text-decoration: none; }

button { cursor: pointer; }

body[data-view="fermentation-dashboard"] .fermentation-shell .pc-nav {
  display: flex;
  gap: 2px;
  background: #ffffff;
  border: 1px solid #dce5ee;
  border-radius: 10px;
  padding: 4px 8px;
  box-shadow: 0 4px 14px rgba(34, 55, 83, 0.06);
}
body[data-view="fermentation-dashboard"] .fermentation-shell .pc-nav a {
  color: #63728a;
  font-size: 12.5px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
body[data-view="fermentation-dashboard"] .fermentation-shell .pc-nav a:hover { color: #0b84e9; }
body[data-view="fermentation-dashboard"] .fermentation-shell .pc-nav a.active { color: #0b84e9; background: #eaf4fd; }

.deepseek-panel {
  background: linear-gradient(180deg, #ffffff, #f6fafe);
  border: 1px solid #d3e2ef;
  border-radius: 14px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deepseek-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.deepseek-head > i {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 15px;
  color: #7057ff;
  background: #f2ecfd;
}
.deepseek-head > div { flex: 1 1 auto; min-width: 0; }
.deepseek-head strong { display: block; font-size: 13px; font-weight: 850; color: #0d1b2f; }
.deepseek-head span { font-size: 10.5px; color: #63728a; }
.deepseek-summary {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: #24344d;
}
.deepseek-recommendation {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #0d1b2f;
  background: #f0f8ff;
  border-left: 3px solid #0b84e9;
  border-radius: 0 8px 8px 0;
  padding: 7px 10px;
}
.deepseek-recommendation:empty { display: none; }
.deepseek-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}
.deepseek-report-link {
  font-size: 12px;
  font-weight: 800;
  color: #0b84e9;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #cfe2f5;
  border-radius: 8px;
  background: #fff;
}
.deepseek-report-link:hover { background: #eaf4fd; }
.deepseek-refresh {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #63728a;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 7px;
}
.deepseek-refresh:hover { color: #0b84e9; background: #eaf4fd; }

@media (max-width: 760px) {
  body[data-view="fermentation-dashboard"] .fermentation-shell .pc-nav {
    flex-wrap: wrap;
    overflow-x: auto;
  }
  body[data-view="fermentation-dashboard"] .fermentation-shell .pc-nav a { padding: 6px 9px; font-size: 12px; }
}

.fermentation-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 249, 252, 0.98)),
    radial-gradient(circle at 45% 10%, rgba(23, 167, 215, 0.06), transparent 34%);
}

.industrial-header {
  min-height: 86px;
  display: grid;
  grid-template-columns: minmax(300px, 1.55fr) repeat(6, minmax(126px, 0.62fr)) 42px;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.header-brand,
.header-metric {
  min-width: 0;
  border-right: 1px solid var(--line);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
}

.brand-shield {
  width: 48px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid #d9efe2;
  border-radius: 16px 16px 20px 20px;
  color: var(--green);
  background: linear-gradient(180deg, #ffffff, #f3fbf7);
  font-size: 25px;
}

.brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  overflow: hidden;
  color: #08244a;
  font-size: 21px;
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--blue);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0;
}

.header-metric {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: 1fr auto auto 1fr;
  column-gap: 10px;
  padding: 0 18px;
  align-items: center;
}

.header-metric > i {
  grid-row: 2 / 4;
  width: 28px;
  color: var(--blue);
  font-size: 22px;
  text-align: center;
}

.header-metric span {
  grid-column: 2;
  align-self: end;
  color: #52617a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-metric strong {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  color: #101a2d;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-metric:nth-of-type(1) > i { color: var(--green); }
.header-metric:nth-of-type(2) > i { color: var(--blue); }
.header-metric:nth-of-type(3) > i { color: var(--green); }
.header-metric:nth-of-type(6) > i { color: var(--green); }

.header-refresh {
  width: 42px;
  border: 0;
  color: #39506f;
  background: transparent;
  font-size: 16px;
}

.header-refresh:hover,
.header-refresh.loading {
  color: var(--blue);
  background: #f1f8ff;
}

.header-refresh.loading i {
  animation: spin 1s linear infinite;
}

.status-dot {
  width: 11px;
  height: 11px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 999px;
  background: #9aa8b8;
  box-shadow: 0 0 0 4px rgba(154, 168, 184, 0.16);
  vertical-align: -1px;
}

.status-dot.normal { background: var(--green); box-shadow: 0 0 0 4px rgba(16, 156, 56, 0.14); }
.status-dot.warning { background: var(--yellow); box-shadow: 0 0 0 4px rgba(213, 155, 18, 0.16); }
.status-dot.alarm { background: var(--red); box-shadow: 0 0 0 4px rgba(207, 63, 63, 0.14); }
.status-dot.offline { background: #78879a; box-shadow: 0 0 0 4px rgba(120, 135, 154, 0.14); }
.status-dot.no-data { background: #9aa8b8; box-shadow: 0 0 0 4px rgba(154, 168, 184, 0.14); }

.fermentation-main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 15fr) minmax(560px, 64fr) minmax(270px, 21fr);
  grid-template-areas: "telemetry tank ai";
  gap: 14px;
}

.telemetry-column,
.tank-column,
.terra-ai-panel {
  min-width: 0;
  min-height: 0;
}

.telemetry-column {
  grid-area: telemetry;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

.column-label {
  color: #52617a;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.telemetry-stack {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(5, minmax(66px, auto));
  gap: 6px;
  align-content: start;
}

.telemetry-card {
  min-width: 0;
  min-height: 66px;
  display: grid;
  grid-template-rows: auto auto minmax(22px, 1fr);
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 4px solid var(--card-color, var(--blue));
  border-radius: var(--radius);
  padding: 6px 11px 5px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.telemetry-card.no-data,
.telemetry-card.offline {
  background: linear-gradient(180deg, #ffffff, #fbfcfe);
}

.telemetry-card-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.telemetry-card-clickable:hover {
  border-color: var(--card-color, var(--blue));
  box-shadow: 0 8px 20px rgba(34, 55, 83, 0.12);
}
.telemetry-card-clickable:focus-visible {
  outline: 2px solid var(--card-color, var(--blue));
  outline-offset: 2px;
}

.card-report-hint {
  margin-left: auto;
  color: #a7b6c8;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.telemetry-card-clickable:hover .card-report-hint,
.telemetry-card-clickable:focus-visible .card-report-hint {
  opacity: 1;
  color: var(--card-color, var(--blue));
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.card-head i {
  width: 20px;
  color: var(--card-color, var(--blue));
  font-size: 16px;
  text-align: center;
}

.card-head strong {
  min-width: 0;
  overflow: hidden;
  color: #142038;
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-value-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.reading-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.reading-value {
  color: #0a1325;
  font-size: 32px;
  line-height: 0.95;
  font-weight: 760;
  letter-spacing: 0;
}

.reading-unit {
  color: #23344f;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.reading-volume {
  color: var(--blue);
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.reading-trend {
  display: grid;
  gap: 2px;
  justify-items: end;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.trend-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--green);
  font-size: 14px;
  font-weight: 850;
}

.trend-value.down { color: var(--green); }
.trend-value.up.warning { color: var(--yellow); }
.trend-value.down.warning { color: var(--yellow); }
.trend-value.alarm { color: var(--red); }
.trend-value.neutral { color: #7a889b; }

.trend-period {
  color: var(--muted);
  font-size: 11px;
}

.card-foot {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(22px, 1fr) auto;
  gap: 1px;
}

.sparkline {
  width: 100%;
  height: 24px;
  overflow: visible;
}

.sparkline path.line {
  fill: none;
  stroke: var(--card-color, var(--blue));
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline path.fill {
  fill: var(--card-color, var(--blue));
  opacity: 0.09;
}

.sparkline .axis {
  stroke: #d8e3ee;
  stroke-width: 1;
}

.sparkline-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px dashed #d6e0eb;
  border-radius: 7px;
  color: #7a889b;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 8px;
}

.reading-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
}

.quality-badge {
  max-width: 52%;
  overflow: hidden;
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 9.5px;
  font-weight: 850;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.quality-badge.normal { color: #08792b; background: #e7f7ec; }
.quality-badge.warning { color: #936200; background: #fff5d9; }
.quality-badge.alarm { color: #a62323; background: #ffe9e9; }
.quality-badge.offline,
.quality-badge.no-data,
.quality-badge.unknown { color: #5f6f83; background: #eef3f8; }

.tank-column {
  grid-area: tank;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}

.tank-stage {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: var(--shadow);
}

.tank-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 2px 14px;
  padding: 4px 16px 0;
}

.tank-meta span {
  grid-column: 1;
  color: #52617a;
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tank-meta strong {
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  color: #10233e;
  font-size: 19px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tank-meta em {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  color: #5a6b83;
  font-size: 11px;
  font-style: normal;
  font-weight: 750;
  white-space: nowrap;
}

.tank-scene {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(140px, 0.12fr) minmax(500px, 1fr) minmax(148px, 0.13fr);
  align-items: start;
  gap: 14px;
  padding: 0 16px 10px;
}

.fermentation-tank-svg {
  width: min(100%, calc((100vh - 160px) * 1.12));
  max-height: 100%;
  justify-self: center;
  height: auto;
  aspect-ratio: 620 / 682;
  min-height: 0;
  display: block;
}

.tank-leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 6;
}

.tank-callouts {
  min-width: 0;
  display: grid;
  gap: 36px;
  align-content: center;
  min-height: clamp(430px, 58vh, 620px);
}

.sensor-callout {
  position: relative;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 9px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 20px rgba(34, 55, 83, 0.09);
}

.sensor-callout::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(11, 132, 233, 0.12);
}

.tank-callouts-left .sensor-callout::before { right: -5px; }
.tank-callouts-right .sensor-callout::before { left: -5px; }

.sensor-callout h2 {
  margin: 0 0 6px;
  color: #0d1b2f;
  font-size: 12.5px;
  line-height: 1.25;
  font-weight: 850;
}

.sensor-callout p {
  margin: 0;
  color: #40516d;
  font-size: 11.5px;
  line-height: 1.45;
}

.callout-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 850;
}

.callout-tag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.sensor-callout.normal .callout-tag { color: var(--green); }
.sensor-callout.warning .callout-tag { color: var(--yellow); }
.sensor-callout.alarm .callout-tag { color: var(--red); }
.sensor-callout.offline .callout-tag,
.sensor-callout.no-data .callout-tag,
.sensor-callout.unknown .callout-tag { color: #78879a; }

.sanitary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.sanitary-strip div {
  min-width: 0;
  min-height: 50px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-right: 1px solid var(--line);
}

.sanitary-strip div:last-child { border-right: 0; }

.sanitary-strip i {
  grid-row: 1 / 3;
  color: var(--green);
  font-size: 22px;
  text-align: center;
}

.sanitary-strip span {
  min-width: 0;
  overflow: visible;
  color: #5b6a82;
  font-size: 10px;
  font-weight: 850;
  line-height: 1.15;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: normal;
}

.sanitary-strip strong {
  min-width: 0;
  overflow: visible;
  color: #18304d;
  font-size: 11.5px;
  font-weight: 850;
  line-height: 1.15;
  text-overflow: clip;
  text-transform: uppercase;
  white-space: normal;
}

.terra-ai-panel {
  grid-area: ai;
  display: grid;
  grid-template-rows: auto minmax(0, auto) auto auto minmax(96px, auto);
  align-content: start;
  gap: 9px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.terra-ai-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
}

.terra-ai-head > i {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #cbe5ff;
  border-radius: 13px;
  color: var(--blue);
  background: #f0f8ff;
  font-size: 23px;
}

.terra-ai-head h1 {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 22px;
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: 0;
}

.terra-ai-head p {
  margin: 0;
  color: #2c3b55;
  font-size: 12.5px;
  line-height: 1.45;
}

.ai-status-list {
  display: grid;
  gap: 8px;
}

.ai-status-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 10px;
  background: #ffffff;
}

.ai-status-item i {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: #ecf9f0;
  font-size: 14px;
}

.ai-status-item.warning i { color: var(--yellow); background: #fff7dd; }
.ai-status-item.alarm i { color: var(--red); background: #ffecec; }
.ai-status-item.no-data i,
.ai-status-item.offline i,
.ai-status-item.unknown i { color: #728197; background: #f0f4f8; }

.ai-status-item strong {
  display: block;
  color: #17253d;
  font-size: 13.5px;
  font-weight: 800;
}

.ai-status-item span {
  display: block;
  margin-top: 2px;
  color: #4f5f78;
  font-size: 12px;
  line-height: 1.35;
}

.ai-card,
.alerts-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #ffffff;
  box-shadow: 0 3px 10px rgba(34, 55, 83, 0.05);
}

.ai-card-title,
.alerts-title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 850;
}

.ai-card-title i,
.alerts-title i {
  width: 22px;
  color: var(--blue);
  text-align: center;
}

.prediction-card strong {
  display: block;
  margin-top: 8px;
  color: #132540;
  font-size: 19px;
  font-weight: 850;
}

.ai-card p,
.prediction-card p {
  margin: 7px 0 0;
  color: #3d4d67;
  font-size: 12.5px;
  line-height: 1.45;
}

.alerts-panel {
  display: grid;
  gap: 10px;
}

.alert-list {
  display: grid;
  gap: 8px;
  color: #32425c;
  font-size: 12.5px;
}

.alert-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  border-radius: 9px;
  padding: 9px 10px;
  background: #f8fbff;
}

.alert-item i { color: var(--yellow); margin-top: 2px; }
.alert-item.critical i,
.alert-item.alarm i { color: var(--red); }
.alert-item.info i,
.alert-item.ok i { color: var(--green); }

.alert-item strong {
  display: block;
  color: #14233d;
  font-size: 12.5px;
}

.alert-item span {
  display: block;
  margin-top: 2px;
  color: #53637c;
  line-height: 1.35;
}

.api-notice {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 30;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  border: 1px solid #f1c7c7;
  border-radius: 12px;
  padding: 12px 16px;
  color: #8d2424;
  background: #fff3f3;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 760;
}

.tank-title-svg,
.tank-value-svg,
.tank-label-svg {
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1640px) {
  .industrial-header {
    grid-template-columns: minmax(260px, 1.25fr) repeat(6, minmax(112px, 0.55fr)) 38px;
  }

  .header-brand { gap: 12px; padding: 0 16px; }
  .brand-shield { width: 44px; height: 52px; font-size: 22px; }
  .brand-copy strong { font-size: 16px; }
  .brand-copy small { font-size: 15px; }
  .header-metric {
    grid-template-columns: 24px minmax(0, 1fr);
    column-gap: 7px;
    padding: 0 9px;
  }
  .header-metric strong { font-size: 13px; }
  .header-metric > i { width: 23px; font-size: 18px; }
  .reading-value { font-size: 30px; }
  .sensor-callout { padding: 10px 11px; }
}

@media (max-height: 840px) and (min-width: 1101px) {
  .fermentation-shell { gap: 8px; }
  .industrial-header { min-height: 74px; }
  .telemetry-stack { gap: 5px; grid-template-rows: repeat(5, minmax(62px, auto)); align-content: start; }
  .telemetry-card { min-height: 62px; padding: 5px 9px 4px; }
  .card-head strong { font-size: 13px; }
  .reading-value { font-size: 29px; }
  .sparkline { height: 20px; }
  .terra-ai-panel { gap: 8px; padding: 12px; }
  .ai-status-item { min-height: 40px; padding: 6px 9px; }
  .terra-ai-head h1 { font-size: 20px; }
  .terra-ai-head p { font-size: 11.5px; }
}

@media (max-width: 1280px) {
  .industrial-header {
    grid-template-columns: repeat(3, minmax(0, 1fr)) 38px;
  }

  .header-brand {
    grid-column: 1 / -2;
    min-height: 72px;
  }

  .header-metric {
    min-height: 66px;
    border-top: 1px solid var(--line);
  }

  .header-refresh {
    grid-column: -2;
    grid-row: 1;
    border-left: 1px solid var(--line);
  }

  .header-metric:nth-of-type(1) { grid-column: 1; grid-row: 2; }
  .header-metric:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .header-metric:nth-of-type(3) { grid-column: 3; grid-row: 2; }
  .header-metric:nth-of-type(4) { grid-column: 1; grid-row: 3; }
  .header-metric:nth-of-type(5) { grid-column: 2; grid-row: 3; }
  .header-metric:nth-of-type(6) { grid-column: 3; grid-row: 3; }

  .fermentation-main {
    grid-template-columns: minmax(0, 1fr) minmax(310px, 0.72fr);
    grid-template-areas:
      "tank tank"
      "telemetry ai";
    align-items: start;
  }

  .telemetry-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: min-content;
    align-content: start;
  }

  .telemetry-card:first-child {
    grid-column: 1 / -1;
  }

  .reading-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .quality-badge {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  .fermentation-shell {
    min-height: 100vh;
    padding: 6px;
  }

  .industrial-header {
    grid-template-columns: minmax(0, 1fr) 38px;
  }

  .header-brand {
    grid-column: 1;
    padding: 12px 14px;
  }

  .brand-shield {
    width: 42px;
    height: 50px;
    font-size: 21px;
  }

  .brand-copy strong {
    white-space: normal;
    font-size: 16px;
  }

  .brand-copy small { font-size: 14px; }

  .header-refresh {
    grid-column: 2;
  }

  .header-metric {
    grid-column: 1 / -1;
    min-height: 58px;
    padding: 0 14px;
    border-right: 0;
  }

  /* vence as regras nth-of-type da media 1280 (especificidade maior) */
  .industrial-header .header-metric:nth-of-type(1),
  .industrial-header .header-metric:nth-of-type(2),
  .industrial-header .header-metric:nth-of-type(3),
  .industrial-header .header-metric:nth-of-type(4),
  .industrial-header .header-metric:nth-of-type(5),
  .industrial-header .header-metric:nth-of-type(6) {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .header-brand { min-width: 0; }
  .brand-copy { min-width: 0; }

  .fermentation-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "tank"
      "telemetry"
      "ai";
  }

  .tank-scene {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 6px 12px 12px;
  }

  .tank-callouts-left,
  .tank-callouts-right {
    display: none;
  }

  .tank-leaders {
    display: none;
  }

  .fermentation-tank-svg { order: 1; height: auto; aspect-ratio: 620 / 682; min-height: 0; }

  .sensor-callout::before,
  .sensor-callout::after {
    display: none;
  }

  .tank-meta {
    grid-template-columns: minmax(0, 1fr);
  }

  .tank-meta em {
    grid-column: 1;
    grid-row: auto;
    white-space: normal;
  }

  .telemetry-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  .telemetry-card:first-child {
    grid-column: auto;
  }

  .terra-ai-panel {
    overflow: visible;
  }

  .sanitary-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .sanitary-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sanitary-strip div:last-child {
    border-bottom: 0;
  }

  .reading-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .quality-badge {
    max-width: 100%;
  }
}
