/* ==========================================================================
   GolfCoach Pro - Design System & Mobile-First Base Styles
   Luxury Augusta Green & Champagne Gold Theme
   ========================================================================== */

:root {
  /* Brand Palette - Luxury Golf */
  --primary-900: #061c11;
  --primary-800: #0b2e1c;
  --primary-700: #104229;
  --primary-600: #185c3b;
  --primary-500: #228052;
  --primary-400: #34a86f;
  --primary-300: #62c794;
  --primary-200: #a1e2bf;
  --primary-100: #d8f5e6;
  --primary-50: #edfbf4;

  /* Gold / Champagne Accents */
  --gold-700: #8c6a21;
  --gold-600: #b28a2c;
  --gold-500: #d4af37;
  --gold-400: #e2c45e;
  --gold-fill-400: #e2c45e;
  --gold-300: #eed88c;
  --gold-200: #f7ebbe;
  --gold-100: #fdf8e6;

  /* Neutral Dark (Default Dark Mode) */
  --bg-main: #0a0f0d;
  --bg-surface: #121915;
  --bg-surface-elevated: #18221d;
  --bg-surface-glass: rgba(18, 25, 21, 0.82);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(212, 175, 55, 0.25);
  
  --text-main: #f3f5f4;
  --text-muted: #94a39b;
  --text-subtle: #819188;
  --text-gold: #e2c45e;
  --focus-ring: #f7d96f;
  --status-error-text: #f5a5a5;
  --primary-fill-300: #62c794;

  /* Status Colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  /* Scores (Golf scoring colors) */
  --score-eagle: #eab308;
  --score-birdie: #ef4444;
  --score-par: #94a3b8;
  --score-bogey: #3b82f6;
  --score-double: #1e293b;

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Type scale: one shared rhythm for navigation, content and forms */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --leading-tight: 1.2;
  --leading-snug: 1.4;
  --leading-normal: 1.55;
  --tracking-tight: -0.015em;
  --tracking-label: 0.055em;

  /* 4 px spacing scale used throughout the product */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --content-gutter: 1.5rem;
  --layout-gap: 1.25rem;
  --section-gap: 1.5rem;
  --card-padding: 1.25rem;

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 25px rgba(212, 175, 55, 0.15);
  --shadow-glow: 0 0 30px rgba(34, 128, 82, 0.25);

  --transition-fast: 0.18s ease;
  --transition-normal: 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  /* Mobile Safe Areas */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* El workspace local nunca se expone sin una identidad de entrenador. */
body.workspace-locked .sidebar .nav-menu,
body.workspace-locked .sidebar-footer,
body.workspace-locked #workspace-player-context,
body.workspace-locked .workspace-context-divider,
body.workspace-locked .coach-bottom-nav,
body.workspace-locked #mobile-drawer-toggle-btn,
body.workspace-locked #profile-settings-btn,
body.workspace-locked #topbar-new-round-btn {
  display: none !important;
}

[hidden] {
  display: none !important;
}

body.workspace-empty .nav-item:not([data-view="dashboard"]):not([data-view="players"]),
body.workspace-empty .bottom-nav-item:not([data-view="dashboard"]):not([data-view="players"]) {
  opacity: 0.42;
}

.secure-entry-card,
.empty-workspace-card {
  padding: clamp(1.5rem, 4vw, 3rem);
  margin: clamp(1rem, 5vh, 3rem) auto;
  max-width: 820px;
}

.onboarding-shell {
  overflow: hidden;
  padding: 0;
}

.onboarding-hero {
  padding: clamp(1.5rem, 4vw, 2.75rem);
  background:
    radial-gradient(circle at 90% 0%, rgba(212, 175, 55, 0.16), transparent 38%),
    linear-gradient(145deg, rgba(24, 92, 59, 0.32), rgba(18, 25, 21, 0.96));
}

