/* ================================================================
   whoof dashboard — neobrutalist redesign v3
   Light palette · bold borders · hard shadows · mobile-first
   Inspired by Bevel's clean score-card layout + brutalism honesty
   ================================================================ */

:root {
  /* ─── Surfaces (light & warm) ──────────────────── */
  --bg:           #F5F3F0;
  --surface-1:    #FFFFFF;
  --surface-2:    #F0EDEA;
  --surface-3:    #E8E4DF;
  --surface-glow: #DDD8D2;
  --border:       #1A1A1A;
  --border-hi:    #000000;
  --hairline:     #D4CFC9;

  /* ─── Text (high contrast) ─────────────────────── */
  --text:         #1A1A1A;
  --text-2:       #2E2E2E;
  --text-muted:   #6B655E;
  --text-faint:   #9C958D;

  /* ─── Metric palette (vibrant, bold) ───────────── */
  --recovery:     #00C853;
  --recovery-2:   #00A845;
  --recovery-glow: rgba(0,200,83,0.3);

  --strain:       #2979FF;
  --strain-2:     #1A5CC7;
  --strain-glow:  rgba(41,121,255,0.3);

  --sleep:        #7C4DFF;
  --sleep-2:      #651FFF;
  --sleep-glow:   rgba(124,77,255,0.3);

  --warn:         #FF6D00;
  --bad:          #D50000;
  --good:         var(--recovery);
  --mid:          var(--warn);

  /* legacy aliases */
  --rec-good:     var(--recovery);
  --rec-mid:      var(--warn);
  --rec-bad:      var(--bad);
  --fg:           var(--text);
  --fg-2:         var(--text-2);
  --fg2:          var(--text-2);
  --muted:        var(--text-muted);
  --card-bg:      var(--surface-1);
  --card-bg2:     var(--surface-2);

  /* Stage colors */
  --stage-wake:   #FF5252;
  --stage-light:  #448AFF;
  --stage-deep:   #7C4DFF;
  --stage-rem:    #E040FB;

  /* Zones */
  --zone-1: #448AFF;
  --zone-2: #00BCD4;
  --zone-3: #00C853;
  --zone-4: #FF6D00;
  --zone-5: #D50000;

  /* ─── Typography ───────────────────────────────── */
  --font:         'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    ui-monospace, 'JetBrains Mono', SFMono-Regular, Menlo, monospace;

  /* ─── Geometry (neobrutalist: tight, bold) ─────── */
  --radius-xs: 0px;
  --radius-sm: 0px;
  --radius:    0px;
  --radius-lg: 0px;
  --gutter:    16px;
  --sidebar-w: 0px;    /* hidden on desktop too — full-width app */
  --topbar-h:  56px;

  /* iOS safe areas */
  --sa-top:    env(safe-area-inset-top, 0px);
  --sa-bottom: env(safe-area-inset-bottom, 0px);
  --sa-left:   env(safe-area-inset-left, 0px);
  --sa-right:  env(safe-area-inset-right, 0px);
}

/* ───────────────────────────────────────────────── */
/* Reset & base                                       */
/* ───────────────────────────────────────────────── */

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

html {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  padding: 0;
  background: var(--bg);
}

::selection { background: var(--strain); color: #fff; }

/* Scrollbar (thin, subtle) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}
h1 { font-size: 28px; line-height: 1.1; }
h2 { font-size: 18px; line-height: 1.2; }
h3 { font-size: 14px; line-height: 1.3; font-weight: 700; }
p  { margin: 0; }

.eyebrow, .card-eyebrow {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ───────────────────────────────────────────────── */
/* Layout — mobile-first, full bleed                  */
/* ───────────────────────────────────────────────── */

/* Sidebar: hidden on all sizes; settings moved to top-bar */
.sidebar { display: none; }

/* ─── BLE Status Bar ─── */
#ble-bar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  padding-top: calc(6px + var(--sa-top));
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  font-size: 11px;
  gap: 8px;
}
#ble-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
#ble-bar-left #mvp-status {
  font-weight: 800;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  white-space: nowrap;
}
#ble-bar-left #ble-hr {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text);
}
#ble-bar-left #ble-hr #mvp-hr { font-size: 14px; }
#ble-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#ble-bar-right #mvp-connect {
  background: var(--recovery);
  color: #fff;
  border: 2px solid var(--border);
  font: 800 10px/1 var(--font);
  padding: 5px 10px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--border);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: box-shadow 80ms, transform 80ms;
}
#ble-bar-right #mvp-connect:active { box-shadow: none; transform: translate(2px, 2px); }
#ble-bar-right #mvp-connect[disabled] { opacity: 0.4; }
#ble-bar-right #mvp-disconnect {
  background: var(--surface-3);
  border: 2px solid var(--border);
  font: 700 10px/1 var(--font);
  padding: 5px 10px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--border);
  transition: box-shadow 80ms, transform 80ms;
}
#ble-bar-right #mvp-disconnect:active { box-shadow: none; transform: translate(2px, 2px); }
#ble-bar-right .icon-btn {
  width: 30px;
  height: 30px;
  background: var(--surface-1);
  border: 2px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 var(--border);
  transition: box-shadow 80ms, transform 80ms;
}
#ble-bar-right .icon-btn:active { box-shadow: none; transform: translate(2px, 2px); }
#ble-bar-right .icon-btn svg { width: 14px; height: 14px; stroke: currentColor; }

