/* ═══════════════════════════════════════════════════════════════════
   MOBILE.CSS - Clean rebuild matching public/mobile-concept.html
   - All classes use unique `.ms-` prefix (no conflicts with desktop CSS)
   - 100dvh shell layout · nav as flex-child (iOS Safari URL-bar safe)
   - Activates via body[data-mobile-shell="active"] on widths ≤ 768px
   ═══════════════════════════════════════════════════════════════════ */

/* ───────── Local theme variables (scoped to shell) ───────── */
.ms-shell {
  --ms-bg: #07090d;
  --ms-bg-2: #0d1119;
  --ms-card: #12161f;
  --ms-card-2: #1a2030;
  --ms-card-3: #242b3d;
  --ms-border: rgba(255,255,255,0.06);
  --ms-border-2: rgba(255,255,255,0.13);
  --ms-text-1: #edf2fa;
  --ms-text-2: #9ba5b8;
  --ms-text-3: #5a6375;
  --ms-accent: var(--accent, #0A84FF);
  --ms-accent-glow: rgba(var(--accent-rgb),0.5);
  --ms-blue: #3b9eff;
  --ms-purple: #a78bfa;
  --ms-amber: #f59e0b;
  --ms-red: #ef4444;
  --ms-pink: #ec4899;
  --ms-cyan: #22d3ee;
}
html[data-theme="light"] .ms-shell {
  --ms-bg: #f4f5f7;
  --ms-bg-2: #eef0f3;
  --ms-card: #ffffff;
  --ms-card-2: #f9fafb;
  --ms-card-3: #f3f4f6;
  --ms-border: rgba(0,0,0,0.08);
  --ms-border-2: rgba(0,0,0,0.14);
  --ms-text-1: #1a1d26;
  --ms-text-2: #4b5563;
  --ms-text-3: #6b7280;
  --ms-accent: var(--accent, #0A84FF);
  --ms-accent-glow: rgba(var(--accent-rgb),0.32);
}

/* ═══════════════════════════════════════════════════════════════════
   ACTIVATION - hide all desktop UI under shell (mobile only)
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Show shell only when active */
  .ms-shell { display: none; }
  body[data-mobile-shell="active"][data-mobile-role="phoner"] #ms-shell-phoner,
  body[data-mobile-shell="active"][data-mobile-role="admin"]  #ms-shell-admin {
    display: flex;
  }

  /* Hide ALL desktop chrome / popups / banners while shell active OR in subview mode.
     Use descendant selectors so deeply-nested elements are caught. */
  body[data-mobile-shell="active"] .layout,
  body[data-mobile-shell="active"] .sidebar,
  body[data-mobile-shell="active"] .sidebar-backdrop,
  body[data-mobile-shell="active"] .main-area,
  body[data-mobile-shell="active"] .visual-toggle,
  body[data-mobile-shell] #beta-banner,
  body[data-mobile-shell] #welcome-splash,
  body[data-mobile-shell] #welcome-modal,
  body[data-mobile-shell] #sync-banner,
  body[data-mobile-shell] #period-filter,
  body[data-mobile-shell] #location-filter,
  body[data-mobile-shell] #portal-footer-nav,
  body[data-mobile-shell] .mobile-tabs,
  body[data-mobile-shell] .mobile-menu-drawer,
  body[data-mobile-shell] .global-toast-stack:not(#toast-container),
  body[data-mobile-shell] #app-tour,
  body[data-mobile-shell] #intro-overlay,
  body[data-mobile-shell] #spin-reminder,
  body[data-mobile-shell] #login-reward,
  body[data-mobile-shell] #streak-reminder,
  body[data-mobile-shell] #pulse-survey-popup,
  body[data-mobile-shell] #setup-wizard-overlay,
  body[data-mobile-shell] #role-picker-overlay,
  body[data-mobile-shell] #consent-overlay,
  body[data-mobile-shell] #tour-overlay,
  body[data-mobile-shell] #initial-loader,
  body[data-mobile-shell] .pulse-survey,
  body[data-mobile-shell] .game-perf-banner,
  body[data-mobile-shell] #impersonation-banner {
    display: none !important;
  }

  body[data-mobile-shell="active"] {
    overflow: hidden;
    background: var(--ms-bg, #07090d);
  }
  body[data-mobile-shell="active"] .ms-shell {
    z-index: 9990 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   SHELL ROOT
   ═══════════════════════════════════════════════════════════════════ */
.ms-shell {
  position: fixed;
  inset: 0;
  z-index: 9990;
  flex-direction: column;
  background: var(--ms-bg);
  color: var(--ms-text-1);
  font-family: var(--bh-body);
  height: 100dvh;
  height: 100vh; /* fallback */
  width: 100vw;
  overflow: hidden;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(var(--accent-rgb),0.06), transparent 55%),
    radial-gradient(ellipse at 100% 50%, rgba(59,158,255,0.05), transparent 55%);
}
.ms-shell *,
.ms-shell *::before,
.ms-shell *::after {
  box-sizing: border-box;
}
.ms-shell button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0;
}
.ms-shell h1, .ms-shell h2, .ms-shell h3,
.ms-shell h4, .ms-shell h5, .ms-shell p {
  margin: 0;
  padding: 0;
}
.ms-shell canvas {
  display: block;
  max-width: 100% !important;
}

/* ───────── Status-bar safe area ───────── */
.ms-statusbar {
  height: env(safe-area-inset-top, 0);
  flex-shrink: 0;
  background: var(--ms-bg);
}

/* ───────── Header ───────── */
.ms-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 10px;
  background: var(--ms-bg);
  border-bottom: 1px solid var(--ms-border);
}
body[data-pwa-banner="1"] .ms-head {
  margin-top: 56px;
}
.ms-greet {
  flex: 1;
  min-width: 0;
}
.ms-hello {
  font-size: 0.72rem;
  color: var(--ms-text-2);
  margin-bottom: 2px;
  font-weight: 600;
}
.ms-greet h1 {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--ms-text-1);
}
.ms-head-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ms-head-btn svg {
  width: 20px;
  height: 20px;
  color: var(--ms-text-1);
}
.ms-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--ms-red);
  color: #fff;
  border-radius: 9px;
  font-size: 0.62rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ms-bg);
}
.ms-badge[hidden] { display: none; }

