/* ═══════════════════════════════════════════════════════════════
   FOXBOT PRO — design tokens + base styles
   Institutional trading terminal aesthetic
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Backgrounds */
  --bg-base:      #08080F;
  --bg-elevated:  #0F0F1A;
  --bg-surface:   #16162B;
  --bg-overlay:   #1F1F3A;

  /* Borders */
  --border-subtle: #1F1F3A;
  --border-base:   #2A2A4D;
  --border-strong: #3D3D6B;

  /* Text */
  --text-primary: #F0EEFF;
  --text-base:    #B8B5D8;
  --text-muted:   #6B678F;
  --text-dim:     #3D3D6B;

  /* Accent — violet/magenta (overridden by tweaks) */
  --accent-50:    #FAF5FF;
  --accent-400:   #C084FC;
  --accent-500:   #A855F7;
  --accent-600:   #9333EA;
  --accent-700:   #7E22CE;
  --accent-glow:  rgba(192, 132, 252, 0.27);
  --accent-soft:  rgba(168, 85, 247, 0.12);
  --accent-mag:   #EC4899;

  /* Semantic */
  --bull:        #10B981;
  --bull-glow:   rgba(16, 185, 129, 0.27);
  --bull-soft:   rgba(16, 185, 129, 0.10);
  --bear:        #EF4444;
  --bear-glow:   rgba(239, 68, 68, 0.27);
  --bear-soft:   rgba(239, 68, 68, 0.10);
  --warn:        #F59E0B;
  --warn-soft:   rgba(245, 158, 11, 0.12);
  --info:        #06B6D4;

  /* Gradients */
  --gradient-accent:  linear-gradient(135deg, #A855F7 0%, #EC4899 100%);
  --gradient-bull:    linear-gradient(135deg, #10B981 0%, #06D6A0 100%);
  --gradient-bear:    linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  --gradient-premium: linear-gradient(135deg, #A855F7 0%, #EC4899 50%, #F59E0B 100%);

  /* Spacing scale (4px) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;
  --space-16: 64px; --space-20: 80px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 32px var(--accent-glow);

  /* Density (overridden by tweaks) */
  --density-pad: var(--space-5);
  --density-gap: var(--space-4);
  --density-row: 44px;

  /* Type */
  --font-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 360ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Density variants */
[data-density="compact"]    { --density-pad: var(--space-3); --density-gap: var(--space-2); --density-row: 36px; }
[data-density="comfortable"]{ --density-pad: var(--space-5); --density-gap: var(--space-4); --density-row: 44px; }
[data-density="spacious"]   { --density-pad: var(--space-6); --density-gap: var(--space-5); --density-row: 52px; }

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { overflow-x: hidden; }
body {
  background: var(--bg-base);
  color: var(--text-base);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
  min-height: 100vh;
  overflow-x: hidden;
}
/* Touch-action et overscroll : MOBILE UNIQUEMENT (sinon casse le touchpad PC) */
@media (max-width: 880px), (pointer: coarse) {
  html { touch-action: pan-y; overscroll-behavior-x: none; }
  body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
    touch-action: pan-y;
  }
  .app, .main, .page { touch-action: pan-y; }
  .chips { touch-action: pan-x; overscroll-behavior-x: contain; }
  .chart-canvas, .tv-lightweight-charts { touch-action: auto; }
}

/* Touch UX mobile : zones tactiles confortables, pas de sélection sur UI */
button, .btn, .chip, .nav-item, .bn-item, .icon-btn, .tf, .ind, .lev-btn, .mode-btn, .act-btn {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
@media (max-width: 880px) {
  .btn, .chip, .tf, .ind { min-height: 38px; }
  .icon-btn { min-width: 38px; min-height: 38px; }
  .act-btn  { min-height: 48px; }
}
/* Empêche zoom auto iOS sur focus input < 16px */
input, textarea, select { font-size: 16px; }
@media (max-width: 880px) {
  input[type="number"], input[type="text"] { font-size: 16px !important; }
}

::selection { background: var(--accent-soft); color: var(--text-primary); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-base); border-radius: var(--radius-full); border: 2px solid var(--bg-base); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Type helpers */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.caption {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}
.tnum { font-variant-numeric: tabular-nums; }

/* Layout primitives */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
}

/* Sidebar */
.sidebar {
  background: var(--bg-base);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  padding: var(--space-5) var(--space-4);
  gap: var(--space-4);
}
@media (max-width: 880px) { .sidebar { display: none; } }

.brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 0 24px var(--accent-glow);
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 1px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), transparent 60%);
  pointer-events: none;
}
.brand-text {
  display: flex; flex-direction: column; line-height: 1.05;
}
.brand-name { color: var(--text-primary); font-weight: 600; letter-spacing: -0.01em; }
.brand-sub  { font-size: 10px; color: var(--text-muted); letter-spacing: 0.12em; text-transform: uppercase; }