main.content {
  padding: 0 16px calc(80px + var(--sa-bottom)) 16px;
  max-width: 680px;
  margin: 0 auto;
  min-width: 0;
}

/* ───────────────────────────────────────────────── */
/* Top bar                                            */
/* ───────────────────────────────────────────────── */

.top-bar {
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sa-top) 0 8px 0;
  margin-bottom: 4px;
  background: var(--bg);
}
.top-bar-left, .top-bar-right { display: flex; align-items: center; gap: 10px; }

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-1);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 3px 3px 0 var(--border);
}
.date-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--recovery);
  box-shadow: 0 0 8px var(--recovery-glow);
}

.icon-btn {
  appearance: none;
  background: var(--surface-1);
  border: 2px solid var(--border);
  width: 36px; height: 36px;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 2px 2px 0 var(--border);
  transition: box-shadow 80ms, transform 80ms;
}
.icon-btn:active { box-shadow: 0 0 0 var(--border); transform: translate(2px, 2px); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; }
.icon-btn .badge-count {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--bad);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  width: 16px; height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
}

.user-profile { display: none; } /* hidden on mobile + desktop PWA */

/* Brand mark (replaces sidebar brand) */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}
.brand-mark::before {
  content: "";
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  background: conic-gradient(from 180deg, var(--recovery), var(--strain), var(--sleep), var(--recovery));
  display: inline-block;
}

/* ───────────────────────────────────────────────── */
/* Tab panels — neobrutalist style                    */
/* ───────────────────────────────────────────────── */

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
  animation: fadeIn 200ms ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-header {
  padding: 4px 0 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.panel-header h1 { font-size: 26px; }
.panel-subtitle { color: var(--text-muted); font-size: 12px; }
.welcome-text {
  font-size: 20px;
  font-weight: 800;
}

.controls { display: flex; gap: 6px; flex-wrap: wrap; }
.controls select, .controls input {
  appearance: none;
  background: var(--surface-1);
  color: var(--text);
  border: 2px solid var(--border);
  padding: 6px 10px;
  font: 700 11px var(--font);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--border);
}

/* ───────────────────────────────────────────────── */
/* Cards — neobrutalist style                         */
/* ───────────────────────────────────────────────── */

.card {
  background: var(--surface-1);
  border: 2px solid var(--border);
  padding: 16px 18px;
  position: relative;
  box-shadow: 4px 4px 0 var(--border);
  transition: box-shadow 120ms, transform 120ms;
}
.card:active { box-shadow: 1px 1px 0 var(--border); transform: translate(3px, 3px); }
.card .card-eyebrow { margin-bottom: 10px; }

