/* ──────────────────────────────────────────────
   DESIGN TOKENS — Unified Design System
   Combina design-system.css + design-tokens.css
   ────────────────────────────────────────────── */

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

:root {
  /* ─── Terminal palette · gold/steel (unificado con el dashboard) ─── */
  --ink:      #0B0F17;   /* fondo casi negro */
  --panel:    #121826;   /* paneles */
  --surface:  #161d2a;   /* superficies intermedias */
  --elevated: #1b2436;   /* elevado / hover */
  --lattice:  #2E4A66;   /* acero del grid */
  --gold:     #E8B339;   /* acento principal */
  --bid:      #5FB98C;   /* positivo (verde azulado) */
  --ask:      #E5705B;   /* negativo (rojo coral) */

  /* ─── Color Palette ─── */
  /* Base backgrounds */
  --bg-primary:   var(--ink);
  --bg-secondary: var(--panel);
  --bg-tertiary:  var(--surface);
  --bg-elevated:  var(--elevated);
  --bg-card:      var(--bg-secondary);
  --bg-card-hover: var(--bg-tertiary);

  /* Borders */
  --border:       #243448;
  --border2:      var(--lattice);
  --border-hover: #3E5E80;
  --border-focus: var(--accent);

  /* Text */
  --text-primary:   #E6EAF2;
  --text-secondary: #9FB0C6;
  --text-muted:     #7C8AA0;
  --text-inverse:   #0B0F17;

  /* Semantic colors */
  --accent:        var(--gold);
  --accent-hover:  #F2C155;
  --accent-dim:    #3a3013;
  --accent-bg:     rgba(232, 179, 57, 0.08);
  --accent-border: rgba(232, 179, 57, 0.3);

  --green:  var(--bid);
  --green-bg:     rgba(95, 185, 140, 0.08);
  --green-border: rgba(95, 185, 140, 0.3);
  --green-dim:    #12241b;

  --red:    var(--ask);
  --red-bg:     rgba(229, 112, 91, 0.08);
  --red-border: rgba(229, 112, 91, 0.3);
  --red-dim:    #2a1512;

  --yellow: #D9A441;
  --yellow-bg:     rgba(217, 164, 65, 0.08);
  --yellow-border: rgba(217, 164, 65, 0.3);
  --yellow-dim:   #2b2109;

  --purple: #8C7BD8;
  --purple-bg:     rgba(140, 123, 216, 0.08);
  --purple-border: rgba(140, 123, 216, 0.3);

  --cyan:   var(--bid);
  --cyan-bg:     rgba(95, 185, 140, 0.08);
  --cyan-border: rgba(95, 185, 140, 0.3);

  /* ─── Alias tokens (consumidos por layout.css / components.css / site.css) ─── */
  --bg:  var(--bg-primary);
  --bg2: var(--bg-secondary);
  --bg3: var(--bg-tertiary);
  --bg4: var(--bg-elevated);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --dim:  #5C6C82;
  --gn-g: rgba(95, 185, 140, 0.12);
  --gn-s: rgba(95, 185, 140, 0.5);
  --rd-g: rgba(229, 112, 91, 0.12);
  --rd-s: rgba(229, 112, 91, 0.5);
  --yl-g: rgba(217, 164, 65, 0.12);
  --acc-g: rgba(232, 179, 57, 0.12);
  --r:  10px;
  --r2: 6px;
  --sh: 0 8px 32px rgba(0, 0, 0, 0.5);
  --z-loader: 9999;
  --z-topbar: 200;
  --z-drawer-overlay: 140;
  --z-sidebar-right: 150;
  --z-sidebar-left: 150;
  --z-toasts: var(--z-toast);

  /* ─── Typography ─── */
  --font-ui:      'IBM Plex Sans', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'JetBrains Mono', monospace;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --mono: var(--font-mono);
  --sans: var(--font-ui);

  /* Font sizes */
  --font-xs:   0.65rem;  /* 10.4px */
  --font-sm:   0.75rem;  /* 12px */
  --font-base: 0.85rem;  /* 13.6px */
  --font-md:   0.875rem; /* 14px */
  --font-lg:   1rem;     /* 16px */
  --font-xl:   1.15rem;  /* 18.4px */
  --font-2xl:  1.5rem;   /* 24px */
  --font-3xl:  2rem;     /* 32px */

  /* Font weights */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* Line heights */
  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.75;

  /* ─── Spacing ─── */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* ─── Border Radius ─── */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;
  --radius-full: 9999px;

  /* ─── Shadows ─── */
  --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.35);
  --shadow-lg:  0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 24px rgba(232, 179, 57, 0.25);

  /* ─── Layout ─── */
  --nav-h: 56px;
  --sidebar-w: 300px;
  --drawer-w: 280px;
  --touch-min: 44px;

  /* ─── Transitions ─── */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;

  /* ─── Z-index ─── */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 1000;
  --z-modal: 1001;
  --z-toast: 1100;
  --z-tooltip: 1200;
}

