:root {
  --bg: #09131a;
  --bg-accent: #123349;
  --surface: rgba(11, 26, 35, 0.78);
  --surface-strong: rgba(8, 20, 28, 0.92);
  --line: rgba(167, 220, 255, 0.16);
  --text: #edf7ff;
  --muted: #8db1c6;
  --warm: #ff8f5a;
  --cool: #6ed3ff;
  --ok: #7ce2aa;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(110, 211, 255, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 143, 90, 0.16), transparent 28%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero-card,
.sky-card,
.metric-card,
.panel-card {
  backdrop-filter: blur(18px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  padding: 28px;
  border-radius: 28px;
  align-items: center;
}

.eyebrow,
.metric-label,
.summary-label,
.metric-foot,
.subtitle,
.panel-head span,
#lastUpdate,
th,
td {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
  max-width: 10ch;
}

.subtitle {
  margin-top: 14px;
  max-width: 60ch;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.status-box {
  min-width: 220px;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.status-box-label,
.status-box-foot {
  color: var(--muted);
}

.status-box-value {
  margin-top: 10px;
  font-size: 1.5rem;
  font-weight: 700;
}

.status-box-foot {
  margin-top: 8px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: inherit;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover:enabled {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.primary-button {
  background: linear-gradient(135deg, #7ce2aa, #6ed3ff);
  color: #06202b;
  font-weight: 700;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--line);
}

.status-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 6px;
}

.help-copy {
  grid-column: 1 / -1;
  margin-top: -8px;
  font-size: 0.92rem;
  color: var(--muted);
}

.sky-card {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  margin-top: 18px;
  padding: 22px 24px;
  border-radius: 28px;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 78% 22%, rgba(255, 209, 102, 0.22), transparent 18%),
    linear-gradient(180deg, rgba(87, 164, 224, 0.22), rgba(8, 20, 28, 0.82)),
    var(--surface);
}

.sky-card.night {
  background:
    radial-gradient(circle at 78% 22%, rgba(255, 244, 194, 0.16), transparent 18%),
    linear-gradient(180deg, rgba(34, 52, 96, 0.42), rgba(7, 12, 24, 0.94)),
    var(--surface);
}

.sky-copy {
  align-self: center;
}

.sky-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
}

.sky-copy h2 {
  margin-top: 8px;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
}

.sky-copy p:last-child {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.sky-time {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f6fbff;
  font-size: 0.92rem;
}

.sky-visual {
  position: relative;
  min-height: 170px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 216, 122, 0.2), transparent 22%),
    linear-gradient(180deg, rgba(120, 196, 255, 0.42), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  overflow: hidden;
}

.sky-card.night .sky-visual {
  background:
    radial-gradient(circle at 72% 18%, rgba(247, 244, 220, 0.1), transparent 18%),
    linear-gradient(180deg, rgba(28, 47, 97, 0.56), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.01);
}

.sun-rays {
  position: absolute;
  inset: 0;
  opacity: 1;
  transition: opacity 220ms ease;
}

.sky-card.night .sun-rays {
  opacity: 0;
}

.sun-rays span {
  position: absolute;
  top: 48px;
  right: 61px;
  width: 3px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 216, 122, 0.8);
  transform-origin: center 48px;
  box-shadow: 0 0 12px rgba(255, 216, 122, 0.35);
}

.sun-rays span:nth-child(1) { transform: rotate(0deg) translateY(-34px); }
.sun-rays span:nth-child(2) { transform: rotate(45deg) translateY(-34px); }
.sun-rays span:nth-child(3) { transform: rotate(90deg) translateY(-34px); }
.sun-rays span:nth-child(4) { transform: rotate(135deg) translateY(-34px); }
.sun-rays span:nth-child(5) { transform: rotate(180deg) translateY(-34px); }
.sun-rays span:nth-child(6) { transform: rotate(225deg) translateY(-34px); }
.sun-rays span:nth-child(7) { transform: rotate(270deg) translateY(-34px); }
.sun-rays span:nth-child(8) { transform: rotate(315deg) translateY(-34px); }

.sky-orb {
  position: absolute;
  top: 20px;
  right: 34px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff1ae, #ffbf47 70%);
  box-shadow: 0 0 44px rgba(255, 209, 102, 0.55);
}

.sky-card.night .sky-orb {
  background: radial-gradient(circle at 30% 30%, #fffef5, #e6e1bf 72%);
  box-shadow: 0 0 30px rgba(244, 241, 220, 0.28);
}

.sky-card.night .sky-orb::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 22px;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(28, 47, 97, 0.92);
}

.sky-stars {
  opacity: 0;
  transition: opacity 180ms ease;
}

.sky-card.night .sky-stars {
  opacity: 1;
}

.sky-stars span {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.35);
}

.sky-stars span:nth-child(1) { top: 28px; left: 38px; }
.sky-stars span:nth-child(2) { top: 56px; left: 92px; }
.sky-stars span:nth-child(3) { top: 42px; left: 170px; }
.sky-stars span:nth-child(4) { top: 88px; left: 134px; }
.sky-stars span:nth-child(5) { top: 28px; left: 236px; }
.sky-stars span:nth-child(6) { top: 70px; left: 220px; }
.sky-stars span:nth-child(7) { top: 102px; left: 58px; }

.sky-cloud {
  position: absolute;
  bottom: 22px;
  height: 26px;
  border-radius: 999px;
  background: rgba(237, 247, 255, 0.86);
  filter: blur(0.2px);
  box-shadow: 0 10px 26px rgba(255, 255, 255, 0.12);
}

.sky-cloud::before,
.sky-cloud::after {
  content: "";
  position: absolute;
  bottom: 8px;
  border-radius: 50%;
  background: inherit;
}

.sky-cloud::before {
  left: 10px;
  width: 24px;
  height: 24px;
}

.sky-cloud::after {
  right: 12px;
  width: 32px;
  height: 32px;
}

.cloud-a {
  left: 24px;
  width: 126px;
}

.cloud-b {
  right: 38px;
  width: 104px;
  opacity: 0.72;
}

.sky-card.night .sky-cloud {
  background: rgba(176, 192, 224, 0.3);
}

.sky-haze {
  position: absolute;
  inset: auto 0 0 0;
  height: 70px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.08));
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #7b8790;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.04);
}