/* ───────── Body / scroll area ───────── */
.ms-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 24px;
  scrollbar-width: none;
}
.ms-body::-webkit-scrollbar { display: none; }

.ms-screen { display: none; }
.ms-screen.active { display: block; }

/* ───────── Pull-to-refresh indicator ───────── */
.ms-ptr {
  position: relative;
  width: 100%;
  height: 0;
  overflow: hidden;
  opacity: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  margin: 0 -16px 0;
  padding: 0 16px;
}
.ms-ptr-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--ms-text-2);
  font-weight: 600;
  padding: 10px 0;
}
.ms-ptr-spinner {
  color: var(--ms-accent);
  transition: transform 0.15s ease-out;
}
.ms-ptr-spinner.spinning {
  animation: msPtrSpin 0.8s linear infinite;
}
@keyframes msPtrSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ───────── Bottom nav (flex-child, NOT fixed → iOS-safe) ─────────
   5-cell grid forces FAB into the centre cell - no float-around drift. */
.ms-nav {
  flex-shrink: 0;
  position: relative;
  z-index: 9997;
  display: grid;
  grid-template-columns: 1fr 1fr 64px 1fr 1fr;
  justify-items: center;
  align-items: center;
  height: 76px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
  background: rgba(7,9,13,0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--ms-border);
}
html[data-theme="light"] .ms-nav {
  background: rgba(255,255,255,0.95);
}
.ms-nav-item {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--ms-text-3);
  min-height: 48px;
  padding: 4px;
}
.ms-nav-item.active { color: var(--ms-accent); }
.ms-nav-item .ms-icn,
.ms-nav-fab .ms-icn {
  display: block;
  width: 22px;
  height: 22px;
  color: currentColor;
}
.ms-nav-item .ms-icn svg {
  width: 22px;
  height: 22px;
  display: block;
  color: currentColor;
}
.ms-nav-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--ms-accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -16px;
  box-shadow: 0 8px 22px var(--ms-accent-glow);
  flex-shrink: 0;
}
.ms-nav-fab .ms-icn {
  width: 26px;
  height: 26px;
}
.ms-nav-fab svg {
  width: 26px;
  height: 26px;
  color: #000;
  display: block;
}
.ms-nav-item .ms-badge {
  top: 2px;
  right: 18%;
  border-color: rgba(7,9,13,0.92);
}
html[data-theme="light"] .ms-nav-item .ms-badge {
  border-color: rgba(255,255,255,0.95);
}

/* ═══════════════════════════════════════════════════════════════════
   SHARED PRIMITIVES
   ═══════════════════════════════════════════════════════════════════ */
.ms-sec-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 4px 10px;
}
.ms-sec-title h3 {
  font-size: 0.85rem;
  font-weight: 800;
}
.ms-sec-link {
  font-size: 0.7rem;
  color: var(--ms-accent);
  font-weight: 700;
}

.ms-progress {
  height: 8px;
  background: rgba(0,0,0,0.3);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
html[data-theme="light"] .ms-progress { background: rgba(0,0,0,0.08); }
.ms-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--ms-accent), var(--ms-cyan));
  border-radius: 100px;
  box-shadow: 0 0 12px var(--ms-accent-glow);
  transition: width 0.3s ease;
}

.ms-kpi-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.ms-kpi {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  padding: 12px;
  min-width: 0;
}
.ms-kpi-lbl {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ms-text-3);
  margin-bottom: 4px;
}
.ms-kpi-val {
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.1;
  color: var(--ms-text-1);
  font-variant-numeric: tabular-nums;
}
.ms-kpi-delta {
  font-size: 0.65rem;
  font-weight: 700;
  margin-top: 2px;
  color: var(--ms-text-3);
}
.ms-kpi-delta.up { color: var(--ms-accent); }
.ms-kpi-delta.down { color: var(--ms-red); }