[data-theme="light"] .onboarding-hero {
  background:
    radial-gradient(circle at 90% 0%, rgba(212, 175, 55, 0.13), transparent 38%),
    linear-gradient(145deg, rgba(216, 245, 230, 0.72), rgba(255, 255, 255, 0.98));
}

.onboarding-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.onboarding-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.15rem;
}

.demo-mode-notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(212, 175, 55, 0.48);
  border-radius: var(--radius-md);
  background: rgba(212, 175, 55, 0.08);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.demo-mode-notice strong {
  color: var(--gold-400);
}

.demo-mode-notice-icon {
  font-size: 1.15rem;
}

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border-top: 1px solid var(--border-subtle);
}

.onboarding-step {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  padding: 0.9rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.onboarding-step-number {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-weight: 800;
}

.onboarding-step.complete .onboarding-step-number {
  border-color: rgba(52, 168, 111, 0.5);
  background: rgba(52, 168, 111, 0.14);
  color: var(--primary-300);
}

.onboarding-step.active {
  border-color: rgba(212, 175, 55, 0.48);
  background: rgba(212, 175, 55, 0.06);
}

.onboarding-step.active .onboarding-step-number {
  border-color: var(--gold-500);
  color: var(--gold-400);
}

.onboarding-step strong,
.onboarding-check-copy strong {
  display: block;
  color: var(--text-main);
  font-size: 0.9rem;
}

.onboarding-step small,
.onboarding-check-copy small {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-subtle);
  line-height: 1.4;
}

.onboarding-checklist {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.onboarding-check {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
}

.onboarding-check-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-subtle);
  font-size: 0.76rem;
  font-weight: 800;
}

.onboarding-check.complete .onboarding-check-icon {
  background: rgba(52, 168, 111, 0.16);
  color: var(--primary-300);
}

