* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0a1628;
  --bg-2: #1e293b;
  --bg-3: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --success: #3ddc84;
  --warning: #fbbf24;
  --danger: #f87171;
}

body {
  font-family: -apple-system, system-ui, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, #131f35 100%);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ─── Header ─── */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 20px 16px;
  padding-top: calc(20px + env(safe-area-inset-top));
}
.app-header .logo { font-size: 2.2rem; }
.app-header .titles { flex: 1; }
.app-header h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 0 currentColor;
  transition: all 0.3s;
}
.dot.connected { background: var(--success); box-shadow: 0 0 8px var(--success); }
.dot.disconnected { background: var(--danger); }

/* ─── Stats ─── */
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px 20px;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--bg-3);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card:first-child { grid-column: span 2; }
.stat-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.stat-value {
  font-size: 1rem;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

/* ─── Events ─── */
.events-section { padding: 0 20px 40px; }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 1rem; font-weight: 700; }
.badge {
  background: var(--bg-3);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.events-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.events-list li {
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease-out;
}
.events-list li.level-active { border-left-color: var(--success); }
.events-list li.level-timeSensitive { border-left-color: var(--warning); }
.events-list li.level-critical { border-left-color: var(--danger); }
.events-list li.empty {
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  justify-content: center;
  padding: 30px;
}
.event-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.event-label { font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-meta { color: var(--text-muted); font-size: 0.75rem; font-family: ui-monospace, monospace; }
.event-time { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.install-btn {
  background: var(--accent);
  color: #0a1628;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}
.install-btn:active { transform: scale(0.95); }

.notif-btn {
  background: #fbbf24;
  color: #0a1628;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  animation: pulse 2s infinite;
}
.notif-btn:active { transform: scale(0.95); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}