:root {
  --alarm-red: #ff434b;
  --alarm-red-soft: rgba(255, 67, 75, 0.16);
  --dashboard-panel: rgba(5, 20, 30, 0.86);
  --dashboard-line: rgba(143, 192, 208, 0.18);
  --dashboard-shadow: 0 22px 62px rgba(0, 0, 0, 0.34);
}

.topbar-status {
  position: absolute;
  left: 50%;
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  padding: 0 11px;
  gap: 7px;
  border: 1px solid rgba(94, 232, 216, 0.2);
  border-radius: 999px;
  color: #9de9df;
  background: rgba(4, 22, 31, 0.68);
  box-shadow: inset 0 0 18px rgba(67, 213, 196, 0.05);
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.topbar-status time {
  min-width: 53px;
  color: #d8e8ed;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.live-pulse,
.health-badge i,
.stream-badge i,
.alarm-level i {
  display: inline-block;
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px rgba(66, 214, 197, 0.8);
}

.live-pulse {
  animation: live-pulse 1.7s ease-out infinite;
}

.dashboard-rail {
  position: absolute;
  z-index: 11;
  inset: 84px 18px 44px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  pointer-events: none;
}

.dashboard-panel {
  display: flex;
  width: 304px;
  max-height: 100%;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: auto;
  scrollbar-color: rgba(111, 170, 180, 0.3) transparent;
  scrollbar-width: thin;
}

.dashboard-panel--right {
  width: 352px;
}

.monitor-card {
  overflow: hidden;
  flex: 0 0 auto;
  border: 1px solid var(--dashboard-line);
  border-radius: 15px;
  background:
    linear-gradient(145deg, rgba(14, 38, 50, 0.88), var(--dashboard-panel));
  box-shadow: var(--dashboard-shadow), inset 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(20px) saturate(125%);
}

.card-heading,
.section-title,
.alarm-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-heading {
  padding: 14px 15px 12px;
}

.card-heading h2,
.section-title h3,
.active-alarm-card h3 {
  margin: 0;
  color: #eef8fb;
  font-weight: 680;
  letter-spacing: 0.01em;
}

.card-heading h2 {
  font-size: 15px;
}

.health-badge,
.stream-badge,
.event-count {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  gap: 6px;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 9px;
  font-weight: 700;
}

.health-badge,
.stream-badge {
  color: #a5eee5;
  background: rgba(63, 206, 190, 0.1);
}

.system-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid rgba(148, 194, 208, 0.1);
}

.system-stats div {
  display: grid;
  min-width: 0;
  min-height: 57px;
  align-content: center;
  padding: 8px 10px;
  border-right: 1px solid rgba(148, 194, 208, 0.1);
}

.system-stats div:last-child {
  border-right: 0;
}

.system-stats strong {
  color: #f5fbfd;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.system-stats span {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-stats .is-alarm strong,
.danger-text {
  color: #ff777d;
}

.section-title {
  padding: 13px 15px 3px;
}

.section-title h3 {
  margin-top: 2px;
  font-size: 14px;
}

.section-kicker {
  color: #6fded1;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 11px 8px 14px;
  gap: 4px;
}

.mini-gauge {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.gauge-visual {
  position: relative;
  width: 58px;
  height: 58px;
}

.gauge-visual svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  transform: rotate(-90deg);
}

.gauge-track,
.gauge-progress {
  fill: none;
  stroke-width: 4;
}

.gauge-track {
  stroke: rgba(143, 187, 201, 0.13);
}

.gauge-progress {
  stroke: #4bd7c7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(75, 215, 199, 0.45));
  transition: stroke-dashoffset 420ms ease;
}

.gauge-progress--danger {
  stroke: #ff555c;
  filter: drop-shadow(0 0 5px rgba(255, 61, 70, 0.58));
}

.gauge-progress--blue {
  stroke: #6baeff;
  filter: drop-shadow(0 0 4px rgba(77, 158, 255, 0.45));
}

.gauge-icon {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8fded5;
  font-size: 10px;
  font-weight: 800;
}

.gauge-icon--smoke {
  color: #ff777d;
}

.mini-gauge > strong {
  margin-top: 3px;
  color: #f3fbfd;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gauge-unit,
.mini-gauge small {
  color: #7e9aa8;
  font-size: 8px;
}

.mini-gauge small {
  margin-top: 4px;
  color: #a9bec8;
  font-size: 9px;
}

.active-alarm-card {
  position: relative;
  padding: 14px 15px 15px;
  border-color: rgba(255, 66, 74, 0.48);
  background:
    radial-gradient(circle at 90% 0, rgba(255, 41, 50, 0.17), transparent 38%),
    linear-gradient(145deg, rgba(42, 20, 27, 0.94), rgba(18, 17, 25, 0.9));
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.4), inset 0 0 34px rgba(255, 40, 48, 0.04);
}

.active-alarm-card::before {
  position: absolute;
  top: 0;
  right: 12%;
  left: 12%;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, #ff545b, transparent);
  box-shadow: 0 0 12px #ff343d;
  animation: alarm-line 1.25s ease-in-out infinite;
}

.alarm-level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #ff8186;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.14em;
}

.alarm-level i {
  background: var(--alarm-red);
  box-shadow: 0 0 10px var(--alarm-red);
  animation: alarm-dot 0.9s ease-in-out infinite;
}

.alarm-sequence {
  color: #b7969c;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.active-alarm-card h3 {
  margin-top: 11px;
  font-size: 15px;
}

.active-alarm-card > p {
  min-height: 32px;
  margin: 6px 0 11px;
  color: #bca8ad;
  font-size: 10px;
  line-height: 1.55;
}

.alarm-location {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border: 1px solid rgba(255, 112, 118, 0.14);
  border-radius: 10px;
  background: rgba(255, 70, 78, 0.045);
}

.alarm-location div {
  padding: 8px 9px;
  border-right: 1px solid rgba(255, 112, 118, 0.12);
}

.alarm-location div:last-child {
  border-right: 0;
}

.alarm-location dt,
.alarm-location dd {
  margin: 0;
}

.alarm-location dt {
  color: #8e747a;
  font-size: 8px;
}

.alarm-location dd {
  margin-top: 2px;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-card {
  min-height: 232px;
}

.trend-chart {
  position: relative;
  height: 130px;
  margin: 0 13px;
  padding-left: 23px;
}

.trend-chart svg {
  display: block;
  width: 100%;
  height: 112px;
  overflow: visible;
}

.trend-axis {
  position: absolute;
  top: 4px;
  bottom: 16px;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #57727e;
  font-size: 7px;
}

.trend-time {
  display: flex;
  justify-content: space-between;
  margin-left: 2px;
  color: #57727e;
  font-size: 7px;
}

.chart-grid path {
  fill: none;
  stroke: rgba(128, 172, 187, 0.1);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.trend-area {
  fill: url(#trend-fill);
}

.trend-line {
  fill: none;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.trend-line--smoke {
  stroke: #ff555c;
  filter: drop-shadow(0 0 3px rgba(255, 61, 69, 0.45));
}

.trend-line--airflow {
  stroke: #50dccb;
}

.trend-line--pressure {
  stroke: #6baeff;
}

.trend-legend {
  display: flex;
  justify-content: center;
  padding: 0 12px;
  gap: 13px;
  color: #91a7b1;
  font-size: 8px;
}

.trend-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.trend-legend i {
  width: 12px;
  height: 2px;
  border-radius: 3px;
  background: currentColor;
}

.legend-smoke { color: #ff696f; }
.legend-airflow { color: #56d9ca; }
.legend-pressure { color: #78b6ff; }

.demo-note {
  margin: 8px 14px 12px;
  color: #59737f;
  font-size: 8px;
  text-align: center;
}

.alarm-history {
  min-height: 196px;
}

.event-count {
  color: #ff9ca0;
  background: var(--alarm-red-soft);
}

.alarm-list {
  max-height: 203px;
  padding: 7px 8px 9px;
  overflow-y: auto;
  scrollbar-color: rgba(164, 111, 118, 0.28) transparent;
  scrollbar-width: thin;
}

.alarm-list-item,
.alarm-item {
  display: grid;
  width: 100%;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 43px;
  padding: 6px 8px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.alarm-list-item + .alarm-list-item,
.alarm-item + .alarm-item {
  margin-top: 2px;
}

.alarm-list-item:hover,
.alarm-item:hover {
  background: rgba(137, 181, 194, 0.06);
}

.alarm-list-item.is-active,
.alarm-item.is-active {
  border-color: rgba(255, 79, 87, 0.28);
  background: linear-gradient(90deg, rgba(255, 52, 61, 0.13), rgba(255, 52, 61, 0.025));
}

.alarm-list-dot,
.alarm-item__state {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #55717c;
}

.is-active .alarm-list-dot,
.alarm-item.is-active .alarm-item__state {
  background: var(--alarm-red);
  box-shadow: 0 0 9px var(--alarm-red);
  animation: alarm-dot 0.9s ease-in-out infinite;
}

.alarm-list-copy,
.alarm-item__copy {
  min-width: 0;
}

.alarm-list-title,
.alarm-list-meta,
.alarm-item__copy strong,
.alarm-item__copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alarm-list-title,
.alarm-item__copy strong {
  color: #dce9ed;
  font-size: 10px;
  font-weight: 650;
}

.alarm-list-meta,
.alarm-item__copy small {
  margin-top: 2px;
  color: #718b96;
  font-size: 8px;
}

.alarm-list-status,
.alarm-item time {
  color: #708792;
  font-size: 8px;
  white-space: nowrap;
}

.is-active .alarm-list-status,
.alarm-item.is-active time {
  color: #ff8d92;
}

.dashboard-panel .layer-panel {
  position: relative;
  inset: auto;
  z-index: auto;
  width: 100%;
  min-height: 270px;
  max-height: 380px;
  border-radius: 15px;
  background: linear-gradient(145deg, rgba(14, 38, 50, 0.88), var(--dashboard-panel));
  box-shadow: var(--dashboard-shadow);
}

.dashboard-panel .panel-heading {
  padding: 13px 15px 10px;
}

.dashboard-panel .layer-list {
  padding: 6px 8px;
}

.dashboard-panel .layer-item {
  min-height: 45px;
  padding: 6px 8px;
}

.dashboard-panel .panel-actions {
  padding: 8px;
}

.layer-item.has-alarm {
  border-color: rgba(255, 72, 80, 0.34);
  background: rgba(255, 56, 65, 0.08);
}

.app.has-active-alarm .topbar::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  content: "";
  pointer-events: none;
  background: linear-gradient(90deg, transparent 20%, rgba(255, 59, 68, 0.6), transparent 80%);
  animation: alarm-line 1.3s ease-in-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(66, 214, 197, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(66, 214, 197, 0); }
  100% { box-shadow: 0 0 0 0 rgba(66, 214, 197, 0); }
}

@keyframes alarm-dot {
  50% { opacity: 0.35; transform: scale(0.78); }
}

@keyframes alarm-line {
  50% { opacity: 0.32; }
}

@media (max-width: 1180px) {
  .dashboard-panel { width: 270px; }
  .dashboard-panel--right { width: 310px; }
  .dashboard-rail { inset-inline: 12px; gap: 12px; }
  .gauge-visual { width: 52px; height: 52px; }
  .alarm-list { max-height: 174px; }
}

@media (max-width: 900px) {
  .topbar-status { display: none; }
  .dashboard-panel { width: 230px; }
  .dashboard-panel--right { width: 250px; }
  .dashboard-rail { inset-inline: 8px; gap: 8px; }
  .gauge-visual { width: 46px; height: 46px; }
  .system-overview .card-heading { gap: 6px; }
  .system-overview .card-heading h2 { font-size: 13px; white-space: nowrap; }
  .system-overview .health-badge { padding-inline: 6px; font-size: 8px; }
}

@media (max-width: 600px) {
  .topbar-status { display: none; }

  .dashboard-rail {
    top: auto;
    right: 8px;
    bottom: 42px;
    left: 8px;
    display: grid;
    max-height: 46dvh;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
    overflow-y: auto;
  }

  .dashboard-panel,
  .dashboard-panel--right {
    width: 100%;
    max-height: none;
    overflow: visible;
  }

  .system-overview,
  .gauge-card,
  .trend-card,
  .alarm-history {
    display: none;
  }

  .dashboard-panel .layer-panel {
    inset: auto;
    width: 100%;
    min-height: 236px;
    max-height: 42dvh;
  }

  .active-alarm-card {
    min-height: 236px;
  }
}

@media (max-width: 560px) {
  .dashboard-rail {
    max-height: 48dvh;
    grid-template-columns: 1fr;
  }

  .dashboard-panel--right {
    display: none;
  }

  .active-alarm-card {
    min-height: auto;
  }
}