.form-section {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.form-section-title {
  margin-bottom: 0.8rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.optional-fields {
  margin-bottom: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.optional-fields summary {
  padding: 0.95rem 1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 700;
}

.optional-fields-content {
  padding: 0 1rem 1rem;
}

.form-status {
  min-height: 1.25rem;
  margin-top: 0.65rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.form-status.error {
  color: var(--status-error-text);
}

.empty-state-panel {
  padding: clamp(1.4rem, 4vw, 2.5rem);
  text-align: center;
}

.empty-state-panel .card-icon {
  margin: 0 auto 0.8rem;
}

.dashboard-kpi-grid {
  margin-bottom: 1.5rem;
}

.dashboard-kpi-value-gold {
  color: var(--gold-400);
}

.dashboard-kpi-value-round {
  font-size: 1.4rem;
}

.dashboard-kpi-value-profile {
  color: var(--primary-300);
  font-size: 1rem;
  line-height: 1.3;
}

.dashboard-kpi-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .onboarding-checklist {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .onboarding-steps,
  .onboarding-checklist {
    grid-template-columns: 1fr;
  }
}

/* Light Theme Mode */
[data-theme="light"] {
  --bg-main: #f4f7f5;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f0f4f1;
  --bg-surface-glass: rgba(255, 255, 255, 0.9);
  --border-subtle: rgba(16, 66, 41, 0.1);
  --border-strong: rgba(178, 138, 44, 0.35);

  --text-main: #0c1811;
  --text-muted: #4e6356;
  --text-subtle: #5b7063;
  --text-gold: #76570d;
  --gold-400: #76570d;
  --primary-300: #17633f;
  --primary-200: #174e35;
  --focus-ring: #6b4e08;
  --status-error-text: #b42318;

  --shadow-sm: 0 2px 10px rgba(11, 46, 28, 0.06);
  --shadow-md: 0 10px 30px rgba(11, 46, 28, 0.08);
  --shadow-lg: 0 20px 48px rgba(11, 46, 28, 0.12);
  --shadow-gold: 0 0 25px rgba(178, 138, 44, 0.12);
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

.skip-link {
  position: fixed;
  z-index: 3000;
  top: max(0.5rem, var(--sat));
  left: max(0.5rem, var(--sal));
  padding: 0.75rem 1rem;
  border: 2px solid var(--focus-ring);
  border-radius: var(--radius-md);
  color: var(--text-main);
  background: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  font-weight: 800;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: var(--leading-normal);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(24, 92, 59, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(212, 175, 55, 0.06) 0%, transparent 35%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.auth-resolving-screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1.5rem;
  text-align: left;
}

.auth-resolving-screen > div:last-child {
  display: flex;
  flex-direction: column;
}

.auth-resolving-screen strong {
  font-family: var(--font-heading);
  font-size: 1.15rem;
}

.auth-resolving-screen span {
  color: var(--text-muted);
  font-size: 0.8rem;
}

body.auth-resolving .auth-resolving-screen {
  display: flex;
}

body.auth-resolving .app-container,
body.auth-resolving .mobile-drawer-overlay,
body.auth-resolving .modal-overlay,
body.auth-resolving .toast-container {
  display: none !important;
}

/* Typography elements */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p {
  color: var(--text-muted);
  line-height: var(--leading-normal);
}

a {
  color: var(--gold-400);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--gold-300);
}

/* Layout Containers */
.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar Navigation (Desktop) */
.sidebar {
  width: 280px;
  background: var(--bg-surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 1.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-badge {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary-700), var(--primary-500));
  border: 1px solid var(--gold-500);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-gold);
  color: var(--gold-400);
  font-size: 1.35rem;
}

.brand-info h2 {
  font-size: var(--text-lg);
  font-weight: 800;
  letter-spacing: var(--tracking-tight);
  background: linear-gradient(90deg, #ffffff, var(--gold-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .brand-info h2 {
  background: linear-gradient(90deg, var(--text-main), var(--text-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  font-weight: 600;
  display: block;
}

.nav-menu {
  list-style: none;
  padding: 1rem 0.75rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  user-select: none;
  background: transparent;
  font: inherit;
  text-align: left;
}

.nav-item:active, .nav-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(24, 92, 59, 0.6), rgba(16, 66, 41, 0.85));
  border-color: rgba(212, 175, 55, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.nav-item .nav-icon {
  font-size: 1.15rem;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
}

.nav-item.active .nav-icon {
  color: var(--gold-300);
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.5));
}

.nav-item .badge-count {
  margin-left: auto;
  background: var(--gold-500);
  color: #061c11;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.15);
}

.player-context-label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--text-subtle);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.player-mini-card {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.2rem;
  border: 0;
  border-radius: var(--radius-md);
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--gold-600), var(--gold-fill-400));
  color: #0c1811;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.player-mini-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.player-mini-info .player-mini-name {
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-mini-info .player-mini-meta {
  font-size: var(--text-xs);
  color: var(--text-gold);
  font-weight: 500;
}

/* Main Content Area */
.main-content {
  margin-left: 280px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: calc(100% - 280px);
}

/* Top Navigation Bar */
.topbar {
  height: 64px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.35rem;
  cursor: pointer;
  padding: 0.5rem;
}

.page-title {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
}

.demo-mode-indicator {
  min-height: 44px;
  padding: 0.35rem 0.65rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  color: #171307;
  background: linear-gradient(135deg, var(--gold-fill-400), var(--gold-600));
  border: 1px solid rgba(255, 225, 118, 0.72);
  border-radius: var(--radius-full);
  box-shadow: 0 5px 18px rgba(212, 175, 55, 0.2);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 850;
  cursor: pointer;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.mobile-topbar-actions-btn,
.topbar-action-label {
  display: none;
}

.mobile-topbar-actions-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.mobile-topbar-actions-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.btn-icon {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.btn-icon:hover, .btn-icon:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--gold-400);
  color: var(--gold-400);
}

/* Keeps the signed-in account separate from the golfer whose data is open. */
.workspace-context-bar {
  min-height: 52px;
  padding: 0.45rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 64px;
  z-index: 80;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.workspace-context-control {
  min-width: 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.55rem;
  color: var(--text-main);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.workspace-context-control:hover,
.workspace-context-control:focus-visible {
  background: var(--bg-surface-elevated);
  border-color: var(--border-strong);
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.workspace-account-context {
  flex: 0 1 280px;
}

.workspace-player-context {
  flex: 1;
}

.workspace-context-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  font-size: 0.9rem;
}

.workspace-context-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: var(--leading-tight);
}

.workspace-context-copy strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-context-label {
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.workspace-context-divider {
  width: 1px;
  height: 26px;
  flex: 0 0 1px;
  background: var(--border-subtle);
}

.workspace-player-handicap {
  margin-left: auto;
  padding: 0.2rem 0.5rem;
  color: var(--gold-400);
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
}

.workspace-context-change {
  color: var(--primary-300);
  font-size: var(--text-xs);
  font-weight: 700;
}

/* Viewport Panels */
.view-panel {
  display: none;
  padding: var(--content-gutter);
  animation: fadeIn 0.25s ease-in-out;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.view-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   MOBILE-FIRST BOTTOM NAVIGATION BAR & DRAWER
   ========================================================================== */

.bottom-nav-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + var(--sab));
  padding-bottom: var(--sab);
  background: var(--bg-surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 120;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  height: 100%;
  color: var(--text-muted);
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

.bottom-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  transition: transform var(--transition-fast), color var(--transition-fast);
}

.bottom-nav-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0;
}

.bottom-nav-item.active {
  color: var(--gold-400);
}

.bottom-nav-item.active .bottom-nav-icon {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.5));
}

/* Mobile Drawer Overlay */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 150;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.mobile-drawer-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-drawer-content {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 82%;
  max-width: 320px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-strong);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
}

.mobile-drawer-overlay.active .mobile-drawer-content {
  transform: translateX(0);
}

/* Responsive Media Queries (< 1024px and < 768px Mobile Phones) */
@media (max-width: 1024px) {
  :root {
    --content-gutter: 1rem;
    --section-gap: 1.25rem;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    /* Extra padding at the bottom so content isn't covered by bottom nav */
    padding-bottom: calc(75px + var(--sab));
  }

  .bottom-nav-bar {
    display: flex;
  }

  .menu-toggle-btn {
    display: block;
  }

  .topbar {
    padding: 0 1rem;
  }

  .workspace-context-bar {
    top: 64px;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
  }

  .workspace-context-control {
    gap: 0.4rem;
    padding: 0.3rem;
  }

  .workspace-account-context {
    flex: 0 1 42%;
  }

  .workspace-context-change,
  .workspace-player-handicap {
    display: none;
  }

  .workspace-context-icon {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    font-size: 0.86rem;
  }

  .view-panel {
    padding: var(--content-gutter) 0.85rem;
  }

  .grid-4.dashboard-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.1rem;
  }

  .dashboard-kpi-grid .stat-card {
    min-width: 0;
    min-height: 108px;
    padding: 0.8rem 0.9rem;
    border-radius: var(--radius-md);
  }

  .dashboard-kpi-grid .stat-label {
    margin-bottom: 0;
    font-size: 0.6875rem;
    line-height: 1.2;
  }

  .dashboard-kpi-grid .stat-value {
    margin-top: 0.3rem;
    font-size: 1.5rem;
  }

  .dashboard-kpi-grid .dashboard-kpi-value-round {
    font-size: 1.2rem;
  }

  .dashboard-kpi-grid .dashboard-kpi-value-profile {
    overflow: hidden;
    font-size: 0.92rem;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard-kpi-grid .stat-sub {
    min-width: 0;
    margin-top: 0.25rem;
    overflow: hidden;
    font-size: 0.6875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding-left: max(0.75rem, var(--sal));
    padding-right: max(0.65rem, var(--sar));
  }

  .topbar-left {
    min-width: 0;
    flex: 1;
  }

  #mobile-drawer-toggle-btn {
    display: none;
  }

  .page-title {
    min-width: 0;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .demo-mode-indicator {
    min-height: 44px;
    padding: 0.3rem 0.5rem;
    font-size: 0.66rem;
  }

  .demo-mode-notice {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 0.75rem;
  }

  .demo-mode-notice .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .onboarding-actions .btn {
    width: 100%;
  }

  .mobile-topbar-actions-btn {
    display: flex;
  }

  .mobile-topbar-actions-btn[aria-expanded="true"] {
    color: var(--gold-400);
    border-color: var(--border-strong);
    background: rgba(212, 175, 55, 0.1);
  }

  .topbar-actions {
    display: none;
    position: absolute;
    top: calc(100% + 0.45rem);
    right: max(0.65rem, var(--sar));
    width: min(270px, calc(100vw - 1.3rem));
    padding: 0.55rem;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
  }

  .topbar-actions.mobile-actions-open {
    display: flex;
  }

  .topbar-actions .btn,
  .topbar-actions .btn-icon {
    width: 100%;
    min-height: 46px;
    height: auto;
    padding: 0.7rem 0.85rem;
    justify-content: flex-start;
    gap: 0.7rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 650;
  }

  .topbar-actions .btn-icon {
    background: transparent;
  }

  .topbar-actions .pwa-install-button::before {
    content: none;
  }

  .topbar-action-label {
    display: inline;
  }

  #topbar-new-round-btn {
    order: -1;
  }
}

