/* style.css — CalcMyTrade Trading Calculator Suite */

/* ===== FONTS ===== */
:root {
  --font-display: 'Cabinet Grotesk', 'Inter', sans-serif;
  --font-body: 'Satoshi', 'Inter', sans-serif;
}

/* ===== FINANCE DARK PALETTE (DEFAULT) ===== */
:root, [data-theme="dark"] {
  --color-bg:             #0A1628;
  --color-surface:        #1B2A4A;
  --color-surface-2:      #1F3054;
  --color-surface-offset: #0E1C34;
  --color-surface-offset-2: #132240;
  --color-surface-dynamic: #243656;
  --color-divider:        #2A3F66;
  --color-border:         #334D77;

  --color-text:           #E8ECF2;
  --color-text-muted:     #8899B0;
  --color-text-faint:     #506680;
  --color-text-inverse:   #0A1628;

  --color-primary:        #3B82F6;
  --color-primary-hover:  #2563EB;
  --color-primary-active: #1D4ED8;
  --color-primary-highlight: rgba(59, 130, 246, 0.15);

  --color-success:        #22C55E;
  --color-success-hover:  #16A34A;
  --color-success-active: #15803D;
  --color-success-highlight: rgba(34, 197, 94, 0.12);

  --color-error:          #EF4444;
  --color-error-hover:    #DC2626;
  --color-error-active:   #B91C1C;
  --color-error-highlight: rgba(239, 68, 68, 0.12);

  --color-warning:        #F59E0B;
  --color-warning-hover:  #D97706;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.5);

  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
}

/* ===== LIGHT PALETTE ===== */
[data-theme="light"] {
  --color-bg:             #F3F5F9;
  --color-surface:        #FFFFFF;
  --color-surface-2:      #F8F9FB;
  --color-surface-offset: #EDF0F5;
  --color-surface-offset-2: #E5E9F0;
  --color-surface-dynamic: #DDE2EC;
  --color-divider:        #D1D8E4;
  --color-border:         #C4CCDB;

  --color-text:           #111827;
  --color-text-muted:     #64748B;
  --color-text-faint:     #94A3B8;
  --color-text-inverse:   #F3F5F9;

  --color-primary:        #2563EB;
  --color-primary-hover:  #1D4ED8;
  --color-primary-active: #1E40AF;
  --color-primary-highlight: rgba(37, 99, 235, 0.1);

  --color-success:        #16A34A;
  --color-success-hover:  #15803D;
  --color-success-active: #166534;
  --color-success-highlight: rgba(22, 163, 74, 0.1);

  --color-error:          #DC2626;
  --color-error-hover:    #B91C1C;
  --color-error-active:   #991B1B;
  --color-error-highlight: rgba(220, 38, 38, 0.1);

  --color-warning:        #D97706;
  --color-warning-hover:  #B45309;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
}

/* ===== LAYOUT ===== */
.container {
  width: 100%;
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

@media (min-width: 768px) {
  .container { padding: 0 var(--space-6); }
}

@media (min-width: 1280px) {
  .container { padding: 0 var(--space-8); }
}

/* ===== HEADER / NAV ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--color-bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--color-text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
}

.logo svg {
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--color-text);
  background: var(--color-primary-highlight);
}

.nav-tab.active {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

/* ===== NAV DROPDOWN ===== */
.nav-dropdown {
  position: relative;
}

.nav-tab-dropdown {
  gap: var(--space-1);
  font-family: var(--font-body);
}

.dropdown-arrow {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  list-style: none;
}

.nav-dropdown.open .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu .nav-tab {
  width: 100%;
  justify-content: flex-start;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.nav-tab-dropdown.parent-active {
  color: var(--color-primary);
  background: var(--color-primary-highlight);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
}

.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-primary-highlight);
}

/* Mobile hamburger */
.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