.account-pill {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-base);
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bull);
  box-shadow: 0 0 0 0 var(--bull-glow);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 var(--bull-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
.paper-dot { background: var(--warn); animation-name: pulse-warn; }
@keyframes pulse-warn {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.27); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-2); }
.nav-section-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: var(--space-3) var(--space-3) var(--space-1);
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-base);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
  position: relative;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-item.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}
.nav-item.active::before {
  content: "";
  position: absolute; left: -1px; top: 8px; bottom: 8px; width: 2px;
  background: var(--accent-500);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--accent-glow);
}
.nav-item .icon { color: var(--text-muted); transition: color var(--transition-fast); }
.nav-item:hover .icon, .nav-item.active .icon { color: var(--accent-400); }
.nav-item .badge {
  margin-left: auto;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}
.nav-item.active .badge { color: var(--accent-400); border-color: var(--border-base); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.user-card {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.avatar {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  background: var(--gradient-accent);
  display: grid; place-items: center;
  font-size: 11px; color: white; font-weight: 600;
}
.user-meta { line-height: 1.1; display: flex; flex-direction: column; gap: 2px; }
.user-name { color: var(--text-primary); font-size: 12px; font-weight: 500; }
.user-tier { font-size: 10px; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; }

/* Topbar */
.main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  padding-top: max(var(--space-3), env(safe-area-inset-top));
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-base);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg-base) 85%, transparent);
}
@media (max-width: 880px) {
  .topbar { padding: var(--space-3) var(--space-4); padding-top: max(var(--space-3), env(safe-area-inset-top)); gap: var(--space-2); }
  .topbar .search { display: none; }              /* recherche déplacée vers le command palette ⌘K */
  .topbar-title h1 { font-size: 14px; }
  .crumb { display: none; }
  .topbar-tick { padding: 3px 8px !important; }
  .topbar-right { gap: var(--space-2) !important; }
  .icon-btn { width: 36px; height: 36px; }
}
.topbar-title { display: flex; align-items: center; gap: var(--space-3); }
.topbar-title h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.crumb { color: var(--text-muted); font-size: 12px; letter-spacing: 0.04em; }
.search {
  flex: 1;
  max-width: 360px;
  min-width: 0;
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
}
.search > span { overflow: hidden; text-overflow: ellipsis; }
.search:hover { border-color: var(--border-base); }
.search kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border: 1px solid var(--border-base);
  border-radius: 4px;
  color: var(--text-muted);
  background: var(--bg-base);
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--radius-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-subtle); }
.icon-btn .notif-dot {
  position: absolute; top: 6px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-mag);
  box-shadow: 0 0 6px var(--accent-mag);
}
.mode-pill {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 4px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--border-base);
  border-radius: var(--radius-full);
  color: var(--text-base);
  background: var(--bg-elevated);
}
.mode-pill.live { color: var(--bull); border-color: rgba(16,185,129,0.3); }
.mode-pill.paper { color: var(--warn); border-color: rgba(245,158,11,0.3); }