.card .big-num {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}
.card .big-num .unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.card .muted { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

/* ───────────────────────────────────────────────── */
/* Hero ring row — Bevel-inspired                     */
/* ───────────────────────────────────────────────── */

.ring-card {
  padding: 20px 16px 16px 16px;
  text-align: center;
  background: var(--surface-1);
  border: 2px solid var(--border);
  position: relative;
  box-shadow: 4px 4px 0 var(--border);
  transition: box-shadow 120ms, transform 120ms;
}
.ring-card:active { box-shadow: 1px 1px 0 var(--border); transform: translate(3px, 3px); }
.ring-card .ring-eyebrow {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ring-card.recovery .ring-eyebrow { color: var(--recovery); }
.ring-card.strain   .ring-eyebrow { color: var(--strain); }
.ring-card.sleep    .ring-eyebrow { color: var(--sleep); }

.ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 8px auto 6px auto;
}
.ring-wrap.big { width: 220px; height: 220px; }
.ring-wrap svg { width: 100%; height: 100%; overflow: visible; }

.ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.ring-value .num {
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ring-value .num .unit { font-size: 20px; font-weight: 700; color: var(--text-muted); }
.ring-value .num.big { font-size: 64px; }
.ring-value .sub {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.ring-card .ring-foot {
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-variant-numeric: tabular-nums;
}
.ring-card .ring-foot strong { color: var(--text); font-weight: 700; }

/* Sparkline */
.ring-card .spark-wrap {
  position: relative;
  width: 100%;
  height: 28px;
  max-height: 28px;
  margin-top: 10px;
  overflow: hidden;
}
.ring-card canvas.spark {
  display: block;
  width: 100% !important;
  height: 28px !important;
  max-height: 28px;
}

/* ───────────────────────────────────────────────── */
/* Grids — mobile-first single column                 */
/* ───────────────────────────────────────────────── */

.hero-ring-row {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

.grid {
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
}

/* Small desktop breakpoint (still single-column for simplicity) */
@media (min-width: 640px) {
  main.content {
    padding: 0 24px calc(80px + var(--sa-bottom)) 24px;
    max-width: 720px;
  }
  .hero-ring-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gutter);
  }
  .grid { display: flex; flex-direction: column; gap: var(--gutter); }
  .grid-live { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gutter); }
}

@media (min-width: 900px) {
  main.content { max-width: 860px; }
  .grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--gutter);
  }
  .grid > .span-2 { grid-column: span 2; }
}

/* ───────────────────────────────────────────────── */
/* "Now" Live tile                                    */
/* ───────────────────────────────────────────────── */