.ms-next {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.ms-next-icn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ms-next-icn svg { width: 20px; height: 20px; color: currentColor; }
.ms-next-icn.amber  { background: rgba(245,158,11,0.15);  color: var(--ms-amber); }
.ms-next-icn.purple { background: rgba(167,139,250,0.15); color: var(--ms-purple); }
.ms-next-icn.green  { background: rgba(25, 195, 125,0.15);   color: #1F9E5A; }
.ms-next-icn.blue   { background: rgba(59,158,255,0.15);  color: var(--ms-blue); }
.ms-next-body { flex: 1; min-width: 0; }
.ms-next-body h4 {
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 2px;
  color: var(--ms-text-1);
}
.ms-next-body p {
  font-size: 0.7rem;
  color: var(--ms-text-2);
  line-height: 1.35;
}

.ms-empty {
  background: var(--ms-card);
  border: 1px dashed var(--ms-border-2);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--ms-text-3);
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════════════════════════
   SCREEN: Phoner Home
   ═══════════════════════════════════════════════════════════════════ */
.ms-hero {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.18), rgba(34,211,238,0.10));
  border: 1px solid rgba(var(--accent-rgb),0.28);
  border-radius: 22px;
  padding: 20px 18px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.ms-hero::before {
  content: '';
  position: absolute;
  right: -30px; top: -30px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb),0.25), transparent 70%);
  pointer-events: none;
}
.ms-hero-lbl {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ms-accent);
  margin-bottom: 8px;
}
.ms-hero-num {
  font-size: clamp(2rem, 12vw, 3rem); /* scale down for 4-digit indices on narrow screens */
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--ms-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
html[data-theme="light"] .ms-hero-num {
  background: linear-gradient(135deg, var(--ms-text-1) 30%, var(--ms-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
.ms-hero-num small {
  font-size: 1.1rem;
  font-weight: 700;
  -webkit-text-fill-color: var(--ms-text-2);
  color: var(--ms-text-2);
}
.ms-hero-sub {
  font-size: 0.8rem;
  color: var(--ms-text-1);
  font-weight: 600;
  margin-bottom: 12px;
}
.ms-hero-sub b { color: var(--ms-accent); font-weight: 800; }
.ms-hero-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ms-text-2);
  letter-spacing: 0.04em;
}

.ms-rank {
  background: linear-gradient(135deg, rgba(167,139,250,0.12), rgba(236,72,153,0.08));
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.ms-rank-pos {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--ms-purple);
  line-height: 1;
  padding-right: 12px;
  border-right: 1px solid var(--ms-border);
  font-variant-numeric: tabular-nums;
}
.ms-rank-body { flex: 1; min-width: 0; }
.ms-rank-body h4 { font-size: 0.78rem; font-weight: 800; margin-bottom: 2px; }
.ms-rank-body p { font-size: 0.68rem; color: var(--ms-text-2); }

/* ═══════════════════════════════════════════════════════════════════
   SCREEN: Live
   ═══════════════════════════════════════════════════════════════════ */
.ms-live {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 14px;
}
.ms-live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.ms-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ms-red);
  box-shadow: 0 0 0 4px rgba(239,68,68,0.2);
  animation: ms-pulse 1.6s infinite;
}
@keyframes ms-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(239,68,68,0.2); }
  50%      { box-shadow: 0 0 0 8px rgba(239,68,68,0.05); }
}
.ms-live-lbl {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ms-text-2);
}
.ms-live-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.ms-live-stat { text-align: center; }
.ms-live-stat .v {
  font-size: 1.4rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.ms-live-stat .l {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--ms-text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ms-call {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.ms-call-av {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 0.78rem;
  flex-shrink: 0;
  position: relative;
  background: linear-gradient(135deg, var(--ms-blue), var(--ms-purple));
}
.ms-call-av::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ms-accent);
  border: 2px solid var(--ms-card);
}
.ms-call-body { flex: 1; min-width: 0; }
.ms-call-name {
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 2px;
  color: var(--ms-text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-call-meta {
  font-size: 0.65rem;
  color: var(--ms-text-2);
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-call-meta .ms-dot { color: var(--ms-text-3); }
.ms-call-time {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ms-accent);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════
   SCREEN: Leaderboard
   ═══════════════════════════════════════════════════════════════════ */
.ms-lb-head {
  background: linear-gradient(135deg, rgba(245,158,11,0.18), rgba(236,72,153,0.10));
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  text-align: center;
}
.ms-lb-head-lbl {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-amber);
  margin-bottom: 6px;
}
.ms-lb-head h2 {
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 2px;
  color: var(--ms-text-1);
}
.ms-lb-head p {
  font-size: 0.7rem;
  color: var(--ms-text-2);
}

.ms-podium {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  align-items: end;
}
.ms-pd {
  position: relative;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  padding: 14px 6px 10px;
  text-align: center;
}
.ms-pd.gold   { border-color: rgba(245,158,11,0.5); background: linear-gradient(180deg, rgba(245,158,11,0.15), var(--ms-card)); }
.ms-pd.silver { border-color: rgba(155,165,184,0.4); }
.ms-pd.bronze { border-color: rgba(180,83,9,0.4); }
.ms-pd-medal {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
}
.ms-pd.gold   .ms-pd-medal { background: #f5b800; }
.ms-pd.silver .ms-pd-medal { background: #c4c9d3; }
.ms-pd.bronze .ms-pd-medal { background: #cd7f32; }
.ms-pd-av {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  margin: 6px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 900;
  font-size: 0.8rem;
}
.ms-pd.gold .ms-pd-av {
  width: 52px;
  height: 52px;
  font-size: 0.95rem;
}
.ms-pd-name {
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ms-text-1);
}
.ms-pd-val {
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--ms-accent);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.ms-lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 6px;
}
.ms-lb-row.me {
  background: linear-gradient(90deg, rgba(var(--accent-rgb),0.18), var(--ms-card));
  border-color: rgba(var(--accent-rgb),0.3);
}
.ms-lb-pos {
  width: 22px;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--ms-text-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ms-lb-row.me .ms-lb-pos { color: var(--ms-accent); }
.ms-lb-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.7rem;
}
.ms-lb-name {
  flex: 1;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ms-text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-lb-you {
  font-size: 0.55rem;
  color: var(--ms-accent);
  font-weight: 800;
  margin-left: 6px;
  padding: 2px 5px;
  background: rgba(var(--accent-rgb),0.15);
  border-radius: 4px;
}
.ms-lb-val {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--ms-text-1);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════
   SCREEN: Min performance
   ═══════════════════════════════════════════════════════════════════ */
.ms-pills {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--ms-card);
  border-radius: 100px;
  border: 1px solid var(--ms-border);
  margin-bottom: 14px;
}
.ms-pills button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 100px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ms-text-2);
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ms-pills button.active {
  background: var(--ms-accent);
  color: #000;
}

.ms-perf-hero {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.ms-perf-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.ms-perf-lbl {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ms-text-3);
}
.ms-perf-delta {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ms-accent);
}
.ms-perf-num {
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  color: var(--ms-text-1);
  font-variant-numeric: tabular-nums;
}
.ms-perf-num small {
  font-size: 1rem;
  color: var(--ms-text-2);
  font-weight: 700;
}
.ms-perf-sub {
  font-size: 0.7rem;
  color: var(--ms-text-2);
  margin-bottom: 14px;
}
/* Bounded chart container - prevents Chart.js infinite-growth bug */
.ms-perf-chart {
  height: 120px;
  width: 100%;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.ms-perf-chart canvas {
  max-height: 120px !important;
}

.ms-skill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 6px;
}
.ms-skill-lbl { flex: 1; min-width: 0; }
.ms-skill-lbl h5 {
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 2px;
  color: var(--ms-text-1);
}
.ms-skill-lbl p {
  font-size: 0.62rem;
  color: var(--ms-text-3);
}
.ms-skill-bar {
  width: 60px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 100px;
  overflow: hidden;
  flex-shrink: 0;
}
html[data-theme="light"] .ms-skill-bar { background: rgba(0,0,0,0.08); }
.ms-skill-bar .fill {
  height: 100%;
  background: var(--ms-accent);
  border-radius: 100px;
}
.ms-skill-pct {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--ms-accent);
  min-width: 36px;
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════════════
   SCREEN: Pulse (admin)
   ═══════════════════════════════════════════════════════════════════ */
.ms-sup {
  background: linear-gradient(135deg, rgba(59,158,255,0.15), rgba(167,139,250,0.08));
  border: 1px solid rgba(59,158,255,0.25);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}
.ms-sup-lbl {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ms-blue);
  margin-bottom: 6px;
}
.ms-sup h3 {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 10px;
  color: var(--ms-text-1);
}
.ms-sup h3 b { color: var(--ms-text-1); font-weight: 900; }
.ms-sup-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.ms-sup-st {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 8px 10px;
}
html[data-theme="light"] .ms-sup-st { background: rgba(255,255,255,0.6); }
.ms-sup-st .v {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ms-text-1);
  font-variant-numeric: tabular-nums;
}
.ms-sup-st .l {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--ms-text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ms-alert {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  padding: 13px;
  margin-bottom: 8px;
  border-left: 3px solid;
  cursor: pointer;
}
.ms-alert.red   { border-left-color: var(--ms-red); }
.ms-alert.amber { border-left-color: var(--ms-amber); }
.ms-alert.blue  { border-left-color: var(--ms-blue); }
.ms-alert.green { border-left-color: #1F9E5A; }
.ms-alert-icn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ms-alert.red   .ms-alert-icn { background: rgba(239,68,68,0.15);  color: var(--ms-red); }
.ms-alert.amber .ms-alert-icn { background: rgba(245,158,11,0.15); color: var(--ms-amber); }
.ms-alert.blue  .ms-alert-icn { background: rgba(59,158,255,0.15); color: var(--ms-blue); }
.ms-alert.green .ms-alert-icn { background: rgba(25, 195, 125,0.15);  color: #1F9E5A; }
.ms-alert-icn svg { width: 18px; height: 18px; color: currentColor; }
.ms-alert-body { flex: 1; min-width: 0; }
.ms-alert-body h5 {
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 2px;
  line-height: 1.3;
  color: var(--ms-text-1);
}
.ms-alert-body p {
  font-size: 0.65rem;
  color: var(--ms-text-2);
  line-height: 1.4;
}
.ms-alert-meta {
  font-size: 0.58rem;
  color: var(--ms-text-3);
  margin-top: 4px;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════
   SCREEN: More
   ═══════════════════════════════════════════════════════════════════ */
.ms-tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}
.ms-tile {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 18px;
  padding: 18px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 112px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), background 0.15s;
  position: relative;
  overflow: hidden;
}
.ms-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--ms-tile-glow, transparent), transparent 65%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.ms-tile:active { transform: scale(0.96); }
.ms-tile:active::before { opacity: 0.6; }
.ms-tile-icn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ms-tile-bg, rgba(var(--accent-rgb),0.14));
  color: var(--ms-tile-color, var(--ms-accent));
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.ms-tile-icn svg { width: 24px; height: 24px; display: block; }
.ms-tile-lbl {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ms-text-1);
  text-align: center;
  line-height: 1.25;
  letter-spacing: -0.005em;
  position: relative;
  z-index: 1;
}
/* Tone-coloured tiles - distinct color per category, mockup-quality */
.ms-tile.ms-tone-green  { --ms-tile-bg: rgba(25, 195, 125,0.14);  --ms-tile-color: #1F9E5A; --ms-tile-glow: rgba(25, 195, 125,0.18); }
.ms-tile.ms-tone-blue   { --ms-tile-bg: rgba(59,158,255,0.14); --ms-tile-color: var(--ms-blue);   --ms-tile-glow: rgba(59,158,255,0.18); }
.ms-tile.ms-tone-purple { --ms-tile-bg: rgba(167,139,250,0.16); --ms-tile-color: var(--ms-purple); --ms-tile-glow: rgba(167,139,250,0.18); }
.ms-tile.ms-tone-amber  { --ms-tile-bg: rgba(245,158,11,0.16); --ms-tile-color: var(--ms-amber);  --ms-tile-glow: rgba(245,158,11,0.20); }
.ms-tile.ms-tone-red    { --ms-tile-bg: rgba(239,68,68,0.14);  --ms-tile-color: var(--ms-red);    --ms-tile-glow: rgba(239,68,68,0.18); }
.ms-tile.ms-tone-pink   { --ms-tile-bg: rgba(236,72,153,0.16); --ms-tile-color: var(--ms-pink);   --ms-tile-glow: rgba(236,72,153,0.18); }
.ms-tile.ms-tone-cyan   { --ms-tile-bg: rgba(34,211,238,0.14); --ms-tile-color: var(--ms-cyan);   --ms-tile-glow: rgba(34,211,238,0.18); }
.ms-tile.ms-tone-gray   { --ms-tile-bg: rgba(155,165,184,0.14); --ms-tile-color: var(--ms-text-2); --ms-tile-glow: rgba(155,165,184,0.16); }
.ms-list-row {
  width: 100%;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  text-align: left;
}
.ms-list-icn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(var(--accent-rgb),0.15);
  color: var(--ms-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.ms-list-icn.red {
  background: rgba(239,68,68,0.15);
  color: var(--ms-red);
}
.ms-list-body { flex: 1; min-width: 0; }
.ms-list-body strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ms-text-1);
  margin-bottom: 2px;
}
.ms-list-body p {
  font-size: 0.65rem;
  color: var(--ms-text-3);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════
   FAB / Bottom sheet
   ═══════════════════════════════════════════════════════════════════ */
/* Sheet overlay + content share the SAME timing curve so they feel unified.
   300ms cubic-bezier(.4,0,.2,1) - Material Design "decelerate" on entry. */
.ms-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9995;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ms-sheet-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.ms-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9996;
  background: #0d1119;
  color: #edf2fa;
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 12px 18px calc(28px + env(safe-area-inset-bottom, 0));
  max-height: 80dvh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--bh-body);
  will-change: transform; /* hint browser for smoother slide on iOS */
}
html[data-theme="light"] .ms-sheet { background: var(--ms-card); color: var(--ms-text-1); }
.ms-sheet.open { transform: translateY(0); }
.ms-sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.13);
  border-radius: 2px;
  margin: 0 auto 16px;
}
html[data-theme="light"] .ms-sheet-handle { background: rgba(0,0,0,0.13); }
.ms-sheet h3 {
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 14px;
}