/* Page */
.page { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-6); }
@media (max-width: 600px) { .page { padding: var(--space-4); gap: var(--space-4); } }

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
  flex-wrap: wrap;
}
.page-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}
.page-header .sub { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* Card */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  position: relative;
  transition: border-color var(--transition-base), background var(--transition-base);
}
.card.pad { padding: var(--density-pad); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.card-header h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card-body { padding: var(--space-5); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid var(--border-base);
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.btn:hover { border-color: var(--border-strong); background: var(--bg-surface); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--accent-500);
  border-color: var(--accent-500);
  color: white;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn.primary:hover { background: var(--accent-400); box-shadow: 0 0 20px var(--accent-glow); }
.btn.ghost { background: transparent; border-color: var(--border-subtle); color: var(--text-base); }
.btn.ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.lg { padding: 10px 18px; font-size: 14px; }

/* Filter chips */
.chips {
  display: flex; align-items: center; gap: var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 5px 11px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--transition-fast);
}
.chip:hover { color: var(--text-base); border-color: var(--border-base); }
.chip.active {
  background: var(--accent-soft);
  border-color: rgba(168, 85, 247, 0.35);
  color: var(--accent-400);
}
.chip .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 5px;
  border-radius: 4px;
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
}

/* Score badge */
.score-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid;
  letter-spacing: -0.02em;
  transition: all var(--transition-base);
}
.score-badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
}
.score-badge .num { font-weight: 600; }
.score-badge .max { color: var(--text-muted); font-weight: 400; }

.score-low { color: var(--bear); border-color: rgba(239,68,68,0.3); background: var(--bear-soft); }
.score-low .dot { background: var(--bear); }
.score-mid { color: var(--warn); border-color: rgba(245,158,11,0.3); background: var(--warn-soft); }
.score-mid .dot { background: var(--warn); }
.score-good { color: var(--bull); border-color: rgba(16,185,129,0.3); background: var(--bull-soft); }
.score-good .dot { background: var(--bull); }
.score-premium {
  color: var(--accent-400);
  border-color: rgba(192,132,252,0.4);
  background: linear-gradient(135deg, rgba(168,85,247,0.18), rgba(236,72,153,0.18));
  box-shadow: 0 0 18px var(--accent-glow);
  animation: score-pulse 2.5s ease-in-out infinite;
}
.score-premium .dot {
  background: var(--accent-400);
  box-shadow: 0 0 8px var(--accent-400);
}
@keyframes score-pulse {
  0%, 100% { box-shadow: 0 0 14px var(--accent-glow); }
  50% { box-shadow: 0 0 24px var(--accent-glow); }
}

/* Risk badge (multi-factor : ATR + SL + lev + vol + score) */
.risk-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-size: 11px; font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.risk-badge .dot { width: 5px; height: 5px; border-radius: 50%; }
.risk-faible  { color: var(--bull); background: var(--bull-soft); border-color: rgba(16,185,129,0.3); }
.risk-faible  .dot { background: var(--bull); box-shadow: 0 0 6px var(--bull-glow); }
.risk-modere  { color: var(--warn); background: var(--warn-soft); border-color: rgba(245,158,11,0.3); }
.risk-modere  .dot { background: var(--warn); }
.risk-eleve   { color: var(--bear); background: var(--bear-soft); border-color: rgba(239,68,68,0.3); }
.risk-eleve   .dot { background: var(--bear); }
.risk-extreme {
  color: white; background: var(--bear); border-color: var(--bear);
  box-shadow: 0 0 14px var(--bear-glow);
  animation: risk-pulse 1.6s ease-in-out infinite;
}
.risk-extreme .dot { background: white; box-shadow: 0 0 4px white; }
@keyframes risk-pulse {
  0%, 100% { box-shadow: 0 0 10px var(--bear-glow); }
  50%      { box-shadow: 0 0 20px var(--bear-glow); }
}

/* Direction badge */
.dir-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  border-radius: var(--radius-sm);
  border: 1px solid;
}
.dir-long  { color: var(--bull); background: var(--bull-soft); border-color: rgba(16,185,129,0.3); }
.dir-short { color: var(--bear); background: var(--bear-soft); border-color: rgba(239,68,68,0.3); }