.now-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.now-hr {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.now-hr .unit { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.heart-pulse {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  color: var(--bad);
  will-change: transform;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50%      { transform: scale(1.18); opacity: 1; }
}
.now-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}
.now-grid > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 3px;
}
.now-grid .lbl {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.now-grid span:last-child {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ───────────────────────────────────────────────── */
/* Plan / Insights / Workouts                         */
/* ───────────────────────────────────────────────── */

#plan-zone {
  font-size: 24px !important;
  font-weight: 800;
  margin: 2px 0 !important;
}
#plan-label { font-size: 13px !important; font-weight: 700; color: var(--text) !important; }
#plan-message { font-size: 11px !important; color: var(--text-muted) !important; line-height: 1.5 !important; }
#plan-target { font-size: 10px !important; color: var(--text-faint) !important; margin-top: 8px !important; padding-top: 6px; border-top: 1px solid var(--hairline); }

.workout-list { display: flex; flex-direction: column; gap: 6px; }
.workout-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--surface-2);
  border: 2px solid var(--border);
  padding: 8px 12px;
  box-shadow: 2px 2px 0 var(--border);
}
.workout-row .wo-time { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.workout-row .wo-name { font-size: 12px; font-weight: 700; color: var(--text); }
.workout-row .wo-strain { font-size: 16px; font-weight: 800; color: var(--strain); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }

/* Insights */
.insight {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 2px solid var(--border);
  font-size: 11px;
  box-shadow: 2px 2px 0 var(--border);
}
.insight .ins-icon {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.insight.warn  .ins-icon { color: var(--warn); }
.insight.info  .ins-icon { color: var(--strain); }
.insight.critical .ins-icon { color: var(--bad); }
.insight .ins-icon svg { width: 14px; height: 14px; }
.insight .ins-title { font-size: 11px; font-weight: 800; color: var(--text); margin-bottom: 1px; }
.insight .ins-body { color: var(--text-muted); line-height: 1.5; }

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.35; }

/* ───────────────────────────────────────────────── */
/* Charts                                             */
/* ───────────────────────────────────────────────── */

.chart-wrap {
  position: relative;
  width: 100%;
  height: 160px;
}
.chart-wrap.tall { height: 220px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* Hypnogram */
.hypnogram-wrap { width: 100%; height: 160px; }
.hypnogram-wrap svg { width: 100%; height: 100%; }
.legend { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; font-size: 10px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.swatch { display: inline-block; width: 8px; height: 8px; }

/* Stage bars */
.stage-bars { display: flex; flex-direction: column; gap: 8px; }
.stage-bars .row {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 11px;
}
.stage-bars .lbl { color: var(--text-muted); font-weight: 700; letter-spacing: 0.03em; }
.stage-bars .v { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-bars .barwrap { height: 6px; background: var(--surface-3); overflow: hidden; }
.stage-bars .bar { height: 100%; }

/* Components */
.components { display: flex; flex-direction: column; gap: 10px; }
.component-row {
  display: grid;
  grid-template-columns: 80px 1fr 36px;
  gap: 10px;
  align-items: center;
  font-size: 11px;
}
.component-row .name { color: var(--text-muted); font-weight: 600; }
.component-row .val { color: var(--text); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.component-row .barwrap { height: 6px; background: var(--surface-3); overflow: hidden; }
.component-row .bar { height: 100%; }

/* Zones */
.zones-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.zone-cell {
  text-align: center;
  background: var(--surface-2);
  border: 2px solid var(--border);
  padding: 8px 4px;
  box-shadow: 2px 2px 0 var(--border);
}
.zone-cell .zlbl { font-size: 9px; font-weight: 800; color: var(--text-muted); letter-spacing: 0.03em; }
.zone-cell .zval { font-size: 14px; font-weight: 800; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }

.donut-wrap { display: flex; justify-content: center; }
.donut-wrap svg { width: 140px; height: 140px; }

/* ───────────────────────────────────────────────── */
/* Tables                                             */
/* ───────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  border: 2px solid var(--border);
}
table th, table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--hairline);
}
table th {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-2);
}
table td { color: var(--text); }

/* Calendar heatmap */
.cal-cell { transition: transform 100ms; }
.cal-cell:hover { transform: scale(1.2); z-index: 2; position: relative; }

/* Journal tags */
.journal-tag {
  appearance: none;
  background: var(--surface-2);
  border: 2px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  font: 700 10px var(--font);
  cursor: pointer;
  transition: all 100ms;
  box-shadow: 2px 2px 0 var(--border);
}
.journal-tag:active { box-shadow: 0 0 0 var(--border); transform: translate(2px, 2px); }
.journal-tag.active {
  background: var(--recovery);
  color: #fff;
  border-color: var(--border);
}

/* Settings drawer — neobrutalist slide-out */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
  display: none;
}
.backdrop.open { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: 360px;
  max-width: 92vw;
  height: 100vh;
  background: var(--surface-1);
  border-left: 2px solid var(--border);
  padding: 24px 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 200ms ease, visibility 0s linear 200ms;
  box-shadow: -8px 0 0 var(--border);
}
.drawer.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 200ms ease;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.drawer-head h2 { font-size: 18px; font-weight: 800; }
.close-btn {
  appearance: none;
  background: var(--surface-2);
  border: 2px solid var(--border);
  width: 32px; height: 32px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 var(--border);
}
.close-btn:active { box-shadow: 0 0 0 var(--border); transform: translate(2px, 2px); }

.settings-form { display: flex; flex-direction: column; gap: 12px; }
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.settings-form input, .settings-form select {
  appearance: none;
  background: var(--surface-2);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.settings-form input:focus, .settings-form select:focus {
  outline: none;
  border-color: var(--strain);
  box-shadow: 3px 3px 0 var(--strain);
}
.settings-form .primary {
  appearance: none;
  background: var(--text);
  color: var(--bg);
  border: 2px solid var(--border);
  padding: 10px 16px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--border);
  transition: box-shadow 80ms, transform 80ms;
}
.settings-form .primary:active { box-shadow: 0 0 0 var(--border); transform: translate(3px, 3px); }
.settings-form .hint { font-size: 10px; color: var(--text-faint); font-weight: normal; letter-spacing: 0; text-transform: none; }

.drawer hr { border: none; border-top: 2px solid var(--border); margin: 0; }
.drawer .actions { display: flex; flex-direction: column; gap: 8px; }
.drawer .actions button {
  appearance: none;
  background: var(--surface-3);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  font: 700 11px var(--font);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--border);
}
.drawer .actions button:active { box-shadow: 0 0 0 var(--border); transform: translate(2px, 2px); }
.drawer .actions .hint { font-size: 10px; color: var(--text-muted); }

/* Live tab event log + stats */
.row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--hairline); font-size: 12px; }
.row:last-child { border-bottom: none; }
.row .k { color: var(--text-muted); font-weight: 600; }
.row .v { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }

.ev {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 11px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ev:last-child { border-bottom: none; }
.ev .kind {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Misc */
.muted { color: var(--text-muted); }
.big-num { font-family: var(--font-display); }
.unit { font-size: 0.5em; color: var(--text-muted); font-weight: 700; margin-left: 3px; }

/* ───────────────────────────────────────────────── */
/* Mobile bottom navigation — always visible          */
/* ───────────────────────────────────────────────── */

.mobile-nav {
  display: flex;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(56px + var(--sa-bottom));
  padding-bottom: var(--sa-bottom);
  background: var(--surface-1);
  border-top: 2px solid var(--border);
  justify-content: space-around;
  align-items: stretch;
  z-index: 50;
}
.mobile-nav .mtab {
  flex: 1;
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-faint);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font: 700 8px var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 0;
  transition: color 100ms;
}
.mobile-nav .mtab svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-nav .mtab.active { color: var(--text); }
.mobile-nav .mtab:active { transform: scale(0.92); }

/* ───────────────────────────────────────────────── */
/* BLE panel — condensed for mobile                   */
/* ───────────────────────────────────────────────── */

/* Tiny panel button */
.panel-btn-tiny {
  font-size: 9px !important;
  padding: 3px 6px !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  border: 2px solid var(--hairline) !important;
}
.panel-btn-tiny:hover { color: var(--text) !important; border-color: var(--border) !important; }

#mvp-panel {
  padding: 12px 14px;
  background: var(--surface-1);
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  box-shadow: 4px 4px 0 var(--border);
}
#mvp-panel strong { font-weight: 800; }
#mvp-panel button {
  appearance: none;
  background: var(--surface-2);
  color: var(--text);
  border: 2px solid var(--border);
  padding: 5px 8px;
  font: 700 10px/1 var(--font);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--border);
  transition: box-shadow 80ms, transform 80ms;
}
#mvp-panel button:active { box-shadow: 0 0 0 var(--border); transform: translate(2px, 2px); }
#mvp-panel button:disabled { opacity: 0.4; cursor: not-allowed; }
#mvp-connect {
  background: var(--recovery) !important;
  color: #fff !important;
  font-weight: 800 !important;
  border: 2px solid var(--border) !important;
  padding: 8px 12px !important;
  font-size: 11px !important;
  letter-spacing: 0.03em !important;
  text-transform: uppercase !important;
  box-shadow: 3px 3px 0 var(--border) !important;
}