.ms-field { margin-bottom: 12px; }
.ms-field label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #5a6375;
  margin-bottom: 6px;
}
.ms-field input,
.ms-field select,
.ms-field textarea {
  width: 100%;
  background: #12161f;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 10px;
  padding: 12px;
  color: #edf2fa;
  font-size: 0.85rem;
  font-family: inherit;
}
html[data-theme="light"] .ms-field input,
html[data-theme="light"] .ms-field select,
html[data-theme="light"] .ms-field textarea {
  background: #f9fafb;
  color: #1a1d26;
  border-color: rgba(0,0,0,0.14);
}
.ms-field textarea {
  min-height: 80px;
  resize: vertical;
}
.ms-btn-primary {
  width: 100%;
  background: var(--accent, #0A84FF);
  color: #000;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.9rem;
  font-weight: 800;
  margin-top: 8px;
}
.ms-btn-primary:disabled { opacity: 0.6; }

.ms-notif-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #12161f;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
}
html[data-theme="light"] .ms-notif-item {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
}
.ms-notif-item.unread {
  border-left: 3px solid var(--accent, #0A84FF);
  background: linear-gradient(90deg, rgba(var(--accent-rgb),0.08), #12161f);
}
.ms-notif-icn {
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.ms-notif-body { flex: 1; min-width: 0; }
.ms-notif-body h5 {
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 2px;
}
.ms-notif-body p {
  font-size: 0.7rem;
  color: #9ba5b8;
  line-height: 1.35;
}
.ms-notif-meta {
  font-size: 0.58rem;
  color: #5a6375;
  margin-top: 4px;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════
   Welcome card (first login)
   ═══════════════════════════════════════════════════════════════════ */
.ms-welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(7,9,13,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.ms-welcome-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.ms-welcome-card {
  background: #12161f;
  color: #edf2fa;
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.13);
  padding: 28px 22px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  font-family: var(--bh-body);
}
html[data-theme="light"] .ms-welcome-card {
  background: #fff;
  color: #1a1d26;
  border-color: rgba(0,0,0,0.14);
}
.ms-welcome-icn {
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent, #0A84FF), #22d3ee);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}
.ms-welcome-icn svg { width: 28px; height: 28px; }
.ms-welcome-card h2 {
  font-size: 1.4rem;
  font-weight: 900;
  margin-bottom: 8px;
}
.ms-welcome-lead {
  font-size: 0.85rem;
  color: #9ba5b8;
  line-height: 1.5;
  margin-bottom: 20px;
}
html[data-theme="light"] .ms-welcome-lead { color: #4b5563; }
.ms-welcome-feats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  text-align: left;
}
.ms-welcome-feat {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
}
html[data-theme="light"] .ms-welcome-feat { background: rgba(0,0,0,0.03); }
.ms-welcome-feat .i {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(var(--accent-rgb),0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.ms-welcome-feat .t { flex: 1; min-width: 0; font-size: 0.78rem; }
.ms-welcome-feat .t strong {
  display: block;
  font-weight: 800;
  margin-bottom: 2px;
}
.ms-welcome-feat .t span {
  font-size: 0.7rem;
  color: #5a6375;
}
.ms-welcome-cta {
  width: 100%;
  background: var(--accent, #0A84FF);
  color: #000;
  border-radius: 14px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 800;
}

/* ═══════════════════════════════════════════════════════════════════
   PWA Install Banner (compact, top-mounted)
   ═══════════════════════════════════════════════════════════════════ */
.ms-pwa-banner {
  position: fixed;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 9998;
  background: #12161f;
  border-bottom: 1px solid rgba(255,255,255,0.13);
  font-family: var(--bh-body);
  color: #edf2fa;
}
html[data-theme="light"] .ms-pwa-banner {
  background: #fff;
  color: #1a1d26;
  border-bottom-color: rgba(0,0,0,0.1);
}
.ms-pwa-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.ms-pwa-icn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
}
.ms-pwa-icn img {
  width: 36px;
  height: 36px;
  display: block;
  border-radius: 10px;
}
.ms-pwa-body { flex: 1; min-width: 0; }
.ms-pwa-body strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 1px;
}
.ms-pwa-body p {
  font-size: 0.65rem;
  color: #5a6375;
  line-height: 1.3;
  margin: 0;
}
.ms-pwa-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.ms-pwa-install {
  background: var(--accent, #0A84FF);
  color: #000;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.7rem;
  font-weight: 800;
}
.ms-pwa-dismiss {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  color: #9ba5b8;
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
html[data-theme="light"] .ms-pwa-dismiss { background: rgba(0,0,0,0.06); color: #4b5563; }

/* ═══════════════════════════════════════════════════════════════════
   Breakpoint adjustments
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .ms-body { padding: 10px 12px 20px; }
  .ms-hero { padding: 16px 14px; }
  .ms-hero-num { font-size: 2.5rem; }
  .ms-perf-num { font-size: 2rem; }
  .ms-tile-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 600px) {
  .ms-body { padding: 14px 22px 24px; }
  .ms-tile-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ───────── Tappable rows (call cards, leaderboard rows, podium) ───── */
@media (max-width: 768px) {
  button.ms-tappable {
    width: 100%;
    text-align: left;
    cursor: pointer;
    border: none;
    font-family: inherit;
    color: inherit;
    transition: transform 0.1s ease, background 0.15s ease;
  }
  button.ms-tappable:active {
    transform: scale(0.98);
    background: var(--ms-card-2) !important;
  }
  button.ms-call.ms-tappable {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--ms-card);
    border: 1px solid var(--ms-border);
    border-radius: 14px;
    margin-bottom: 8px;
    width: 100%;
  }
  button.ms-lb-row.ms-tappable {
    display: grid;
    grid-template-columns: 28px 36px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--ms-card);
    border: 1px solid var(--ms-border);
    border-radius: 12px;
    margin-bottom: 6px;
  }
  button.ms-pd.ms-tappable {
    display: block;
    padding: 14px 6px 10px;
  }
  .ms-lb-divider {
    margin: 16px 4px 8px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ms-text-3);
  }
}

/* ───────── Phoner detail sheet ───────── */
.ms-phoner-sheet {
  padding: 4px 0 12px;
}
.ms-phoner-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.ms-phoner-av {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
}
.ms-phoner-info { flex: 1; min-width: 0; }
.ms-phoner-info h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 2px;
  color: var(--ms-text-1);
}
.ms-phoner-info p {
  font-size: 0.78rem;
  color: var(--ms-text-2);
  margin: 0;
}
.ms-phoner-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.ms-phoner-st {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
html[data-theme="light"] .ms-phoner-st { background: rgba(0,0,0,0.04); }
.ms-phoner-st .v {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ms-text-1);
  font-variant-numeric: tabular-nums;
}
.ms-phoner-st .l {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--ms-text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}
.ms-phoner-action {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--ms-border-2);
  background: var(--ms-card);
  color: var(--ms-text-1);
  font-weight: 800;
  font-size: 0.85rem;
  border-radius: 12px;
  cursor: pointer;
  min-height: 48px;
}
.ms-phoner-action.accent {
  background: linear-gradient(135deg, var(--ms-accent), var(--ms-cyan));
  color: #000;
  border: none;
  box-shadow: 0 6px 20px var(--ms-accent-glow);
}

/* ───────── Loading skeletons + error retry ───────── */
.ms-skel {
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 18px;
  padding: 20px 18px;
  margin-bottom: 14px;
}
.ms-skel-bar {
  background: linear-gradient(90deg, var(--ms-card-2) 25%, var(--ms-card-3) 50%, var(--ms-card-2) 75%);
  background-size: 200% 100%;
  border-radius: 6px;
  animation: msSkel 1.4s ease-in-out infinite;
}
.ms-skel-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.ms-skel-tile {
  height: 78px;
  background: linear-gradient(90deg, var(--ms-card) 25%, var(--ms-card-2) 50%, var(--ms-card) 75%);
  background-size: 200% 100%;
  border: 1px solid var(--ms-border);
  border-radius: 14px;
  animation: msSkel 1.4s ease-in-out infinite;
}
.ms-skel-row {
  height: 56px;
  background: linear-gradient(90deg, var(--ms-card) 25%, var(--ms-card-2) 50%, var(--ms-card) 75%);
  background-size: 200% 100%;
  border: 1px solid var(--ms-border);
  border-radius: 12px;
  margin-bottom: 8px;
  animation: msSkel 1.4s ease-in-out infinite;
}
@keyframes msSkel {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ms-error {
  text-align: center;
  padding: 60px 24px 40px;
}
.ms-error-icn {
  font-size: 2.5rem;
  margin-bottom: 16px;
  color: var(--ms-amber);
}
.ms-error h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--ms-text-1);
}
.ms-error p {
  font-size: 0.85rem;
  color: var(--ms-text-2);
  margin-bottom: 22px;
  line-height: 1.5;
}
.ms-error-retry {
  background: linear-gradient(135deg, var(--ms-accent), var(--ms-cyan));
  color: #000;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  min-height: 48px;
  box-shadow: 0 6px 20px var(--ms-accent-glow);
}

/* ───────── Period pills (leaderboard, me) ───────── */
.ms-pills {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--ms-card);
  border: 1px solid var(--ms-border);
  border-radius: 100px;
  margin-bottom: 14px;
}
.ms-pill {
  flex: 1;
  padding: 8px 10px;
  border-radius: 100px;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ms-text-2);
  background: none;
  border: none;
  cursor: pointer;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ms-pill.active {
  background: var(--ms-accent);
  color: #000;
}

/* ───────── Top performer celebration card ───────── */
.ms-next-celebrate {
  background: linear-gradient(135deg, rgba(var(--accent-rgb),0.18), rgba(34,211,238,0.10));
  border: 1px solid rgba(var(--accent-rgb),0.28);
}

/* ───────── Spinner (used in send-notif button) ───────── */
.ms-spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #000;
  border-radius: 50%;
  animation: msPtrSpin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* ───────── Freshness indicator ("Live · 2 min siden") ───────── */
.ms-freshness {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 8px;
  background: rgba(var(--accent-rgb),0.12);
  border: 1px solid rgba(var(--accent-rgb),0.25);
  border-radius: 100px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ms-accent);
  letter-spacing: 0;
  text-transform: none;
}
.ms-freshness.err {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.35);
  color: var(--ms-red);
}