@media (max-width: 767px) {
  .mobile-menu-btn { display: inline-flex; }
  .nav-tabs {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: var(--space-3);
    box-shadow: var(--shadow-md);
  }
  .nav-tabs.open { display: flex; }
  .nav-tab { width: 100%; justify-content: flex-start; padding: var(--space-3); }
  .nav-dropdown { width: 100%; }
  .nav-tab-dropdown { width: 100%; justify-content: space-between; }
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding-left: var(--space-4);
    min-width: auto;
    background: transparent;
  }
  .nav-dropdown-menu .nav-tab {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
  }
}

/* ===== AD ZONES ===== */
.ad-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  text-align: center;
  background: color-mix(in srgb, var(--color-surface) 50%, transparent);
  overflow: hidden;
}

.ad-zone-leaderboard {
  max-width: 728px;
  height: 90px;
  margin: var(--space-3) auto;
}

.ad-zone-rectangle {
  width: 300px;
  height: 250px;
  margin: var(--space-4) auto;
}

.ad-zone-infeed {
  max-width: 728px;
  height: 90px;
  margin: var(--space-6) auto;
}

.ad-zone-footer {
  max-width: 728px;
  height: 90px;
  margin: var(--space-4) auto;
}

@media (max-width: 767px) {
  .ad-zone-leaderboard,
  .ad-zone-infeed,
  .ad-zone-footer {
    max-width: 100%;
    height: 60px;
  }
  .ad-zone-rectangle {
    width: 100%;
    max-width: 300px;
    height: 250px;
  }
  .calc-sidebar .ad-zone-rectangle {
    display: none;
  }
}

/* ===== HERO ===== */
.hero {
  text-align: center;
  padding: clamp(var(--space-12), 8vw, var(--space-24)) 0 clamp(var(--space-8), 5vw, var(--space-16));
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-success-highlight);
  color: var(--color-success);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-bottom: var(--space-6);
  border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
}

.hero-badge .pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.5); }
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
}

.hero h1 .accent {
  color: var(--color-primary);
}

.hero .tagline {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  max-width: 560px;
  margin: 0 auto var(--space-8);
}

/* ===== HOME CATEGORIES ===== */
.home-category {
  margin-bottom: clamp(var(--space-8), 4vw, var(--space-12));
}

.category-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  color: var(--color-text-muted);
}

.category-title svg {
  display: inline;
  flex-shrink: 0;
}

/* ===== CALCULATOR CARDS (HOMEPAGE) ===== */
.calc-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-6);
}

.calc-cards-2col {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

@media (min-width: 768px) {
  .calc-cards-2col {
    grid-template-columns: repeat(2, 1fr);
  }
}

.calc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

.calc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* Card accent colors by type */
.card-crypto::before, .card-margin::before, .card-dca::before { background: #F7931A; }
.card-forex::before, .card-pip::before, .card-riskrw::before { background: var(--color-primary); }
.card-stock::before, .card-avgdown::before, .card-compound::before { background: var(--color-success); }

.calc-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.calc-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  font-size: 1.5rem;
}

/* Icon color classes */
.icon-orange { background: rgba(247, 147, 26, 0.12); color: #F7931A; }
.icon-primary { background: var(--color-primary-highlight); color: var(--color-primary); }
.icon-success { background: var(--color-success-highlight); color: var(--color-success); }
.icon-warning { background: rgba(245, 158, 11, 0.12); color: var(--color-warning); }

.calc-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.calc-card p {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  flex: 1;
  margin-bottom: var(--space-4);
}

.calc-card-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.calc-card-cta svg {
  display: inline;
  transition: transform var(--transition-interactive);
}

.calc-card:hover .calc-card-cta svg {
  transform: translateX(4px);
}

/* ===== WHY SECTION ===== */
.why-section {
  padding: clamp(var(--space-8), 5vw, var(--space-16)) 0;
  border-top: 1px solid var(--color-border);
}

.why-section h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-8);
}

.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-6);
}

.why-item {
  text-align: center;
  padding: var(--space-4);
}

.why-item-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-primary-highlight);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
  color: var(--color-primary);
}

.why-item h3 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.why-item p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 280px;
  margin: 0 auto;
}