.status-dot.online {
  background: var(--ok);
}

.status-dot.error {
  background: var(--warm);
}

.metrics-grid,
.panel-grid,
.summary-grid {
  display: grid;
  gap: 18px;
}

.metrics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.metric-card {
  padding: 24px;
  border-radius: 24px;
}

.metric-card.warm {
  background:
    linear-gradient(180deg, rgba(255, 143, 90, 0.16), transparent 60%),
    var(--surface-strong);
}

.metric-card.cool {
  background:
    linear-gradient(180deg, rgba(110, 211, 255, 0.16), transparent 60%),
    var(--surface-strong);
}

.metric-value {
  margin-top: 10px;
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 700;
  line-height: 1;
}

.metric-unit {
  font-size: 0.38em;
  color: var(--muted);
}

.metric-foot {
  margin-top: 12px;
}

.panel-grid {
  grid-template-columns: 0.9fr 1.1fr;
  margin-top: 18px;
}

.panel-card {
  padding: 22px;
  border-radius: 24px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

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

.summary-value {
  margin-top: 8px;
  font-size: 1.2rem;
  font-weight: 600;
}

.chart-wrap {
  height: 220px;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
}

#trendChart {
  width: 100%;
  height: 100%;
  display: block;
}

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

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 8px;
}

.legend-swatch.temp {
  background: var(--warm);
}

.legend-swatch.hum {
  background: var(--cool);
}

.table-wrap {
  overflow-x: auto;
}

.serial-log {
  min-height: 84px;
  max-height: 220px;
  overflow: auto;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}

tbody tr:last-child td {
  border-bottom: 0;
}

code {
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 860px) {
  .hero-card,
  .sky-card,
  .panel-grid,
  .summary-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  button {
    width: 100%;
  }
}