/* ───────── A11y: focus-visible (keyboard navigation) ───────── */
.ms-shell *:focus { outline: none; }
.ms-shell *:focus-visible {
  outline: 2px solid var(--ms-accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.ms-nav-item:focus-visible,
.ms-nav-fab:focus-visible {
  outline-offset: -2px;
}
.ms-tappable:focus-visible {
  outline-offset: 0;
}

/* ───────── Sheet close button (X) ───────── */
.ms-sheet-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  color: var(--ms-text-2);
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}
html[data-theme="light"] .ms-sheet-close {
  background: rgba(0,0,0,0.04);
  color: var(--ms-text-1);
}
.ms-sheet-close:active { transform: scale(0.92); }

/* ───────── Campaign detail-sheet ───────── */
.ms-camp-sheet { padding: 4px 0 12px; }
.ms-camp-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.ms-camp-icn {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--ms-accent), var(--ms-cyan));
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ms-camp-icn svg { width: 28px; height: 28px; }
.ms-camp-info { flex: 1; min-width: 0; }
.ms-camp-info h3 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 2px;
  color: var(--ms-text-1);
  word-break: break-word;
}
.ms-camp-info p {
  font-size: 0.78rem;
  color: var(--ms-text-2);
  margin: 0;
}
.ms-camp-prog { margin-bottom: 18px; }
.ms-camp-prog-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ms-text-2);
  margin-bottom: 6px;
  font-weight: 600;
}
.ms-camp-pct {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ms-camp-pct.ok { color: var(--ms-accent); }
.ms-camp-pct.warn { color: var(--ms-amber); }
.ms-camp-pct.bad { color: var(--ms-red); }
.ms-camp-sec {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ms-text-3);
  margin: 14px 0 8px;
}
.ms-camp-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--ms-card-2);
  border: 1px solid var(--ms-border);
  border-radius: 12px;
  margin-bottom: 6px;
  text-align: left;
}
.ms-camp-row-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ms-text-1);
}
.ms-camp-row-stat {
  font-size: 0.72rem;
  color: var(--ms-text-2);
  font-variant-numeric: tabular-nums;
}

