
/* ==========================================================================
   EXPLICIT ICONOGRAPHY SYSTEM
   Fixes icon sizing blowout with strict dimension tokens & fallbacks.
   ========================================================================== */
svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.icon, svg.icon {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 2;
}

.icon-xs, svg.icon-xs { width: 0.875rem; height: 0.875rem; }
.icon-sm, svg.icon-sm { width: 1rem; height: 1rem; }
.icon-md, svg.icon-md { width: 1.25rem; height: 1.25rem; }
.icon-lg, svg.icon-lg { width: 1.5rem; height: 1.5rem; }
.icon-xl, svg.icon-xl { width: 2rem; height: 2rem; }
.icon-2xl, svg.icon-2xl { width: 3rem; height: 3rem; }

.w-3, svg.w-3 { width: 0.75rem !important; }
.h-3, svg.h-3 { height: 0.75rem !important; }
.w-4, svg.w-4 { width: 1rem !important; }
.h-4, svg.h-4 { height: 1rem !important; }
.w-5, svg.w-5 { width: 1.25rem !important; }
.h-5, svg.h-5 { height: 1.25rem !important; }
.w-6, svg.w-6 { width: 1.5rem !important; }
.h-6, svg.h-6 { height: 1.5rem !important; }
.w-8, svg.w-8 { width: 2rem !important; }
.h-8, svg.h-8 { height: 2rem !important; }
.w-10, svg.w-10 { width: 2.5rem !important; }
.h-10, svg.h-10 { height: 2.5rem !important; }
.w-12, svg.w-12 { width: 3rem !important; }
.h-12, svg.h-12 { height: 3rem !important; }

/* ==========================================================================
   SENTINEL-FX · Component Styles & Responsive Layout
   Mobile-first ergonomic terminal layout, desktop rail, touch hitboxes >= 44px
   ========================================================================== */

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

html {
  font-family: var(--font-body);
  font-size: 16px;
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  min-height: 100%;
  background-color: var(--bg-page);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 16px));
}

@media (min-width: 1024px) {
  body {
    padding-bottom: 0;
    padding-left: 260px;
  }
}

/* Tabular numbers for all financial metrics */
.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ==========================================================================
   TOP BAR CONTRACT: [Brand wordmark] — [Status/Mode Pill] — [Quick Actions]
   ========================================================================== */
.top-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: 56px;
  padding: 0 var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text-primary);
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Mode Switcher Pill */
.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--duration-fast) ease;
  min-height: 32px;
}

.mode-pill.demo {
  background: var(--demo-subtle);
  color: var(--demo-accent);
  border-color: rgba(56, 189, 248, 0.25);
}

.mode-pill.real {
  background: var(--real-subtle);
  color: var(--real-accent);
  border-color: rgba(249, 115, 22, 0.35);
  font-weight: 700;
}

/* Status indicator dot */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--profit);
  box-shadow: 0 0 8px var(--profit);
}

.dot-paused {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}

.dot-error {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--loss);
}

/* ==========================================================================
   DESKTOP RAIL NAVIGATION (>=1024px)
   ========================================================================== */
.desktop-rail {
  display: none;
}

@media (min-width: 1024px) {
  .desktop-rail {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    z-index: var(--z-sidebar);
    padding: var(--space-4) var(--space-3);
  }

  .rail-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3) var(--space-6);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--space-4);
  }

  .rail-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
  }

  .rail-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--duration-fast) ease;
    min-height: 44px;
  }

  .rail-link:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
  }

  .rail-link.active {
    background: var(--accent-subtle);
    color: var(--accent-primary);
    font-weight: 600;
  }

  .rail-footer {
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
  }
}

/* ==========================================================================
   MOBILE BOTTOM NAVIGATION BAR (<1024px)
   Thumb-reach zone, min 44px hitboxes, safe area support
   ========================================================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  z-index: var(--z-bottom-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

@media (min-width: 1024px) {
  .bottom-nav {
    display: none;
  }
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  min-height: 48px;
  min-width: 48px;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-fast) ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bottom-tab svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  transition: transform var(--duration-fast) ease;
}

.bottom-tab.active {
  color: var(--accent-primary);
}

.bottom-tab.active svg {
  transform: translateY(-1px);
}

/* ==========================================================================
   VIEWPORT WRAPPER & RESPONSIVE GRID
   ========================================================================== */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4);
}

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