@media (max-width: 480px) {
  :root {
    --content-gutter: 0.75rem;
    --layout-gap: 0.75rem;
    --section-gap: 1rem;
    --card-padding: 1rem;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.0625rem; }

  .topbar {
    height: 58px;
  }

  .workspace-context-bar {
    top: 58px;
  }

  .view-panel {
    padding: var(--content-gutter) 0.65rem;
  }

  .grid-4.dashboard-kpi-grid {
    gap: 0.55rem;
    margin-bottom: 0.9rem;
  }

  .dashboard-kpi-grid .stat-card {
    min-height: 98px;
    padding: 0.7rem 0.75rem;
  }

  .dashboard-kpi-grid .stat-label {
    font-size: 0.6875rem;
    letter-spacing: 0.035em;
  }

  .dashboard-kpi-grid .stat-value {
    font-size: 1.35rem;
  }

  .dashboard-kpi-grid .dashboard-kpi-value-round {
    font-size: 1.05rem;
  }

  .dashboard-kpi-grid .dashboard-kpi-value-profile {
    font-size: 0.82rem;
  }

  .dashboard-kpi-grid .stat-sub {
    font-size: 0.6875rem;
  }
}

/* Authenticated golfers get a focused portal instead of coach controls. */
body.player-portal-active .sidebar,
body.player-portal-active .coach-bottom-nav,
body.player-portal-active .mobile-drawer-overlay,
body.player-portal-active #mobile-drawer-toggle-btn,
body.player-portal-active #profile-settings-btn,
body.player-portal-active #topbar-new-round-btn,
body.player-portal-active #cloud-sync-btn,
body.player-portal-active #workspace-context-bar {
  display: none !important;
}

body.player-portal-active .main-content {
  margin-left: 0;
  width: 100%;
  padding-bottom: 0;
}

body.player-portal-active #player-portal-panel {
  max-width: 1180px;
  padding-bottom: calc(2rem + var(--sab));
}

body.player-portal-active .topbar {
  padding-left: max(1rem, var(--sal));
  padding-right: max(1rem, var(--sar));
}

@media (max-width: 1024px) {
  body.player-portal-active .main-content {
    padding-bottom: calc(75px + var(--sab));
  }

  body.player-portal-active #player-portal-panel {
    padding-bottom: calc(1.25rem + var(--sab));
  }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-700);
  border-radius: 3px;
}