/* ─── Base Styles ─── */
html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: var(--lh-normal);
  min-height: 100vh;
}

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

a:hover {
  color: var(--accent-hover);
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
  border: 2px solid var(--bg-tertiary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-hover);
}

::-webkit-scrollbar-corner {
  background: var(--bg-primary);
}

/* ─── Selection ─── */
::selection {
  background: var(--accent-dim);
  color: var(--text-primary);
}

/* ─── Focus Visible (Accessibility) ─── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Reduced Motion ─── */
@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;
  }
}

/* ─── High Contrast ─── */
@media (prefers-contrast: high) {
  :root {
    --border: #6a9ce0;
    --border-hover: #8ab4e8;
    --text-secondary: #c8daf0;
    --text-muted: #d0e0f0;
    --accent: #38bdf8;
    --green: #4ade80;
    --red: #f87171;
    --yellow: #fde047;
  }
}

/* ─── Print Styles ─── */
@media print {
  .no-print,
  .toast,
  .modal-overlay,
  .drawer-overlay {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }
}

/* ─── Utility Classes ─── */
/* Spacing */
.mt-xs { margin-top: var(--space-xs) !important; }
.mt-sm { margin-top: var(--space-sm) !important; }
.mt-md { margin-top: var(--space-md) !important; }
.mt-lg { margin-top: var(--space-lg) !important; }
.mt-xl { margin-top: var(--space-xl) !important; }

.mb-xs { margin-bottom: var(--space-xs) !important; }
.mb-sm { margin-bottom: var(--space-sm) !important; }
.mb-md { margin-bottom: var(--space-md) !important; }
.mb-lg { margin-bottom: var(--space-lg) !important; }
.mb-xl { margin-bottom: var(--space-xl) !important; }

.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Padding */
.p-xs { padding: var(--space-xs) !important; }
.p-sm { padding: var(--space-sm) !important; }
.p-md { padding: var(--space-md) !important; }
.p-lg { padding: var(--space-lg) !important; }
.p-xl { padding: var(--space-xl) !important; }

/* Text Colors */
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-accent { color: var(--accent) !important; }
.text-green { color: var(--green) !important; }
.text-red { color: var(--red) !important; }
.text-yellow { color: var(--yellow) !important; }
.text-purple { color: var(--purple) !important; }
.text-cyan { color: var(--cyan) !important; }

/* Background Colors */
.bg-primary { background: var(--bg-primary) !important; }
.bg-secondary { background: var(--bg-secondary) !important; }
.bg-tertiary { background: var(--bg-tertiary) !important; }
.bg-elevated { background: var(--bg-elevated) !important; }
.bg-accent { background: var(--accent-bg) !important; }
.bg-green { background: var(--green-bg) !important; }
.bg-red { background: var(--red-bg) !important; }
.bg-yellow { background: var(--yellow-bg) !important; }

