/* ── Reset ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--surface-0);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top bar ─────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  gap: var(--space-md);
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.topbar-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Beacon ──────────────────────────────── */
.beacon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: var(--shadow-glow-green);
  animation: beacon-pulse 3s ease-in-out infinite;
}

.beacon.amber {
  background: var(--amber);
  box-shadow: var(--shadow-glow-amber);
}

.beacon.red {
  background: var(--red);
  box-shadow: var(--shadow-glow-red);
}

@keyframes beacon-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Navigation (horizontal tabs) ────────── */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  justify-content: center;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  position: relative;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--text-secondary);
  background: var(--glass-hover);
}

.nav-btn.active {
  color: var(--text-primary);
  background: var(--glass-hover);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.nav-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-btn.active svg { opacity: 0.9; color: var(--accent); }

.nav-badge {
  background: var(--accent);
  color: var(--black);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.nav-badge:empty { display: none; }

/* ── Top bar right ───────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar-status:empty { display: none; }

.topbar-status-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-ghost);
}

.topbar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.topbar-status-dot.green { background: var(--green); box-shadow: 0 0 4px rgba(52, 211, 153, 0.4); }
.topbar-status-dot.amber { background: var(--amber); box-shadow: 0 0 4px rgba(251, 191, 36, 0.4); }
.topbar-status-dot.red { background: var(--red); box-shadow: 0 0 4px rgba(248, 113, 113, 0.4); }
.topbar-status-dot.dim { background: var(--text-ghost); }

.topbar-clock {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ── Main content ─────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.tab-panel {
  display: none;
  padding: var(--space-xl);
  min-height: 100%;
}

.tab-panel.active {
  display: block;
  animation: panelEnter 350ms var(--ease-out) forwards;
}

@keyframes panelEnter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Tab header ───────────────────────────── */
.tab-header {
  margin-bottom: var(--space-xl);
}

.tab-header h2 {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.tab-header .subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Grid layouts ─────────────────────────── */
.grid-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.grid-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

@media (max-width: 1200px) {
  .grid-3col { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 900px) {
  .grid-2col,
  .grid-3col { grid-template-columns: 1fr; }
}

/* ── Scrollbar ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-ghost); }

/* ── Mobile top bar (hidden on desktop) ──── */
.mobile-bar {
  display: none;
}

/* ── Mobile: topbar hidden, bottom nav ───── */
@media (max-width: 768px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px var(--space-md);
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: var(--surface-0);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
  }

  .mobile-beacon {
    width: 7px;
    height: 7px;
  }

  .mobile-bar-title {
    flex: 1;
    font-family: var(--font-sans);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
  }

  .mobile-bar-clock {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
  }

  /* Hide desktop top bar chrome on mobile, keep nav for bottom bar */
  .topbar {
    display: contents;
  }

  .topbar-left,
  .topbar-right {
    display: none;
  }

  /* Bottom nav from nav buttons */
  .topbar-nav {
    display: flex;
    flex-direction: row;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface-0);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    gap: 0;
    justify-content: stretch;
  }

  .nav-btn {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0 5px;
    min-width: 0;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .nav-btn:active {
    transform: scale(0.92);
    opacity: 0.7;
    transition: transform 60ms ease-out, opacity 60ms ease-out;
  }

  .nav-btn span {
    display: block;
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1;
    opacity: 0.5;
  }

  .nav-btn.active span {
    opacity: 1;
    color: var(--accent);
  }

  .nav-btn.active::after {
    bottom: auto;
    top: 0;
    width: 24px;
  }

  .nav-btn svg {
    width: 20px;
    height: 20px;
  }

  .nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 14px);
    min-width: 14px;
    height: 14px;
    font-size: 8px;
    padding: 0 3px;
  }

  .content {
    height: 100dvh;
    padding-top: calc(40px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  }

  .tab-panel {
    padding: var(--space-md);
  }
}