/* ===== CALCULATOR LAYOUT ===== */
.calculator-page {
  padding: var(--space-6) 0 var(--space-12);
}

.calculator-header {
  margin-bottom: var(--space-6);
}

.calculator-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.calculator-header p {
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

.calc-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 1024px) {
  .calc-layout {
    grid-template-columns: 1fr 340px;
  }
}

.calc-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.calc-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* ===== FORM PANELS ===== */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.panel-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
}

.form-group label .required {
  color: var(--color-error);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper .prefix,
.input-wrapper .suffix {
  position: absolute;
  color: var(--color-text-faint);
  font-size: var(--text-sm);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.input-wrapper .prefix { left: var(--space-3); }
.input-wrapper .suffix { right: var(--space-3); }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: var(--space-3);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  outline: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-highlight);
}

input.has-prefix { padding-left: var(--space-8); }
input.has-suffix { padding-right: var(--space-10); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238899B0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

[data-theme="light"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Toggle switch for long/short */
.toggle-group {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.toggle-option {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  color: var(--color-text-muted);
  background: none;
  border: none;
}

.toggle-option.active {
  background: var(--color-primary);
  color: #fff;
}

.toggle-option:not(.active):hover {
  color: var(--color-text);
  background: var(--color-primary-highlight);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  border: none;
  white-space: nowrap;
  min-height: 44px;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface-dynamic);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  background: var(--color-success-hover);
}

.btn-block {
  width: 100%;
}

.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== RESULTS ===== */
.results-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.results-panel .panel-title {
  color: var(--color-text);
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

@media (max-width: 600px) {
  .result-grid { grid-template-columns: 1fr; }
}

.result-item {
  padding: var(--space-3);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.result-item .label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.result-item .value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-item .value.profit { color: var(--color-success); }
.result-item .value.loss { color: var(--color-error); }
.result-item .value.neutral { color: var(--color-text); }

.result-item.highlight {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-4);
  border-color: var(--color-success);
  background: var(--color-success-highlight);
}

.result-item.highlight.negative {
  border-color: var(--color-error);
  background: var(--color-error-highlight);
}

.result-item.highlight .value {
  font-size: var(--text-xl);
}

/* Placeholder for empty results */
.results-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-text-faint);
}

.results-placeholder svg {
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

.results-placeholder p {
  font-size: var(--text-sm);
}

/* ===== SLIDER (What-If) ===== */
.slider-group {
  margin-top: var(--space-4);
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.slider-group label .slider-value {
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

/* ===== RISK GAUGE ===== */
.risk-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-top: var(--space-4);
}

.risk-gauge-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--color-success), var(--color-warning), var(--color-error));
  position: relative;
  margin-bottom: var(--space-2);
}

.risk-gauge-indicator {
  position: absolute;
  top: -4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-text);
  border: 3px solid var(--color-surface);
  transform: translateX(-50%);
  transition: left 0.5s ease;
  box-shadow: var(--shadow-sm);
}

.risk-gauge-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.risk-gauge-level {
  font-size: var(--text-sm);
  font-weight: 700;
  margin-top: var(--space-2);
}

.risk-gauge-level.low { color: var(--color-success); }
.risk-gauge-level.medium { color: var(--color-warning); }
.risk-gauge-level.high { color: var(--color-error); }

/* ===== COMPARISON TABLE ===== */
.comparison-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
  font-variant-numeric: tabular-nums;
}

.comparison-table th,
.comparison-table td {
  padding: var(--space-3);
  text-align: right;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);
}

.comparison-table th {
  text-align: right;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.comparison-table th:first-child,
.comparison-table td:first-child {
  text-align: left;
}

.comparison-table tr.highlight-row {
  background: var(--color-primary-highlight);
}

.comparison-table tr.highlight-row td {
  font-weight: 600;
}

.table-profit { color: var(--color-success); }
.table-loss { color: var(--color-error); }

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-6) 0 var(--space-4);
  margin-top: var(--space-12);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
}

.footer-inner p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.footer-inner a {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-xs);
}

.footer-inner a:hover {
  color: var(--color-primary);
}