/* Border Colors */
.border-accent { border-color: var(--accent-border) !important; }
.border-green { border-color: var(--green-border) !important; }
.border-red { border-color: var(--red-border) !important; }
.border-yellow { border-color: var(--yellow-border) !important; }

/* Font Families */
.font-ui { font-family: var(--font-ui) !important; }
.font-mono { font-family: var(--font-mono) !important; }
.font-display { font-family: var(--font-display) !important; }

/* Font Sizes */
.fs-xs { font-size: var(--font-xs) !important; }
.fs-sm { font-size: var(--font-sm) !important; }
.fs-base { font-size: var(--font-base) !important; }
.fs-md { font-size: var(--font-md) !important; }
.fs-lg { font-size: var(--font-lg) !important; }
.fs-xl { font-size: var(--font-xl) !important; }
.fs-2xl { font-size: var(--font-2xl) !important; }
.fs-3xl { font-size: var(--font-3xl) !important; }

/* Font Weights */
.fw-normal { font-weight: var(--fw-normal) !important; }
.fw-medium { font-weight: var(--fw-medium) !important; }
.fw-semibold { font-weight: var(--fw-semibold) !important; }
.fw-bold { font-weight: var(--fw-bold) !important; }

/* Display */
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }
.d-block { display: block !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }

/* Flex */
.flex-1 { flex: 1 !important; }
.flex-auto { flex: 1 1 auto !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.items-center { align-items: center !important; }
.items-start { align-items: flex-start !important; }
.items-end { align-items: flex-end !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-end { justify-content: flex-end !important; }
.gap-xs { gap: var(--space-xs) !important; }
.gap-sm { gap: var(--space-sm) !important; }
.gap-md { gap: var(--space-md) !important; }
.gap-lg { gap: var(--space-lg) !important; }
.gap-xl { gap: var(--space-xl) !important; }

/* Grid */
.grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
.grid-3 { grid-template-columns: repeat(3, 1fr) !important; }
.grid-4 { grid-template-columns: repeat(4, 1fr) !important; }

/* Border Radius */
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded-md { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

/* Shadows */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }
.shadow-xl { box-shadow: var(--shadow-xl) !important; }
.shadow-glow { box-shadow: var(--shadow-glow) !important; }

/* Transitions */
.transition-fast { transition: all var(--transition-fast) !important; }
.transition-normal { transition: all var(--transition-normal) !important; }
.transition-slow { transition: all var(--transition-slow) !important; }

/* Overflow */
.overflow-auto { overflow: auto !important; }
.overflow-hidden { overflow: hidden !important; }
.overflow-y-auto { overflow-y: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }

/* Position */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }
.sticky { position: sticky !important; }

/* Width/Height */
.w-full { width: 100% !important; }
.h-full { height: 100% !important; }
.min-h-screen { min-height: 100vh !important; }

/* Text Alignment */
.text-left { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }

/* White Space */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whitespace-nowrap { white-space: nowrap !important; }
.whitespace-pre { white-space: pre !important; }

/* Cursor */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }
.cursor-not-allowed { cursor: not-allowed !important; }

/* Opacity */
.opacity-0 { opacity: 0 !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-100 { opacity: 1 !important; }

/* Visibility */
.invisible { visibility: hidden !important; }
.visible { visibility: visible !important; }

/* Pointer Events */
.pointer-events-none { pointer-events: none !important; }
.pointer-events-auto { pointer-events: auto !important; }

/* User Select */
.select-none { user-select: none !important; }
.select-auto { user-select: auto !important; }
.select-text { user-select: text !important; }

/* ─── Screen Reader Only ─── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Skip Link ─── */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--accent);
  color: var(--text-inverse);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  z-index: var(--z-tooltip);
  transition: top var(--transition-fast);
}

.skip-link:focus {
  top: var(--space-md);
}