:root {
  --bg: #0b1020;
  --panel: #121a33;
  --panel-2: #1a2342;
  --border: #2a3558;
  --text: #e6ecff;
  --muted: #8aa0c6;
  --ok: #22c55e;
  --ok-glow: rgba(34, 197, 94, 0.4);
  --warn: #f59e0b;
  --warn-glow: rgba(245, 158, 11, 0.4);
  --err: #ef4444;
  --err-glow: rgba(239, 68, 68, 0.5);
  --info: #3b82f6;
  --gray: #6b7280;
  --link: #7dd3fc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: max(14px, env(safe-area-inset-top));
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { height: 32px; width: auto; }
h1 { font-size: 18px; margin: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 10px; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.lang-btn {
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.lang-btn.active { background: var(--panel-2); color: var(--text); }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
}
.status-light {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  flex: 0 0 56px;
  border: 2px solid var(--border);
  transition: background 0.3s, box-shadow 0.3s;
}
.status-light.connected {
  background: var(--ok);
  box-shadow: 0 0 16px var(--ok-glow);
}
.status-light.error {
  background: var(--err);
  box-shadow: 0 0 16px var(--err-glow);
  animation: pulse 1.6s infinite;
}
.status-light.not-connected {
  background: var(--gray);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.status-label { font-size: 22px; font-weight: 600; }
.status-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }

.events-section { margin-bottom: 24px; }
.events-section h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px 0;
}

.event-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.event-list.history {
  max-height: 300px;
  overflow-y: auto;
  opacity: 0.7;
}
.event-list:empty { display: none; }

.event-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.event-item:last-child { border-bottom: 0; }
.event-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 12px;
  margin-top: 8px;
}
.event-dot.info { background: var(--info); }
.event-dot.warning { background: var(--warn); }
.event-dot.critical { background: var(--err); }
.event-dot.resolved { background: var(--gray); }

.event-body { flex: 1 1 auto; min-width: 0; }
.event-text { font-size: 17px; font-weight: 500; word-break: break-word; }
.event-time { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Event history is rendered smaller and muted so it's visually secondary */
.event-list.history .event-item { padding: 8px 14px; }
.event-list.history .event-dot {
  width: 8px; height: 8px; flex-basis: 8px; margin-top: 7px;
}
.event-list.history .event-text {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.event-list.history .event-time { font-size: 11px; }

.muted { color: var(--muted); font-size: 14px; padding: 8px 4px; }

.footer-actions {
  display: flex;
  justify-content: center;
  margin-top: 28px;
}

.primary-btn, .secondary-btn, .text-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 18px;
  border: 1px solid var(--border);
}
.primary-btn {
  background: var(--link);
  color: #0b1020;
  border-color: var(--link);
  font-weight: 600;
}
.secondary-btn { background: var(--panel); color: var(--text); }
.text-btn { background: transparent; color: var(--muted); border: 0; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin-top: 0; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  color: var(--muted);
  border: 0;
  font-size: 22px;
  cursor: pointer;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.platform-instructions ol { padding-left: 20px; }
.platform-instructions li { margin: 6px 0; }

@media (max-width: 480px) {
  .app-header { padding: 12px 14px; }
  h1 { font-size: 16px; }
  .logo { height: 26px; }
  main { padding: 14px; }
  .status-panel { padding: 18px; gap: 14px; }
  .status-light { width: 44px; height: 44px; flex-basis: 44px; }
  .status-label { font-size: 18px; }
}
