:root {
  --bg: #07111a;
  --panel: rgba(8, 18, 29, 0.74);
  --line: rgba(129, 224, 210, 0.2);
  --text: #eef7f8;
  --text-soft: rgba(238, 247, 248, 0.68);
  --accent: #73f2db;
  --accent-strong: #36d8ff;
  --warning: #ff9e72;
  --danger: #ff6d7d;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
  --radius-lg: 30px;
  --mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --display: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--display);
  color: var(--text);
  background:
    radial-gradient(circle at 18% 18%, rgba(54, 216, 255, 0.18), transparent 28%),
    radial-gradient(circle at 82% 12%, rgba(115, 242, 219, 0.12), transparent 22%),
    linear-gradient(180deg, #051019 0%, #08131d 44%, #03070b 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.ambient-grid,
.ambient-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.ambient-grid {
  background-image:
    linear-gradient(rgba(115, 242, 219, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(115, 242, 219, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent);
  opacity: 0.4;
}

.ambient-grid::after {
  content: "";
  position: absolute;
  inset: -20% 0;
  background: linear-gradient(180deg, transparent, rgba(115, 242, 219, 0.06), transparent);
  animation: sweep 8s linear infinite;
}

.ambient-glow-left {
  background: radial-gradient(circle at 18% 25%, rgba(54, 216, 255, 0.18), transparent 24%);
}

.ambient-glow-right {
  background: radial-gradient(circle at 82% 32%, rgba(115, 242, 219, 0.14), transparent 20%);
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 26px;
  min-height: 100vh;
  padding: 24px;
}

.nav-rail,
.panel,
.topbar,
.metrics-strip,
.hero {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.nav-rail {
  position: sticky;
  top: 24px;
  align-self: start;
  min-height: calc(100vh - 48px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(8, 18, 29, 0.94), rgba(5, 11, 18, 0.82));
  box-shadow: var(--shadow);
}

.brand-block h1,
.hero h2,
.panel-heading h3,
.topbar-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.brand-block p,
.hero p,
.panel-heading p {
  color: var(--text-soft);
}

.eyebrow,
.hero-tag,
.reading-label,
.stage-head,
.metric-cell span,
.hint-title,
.trend-legend,
.rail-meta span,
.module-list span {
  font-family: var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow,
.hero-tag {
  color: var(--accent);
  font-size: 0.76rem;
}

.brand-block {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}

.brand-block p {
  margin: 12px 0 0;
  line-height: 1.6;
}

.rail-nav {
  display: grid;
  gap: 12px;
  margin: 26px 0;
}

.rail-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  transition: transform 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.rail-nav a:hover {
  transform: translateX(6px);
  border-color: var(--line);
  background: rgba(115, 242, 219, 0.06);
}

.rail-meta {
  display: grid;
  gap: 16px;
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.rail-meta div {
  display: grid;
  gap: 4px;
}

.rail-meta strong {
  font-size: 1.1rem;
}

.workspace {
  display: grid;
  gap: 22px;
}

.topbar,
.metrics-strip,
.panel,
.hero {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(11, 22, 34, 0.8), rgba(7, 14, 22, 0.86));
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
}

.topbar-title {
  font-size: clamp(1.1rem, 2vw, 1.6rem);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(115, 242, 219, 0.09);
  border: 1px solid rgba(115, 242, 219, 0.14);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(115, 242, 219, 0.8);
  animation: pulse 1.8s ease-in-out infinite;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(380px, 0.95fr);
  gap: 22px;
  padding: 30px;
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -38% auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(54, 216, 255, 0.14), transparent 62%);
}

.hero-copy {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 16px;
  padding-right: 20px;
}

.hero h2 {
  font-size: clamp(2.4rem, 5vw, 4.3rem);
  line-height: 0.95;
  max-width: 12ch;
}

.hero p {
  margin: 0;
  max-width: 54ch;
  line-height: 1.7;
}

.hero-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.primary-button {
  color: #06232b;
  background: linear-gradient(135deg, var(--accent), #b4fff0);
  box-shadow: 0 12px 34px rgba(115, 242, 219, 0.28);
}

.secondary-button,
.ghost-button {
  color: var(--text);
  background: rgba(115, 242, 219, 0.06);
  border-color: var(--line);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
}

.hero-stage {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(8, 17, 26, 0.96), rgba(4, 11, 17, 0.9)),
    radial-gradient(circle at top, rgba(115, 242, 219, 0.08), transparent 60%);
  border: 1px solid rgba(115, 242, 219, 0.18);
}

.hero-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(115, 242, 219, 0.03), transparent);
  animation: scan 6s linear infinite;
}

.stage-head,
.hero-footer,
.main-reading {
  position: relative;
  z-index: 1;
}

.stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-soft);
  font-size: 0.76rem;
}

.main-reading {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
}

