@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #0e0e16;
  --border: #1e1e2e;
  --text-primary: #f0f0f0;
  --text-muted: #555;
  --accent: #7c6aff;
  --mag: #ffd96a;
  --font: 'Inter', system-ui, sans-serif;
}

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(124,106,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124,106,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text-primary);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 350px;
  background: radial-gradient(ellipse, rgba(124,106,255,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

#app {
  width: 100%;
  max-width: 480px;
  padding: 2rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  position: relative;
  z-index: 1;
}

/* Top bar */
#top-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#back-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

#back-btn:hover { border-color: var(--accent); color: var(--accent); }

#page-title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

#page-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.5;
}

#page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

#status-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.3s;
}

#status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

#status-pill.live .dot {
  background: var(--accent);
  animation: pulse 2s infinite;
}

#status-pill.live { color: var(--text-primary); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}

/* Permission banner */
#permission-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#permission-banner p {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

#permission-banner.hidden { display: none; }

#request-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.2s;
  align-self: flex-start;
}

#request-btn:hover { opacity: 0.85; }

/* Readout */
#readout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.readout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.readout-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.readout-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.readout-unit {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.label-mag { color: var(--mag); }

/* Divider */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #7c6aff22, transparent);
}

/* Chart sections */
.chart-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
}

.chart-wrap canvas {
  width: 100% !important;
  max-height: 180px;
}