/**
 * BINARY FUND PRO - UNIFIED CORE DESIGN SYSTEM & FOUNDATION (bfp-core.css)
 * Version: 2.0.0 Production Upgrade
 *
 * Provides consolidated design tokens, typography normalization, responsive grid,
 * mobile drawer navigation, buttons, forms, tables, modals, and iOS safe-area handling.
 */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@500;600;700;800;900&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400;1,600&display=swap');

:root {
  /* ==========================================================
     1. COLOR SYSTEM (Canonical Binary Fund Pro Theme)
     ========================================================== */
  --canvas: #07142A;
  --canvas-deep: #040D1D;
  --canvas-panel: #0D1F3C;
  --panel: rgba(12, 30, 58, 0.88);
  --panel-solid: #0D1F3C;
  --panel-card: #0D2140;
  --panel-card-hover: #132C54;
  --panel-light: rgba(19, 44, 82, 0.85);

  /* Primary Accent: Emerald Green (High Trust, Growth, Primary CTA) */
  --accent: #10D98A;
  --accent-hover: #0EB775;
  --accent-glow: rgba(16, 217, 138, 0.32);
  --accent-subtle: rgba(16, 217, 138, 0.12);
  --accent-border: rgba(16, 217, 138, 0.28);

  /* Gold (VIP, Challenge Promo, #1 Podium) */
  --gold: #F59E0B;
  --gold-hover: #D97706;
  --gold-glow: rgba(245, 158, 11, 0.32);
  --gold-subtle: rgba(245, 158, 11, 0.12);
  --gold-border: rgba(245, 158, 11, 0.3);

  /* Cyan & Institutional Blue */
  --blue: #0074FF;
  --blue-hover: #005ECC;
  --blue-glow: rgba(0, 116, 255, 0.32);
  --blue-subtle: rgba(0, 116, 255, 0.12);
  --cyan: #00E5FF;
  --cyan-glow: rgba(0, 229, 255, 0.32);
  --cyan-subtle: rgba(0, 229, 255, 0.12);

  /* Danger & Loss */
  --danger: #FF4B55;
  --red: #FF4B55;
  --danger-hover: #E03E48;
  --danger-glow: rgba(255, 75, 85, 0.32);
  --danger-subtle: rgba(255, 75, 85, 0.12);

  /* Text Hierarchy */
  --text-primary: #F0F4FA;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #040D1D;

  /* Borders & Surfaces */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-glow: rgba(16, 217, 138, 0.35);

  /* ==========================================================
     2. LEGACY COMPATIBILITY ALIASES
     ========================================================== */
  --bg: var(--canvas-deep);
  --bg-dark: var(--canvas-deep);
  --bg-panel: #0B162C;
  --bg-rail: #0A1428;
  --bg-card: var(--panel-card);
  --bg-card-hover: var(--panel-card-hover);
  --tp: var(--text-primary);
  --ts: var(--text-secondary);
  --tm: var(--text-muted);

  /* ==========================================================
     3. TYPOGRAPHY SYSTEM (Single Source of Truth)
     ========================================================== */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Typographic Aliases */
  --font-sans: var(--font-body);
  --font-main: var(--font-body);
  --display: var(--font-display);
  --mono: var(--font-mono);

  /* ==========================================================
     4. ELEVATIONS, RADII & SPACING
     ========================================================== */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow-accent: 0 0 28px rgba(16, 217, 138, 0.24);
  --shadow-glow-gold: 0 0 28px rgba(245, 158, 11, 0.24);

  --header-height: 72px;

  /* iOS Safe Area Insets */
  --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);
}

/* ==========================================================
   5. BASE RESET & BOX SIZING
   ========================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--canvas);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 50% 0%, #0F2A52 0%, var(--canvas) 65%, var(--canvas-deep) 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
}

body.bfp-scroll-locked {
  overflow: hidden !important;
  touch-action: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* Code & Monospace Elements */
code, pre, .mono, [data-mono] {
  font-family: var(--font-mono) !important;
}

/* ==========================================================
   6. UNIFIED SITE HEADER (72px desktop, responsive)
   ========================================================== */
.bfp-header {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  z-index: 1000;
  background: rgba(7, 20, 42, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.bfp-header-container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.bfp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.bfp-brand-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
}

.bfp-brand-text {
  display: flex;
  flex-direction: column;
}

.bfp-brand-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #FFFFFF;
}

.bfp-brand-title span {
  color: var(--accent);
}

.bfp-brand-tag {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Header Nav Links */
.bfp-nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  list-style: none;
}

.bfp-nav-link {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  position: relative;
  padding: 6px 0;
}

.bfp-nav-link:hover,
.bfp-nav-link.active {
  color: #FFFFFF;
}

.bfp-nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: var(--shadow-glow-accent);
}

.bfp-nav-link .badge-hot {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.18);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.35);
  margin-left: 6px;
  vertical-align: middle;
}

/* Header Action Buttons */
.bfp-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Mobile Hamburger Toggle */
.bfp-hamburger {
  display: none;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
}

.bfp-hamburger:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================
   7. OFF-CANVAS MOBILE NAVIGATION DRAWER
   ========================================================== */