/* Numbers — bull/bear */
.bull { color: var(--bull); }
.bear { color: var(--bear); }
.warn { color: var(--warn); }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.primary { color: var(--text-primary); }

/* Skeleton / shimmer */
.skel {
  background: linear-gradient(90deg,
    var(--bg-elevated) 0%,
    var(--bg-surface) 40%,
    var(--accent-soft) 50%,
    var(--bg-surface) 60%,
    var(--bg-elevated) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Toasts */
.toasts {
  position: fixed; top: 60px; right: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--bg-overlay);
  border: 1px solid var(--border-base);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-3);
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
.toast.success { border-color: rgba(16,185,129,0.4); }
.toast.success .toast-icon { color: var(--bull); }
.toast.warn { border-color: rgba(245,158,11,0.4); }
.toast.warn .toast-icon { color: var(--warn); }
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast.error .toast-icon { color: var(--bear); }
.toast.info { border-color: rgba(192,132,252,0.4); }
.toast.info .toast-icon { color: var(--accent-400); }
.toast .toast-msg { font-size: 13px; color: var(--text-primary); line-height: 1.3; }
.toast .toast-sub { font-size: 11px; color: var(--text-muted); }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Pair logo */
.pair-logo {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
}

/* Mini bar / gauge */
.gauge {
  height: 3px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.gauge-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-500);
  transition: width var(--transition-base);
}
.gauge.bull .gauge-fill { background: var(--bull); }
.gauge.bear .gauge-fill { background: var(--bear); }
.gauge.warn .gauge-fill { background: var(--warn); }

/* Stripes (placeholder zones) */
.stripes {
  background-image: repeating-linear-gradient(
    -45deg,
    var(--bg-surface) 0,
    var(--bg-surface) 6px,
    var(--bg-elevated) 6px,
    var(--bg-elevated) 12px
  );
}