/* ───────── Sustained tap feedback (50ms held highlight) ───────── */
@keyframes msTapFlash {
  0%   { background: var(--ms-card-3); }
  100% { background: var(--ms-card); }
}
button.ms-tappable:active,
button.ms-tappable:focus:active {
  animation: msTapFlash 0.18s ease-out;
}

/* ───────── Light-mode contrast fixes for freshness err pill ───────── */
html[data-theme="light"] .ms-freshness {
  background: rgba(var(--accent-rgb),0.12);
  color: var(--ms-accent);
  border-color: rgba(var(--accent-rgb),0.35);
}
html[data-theme="light"] .ms-freshness.err {
  background: rgba(217,48,37,0.18);
  color: #c11d1d;
  border-color: rgba(217,48,37,0.45);
}

/* ═══════════════════════════════════════════════════════════════════
   SUBVIEW MODE - when user exits shell to a legacy desktop view via tile/back-pill
   These rules make EVERY desktop view at least usable on 320-768px wide.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  body[data-mobile-shell="subview"] .main-area {
    display: block !important;
    padding: 12px 12px calc(80px + env(safe-area-inset-bottom, 0)) !important;
    width: 100vw;
    overflow-x: hidden;
    background: var(--ms-bg, #07090d);
  }
  body[data-mobile-shell="subview"] .topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    padding: 10px 14px !important;
    flex-wrap: wrap;
    gap: 8px;
  }
  body[data-mobile-shell="subview"] .topbar-actions { gap: 6px; }
  body[data-mobile-shell="subview"] .topbar-title {
    font-size: 1.1rem !important;
    font-weight: 800;
  }
  body[data-mobile-shell="subview"] .content-wrapper {
    padding: 0 !important;
    margin: 0 !important;
  }
  /* Force any KPI grid to single/double column on mobile */
  body[data-mobile-shell="subview"] [class*="grid"]:not(.ms-shell *),
  body[data-mobile-shell="subview"] [class*="kpi"]:not(.ms-shell *),
  body[data-mobile-shell="subview"] .bv-dash-3,
  body[data-mobile-shell="subview"] .bv-dash-4,
  body[data-mobile-shell="subview"] .bv-dash-5,
  body[data-mobile-shell="subview"] .ds-dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  body[data-mobile-shell="subview"] .bv-grid-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  /* Tables: horizontal scroll wrapper */
  body[data-mobile-shell="subview"] table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    white-space: nowrap;
  }
  body[data-mobile-shell="subview"] table th,
  body[data-mobile-shell="subview"] table td {
    padding: 8px 10px !important;
    font-size: 0.78rem !important;
  }
  /* Tap targets - 44px minimum */
  body[data-mobile-shell="subview"] button,
  body[data-mobile-shell="subview"] a.btn,
  body[data-mobile-shell="subview"] input[type="submit"],
  body[data-mobile-shell="subview"] .ds-btn,
  body[data-mobile-shell="subview"] .bv-btn {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 0.85rem !important;
  }
  /* Inputs - 16px min to prevent iOS zoom */
  body[data-mobile-shell="subview"] input:not([type="checkbox"]):not([type="radio"]),
  body[data-mobile-shell="subview"] select,
  body[data-mobile-shell="subview"] textarea {
    font-size: 16px !important;
    min-height: 44px !important;
    padding: 10px !important;
  }
  /* Cards - full width */
  body[data-mobile-shell="subview"] .card,
  body[data-mobile-shell="subview"] [class*="card"]:not(.ms-shell *) {
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 10px;
  }
  /* Charts - constrain height */
  body[data-mobile-shell="subview"] canvas {
    max-width: 100% !important;
    height: auto !important;
    max-height: 280px !important;
  }
  /* Hide super-dense desktop controls that don't make sense on mobile */
  body[data-mobile-shell="subview"] .desktop-only,
  body[data-mobile-shell="subview"] .hide-mobile {
    display: none !important;
  }
  /* Period/location filters: stack vertically with full width */
  body[data-mobile-shell="subview"] .view-period-filter,
  body[data-mobile-shell="subview"] .view-location-filter,
  body[data-mobile-shell="subview"] [class*="filter-row"] {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    width: 100%;
  }
  body[data-mobile-shell="subview"] .view-period-filter select,
  body[data-mobile-shell="subview"] .view-location-filter select {
    width: 100% !important;
  }
}

