:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-strong: #ecfdf5;
  --text: #14221f;
  --muted: #62706b;
  --line: #dce6e2;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #8b5cf6;
  --warning: #f59e0b;
  --danger: #b91c1c;
  --success: #15803d;
  --shadow: 0 18px 45px rgba(15, 35, 31, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(139, 92, 246, 0.10)),
    var(--bg);
}

.auth-panel {
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

.auth-panel h1,
.topbar h1 {
  letter-spacing: 0;
}

.auth-panel h1 {
  font-size: 1.75rem;
  line-height: 1.15;
}

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

.auth-panel .muted {
  margin-top: 8px;
}

.auth-form {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 7px;
}

label span,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.api-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfc;
}

.api-details summary {
  color: var(--muted);
  font-weight: 700;
}

.api-details label {
  margin-top: 12px;
}

.primary-action,
.secondary-action,
.ghost-action {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.primary-action {
  background: var(--primary);
  color: #fff;
}

.primary-action:hover {
  background: var(--primary-dark);
}

.secondary-action {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.secondary-action:hover {
  border-color: #b8c7c2;
  background: #f9fbfa;
}

.ghost-action {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.form-error,
.dashboard-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 700;
}

.dashboard {
  min-height: 100vh;
  padding-bottom: max(26px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 18px 18px;
  background: linear-gradient(120deg, #0f766e, #283593 55%, #7c3aed);
  color: #fff;
}

.topbar .eyebrow {
  color: rgba(255, 255, 255, 0.74);
}

.topbar h1 {
  margin-top: 3px;
  font-size: clamp(1.35rem, 5vw, 2.05rem);
  line-height: 1.1;
}

.toolbar,
.push-panel,
.stats-grid,
.content-grid,
.live-alert,
.dashboard-error {
  width: min(1180px, calc(100% - 28px));
  margin-inline: auto;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(135px, 0.7fr)) auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 34, 31, 0.06);
}

.push-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #c8e8dc;
  border-radius: 8px;
  background: var(--surface-strong);
}

.push-panel strong {
  display: block;
  margin-bottom: 4px;
}

.live-alert {
  margin-top: 14px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  background: #f4f0ff;
  color: #4c1d95;
  padding: 12px 14px;
  font-weight: 800;
}

.dashboard-error {
  margin-top: 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  padding: 12px 14px;
}

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

.stat-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 15px;
  box-shadow: 0 10px 28px rgba(20, 34, 31, 0.05);
  transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.stat-card.highlighted {
  border-color: var(--warning);
  background: #fffbeb;
  transform: translateY(-2px);
}

.stat-label {
  min-height: 34px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 14px;
  font-size: clamp(1.65rem, 6vw, 2.2rem);
  font-weight: 900;
  line-height: 1;
}

.stat-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(20, 34, 31, 0.05);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.panel h2 {
  font-size: 1rem;
}

.status-pill {
  display: inline-flex;
  min-width: 100px;
  justify-content: center;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill.connected {
  background: #dcfce7;
  color: var(--success);
}

.status-pill.connecting {
  background: #fef3c7;
  color: #92400e;
}

.activity-list,
.event-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
}

.activity-item,
.event-item,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 12px;
}

.activity-top,
.event-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.activity-date,
.event-title {
  font-weight: 900;
}

.activity-count,
.event-time {
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.activity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.activity-tag {
  border-radius: 999px;
  background: #eef7f4;
  color: #0f766e;
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.event-meta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.event-detail {
  margin-top: 8px;
  color: #34413d;
  font-size: 0.9rem;
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

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

  .toolbar label:first-child,
  .toolbar button {
    grid-column: 1 / -1;
  }

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

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-layout {
    padding: 14px;
  }

  .auth-panel {
    padding: 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .ghost-action {
    width: 100%;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar label:first-child,
  .toolbar button {
    grid-column: auto;
  }

  .push-panel {
    align-items: stretch;
    flex-direction: column;
  }

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

  .panel-header,
  .activity-top,
  .event-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .activity-count,
  .event-time {
    white-space: normal;
  }
}