/* Sidebar panel classes */
.panel-metrics { display: flex; justify-content: space-between; margin: 6px 0 8px 0; padding-top: 6px; border-top: 2px solid var(--border); }
.panel-metric { display: flex; flex-direction: column; gap: 1px; }
.panel-metric-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.panel-metric-value { font-size: 13px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.panel-section { border-top: 2px solid var(--border); margin: 4px 0 2px 0; }
.panel-badge-row { display: flex; gap: 6px; font-size: 10px; color: var(--text-muted); margin: 2px 0; flex-wrap: wrap; }
.panel-divider { border-top: 2px solid var(--border); margin: 6px 0 2px 0; padding-top: 6px; }
.panel-section-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 800; margin-bottom: 2px; }

#mvp-panel details > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--text-muted);
}
#mvp-panel details > summary:hover { color: var(--text); }
#mvp-panel details > summary::-webkit-details-marker { display: none; }
#mvp-panel details[open] > summary::before { content: "▾ "; }
#mvp-panel details:not([open]) > summary::before { content: "▸ "; }

#mvp-panel button[id^="mvp-export"], #mvp-panel #mvp-import, #mvp-panel #mvp-reset {
  background: transparent !important;
  color: var(--text-muted) !important;
  border: 2px solid var(--hairline) !important;
  padding: 3px 6px !important;
  font-size: 9px !important;
}
#mvp-panel button[id^="mvp-export"]:hover, #mvp-panel #mvp-import:hover, #mvp-panel #mvp-reset:hover {
  color: var(--text) !important;
  border-color: var(--border) !important;
}

/* Coach tab */
#coach-input {
  border: 2px solid var(--border) !important;
  background: var(--surface-1) !important;
  color: var(--text) !important;
  box-shadow: 3px 3px 0 var(--border) !important;
}

/* Wake alarm time input */
#wake-alarm-time {
  border: 2px solid var(--border) !important;
  background: var(--surface-1) !important;
  color: var(--text) !important;
  font-weight: 800 !important;
  box-shadow: 2px 2px 0 var(--border) !important;
}

/* Responsive overflow on tables */
@media (max-width: 480px) {
  #trends-table { font-size: 8px; }
  #trends-table th, #trends-table td { padding: 4px 4px; }
}

/* Panel date (small top-right date) */
.panel-date {
  color: var(--text-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Date nav buttons */
.date-nav-btn {
  appearance: none;
  background: var(--surface-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--border);
  font-weight: 700;
}
.date-nav-btn:disabled { opacity: 0.35; }
