:root {
  --bg: #f4f1ea;
  --panel: #fffdf8;
  --ink: #1f2933;
  --muted: #6b7280;
  --accent: #0f766e;
  --accent-soft: #d8f3ef;
  --line: #d9d4ca;
  --shadow: 0 14px 40px rgba(32, 24, 16, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.15), transparent 25%),
    linear-gradient(180deg, #f7f3ec 0%, #efe6d8 100%);
  color: var(--ink);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.page-narrow {
  max-width: 560px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 0.78rem;
  margin-bottom: 8px;
}

h1, h2 {
  margin: 0 0 8px;
}

.subtle {
  color: var(--muted);
  max-width: 60ch;
}

.card, .stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.hero-actions {
  display: flex;
  gap: 16px;
  align-items: stretch;
  flex-wrap: wrap;
}

.stat-card {
  min-width: 220px;
  padding: 18px 20px;
}

.stat-label {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 2.5rem;
}

.card {
  padding: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

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

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

thead th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  margin-top: 6px;
}

button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  padding: 11px 18px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

.ghost-button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.inline-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.action-cell {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
}

.stats-grid dt {
  color: var(--muted);
  font-size: 0.85rem;
}

.stats-grid dd {
  margin: 6px 0 0;
  font-weight: 700;
}

.auth-card {
  margin-top: 80px;
}

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  background: #fde7e1;
  color: #8f2d1f;
}

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

.event-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(15, 118, 110, 0.04);
}

.websocket-summary {
  margin-bottom: 20px;
}

.websocket-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.websocket-column-head {
  margin-bottom: 16px;
}

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

.websocket-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: rgba(15, 118, 110, 0.04);
}

.websocket-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.websocket-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ws-mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.ws-mini-badge.status {
  background: rgba(45, 138, 74, 0.12);
  color: #1f6a36;
  border-color: rgba(45, 138, 74, 0.24);
}

.ws-mini-badge.log {
  background: rgba(217, 139, 31, 0.12);
  color: #9a5d08;
  border-color: rgba(217, 139, 31, 0.24);
}

.ws-mini-badge.command {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent);
  border-color: rgba(15, 118, 110, 0.22);
}

.ws-mini-badge.connect {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, 0.22);
}

.ws-mini-badge.unknown {
  background: rgba(197, 71, 59, 0.12);
  color: #a13228;
  border-color: rgba(197, 71, 59, 0.22);
}

.ws-mini-badge.neutral {
  background: rgba(31, 41, 51, 0.08);
  color: var(--ink);
  border-color: rgba(31, 41, 51, 0.1);
}

.ws-device-link {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.ws-time {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.ws-message {
  margin: 0 0 10px;
  font-weight: 700;
}

code, pre {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 0.9rem;
}

pre {
  white-space: pre-wrap;
  margin: 0;
  color: var(--muted);
}

.meta-row td {
  background: rgba(15, 118, 110, 0.03);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px;
}

@media (max-width: 900px) {
  .hero {
    flex-direction: column;
    align-items: stretch;
  }

  .grid,
  .stats-grid,
  .websocket-grid {
    grid-template-columns: 1fr;
  }

  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }

  td {
    border: 0;
    padding: 6px 0;
  }
}