/* Cards & Surfaces */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-subtle);
  transition: border-color var(--duration-fast) ease, box-shadow var(--duration-fast) ease;
}

.card:hover {
  border-color: var(--border-medium);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Hero Balance Card */
.hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.hero-balance {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  margin: var(--space-2) 0 var(--space-4);
}

@media (min-width: 640px) {
  .hero-balance {
    font-size: var(--text-4xl);
  }
}

.hero-metrics-grid {
  display: grid;
  grid-cols: 2;
  gap: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
}

@media (min-width: 640px) {
  .hero-metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.metric-val {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

/* Semantic Badges & Signals */
.badge-profit {
  color: var(--profit);
  background: var(--profit-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: var(--text-xs);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-loss {
  color: var(--loss);
  background: var(--loss-subtle);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-weight: 600;
  font-size: var(--text-xs);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.badge-side-buy {
  color: var(--profit);
  background: var(--profit-subtle);
  border: 1px solid var(--profit-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

.badge-side-sell {
  color: var(--loss);
  background: var(--loss-subtle);
  border: 1px solid var(--loss-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}

/* ==========================================================================
   BUTTONS & CONTROLS (Min 44px hitbox)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: all var(--duration-fast) var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--loss);
  color: var(--text-inverse);
}

.btn-danger:hover:not(:disabled) {
  background: var(--loss-hover);
}

.btn-sm {
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
}

.btn-lg {
  min-height: 48px;
  padding: 0 var(--space-6);
  font-size: var(--text-base);
}

/* Spinner inside button */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ==========================================================================
   FORM INPUTS & TOGGLES
   ========================================================================== */
.input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--duration-fast) ease;
}

.input:focus {
  border-color: var(--border-focus);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-inset);
  transition: .2s;
  border-radius: 28px;
  border: 1px solid var(--border-medium);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
  background-color: var(--profit);
  border-color: var(--profit);
}

input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   BOTTOM SHEETS & MODALS
   ========================================================================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-normal) ease;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 640px) {
  .sheet-backdrop {
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
  }
}

.sheet-container {
  width: 100%;
  max-height: 90vh;
  background: var(--bg-surface);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 16px));
  box-shadow: var(--shadow-modal);
  transform: translateY(100%);
  transition: transform var(--duration-normal) var(--ease-spring);
  overflow-y: auto;
}

@media (min-width: 640px) {
  .sheet-container {
    max-width: 540px;
    border-radius: var(--radius-lg);
    border-bottom: 1px solid var(--border-subtle);
    transform: scale(0.95);
    padding-bottom: var(--space-5);
  }
}

.sheet-backdrop.open .sheet-container {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .sheet-backdrop.open .sheet-container {
    transform: scale(1);
  }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-4);
}

@media (min-width: 640px) {
  .sheet-handle {
    display: none;
  }
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
#toast-root {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom, 16px));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
  width: 90%;
  max-width: 440px;
}

@media (min-width: 1024px) {
  #toast-root {
    bottom: var(--space-6);
    right: var(--space-6);
    left: auto;
    transform: none;
  }
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-modal);
  animation: toast-in 0.25s var(--ease-spring);
  max-width: 100%;
}

.toast-success {
  border-color: var(--profit-border);
  background: var(--bg-surface);
}

.toast-error {
  border-color: var(--loss-border);
  background: var(--bg-surface);
}

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

/* ==========================================================================
   LIVE FLASH NUMBER ANIMATIONS
   ========================================================================== */
.flash-profit {
  animation: flash-profit-anim 1.2s ease-out;
}

.flash-loss {
  animation: flash-loss-anim 1.2s ease-out;
}

@keyframes flash-profit-anim {
  0% { background-color: var(--profit-subtle); color: var(--profit); }
  100% { background-color: transparent; }
}

@keyframes flash-loss-anim {
  0% { background-color: var(--loss-subtle); color: var(--loss); }
  100% { background-color: transparent; }
}

/* Skeletons */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 25%,
    var(--bg-surface-elevated) 50%,
    var(--bg-subtle) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-xs);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus-visible rings for keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