/* ═══ MORE PROMINENT BACK-PILL - bottom-center floating ═══════════ */
@media (max-width: 768px) {
  .ms-back-pill {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 0));
    left: 50%;
    transform: translateX(-50%);
    z-index: 9994;
    display: flex;
    gap: 8px;
    align-items: center;
    background: linear-gradient(135deg, var(--ms-accent, var(--accent, #0A84FF)), var(--ms-cyan, #22d3ee));
    color: #000;
    border: none;
    border-radius: 100px;
    padding: 12px 20px;
    font-size: 0.85rem;
    font-weight: 800;
    box-shadow: 0 8px 24px var(--ms-accent-glow, rgba(var(--accent-rgb),0.5));
    cursor: pointer;
    min-height: 48px;
  }
  .ms-back-pill:active { transform: translateX(-50%) scale(0.96); }
  .ms-back-pill svg {
    width: 18px;
    height: 18px;
  }
  .ms-back-pill-sub {
    color: rgba(0,0,0,0.7);
    font-weight: 700;
    margin-left: 4px;
  }
}

/* ═══ MISSING CSS for .ms-search (leaderboard search input) ═══════ */
@media (max-width: 768px) {
  .ms-search {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 14px;
    padding: 10px 14px;
    background: var(--ms-card);
    border: 1px solid var(--ms-border);
    border-radius: 12px;
  }
  .ms-search-icn {
    color: var(--ms-text-3);
    flex-shrink: 0;
    display: flex;
  }
  .ms-search-icn svg { width: 18px; height: 18px; }
  .ms-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--ms-text-1);
    font-size: 16px; /* prevent iOS zoom */
    font-family: inherit;
    outline: none;
    min-width: 0;
  }
  .ms-search-input::placeholder { color: var(--ms-text-3); }
  .ms-search-clear {
    background: var(--ms-card-2);
    border: none;
    color: var(--ms-text-2);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ═══ LIGHT MODE PARITY - fix gradient + skeleton + form labels ═══ */
@media (max-width: 768px) {
  html[data-theme="light"] .ms-skel-bar {
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  }
  html[data-theme="light"] .ms-skel-tile,
  html[data-theme="light"] .ms-skel-row {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  }
  html[data-theme="light"] .ms-hero-num {
    background: linear-gradient(135deg, var(--ms-text-1) 30%, var(--ms-accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
  html[data-theme="light"] .ms-form-field label,
  html[data-theme="light"] .ms-field label {
    color: var(--ms-text-2);
  }
  html[data-theme="light"] .ms-pwa-body p {
    color: var(--ms-text-2);
  }
  html[data-theme="light"] .ms-welcome-icn {
    background: linear-gradient(135deg, var(--ms-accent), var(--ms-cyan));
  }
  /* Tap targets - pills + section links 44px min */
  .ms-pill {
    min-height: 44px !important;
  }
  /* Smaller phones (iPhone SE 320px) */
  @media (max-width: 320px) {
    .ms-hero-num { font-size: 2rem !important; }
    .ms-body { padding: 8px 10px 16px !important; }
    .ms-tile-grid { grid-template-columns: 1fr 1fr !important; }
  }
}

/* ───────── Universal launcher (FAB sheet content) - Wolt-quality polish ───────── */
@media (max-width: 768px) {
  .ms-launcher { padding: 4px 0 8px; }
  .ms-launcher-head { margin-bottom: 16px; }
  .ms-launcher-eyebrow {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ms-accent);
    margin-bottom: 6px;
  }
  .ms-launcher-title {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -0.015em;
    color: var(--ms-text-1);
    margin: 0;
    line-height: 1.15;
  }
  .ms-launcher-search-wrap {
    margin-bottom: 18px;
  }
  /* Top action cards - full width, premium horizontal layout with arrow */
  .ms-launcher-top {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
  }
  .ms-launcher-top-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: transform 0.12s cubic-bezier(0.4,0,0.2,1), box-shadow 0.2s;
    border: 1px solid var(--ms-border);
    position: relative;
    overflow: hidden;
  }
  .ms-launcher-top-btn:active { transform: scale(0.985); }
  .ms-launcher-top-btn.primary {
    background: linear-gradient(135deg, rgba(var(--accent-rgb),0.14), rgba(34,211,238,0.08));
    border-color: rgba(var(--accent-rgb),0.32);
    box-shadow: 0 4px 18px rgba(var(--accent-rgb),0.12);
  }
  .ms-launcher-top-btn.primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 100% 50%, rgba(var(--accent-rgb),0.18), transparent 70%);
    pointer-events: none;
  }
  .ms-launcher-top-btn.secondary {
    background: var(--ms-card);
    border-color: var(--ms-border);
  }
  .ms-launcher-top-icn-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
  }
  .ms-launcher-top-btn.primary .ms-launcher-top-icn-wrap {
    background: var(--ms-accent);
    color: #000;
    box-shadow: 0 4px 12px var(--ms-accent-glow);
  }
  .ms-launcher-top-btn.secondary .ms-launcher-top-icn-wrap {
    background: rgba(167,139,250,0.16);
    color: var(--ms-purple);
  }
  .ms-launcher-top-icn-wrap svg { width: 22px; height: 22px; }
  .ms-launcher-top-meta { flex: 1; min-width: 0; position: relative; z-index: 1; }
  .ms-launcher-top-lbl {
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--ms-text-1);
    line-height: 1.2;
    letter-spacing: -0.005em;
  }
  .ms-launcher-top-sub {
    font-size: 0.7rem;
    color: var(--ms-text-2);
    margin-top: 3px;
    font-weight: 500;
  }
  .ms-launcher-top-arrow {
    color: var(--ms-text-3);
    font-size: 1.2rem;
    font-weight: 600;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    transition: transform 0.15s;
  }
  .ms-launcher-top-btn:active .ms-launcher-top-arrow { transform: translateX(3px); }
  /* Section header with count badge */
  .ms-launcher-sec {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ms-text-3);
    margin: 22px 4px 10px;
  }
  .ms-launcher-count {
    background: var(--ms-card-2);
    color: var(--ms-text-2);
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
  }
}
