:root {
  color-scheme: dark;
  --bg: #071018;
  --bg-2: #0b1722;
  --panel: rgba(16, 31, 45, 0.88);
  --panel-2: rgba(9, 23, 35, 0.96);
  --line: rgba(132, 171, 197, 0.18);
  --line-strong: rgba(114, 211, 255, 0.32);
  --text: #e8f3fb;
  --muted: #89a4b8;
  --subtle: #527087;
  --cyan: #34d6ff;
  --green: #3ee58c;
  --yellow: #f7c94a;
  --orange: #ff8b3d;
  --red: #ff4f61;
  --purple: #9d7cff;
  --gray: #7b8794;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(20, 64, 88, 0.2), transparent 34%),
    radial-gradient(circle at 70% 10%, rgba(52, 214, 255, 0.1), transparent 30%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, rgba(8, 18, 27, 0.98), rgba(7, 13, 20, 0.98));
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  padding: 4px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(213, 232, 241, 0.72);
  border-radius: 7px;
  background: linear-gradient(145deg, #f5fafc, #aebfcb);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: contrast(1.08) saturate(1.08) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.22));
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: 6px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: var(--line-strong);
  background: rgba(52, 214, 255, 0.1);
  color: var(--text);
}

.nav-icon {
  width: 22px;
  color: var(--cyan);
  text-align: center;
}

.side-status {
  margin-top: auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  border-radius: 6px;
}

.side-status span,
.side-status small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.side-status strong {
  display: block;
  margin: 8px 0;
  color: var(--green);
  font-size: 24px;
  font-family: "Segoe UI", Arial, sans-serif;
}

.workspace {
  padding: 18px;
  height: 116vh;
  overflow: hidden;
}

.topbar {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
}

.topbar p,
.panel-header p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.segmented button {
  border-radius: 6px;
  height: 36px;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(52, 214, 255, 0.1);
  cursor: pointer;
  padding: 0 14px;
}

.primary-btn {
  background: linear-gradient(90deg, #1278a0, #1d9b89);
  border-color: rgba(52, 214, 255, 0.48);
  font-weight: 700;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), rgba(7, 18, 28, 0.92));
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.metric-card {
  min-height: 96px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.7;
}

.metric-card span,
.sensor-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.metric-card small,
.sensor-card small {
  display: block;
  margin-top: 8px;
  color: var(--subtle);
  font-size: 12px;
}

.metric-card.danger strong {
  color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 380px;
  grid-template-rows: minmax(0, 1fr) 184px;
  height: calc(116vh - 174px);
  gap: 14px;
  padding-bottom: 18px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.map-panel {
  min-height: 0;
  height: 100%;
}

.alarm-panel {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.monitor-panel {
  grid-column: 1 / 2;
}

.security-panel {
  grid-column: 1 / 3;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header.compact {
  align-items: center;
}

h2 {
  font-size: 17px;
  font-weight: 700;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  height: 30px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segmented button.active {
  color: var(--text);
  background: rgba(52, 214, 255, 0.18);
}

.plant-map {
  position: relative;
  height: calc(100% - 52px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(132, 171, 197, 0.2);
  border-radius: 6px;
  background:
    linear-gradient(rgba(52, 214, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52, 214, 255, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(5, 14, 22, 0.14), rgba(5, 14, 22, 0.36)),
    url("./assets/plant-map.png"),
    linear-gradient(145deg, rgba(16, 38, 54, 0.92), rgba(5, 14, 22, 0.95));
  background-size: 28px 28px, 28px 28px, cover, cover, auto;
  background-position: 0 0, 0 0, center, center, center;
}

.plant-map::before {
  content: "";
  position: absolute;
  inset: 22px 34px 24px 34px;
  border: 1px solid rgba(132, 171, 197, 0.16);
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(52, 214, 255, 0.07) 18% 18.5%, transparent 18.5%),
    linear-gradient(180deg, transparent 0 64%, rgba(52, 214, 255, 0.07) 64% 64.5%, transparent 64.5%);
  pointer-events: none;
  opacity: 0.45;
}

.plant-roads,
.facility {
  position: absolute;
  pointer-events: none;
}

.plant-roads {
  inset: 0;
  z-index: 1;
  display: none;
}

.road {
  position: absolute;
  display: block;
  height: 9px;
  border: 1px solid rgba(103, 146, 172, 0.2);
  background: rgba(103, 146, 172, 0.09);
  transform-origin: left center;
}

.road-main {
  left: 8%;
  right: 7%;
  bottom: 16%;
}

.road-branch {
  left: 38%;
  top: 17%;
  width: 9px;
  height: 68%;
}

.road-loop {
  left: 62%;
  top: 18%;
  width: 34%;
  transform: rotate(18deg);
}

.facility {
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid rgba(132, 171, 197, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)),
    repeating-linear-gradient(90deg, rgba(132, 171, 197, 0.05) 0 1px, transparent 1px 9px);
  color: rgba(232, 243, 251, 0.54);
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  display: none;
}

.block-turbine { left: 8%; top: 9%; width: 29%; height: 28%; }
.block-cooling { left: 9%; top: 54%; width: 28%; height: 28%; }
.block-cable { left: 42%; top: 12%; width: 27%; height: 70%; }
.block-valve { left: 73%; top: 20%; width: 20%; height: 50%; }
.block-tank {
  left: 76%;
  top: 11%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
.block-office { left: 48%; top: 72%; width: 15%; height: 12%; }

.map-zone {
  position: absolute;
  border: 1px solid rgba(132, 171, 197, 0.16);
  background: rgba(255, 255, 255, 0.012);
  color: transparent;
  font-size: 0;
  display: grid;
  place-items: center;
  letter-spacing: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.42;
}

.zone-a { left: 5%; top: 8%; width: 30%; height: 32%; }
.zone-b { left: 39%; top: 10%; width: 28%; height: 74%; }
.zone-c { left: 6%; top: 50%; width: 30%; height: 36%; }
.zone-d { left: 72%; top: 18%; width: 22%; height: 64%; }

.link-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.link-lines path {
  fill: none;
  stroke: rgba(52, 214, 255, 0.24);
  stroke-width: 0.5;
  stroke-dasharray: 2 2;
}

.map-point {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(62, 229, 140, 0.1), 0 0 22px currentColor;
  color: var(--green);
  z-index: 3;
}

.map-point::after {
  content: attr(data-code);
  position: absolute;
  left: 18px;
  top: -14px;
  color: rgba(232, 243, 251, 0.88);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border: 1px solid rgba(132, 171, 197, 0.18);
  border-radius: 4px;
  background: rgba(6, 16, 25, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  pointer-events: none;
}

.map-point.warn { background: var(--yellow); color: var(--yellow); box-shadow: 0 0 0 6px rgba(247, 201, 74, 0.12), 0 0 22px currentColor; }
.map-point.alarm { background: var(--red); color: var(--red); box-shadow: 0 0 0 8px rgba(255, 79, 97, 0.14), 0 0 28px currentColor; animation: pulse 1.2s infinite; }
.map-point.work { background: var(--purple); color: var(--purple); box-shadow: 0 0 0 6px rgba(157, 124, 255, 0.16), 0 0 22px currentColor; }
.map-point.offline { background: var(--gray); color: var(--gray); box-shadow: 0 0 0 6px rgba(123, 135, 148, 0.12), 0 0 14px currentColor; }

@keyframes pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.22); }
}

.live-dot {
  color: var(--green);
  font-size: 12px;
}

.live-dot::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px var(--green);
}

.active-alarm {
  border: 1px solid rgba(255, 79, 97, 0.32);
  background: rgba(255, 79, 97, 0.08);
  padding: 14px;
  border-radius: 6px;
}

.active-alarm > strong {
  display: block;
  color: var(--red);
  font-size: 18px;
  margin-bottom: 8px;
}

.active-alarm span,
.active-alarm small {
  display: block;
  color: var(--muted);
  line-height: 1.6;
}

.risk-verdict {
  min-height: 34px;
  margin: 8px 0;
  padding: 6px 10px;
  border: 1px solid rgba(255, 79, 97, 0.7);
  border-left: 4px solid var(--red);
  border-radius: 5px;
  background: rgba(255, 79, 97, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: inset 0 0 18px rgba(255, 79, 97, 0.08), 0 0 16px rgba(255, 79, 97, 0.08);
}

.risk-verdict span {
  color: #ffb5bd;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.risk-verdict b {
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.alarm-responsibility {
  margin: 7px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
}

.active-alarm .alarm-responsibility span {
  color: #c6d8e5;
  font-size: 11px;
  line-height: 1.3;
}

.workflow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 14px;
}

.workflow::before {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  top: 17px;
  height: 2px;
  background: linear-gradient(90deg, rgba(62, 229, 140, 0.7), rgba(52, 214, 255, 0.25));
  z-index: 0;
}

.workflow span {
  min-height: 34px;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  color: var(--subtle);
  font-size: 12px;
  border-radius: 6px;
  background: rgba(7, 18, 28, 0.96);
}

.workflow span.done {
  color: var(--text);
  border-color: rgba(62, 229, 140, 0.45);
  background: rgba(62, 229, 140, 0.09);
}

.workflow i {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-style: normal;
  font-size: 10px;
  line-height: 1;
}

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

.alarm-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 68px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
  min-width: 0;
}

.alarm-item > span:first-child {
  color: var(--muted);
  font-size: 12px;
}

.alarm-item-content {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.alarm-item-content strong {
  display: block;
  font-size: 12px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alarm-item-content small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alarm-item-state {
  display: grid;
  justify-items: end;
  gap: 3px;
}

.alarm-item-state b {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.alarm-item[data-state="未确认"] .alarm-item-state b {
  color: var(--red);
}

.alarm-item[data-state="处理中"] .alarm-item-state b,
.alarm-item[data-state="待复核"] .alarm-item-state b {
  color: var(--yellow);
}

.alarm-tag {
  display: inline-block;
  width: 48px;
  color: var(--text);
  border: 1px solid rgba(255, 139, 61, 0.35);
  background: rgba(255, 139, 61, 0.12);
  padding: 4px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-style: normal;
  text-align: center;
  white-space: nowrap;
}

@media (min-width: 1101px) and (max-height: 850px) {
  .workspace {
    height: 100vh;
    padding: 14px 16px 10px;
    overflow: hidden;
  }

  .topbar {
    min-height: 42px;
  }

  h1 {
    font-size: 21px;
  }

  .metric-strip {
    margin: 8px 0 10px;
  }

  .metric-card {
    min-height: 62px;
    padding: 8px 14px;
  }

  .metric-card strong {
    margin-top: 5px;
    font-size: 24px;
  }

  .metric-card small {
    margin-top: 5px;
  }

  .dashboard-grid {
    height: auto;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: 360px 184px;
    grid-auto-rows: auto;
    gap: 12px;
    align-items: stretch;
  }

  .panel {
    padding: 12px;
  }

  .map-panel,
  .alarm-panel {
    min-height: 0;
    height: 100%;
  }

  .alarm-panel {
    overflow: hidden;
  }

  .panel-header {
    margin-bottom: 10px;
  }

  .panel-header p {
    margin-top: 4px;
  }

  .active-alarm {
    padding: 9px 10px;
  }

  .active-alarm > strong {
    margin-bottom: 4px;
    font-size: 16px;
  }

  .active-alarm span,
  .active-alarm small {
    line-height: 1.45;
  }

  .workflow {
    margin: 7px 0;
  }

  .workflow span {
    min-height: 30px;
    font-size: 11px;
  }

  .alarm-list {
    max-height: 116px;
    overflow: hidden;
  }

  .alarm-item {
    padding: 7px 10px;
  }

  .plant-map {
    height: calc(100% - 50px);
    min-height: 0;
  }

  .monitor-panel,
  .ops-panel {
    height: 184px;
    min-height: 0;
    overflow: hidden;
  }

  .status-footer {
    display: none;
  }

  .sensor-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .sensor-card {
    min-height: 74px;
    padding: 10px 12px;
  }

  .sensor-card strong {
    margin: 6px 0;
    font-size: 21px;
  }

  .sensor-card small {
    margin-top: 4px;
  }

  .sparkline {
    display: none;
  }

  .health-list {
    gap: 7px;
  }

  .health-row {
    font-size: 12px;
    gap: 8px;
  }

  .health-row div {
    height: 8px;
  }
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.sensor-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
  padding: 14px;
  min-height: 154px;
}

.sensor-card strong {
  display: block;
  margin: 10px 0;
  font-size: 26px;
}

.sensor-card.gas strong { color: var(--red); }
.sensor-card.liquid strong { color: var(--yellow); }
.sensor-card.cover strong { color: var(--orange); }

.sparkline {
  height: 42px;
  margin-top: 12px;
  border-radius: 4px;
  background-size: 100% 100%;
}

.danger-line {
  background-image: linear-gradient(160deg, transparent 45%, rgba(255, 79, 97, 0.42) 46%, transparent 49%),
    linear-gradient(90deg, rgba(255, 79, 97, 0.08), rgba(255, 79, 97, 0.18));
}

.ok-line {
  background-image: linear-gradient(170deg, transparent 48%, rgba(62, 229, 140, 0.5) 49%, transparent 52%),
    linear-gradient(90deg, rgba(62, 229, 140, 0.06), rgba(62, 229, 140, 0.16));
}

.warn-line {
  background-image: linear-gradient(150deg, transparent 38%, rgba(247, 201, 74, 0.5) 39%, transparent 44%),
    linear-gradient(90deg, rgba(247, 201, 74, 0.06), rgba(247, 201, 74, 0.16));
}

.event-line {
  background: repeating-linear-gradient(90deg, rgba(255, 139, 61, 0.35) 0 5px, transparent 5px 12px),
    rgba(255, 139, 61, 0.08);
}

.health-list {
  display: grid;
  gap: 14px;
}

.health-row {
  display: grid;
  grid-template-columns: 86px 1fr 46px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.health-row div {
  height: 9px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  overflow: hidden;
}

.health-row i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.health-row strong {
  color: var(--text);
  text-align: right;
}

.topology {
  display: grid;
  grid-template-columns: 1fr 60px 1fr 60px 1fr 60px 1fr 1.4fr;
  align-items: center;
  gap: 8px;
}

.status-footer {
  min-height: 42px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 18, 28, 0.78);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 16px;
  font-size: 12px;
}

@media (min-width: 1101px) {
  .status-footer {
    display: flex !important;
    position: fixed !important;
    left: 252px !important;
    right: 16px !important;
    bottom: 12px !important;
    z-index: 100 !important;
    height: 46px !important;
    min-height: 46px !important;
    margin: 0 !important;
    padding: 0 18px !important;
    background: rgba(7, 18, 28, 0.96) !important;
    border-color: rgba(52, 214, 255, 0.24) !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  }
}

@media (min-width: 900px) and (max-height: 850px) {
  body {
    overflow: hidden !important;
  }

  .app-shell,
  .workspace {
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
  }

  .dashboard-grid {
    height: calc(100vh - 174px) !important;
    grid-template-columns: minmax(0, 1fr) 380px !important;
    grid-template-rows: minmax(0, 1fr) 132px !important;
    gap: 12px !important;
    padding-bottom: 0 !important;
  }

  .map-panel,
  .alarm-panel,
  .monitor-panel,
  .ops-panel {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .plant-map {
    height: calc(100% - 50px) !important;
    min-height: 0 !important;
  }

  body .status-footer[data-section="overview"] {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    left: 252px !important;
    right: 16px !important;
    bottom: 10px !important;
    z-index: 999 !important;
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 !important;
    padding: 0 16px !important;
    background: rgba(7, 18, 28, 0.97) !important;
    border: 1px solid rgba(52, 214, 255, 0.3) !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45) !important;
  }

  .sensor-grid {
    display: flex !important;
    gap: 10px !important;
  }

  .sensor-card {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 46px !important;
    padding: 8px 10px !important;
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    align-items: center !important;
    column-gap: 8px !important;
  }

  .sensor-card small,
  .sensor-card .sparkline {
    display: none !important;
  }

  .health-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .monitor-panel,
  .ops-panel {
    display: none !important;
  }

  .dashboard-grid {
    height: calc(100vh - 174px - 144px) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    padding-bottom: 0 !important;
  }
}

.status-footer span::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px rgba(62, 229, 140, 0.85);
}

.status-footer strong {
  margin-left: auto;
  color: var(--subtle);
  font-weight: 600;
}

.topo-node,
.topo-split div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
}

.topo-node.core {
  border-color: rgba(52, 214, 255, 0.46);
  box-shadow: inset 0 0 24px rgba(52, 214, 255, 0.1);
}

.topo-arrow {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan));
  position: relative;
}

.topo-arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: -4px;
  border-left: 8px solid var(--cyan);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.topo-arrow.guarded {
  background: linear-gradient(90deg, transparent, var(--yellow));
}

.topo-arrow.guarded::after {
  border-left-color: var(--yellow);
}

.topo-split {
  display: grid;
  gap: 8px;
}

.point-drawer {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  box-shadow: var(--shadow);
}

.point-drawer::backdrop {
  background: rgba(0, 0, 0, 0.52);
}

.close-btn {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.detail-title {
  margin: 8px 36px 16px 0;
}

.detail-title strong {
  display: block;
  font-size: 20px;
}

.detail-title span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.detail-cell {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.detail-cell span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-cell strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.status-alarm { color: var(--red); }
.status-warn { color: var(--yellow); }
.status-normal { color: var(--green); }
.status-work { color: var(--purple); }
.status-offline { color: var(--gray); }

@media (max-width: 1100px) {
  body {
    overflow: auto;
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    overflow: hidden;
    max-width: 100vw;
    padding: 10px;
  }

  .brand {
    flex: 0 0 auto;
  }

  .nav-list {
    display: flex;
    min-width: 0;
    overflow-x: auto;
    gap: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: 96px;
    white-space: nowrap;
  }

  .workspace {
    width: 100vw;
    max-width: 100vw;
    min-width: 0;
    padding: 16px;
    overflow-x: hidden;
  }

  .topbar,
  .metric-strip,
  .dashboard-grid {
    width: 100%;
    max-width: 100%;
  }

  .side-status {
    display: none;
  }

  .metric-strip,
  .dashboard-grid,
  .sensor-grid,
  .topology {
    grid-template-columns: 1fr;
  }

  .security-panel,
  .monitor-panel {
    grid-column: auto;
  }

  .topbar,
  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  h1 {
    max-width: 100%;
    font-size: 20px;
    line-height: 1.35;
    word-break: break-all;
    overflow-wrap: anywhere;
  }

  .plant-map {
    height: 320px;
  }
}

@media (min-width: 1101px) and (max-height: 850px) {
  .monitor-panel,
  .ops-panel {
    height: 184px !important;
  }

  .monitor-panel .panel-header,
  .ops-panel .panel-header {
    margin-bottom: 8px;
  }

  .monitor-panel h2,
  .ops-panel h2 {
    font-size: 16px;
  }

  .monitor-panel .panel-header p,
  .ops-panel .panel-header p {
    font-size: 12px;
  }

  .sensor-grid {
    display: flex !important;
    gap: 10px !important;
  }

  .sensor-card {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    min-height: 46px !important;
    padding: 8px 10px !important;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 8px;
  }

  .sensor-card strong {
    margin: 4px 0;
    font-size: 18px;
  }

  .sensor-card small {
    display: none;
  }

  .sensor-card .sparkline {
    display: none;
  }

  .health-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .health-row {
    grid-template-columns: 58px 1fr 34px;
    font-size: 11px;
    gap: 4px;
  }

  .health-row div {
    height: 7px;
  }

  .status-footer {}
}

@media (min-width: 1101px) and (max-height: 850px) {
  .workspace {
    height: 100vh !important;
    overflow: hidden !important;
  }

  .dashboard-grid {
    height: calc(100vh - 104px) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    align-content: stretch !important;
  }

  .map-panel,
  .alarm-panel,
  .monitor-panel,
  .ops-panel {
    height: 100% !important;
    min-height: 0 !important;
  }

  .plant-map {
    height: calc(100% - 50px) !important;
    min-height: 0 !important;
  }
}

@media (min-width: 1101px) {
  body .status-footer[data-section="overview"] {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    left: 248px !important;
    right: 16px !important;
    bottom: 14px !important;
    z-index: 999 !important;
    height: 86px !important;
    min-height: 86px !important;
    margin: 0 !important;
    padding: 12px 18px !important;
    align-items: center !important;
    gap: 14px !important;
    background:
      linear-gradient(180deg, #07121c, #050d14),
      linear-gradient(90deg, rgba(52, 214, 255, 0.08), transparent 48%, rgba(62, 229, 140, 0.06)) !important;
    border-top: 1px solid rgba(52, 214, 255, 0.3) !important;
    border-left: 1px solid rgba(52, 214, 255, 0.16) !important;
    box-shadow: 0 -18px 42px rgba(0, 0, 0, 0.46) !important;
  }

  body .status-footer[data-section="overview"] span,
  body .status-footer[data-section="overview"] strong {
    height: 54px !important;
    margin: 0 !important;
    border: 1px solid rgba(132, 171, 197, 0.18) !important;
    border-radius: 8px !important;
    background: #0b1a27 !important;
    color: var(--text) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    font-weight: 700 !important;
  }
}

@media (min-width: 900px) and (max-height: 850px) {
  .side-status {
    display: none !important;
  }
}

/* Presentation viewport lock: keep the bottom status rail in normal layout, never as an overlay. */
@media (min-width: 900px) {
  body .status-footer[data-section="overview"] {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    z-index: auto !important;
    width: auto !important;
    margin: 0 !important;
  }
}

@media (min-width: 900px) and (max-height: 850px) {
  body {
    overflow: hidden !important;
  }

  .workspace {
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
    padding: 12px 16px !important;
  }

  .topbar {
    min-height: 42px !important;
  }

  .metric-strip {
    margin: 8px 0 10px !important;
    gap: 10px !important;
  }

  .metric-card {
    min-height: 70px !important;
    padding: 10px 14px !important;
  }

  .dashboard-grid {
    height: calc(100vh - 180px) !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 380px !important;
    grid-template-rows: minmax(0, 1fr) 76px !important;
    gap: 12px !important;
    padding-bottom: 0 !important;
    align-content: stretch !important;
  }

  .map-panel {
    grid-column: 1 !important;
    grid-row: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .alarm-panel {
    grid-column: 2 !important;
    grid-row: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  body[data-view="overview"] .monitor-panel,
  body[data-view="overview"] .ops-panel,
  body[data-view="overview"] .security-panel {
    display: none !important;
  }

  .plant-map {
    height: calc(100% - 50px) !important;
    min-height: 0 !important;
  }

  body .status-footer[data-section="overview"] {
    grid-column: 1 / 3 !important;
    grid-row: 2 !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    height: 100% !important;
    min-height: 0 !important;
    padding: 10px 14px !important;
    gap: 12px !important;
    border: 1px solid rgba(52, 214, 255, 0.28) !important;
    border-radius: 8px !important;
    background: linear-gradient(180deg, rgba(8, 22, 33, 0.98), rgba(5, 14, 21, 0.98)) !important;
    box-shadow: none !important;
  }

  body .status-footer[data-section="overview"] span,
  body .status-footer[data-section="overview"] strong {
    height: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    border: 1px solid rgba(132, 171, 197, 0.18) !important;
    border-radius: 8px !important;
    background: #0b1a27 !important;
    color: var(--text) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 10px !important;
    overflow: hidden !important;
    text-align: center !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    font-weight: 700 !important;
  }
}

@media (min-width: 900px) {
  body:not([data-view="overview"]) .status-footer[data-section="overview"] {
    display: none !important;
  }

  body:not([data-view="overview"]) .dashboard-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) !important;
    align-content: stretch !important;
  }

  body[data-view="map"] .map-panel,
  body[data-view="alarms"] .alarm-panel,
  body[data-view="monitor"] .monitor-panel,
  body[data-view="ops"] .ops-panel,
  body[data-view="security"] .security-panel {
    display: block !important;
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  body[data-view="map"] .map-panel,
  body[data-view="alarms"] .alarm-panel {
    overflow: hidden !important;
  }

  body[data-view="monitor"] .monitor-panel,
  body[data-view="ops"] .ops-panel,
  body[data-view="security"] .security-panel {
    overflow: auto !important;
  }

  body[data-view="alarms"] .alarm-list {
    max-height: none !important;
    overflow: auto !important;
  }
}

@media (min-width: 900px) and (max-height: 850px) {
  body:not([data-view="overview"]) .dashboard-grid {
    height: calc(100vh - 172px) !important;
  }

  body[data-view="monitor"] .sensor-grid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }

  body[data-view="monitor"] .sensor-card {
    min-height: 132px !important;
    padding: 16px !important;
  }

  body[data-view="monitor"] .sensor-card small,
  body[data-view="monitor"] .sensor-card .sparkline {
    display: block !important;
  }

  body[data-view="ops"] .health-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 14px !important;
  }

  body[data-view="security"] .topology {
    min-height: 260px !important;
  }
}

.detail-analytics {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

body[data-view="overview"] .detail-analytics {
  display: none !important;
}

.detail-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid rgba(132, 171, 197, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(16, 32, 47, 0.88), rgba(8, 20, 31, 0.88)),
    radial-gradient(circle at 16% 0, rgba(52, 214, 255, 0.1), transparent 30%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.detail-card.wide {
  grid-column: span 2;
}

.detail-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--text);
}

.detail-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.mini-table {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mini-table strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-text {
  color: var(--red) !important;
}

.ok-text {
  color: var(--green) !important;
}

.big-number {
  display: block;
  margin: 8px 0;
  color: var(--text);
  font-size: 34px;
  line-height: 1;
}

.timeline-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-list li {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-list b {
  color: var(--blue);
  font-weight: 600;
}

.trend-canvas {
  position: relative;
  height: 132px;
  overflow: hidden;
  border: 1px solid rgba(132, 171, 197, 0.16);
  border-radius: 7px;
  background:
    linear-gradient(rgba(52, 214, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(52, 214, 255, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(7, 18, 28, 0.78), rgba(4, 12, 19, 0.92));
  background-size: 32px 32px, 32px 32px, auto;
}

.trend-line,
.threshold-line {
  position: absolute;
  left: 18px;
  right: 18px;
  height: 2px;
  border-radius: 99px;
  transform-origin: left center;
}

.trend-line.oxygen {
  top: 62%;
  background: linear-gradient(90deg, transparent, var(--red), #ff9aa7);
  transform: rotate(-8deg);
  box-shadow: 0 0 18px rgba(255, 79, 97, 0.3);
}

.trend-line.methane {
  top: 72%;
  background: linear-gradient(90deg, transparent, var(--green), #7fffc0);
  transform: rotate(-5deg);
  box-shadow: 0 0 18px rgba(62, 229, 140, 0.24);
}

.threshold-line {
  top: 43%;
  border-top: 1px dashed rgba(247, 201, 74, 0.72);
}

.legend-row {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-row span::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.legend-row span:nth-child(1)::before {
  background: var(--red);
}

.legend-row span:nth-child(2)::before {
  background: var(--green);
}

.legend-row span:nth-child(3)::before {
  background: var(--yellow);
}

body[data-view="monitor"] .monitor-detail .detail-card:last-child,
body[data-view="ops"] .ops-detail .detail-card:last-child {
  grid-column: 1 / -1;
  min-height: 72px;
}

body[data-view="alarms"] .alarm-detail {
  grid-template-columns: 0.85fr 1.15fr 1fr;
}

body[data-view="security"] .security-detail {
  margin-top: 18px;
}

@media (min-width: 900px) and (max-height: 850px) {
  body[data-view="monitor"] .monitor-panel {
    overflow: hidden !important;
  }

  body[data-view="monitor"] .sensor-card {
    min-height: 112px !important;
    padding: 12px 14px !important;
  }

  body[data-view="monitor"] .monitor-detail {
    margin-top: 10px;
    gap: 10px;
  }

  body[data-view="monitor"] .detail-card {
    min-height: 96px;
    padding: 12px;
  }

  body[data-view="monitor"] .trend-canvas {
    height: 104px;
  }

  body[data-view="monitor"] .monitor-detail .detail-card:last-child {
    display: none !important;
  }
}

/* Responsive flow: compact screens must grow with content instead of clipping it to the presentation viewport. */
@media (max-width: 1100px) {
  body {
    min-height: 100vh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  .app-shell {
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
  }

  .workspace {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .metric-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  }

  .dashboard-grid {
    height: auto !important;
    min-height: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    grid-auto-rows: auto !important;
    overflow: visible !important;
    padding-bottom: 16px !important;
  }

  .dashboard-grid > [data-section] {
    grid-column: 1 !important;
    grid-row: auto !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .map-panel {
    order: 1 !important;
  }

  .alarm-panel {
    order: 2 !important;
  }

  .monitor-panel {
    order: 3 !important;
  }

  .ops-panel {
    order: 4 !important;
  }

  .plant-map {
    height: 320px !important;
    min-height: 320px !important;
  }

  body:not([data-view="overview"]) .dashboard-grid > [data-section] {
    overflow: visible !important;
  }

  .detail-analytics {
    grid-template-columns: 1fr !important;
  }

  .detail-card.wide,
  body[data-view="monitor"] .monitor-detail .detail-card:last-child,
  body[data-view="ops"] .ops-detail .detail-card:last-child {
    grid-column: auto !important;
  }

  body .status-footer[data-section="overview"] {
    position: static !important;
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    grid-column: 1 !important;
    grid-row: auto !important;
    order: 5 !important;
    height: auto !important;
    min-height: 64px !important;
    margin: 0 !important;
  }

  body:not([data-view="overview"]) .status-footer[data-section="overview"] {
    display: none !important;
  }
}

@media (max-width: 600px) {
  .workspace {
    padding: 14px !important;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .metric-card {
    min-height: 104px !important;
    padding: 12px !important;
  }

  .metric-card:last-child {
    grid-column: 1 / -1;
  }

  body .status-footer[data-section="overview"] {
    grid-template-columns: 1fr !important;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Overview alarm rail: reserve fixed space for the active event and let history use the remaining panel height. */
@media (min-width: 1101px) {
  body[data-view="overview"] .alarm-panel {
    display: flex !important;
    flex-direction: column !important;
  }

  body[data-view="overview"] .alarm-panel .panel-header,
  body[data-view="overview"] .active-alarm,
  body[data-view="overview"] .workflow {
    flex: 0 0 auto;
  }

  body[data-view="overview"] .active-alarm {
    padding: 8px 10px;
  }

  body[data-view="overview"] .active-alarm > strong {
    margin-bottom: 3px;
    font-size: 15px;
  }

  body[data-view="overview"] .risk-verdict {
    min-height: 36px;
    margin: 6px 0;
    padding: 6px 9px;
    border-color: rgba(255, 79, 97, 0.88);
    background: rgba(255, 79, 97, 0.24);
    box-shadow: inset 0 0 22px rgba(255, 79, 97, 0.12), 0 0 18px rgba(255, 79, 97, 0.12);
  }

  body[data-view="overview"] .risk-verdict span {
    font-size: 11px;
  }

  body[data-view="overview"] .risk-verdict b {
    font-size: 17px;
  }

  body[data-view="overview"] .active-alarm > span {
    font-size: 12px;
    line-height: 1.35;
  }

  body[data-view="overview"] .alarm-responsibility {
    margin: 4px 0;
    gap: 4px 8px;
  }

  body[data-view="overview"] .active-alarm .alarm-responsibility span {
    font-size: 9px;
  }

  body[data-view="overview"] .active-alarm > small {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-view="overview"] .alarm-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    grid-auto-rows: 48px;
    align-content: start;
    gap: 6px;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(52, 214, 255, 0.34) rgba(7, 18, 28, 0.35);
  }

  body[data-view="overview"] .alarm-item {
    height: 48px;
    min-height: 48px;
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    padding: 5px 7px !important;
    gap: 6px;
  }

  body[data-view="overview"] .alarm-tag {
    padding: 2px 6px;
  }

  body[data-view="overview"] .alarm-item-content small {
    font-size: 9px;
  }

  body[data-view="overview"] .alarm-item-state b {
    font-size: 9px;
  }

  body[data-view="overview"] .alarm-list::-webkit-scrollbar {
    width: 5px;
  }

  body[data-view="overview"] .alarm-list::-webkit-scrollbar-track {
    background: rgba(7, 18, 28, 0.35);
  }

  body[data-view="overview"] .alarm-list::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: rgba(52, 214, 255, 0.34);
  }
}

.map-legend {
  min-height: 38px;
  margin-bottom: 8px;
  padding: 5px 8px;
  border: 1px solid rgba(132, 171, 197, 0.2);
  border-radius: 6px;
  background: rgba(7, 18, 28, 0.86);
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
}

.map-legend > strong {
  flex: 0 0 auto;
  color: var(--text);
  font-size: 11px;
}

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

.legend-group span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.legend-separator {
  align-self: stretch;
  width: 1px;
  background: rgba(132, 171, 197, 0.18);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.legend-dot.normal { color: var(--green); background: var(--green); }
.legend-dot.warn { color: var(--yellow); background: var(--yellow); }
.legend-dot.alarm { color: var(--red); background: var(--red); }
.legend-dot.offline { color: var(--gray); background: var(--gray); }
.legend-dot.work { color: var(--purple); background: var(--purple); }

.legend-type {
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border: 1px solid rgba(52, 214, 255, 0.32);
  border-radius: 5px;
  background: rgba(52, 214, 255, 0.08);
  color: var(--text);
  display: inline-grid;
  place-items: center;
  font-size: 9px;
  font-style: normal;
  font-weight: 800;
}

.map-point {
  width: 22px;
  height: 22px;
  padding: 0;
  display: grid;
  place-items: center;
}

.map-point-icon {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

.map-point::after {
  left: 24px;
  top: -12px;
}

@media (min-width: 1101px) {
  .map-panel .plant-map {
    height: calc(100% - 98px) !important;
  }
}

@media (max-width: 1100px) {
  .map-legend {
    flex-wrap: wrap;
    min-height: 0;
    padding: 8px;
  }

  .legend-group {
    flex-wrap: wrap;
  }

  .legend-separator {
    display: none;
  }
}

@media (max-width: 600px) {
  .map-legend {
    align-items: flex-start;
  }

  .map-legend > strong {
    width: 100%;
  }

  .legend-group {
    width: 100%;
  }
}

/* Alarm command center: keep the full responsibility loop visible in the first viewport. */
@media (min-width: 900px) {
  body[data-view="alarms"] .alarm-panel {
    display: grid !important;
    grid-template-columns: minmax(0, 0.96fr) minmax(0, 1.04fr);
    grid-template-rows: auto auto minmax(0, 1fr) 116px;
    gap: 8px 12px;
    align-content: stretch;
    overflow: hidden !important;
  }

  body[data-view="alarms"] .alarm-panel > .panel-header {
    grid-column: 1 / -1;
    grid-row: 1;
    margin: 0;
  }

  body[data-view="alarms"] .active-alarm {
    grid-column: 1;
    grid-row: 2 / 4;
    min-height: 0;
    padding: 14px 16px;
    overflow: hidden;
    background:
      linear-gradient(145deg, rgba(255, 79, 97, 0.12), rgba(14, 29, 43, 0.82)),
      rgba(255, 79, 97, 0.06);
  }

  body[data-view="alarms"] .active-alarm > strong {
    font-size: 18px;
  }

  body[data-view="alarms"] .risk-verdict {
    min-height: 42px;
    margin: 12px 0;
    padding: 8px 12px;
  }

  body[data-view="alarms"] .risk-verdict b {
    font-size: 18px;
  }

  body[data-view="alarms"] .alarm-responsibility {
    margin: 10px 0;
    gap: 8px 14px;
  }

  body[data-view="alarms"] .active-alarm .alarm-responsibility span {
    padding: 5px 8px;
    border: 1px solid rgba(132, 171, 197, 0.18);
    border-radius: 4px;
    background: rgba(6, 17, 27, 0.48);
    font-size: 11px;
  }

  body[data-view="alarms"] .workflow {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
  }

  body[data-view="alarms"] .alarm-list {
    grid-column: 2;
    grid-row: 3;
    min-height: 0;
    max-height: none !important;
    grid-template-rows: repeat(4, minmax(0, 1fr));
    gap: 7px;
    overflow: hidden !important;
  }

  body[data-view="alarms"] .alarm-item {
    height: 100%;
    min-height: 0;
    padding: 7px 10px;
  }

  body[data-view="alarms"] .alarm-detail {
    grid-column: 1 / -1;
    grid-row: 4;
    min-height: 0;
    margin: 0;
    gap: 10px;
  }

  body[data-view="alarms"] .alarm-detail .detail-card {
    min-height: 0;
    padding: 9px 12px;
    overflow: hidden;
  }

  body[data-view="alarms"] .alarm-detail .detail-card h3 {
    margin-bottom: 6px;
    font-size: 14px;
  }

  body[data-view="alarms"] .alarm-detail .mini-table {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 4px 10px;
    font-size: 11px;
  }

  body[data-view="alarms"] .alarm-detail .mini-table strong {
    font-size: 12px;
  }

  body[data-view="alarms"] .alarm-detail .timeline-list {
    gap: 4px;
  }

  body[data-view="alarms"] .alarm-detail .timeline-list li {
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 8px;
    font-size: 11px;
  }

  body[data-view="alarms"] .alarm-detail .detail-card p {
    font-size: 12px;
    line-height: 1.55;
  }
}
