:root {
  --bg: #f4efe6;
  --surface: rgba(255, 252, 246, 0.86);
  --surface-strong: #fffaf0;
  --line: rgba(17, 43, 60, 0.12);
  --text: #163040;
  --muted: #597182;
  --accent: #0d7287;
  --accent-soft: rgba(13, 114, 135, 0.12);
  --warning: #d87533;
  --warning-soft: rgba(216, 117, 51, 0.14);
  --ok: #2a8c64;
  --shadow: 0 22px 60px rgba(20, 41, 53, 0.12);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --mono: "IBM Plex Mono", "SFMono-Regular", monospace;
  --sans: "Sora", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(13, 114, 135, 0.18), transparent 34%),
    radial-gradient(circle at bottom right, rgba(216, 117, 51, 0.16), transparent 28%),
    linear-gradient(180deg, #f6f1e8 0%, #efe7dc 100%);
  color: var(--text);
  font-family: var(--sans);
}

button,
input,
select {
  font: inherit;
}

.background-glow {
  position: fixed;
  width: 34rem;
  height: 34rem;
  border-radius: 999px;
  filter: blur(60px);
  opacity: 0.45;
  pointer-events: none;
}

.background-glow-a {
  top: -10rem;
  left: -8rem;
  background: rgba(18, 138, 162, 0.25);
}

.background-glow-b {
  right: -8rem;
  bottom: -12rem;
  background: rgba(217, 132, 72, 0.18);
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1.4rem 0 3rem;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1rem 0 2rem;
}

.hero h1 {
  margin: 0.3rem 0 0.6rem;
  max-width: 14ch;
  font-size: clamp(2.5rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.hero-copy {
  margin: 0;
  max-width: 42rem;
  font-size: 1.03rem;
  line-height: 1.7;
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-status {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.74);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(216, 117, 51, 0.12);
}

.hidden {
  display: none !important;
}

.login-panel,
.dashboard {
  animation: fadeUp 0.4s ease;
}

.panel {
  border: 1px solid rgba(22, 48, 64, 0.08);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.panel-tight {
  max-width: 30rem;
  padding: 2rem;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.panel-header h2,
.panel-tight h2 {
  margin: 0.2rem 0 0;
  font-size: 1.4rem;
}

.muted {
  color: var(--muted);
}

.stats-grid,
.content-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.content-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(340px, 0.95fr);
}

.admin-grid {
  align-items: start;
}

.stat-card {
  padding: 1.3rem 1.4rem;
}

.stat-card .label {
  margin: 0;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: -0.05em;
}

.panel > *:first-child,
.panel > form:first-child {
  margin-top: 0;
}

.panel > * {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.panel > :first-child {
  padding-top: 1.5rem;
}

.panel > :last-child {
  padding-bottom: 1.5rem;
}

.sensor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  padding-bottom: 1.5rem;
}

.sensor-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid rgba(22, 48, 64, 0.08);
}

.sensor-card header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.sensor-card h3 {
  margin: 0;
  font-size: 1rem;
}

.sensor-topic {
  margin-top: 0.2rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.sensor-value {
  margin: 1rem 0 0.25rem;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.06em;
}

.sensor-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.heartbeat {
  width: 0.7rem;
  height: 0.7rem;
  margin-top: 0.25rem;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(42, 140, 100, 0.12);
}

.heartbeat.offline {
  background: var(--warning);
  box-shadow: 0 0 0 6px rgba(216, 117, 51, 0.12);
}

.alert-list {
  display: grid;
  gap: 0.85rem;
  padding-bottom: 1.5rem;
}

.alert-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 247, 241, 0.9), rgba(255, 250, 246, 0.95));
  border: 1px solid rgba(216, 117, 51, 0.16);
}

.alert-card strong,
.table-shell td strong {
  display: block;
}

.alert-card p,
.alert-card small {
  margin: 0.3rem 0 0;
}

.alert-card small {
  color: var(--muted);
}

.table-shell {
  overflow: auto;
  padding-bottom: 1.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.9rem 0;
  text-align: left;
  border-bottom: 1px solid rgba(22, 48, 64, 0.08);
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stack-form,
.report-form {
  display: grid;
  gap: 0.95rem;
}

.report-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 1rem;
}

label {
  display: grid;
  gap: 0.45rem;
}

label span {
  font-size: 0.84rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(22, 48, 64, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.84);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(13, 114, 135, 0.18);
  border-color: var(--accent);
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.95rem 1.2rem;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, #0d7287, #0f8f8b);
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
  box-shadow: 0 14px 30px rgba(13, 114, 135, 0.24);
}

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

.ghost-button {
  background: rgba(255, 250, 240, 0.72);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.mini-stat {
  padding: 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 250, 240, 0.76);
  border: 1px solid rgba(22, 48, 64, 0.08);
}

.mini-stat span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.mini-stat strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
}

.empty-state {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(13, 114, 135, 0.06);
  color: var(--muted);
}

.error-message {
  min-height: 1.2rem;
  color: #b24f1e;
}

code {
  font-family: var(--mono);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .stats-grid,
  .content-grid,
  .report-form {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100vw - 1rem, 1320px);
    padding-top: 0.6rem;
  }

  .hero h1 {
    max-width: 10ch;
  }

  .panel > * {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  th:nth-child(3),
  td:nth-child(3) {
    white-space: nowrap;
  }
}