/* ===== SECTION TRANSITIONS ===== */
.page-section {
  display: none;
  opacity: 0;
  transform: translateY(8px);
}

.page-section.active {
  display: block;
  animation: fadeIn 0.3s ease forwards;
}

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

/* ===== LOADING SHIMMER ===== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--color-surface-offset) 25%, var(--color-surface-dynamic) 50%, var(--color-surface-offset) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ===== ERROR MESSAGE ===== */
.error-msg {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-error-highlight);
  border: 1px solid color-mix(in srgb, var(--color-error) 30%, transparent);
  border-radius: var(--radius-md);
  color: var(--color-error);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.success-msg {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-success-highlight);
  border: 1px solid color-mix(in srgb, var(--color-success) 30%, transparent);
  border-radius: var(--radius-md);
  color: var(--color-success);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-muted { color: var(--color-text-muted); }
.text-faint { color: var(--color-text-faint); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.gap-2 { gap: var(--space-2); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* Number animation */
.count-up {
  display: inline-block;
}

/* Scrollbar styling (dark theme friendly) */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-faint);
}

/* ===== FETCH PRICE ROW ===== */
.fetch-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
}

.fetch-row .form-group { flex: 1; }

.btn-fetch {
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-dynamic);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-fetch:hover {
  background: var(--color-primary-highlight);
  border-color: var(--color-primary);
}

@media (max-width: 600px) {
  .btn-fetch { width: 100%; justify-content: center; }
}

.price-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--color-success-highlight);
  border-radius: var(--radius-sm);
  color: var(--color-success);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Back to Home link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
  margin-bottom: var(--space-4);
}

.back-link:hover {
  color: var(--color-primary);
}

/* What-if panel */
.whatif-panel {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.whatif-panel h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
}

.whatif-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
  font-variant-numeric: tabular-nums;
}

.whatif-result:last-child { border-bottom: none; }

.whatif-result .label { font-size: var(--text-sm); color: var(--color-text-muted); }
.whatif-result .value { font-size: var(--text-sm); font-weight: 600; }

/* ===== LEVERAGE TICKS ===== */
.leverage-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ===== LIQUIDATION DISTANCE BAR ===== */
.liquidation-bar {
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: var(--color-surface-offset);
  position: relative;
  overflow: hidden;
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

.liquidation-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}

.liquidation-bar-fill.safe { background: linear-gradient(90deg, var(--color-success), #4ade80); }
.liquidation-bar-fill.warning { background: linear-gradient(90deg, var(--color-warning), #fbbf24); }
.liquidation-bar-fill.danger { background: linear-gradient(90deg, var(--color-error), #f87171); }

.liquidation-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ===== RISK/REWARD BAR ===== */
.rr-bar-container {
  padding: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-top: var(--space-4);
}

.rr-bar {
  display: flex;
  height: 32px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.rr-bar-risk {
  background: var(--color-error);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  min-width: 40px;
}

.rr-bar-reward {
  background: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #fff;
  min-width: 40px;
}

.rr-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ===== AVERAGE DOWN ROWS ===== */
.avgdown-row {
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.avgdown-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* ===== DCA / COMPOUND PROJECTION TABLE ===== */
.projection-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-4);
  font-variant-numeric: tabular-nums;
}

.projection-table th,
.projection-table td {
  padding: var(--space-2) var(--space-3);
  text-align: right;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);
}

.projection-table th {
  text-align: right;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  background: var(--color-surface);
}

.projection-table th:first-child,
.projection-table td:first-child {
  text-align: left;
}

.projection-table-wrapper {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

/* ===== 3-OPTION TOGGLE ===== */
.toggle-group-3 {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
}

.toggle-group-3 .toggle-option {
  flex: 1;
  padding: var(--space-2) var(--space-2);
  font-size: var(--text-xs);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .toggle-group-3 .toggle-option {
    font-size: 0.7rem;
    padding: var(--space-2) var(--space-1);
  }
}

.site-footer .footer-sub {
  font-size: 12.5px;
  margin-top: 6px;
  opacity: 0.75;
}