.reading-block {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 220px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(115, 242, 219, 0.04);
  border: 1px solid rgba(115, 242, 219, 0.12);
}

.reading-block-primary {
  background:
    radial-gradient(circle at 20% 20%, rgba(54, 216, 255, 0.16), transparent 32%),
    rgba(115, 242, 219, 0.06);
}

.reading-block strong {
  font-size: clamp(4rem, 10vw, 7rem);
  line-height: 0.9;
  letter-spacing: -0.06em;
}

.reading-unit {
  font-size: 1.1rem;
  color: var(--text-soft);
}

.hero-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.hero-footer div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-top: 1px solid rgba(115, 242, 219, 0.12);
}

.hero-footer span {
  color: var(--text-soft);
  font-size: 0.86rem;
}

.hero-footer strong {
  font-size: 1.15rem;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

.metric-cell {
  position: relative;
  padding: 22px;
  min-height: 134px;
  display: grid;
  align-content: end;
  gap: 8px;
}

.metric-cell + .metric-cell {
  border-left: 1px solid var(--line);
}

.metric-cell strong {
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.05em;
}

.metric-cell small {
  color: var(--text-soft);
}

.metric-cell.flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent, rgba(115, 242, 219, 0.16), transparent);
  animation: flash 720ms ease-out;
}

.operations-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 22px;
}

.panel {
  padding: 24px;
}

.trend-panel {
  display: grid;
  gap: 18px;
}

.panel-heading {
  display: grid;
  gap: 8px;
}

.panel-heading p {
  margin: 0;
  line-height: 1.65;
}

.panel-heading h3 {
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

#trendCanvas {
  width: 100%;
  height: auto;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(7, 15, 22, 0.9), rgba(6, 12, 19, 0.86)),
    linear-gradient(90deg, rgba(115, 242, 219, 0.04) 1px, transparent 1px);
  border: 1px solid rgba(115, 242, 219, 0.12);
}

.trend-legend {
  display: flex;
  gap: 18px;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
}

.legend-temp {
  background: #59b8ff;
}

.legend-humidity {
  background: #73f2db;
}

.connect-panel,
.alerts-panel,
.modules-panel {
  display: grid;
  gap: 18px;
}

.config-form,
.threshold-grid {
  display: grid;
  gap: 14px;
}

.config-form label,
.threshold-grid label {
  display: grid;
  gap: 8px;
  color: var(--text-soft);
}

.config-form input,
.threshold-grid input {
  min-height: 48px;
  padding: 0 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(115, 242, 219, 0.14);
  border-radius: 14px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.config-form input:focus,
.threshold-grid input:focus {
  border-color: rgba(115, 242, 219, 0.5);
  box-shadow: 0 0 0 4px rgba(115, 242, 219, 0.08);
}

.hint-block {
  padding: 18px;
  border-radius: 22px;
  background: rgba(115, 242, 219, 0.05);
  border: 1px solid rgba(115, 242, 219, 0.1);
}

.hint-block pre {
  margin: 10px 0 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--text);
}

.threshold-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-span {
  grid-column: 1 / -1;
}

.alert-feed {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.alert-feed li {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(115, 242, 219, 0.08);
}

.alert-feed li.alert-danger {
  border-color: rgba(255, 109, 125, 0.28);
}

.alert-feed li.alert-warning {
  border-color: rgba(255, 158, 114, 0.24);
}

.alert-feed time {
  font-family: var(--mono);
  color: var(--text-soft);
  font-size: 0.8rem;
}

.module-list {
  display: grid;
  gap: 12px;
}

.module-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(115, 242, 219, 0.1);
}

.module-list strong {
  text-align: right;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 700ms ease, transform 700ms ease;
}

.reveal.reveal-active {
  opacity: 1;
  transform: translateY(0);
}

.status-live .status-dot {
  background: var(--accent);
}

.status-error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 16px rgba(255, 109, 125, 0.7);
}

.status-warn .status-dot {
  background: var(--warning);
  box-shadow: 0 0 16px rgba(255, 158, 114, 0.7);
}

.alert-shake {
  animation: alertPulse 820ms ease;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .nav-rail {
    position: relative;
    top: 0;
    min-height: auto;
  }

  .hero,
  .operations-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .hero,
  .panel,
  .nav-rail {
    padding: 18px;
  }

  .topbar,
  .topbar-actions,
  .hero-actions,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .main-reading,
  .hero-footer,
  .metrics-strip,
  .threshold-grid {
    grid-template-columns: 1fr;
  }

  .metric-cell + .metric-cell {
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .module-list div {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.82);
    opacity: 0.65;
  }
}

@keyframes sweep {
  0% {
    transform: translateY(-40%);
  }
  100% {
    transform: translateY(140%);
  }
}

@keyframes scan {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(120%);
  }
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes alertPulse {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}