.bfp-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 24, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.bfp-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.bfp-mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(340px, calc(100vw - 32px));
  height: 100vh;
  height: 100dvh;
  background: #081730;
  border-left: 1px solid var(--border-strong);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
  z-index: 2001;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding-top: var(--sat);
  padding-bottom: var(--sab);
}

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

.bfp-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.bfp-drawer-close {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  transition: all 0.2s ease;
}

.bfp-drawer-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

.bfp-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.bfp-drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bfp-drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.bfp-drawer-link:hover,
.bfp-drawer-link.active {
  color: #FFFFFF;
  background: rgba(16, 217, 138, 0.08);
  border-color: rgba(16, 217, 138, 0.2);
}

.bfp-drawer-foot {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ==========================================================
   8. UNIFIED BUTTON SYSTEM
   ========================================================== */
.bfp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 700;
  padding: 12px 22px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
}

.bfp-btn:active {
  transform: scale(0.98);
}

/* Primary Emerald CTA */
.bfp-btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 4px 18px rgba(16, 217, 138, 0.28);
}

.bfp-btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 24px rgba(16, 217, 138, 0.42);
  color: var(--text-inverse);
}

/* Secondary / Dark Outlined */
.bfp-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
  border: 1px solid var(--border-strong);
}

.bfp-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: #FFFFFF;
}

/* Gold Promo CTA */
.bfp-btn-gold {
  background: var(--gold);
  color: #040D1D;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.28);
}

.bfp-btn-gold:hover {
  background: var(--gold-hover);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.42);
}

/* Outline Emerald */
.bfp-btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.bfp-btn-outline:hover {
  background: rgba(16, 217, 138, 0.1);
  border-color: var(--accent);
}

/* Danger Button */
.bfp-btn-danger {
  background: var(--danger);
  color: #FFFFFF;
  box-shadow: 0 4px 18px rgba(255, 75, 85, 0.28);
}

.bfp-btn-danger:hover {
  background: var(--danger-hover);
}

/* Sizes */
.bfp-btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
  min-height: 36px;
}

.bfp-btn-lg {
  padding: 16px 28px;
  font-size: 1.05rem;
  min-height: 52px;
  border-radius: var(--radius-md);
}

.bfp-btn-block {
  width: 100%;
}

/* ==========================================================
   9. UNIFIED CARD SYSTEM & GLASSMORPHISM
   ========================================================== */
.bfp-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.bfp-card-hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}

.bfp-card-accent {
  border-color: var(--accent-border);
  background: linear-gradient(180deg, rgba(16, 217, 138, 0.05) 0%, rgba(13, 31, 60, 0.8) 100%);
}

.bfp-card-gold {
  border-color: var(--gold-border);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.06) 0%, rgba(13, 31, 60, 0.8) 100%);
}

/* ==========================================================
   10. FORM INPUTS & iOS SAFARI ZOOM FIX
   ========================================================== */
.bfp-form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.bfp-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.bfp-input,
.bfp-select,
.bfp-textarea {
  width: 100%;
  min-height: 46px;
  padding: 12px 16px;
  background: rgba(3, 11, 24, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-family: var(--font-body);
  font-size: 16px !important; /* CRITICAL: Strictly prevents iOS Safari viewport auto-zoom */
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bfp-input:focus,
.bfp-select:focus,
.bfp-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16, 217, 138, 0.18);
}

.bfp-input::placeholder {
  color: var(--text-muted);
}

/* ==========================================================
   11. RESPONSIVE TABLES & HORIZONTAL OVERFLOW SHIELD
   ========================================================== */
.bfp-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-card);
}

.bfp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.bfp-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 14px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.bfp-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

.bfp-table tr:last-child td {
  border-bottom: none;
}

.bfp-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================================
   12. UNIFIED MODAL COMPONENT
   ========================================================== */
.bfp-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 24, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.bfp-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bfp-modal-content {
  background: #091A36;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  width: min(520px, calc(100% - 24px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.bfp-modal-overlay.active .bfp-modal-content {
  transform: scale(1) translateY(0);
}

.bfp-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.bfp-modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: all 0.2s ease;
}

.bfp-modal-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

/* ==========================================================
   13. TOAST NOTIFICATIONS
   ========================================================== */
#bfpToastContainer {
  position: fixed;
  bottom: calc(24px + var(--sab));
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}

.bfp-toast {
  background: #0D2140;
  border: 1px solid var(--border-strong);
  color: #FFFFFF;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  animation: bfpToastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bfp-toast.success { border-color: var(--accent); }
.bfp-toast.error { border-color: var(--danger); }
.bfp-toast.gold { border-color: var(--gold); }

@keyframes bfpToastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================
   14. RESPONSIVE BREAKPOINT RULES
   ========================================================== */
@media (max-width: 1024px) {
  .bfp-nav-links {
    display: none;
  }
  .bfp-hamburger {
    display: inline-flex;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }
  .bfp-header {
    padding: 0 16px;
  }
  .bfp-card {
    padding: 18px;
  }
  .bfp-modal-content {
    padding: 20px;
    width: calc(100% - 16px);
  }
}

@media (max-width: 480px) {
  .bfp-btn {
    width: 100%;
  }
  .bfp-header-actions .bfp-btn:not(.bfp-btn-mobile-visible) {
    display: none;
  }
}

/* ==========================================================
   15. REDUCED MOTION QUERY
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