/* Mobile bottom nav — feel native iOS/Android */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  background: color-mix(in srgb, var(--bg-base) 92%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 40;
  padding: 8px var(--space-3) calc(8px + env(safe-area-inset-bottom));
}
.bottom-nav-inner {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px;
}
.bn-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px;
  min-height: 48px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  cursor: pointer;
  position: relative;
}
.bn-item .icon { width: 20px; height: 20px; }
.bn-item.active { color: var(--accent-400); }
.bn-item.active::before {
  content: "";
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 2px;
  background: var(--accent-500);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--accent-glow);
}
@media (max-width: 880px) {
  .bottom-nav { display: block; }
  .page { padding: var(--space-4); padding-bottom: calc(96px + env(safe-area-inset-bottom)); gap: var(--space-4); }
  .page-header { gap: var(--space-3); flex-direction: column; align-items: flex-start; }
  .page-header h2 { font-size: 20px; }
  .page-header .sub { font-size: 12px; }
  /* KPIs : grille 2 colonnes au lieu d'auto-fit qui peut faire 4 trop étroites */
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; gap: var(--space-3) !important; }
  .kpi-main span { font-size: 20px !important; }
  /* Cards : prennent toute la largeur, padding réduit */
  .card { border-radius: var(--radius-md); }
  .card.pad { padding: var(--space-4); }
  .card-header { padding: var(--space-3) var(--space-4); flex-wrap: wrap; gap: var(--space-2); }
  .card-body { padding: var(--space-4); }
  /* Signals grid : 1 colonne sur mobile */
  .signals-grid { grid-template-columns: 1fr !important; gap: var(--space-3) !important; }
  /* Dash split (positions + signaux) : empilé sur mobile */
  .dash-split { grid-template-columns: 1fr !important; gap: var(--space-3) !important; }
  /* Topbar : on cache search, layout horizontal compact */
  .topbar-tick { margin-left: auto; }
  /* Sidebar invisible mobile, garde déjà via @media existing */
  /* Toasts : passe en bottom + safe area */
  .toasts { top: auto !important; bottom: calc(96px + env(safe-area-inset-bottom)) !important; right: var(--space-3) !important; left: var(--space-3) !important; }
  .toast { min-width: 0 !important; }
  /* Chart canvas : hauteur réduite mais lisible */
  .chart-canvas { height: 320px !important; }
  /* Chart price bar : wrap propre */
  .chart-price-bar { flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) !important; }
  /* Tables (positions) : scrollables horizontalement plutôt que d'écraser */
  .ptable { font-size: 12px; }

  /* ─── Signaux ultra-compacts mobile (~50% hauteur) ─── */
  .signal-card { padding: 10px !important; gap: 6px !important; border-radius: var(--radius-md) !important; }
  .sig-head { padding-bottom: 6px !important; gap: 8px !important; }
  .sig-symbol { font-size: 13px !important; }
  .sig-head-meta { font-size: 10px !important; gap: 4px !important; }
  /* 2 colonnes TECH | PLAN — densité max */
  .sig-body {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important; padding: 6px 0 !important;
    border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle);
  }
  .sig-col-label { font-size: 9px !important; padding-bottom: 3px !important; }
  .sig-col { gap: 2px !important; }
  .data-row, .plan-row { padding: 2px 0 !important; min-height: 18px; }
  .data-label, .plan-label { font-size: 10px !important; }
  .data-value, .plan-value { font-size: 10px !important; }
  .data-mid { display: none !important; }                /* Cache les jauges sur mobile (lisibilité) */
  /* Cache 2 rows non-critiques pour gagner de la hauteur */
  .sig-body .sig-col .data-row:nth-child(6) { display: none !important; }   /* BB → caché */
  .sig-body .sig-col .data-row:nth-child(5) { display: none !important; }   /* ATR → caché (déjà dans pills risque) */
  /* Track horizontal : plus serré */
  .track-wrap { padding: 14px 4px 4px !important; }
  .track { height: 2px !important; }
  .tm-label .caption { font-size: 8px !important; }
  .tm-label .mono   { font-size: 9px !important; }
  /* Pills : 3 colonnes compactes */
  .sig-pills { grid-template-columns: repeat(3, 1fr) !important; gap: 5px !important; padding-top: 4px !important; }
  .sig-pill { padding: 5px 6px !important; }
  .sig-pill .caption { font-size: 8px !important; }
  .sig-pill .mono { font-size: 11px !important; }
  /* Cache 2 pills moins critiques sur mobile (Position + Risque ATR — gardent Perte/TP1/TP2) */
  .sig-pill:nth-child(4), .sig-pill:nth-child(5) { display: none !important; }
  /* Actions : 4 boutons grid 2x2 plus serré */
  .sig-actions { gap: 6px !important; padding-top: 4px !important; }
  .act-btn { font-size: 10px !important; padding: 8px 4px !important; min-height: 40px !important; }
  /* Cache Sparkline sur mobile pour gagner de la place */
  .sig-head-right > svg { display: none !important; }
  /* Bandeau WAIT : version courte mobile (juste 'WAIT' badge en haut à gauche) */
  .sig-banner.banner-wait .sig-banner-full { display: none !important; }
  .sig-banner.banner-wait .sig-banner-short { display: inline !important; font-size: 10px !important; font-weight: 600; letter-spacing: 0.08em; }
  .sig-banner.banner-wait { padding: 4px 8px !important; gap: 4px !important; }
}
/* Desktop : bandeau full visible */
.sig-banner.banner-wait .sig-banner-short { display: none; }
.sig-banner.banner-wait .sig-banner-full { display: inline; }


/* Connection bar (incident) */
.incident {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-6);
  background: rgba(239, 68, 68, 0.08);
  border-bottom: 1px solid rgba(239,68,68,0.25);
  color: var(--bear);
  font-size: 12px;
  font-weight: 500;
}

/* Glow utility */
.has-glow { position: relative; }
.has-glow::after {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 0 1px transparent, 0 0 24px var(--accent-glow);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-base);
}
.has-glow:hover::after { opacity: 1; }

/* Tooltips on hover */
.tip {
  position: relative;
}
.tip[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  background: var(--bg-overlay);
  border: 1px solid var(--border-base);
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  pointer-events: none;
  z-index: 50;
}

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