:root {
  --bg: #0b0f17;
  --panel: #111826;
  --panel-2: #172033;
  --line: #222c40;
  --text: #e6ebf5;
  --muted: #8a96ad;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .16);
  --up: #26a69a;
  --down: #ef5350;
  --radius: 10px;
  --tap: 40px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }

/* Barre du haut */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 15px; }
.brand b { color: var(--accent); font-weight: 600; }
.modules { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.modules::-webkit-scrollbar { display: none; }
.module {
  border: 0; background: none; padding: 8px 12px; border-radius: 8px;
  color: var(--muted); white-space: nowrap; min-height: var(--tap);
}
.module.active { color: var(--text); background: var(--panel-2); }
.module:disabled { opacity: .55; }
.module small { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; margin-left: 4px; color: var(--muted); }
.badge-demo {
  font-size: 12px; color: #fbbf24; border: 1px solid rgba(251, 191, 36, .35);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

/* Réglages */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.group { display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; }
.group.tools { background: none; border: 0; padding: 0; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.seg {
  border: 0; background: none; min-height: 36px; min-width: 44px; padding: 6px 12px;
  border-radius: 8px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.seg:hover { color: var(--text); }
.seg.active { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(59, 130, 246, .5); }
.seg:disabled { opacity: .35; cursor: default; }
.seg.icon { background: var(--panel); border: 1px solid var(--line); }
.field {
  display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0 10px; min-height: 42px;
}
.field span { color: var(--muted); font-size: 12px; }
.field select, .field input { background: none; border: 0; outline: 0; min-height: 36px; }
.field input[type="date"] { min-width: 130px; }

/* Graphiques */
.charts { flex: 1; min-height: 0; display: grid; gap: 1px; background: var(--line); }
.charts.single { grid-template-columns: 1fr; }
.charts.multi { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 900px), (orientation: portrait) {
  .charts.multi { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr 1fr; }
}
.pane { position: relative; background: var(--bg); min-height: 0; min-width: 0; }
.pane .chart { position: absolute; inset: 0; }
.legend {
  position: absolute; top: 8px; left: 12px; z-index: 3; pointer-events: none;
  font-size: 12px; font-variant-numeric: tabular-nums; line-height: 1.5;
  text-shadow: 0 1px 2px var(--bg);
}
.legend .title { font-size: 14px; font-weight: 600; }
.legend .title .tf { color: var(--accent); margin-left: 6px; }
.legend .title .sub { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.legend .ohlc span { margin-right: 10px; color: var(--muted); }
.legend .ohlc b { font-weight: 500; color: var(--text); }
.legend .up { color: var(--up) !important; }
.legend .down { color: var(--down) !important; }
.pane .loading {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 4;
  color: var(--muted); background: rgba(11, 15, 23, .6); font-size: 13px;
}
.pane .empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); padding: 24px; text-align: center; }

/* Pied de page */
.status {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
  background: var(--panel);
}

@media (max-width: 700px) {
  .brand span { display: none; }
  .badge-demo { display: none; }
  .group.tools { margin-left: 0; }
}

.charts.multi .legend .title .sub { display: none; }
.charts.multi .legend .ohlc span:last-child { display: block; }
@media (min-width: 1100px) {
  .toolbar { gap: 8px 10px; }
  .seg { padding: 6px 10px; }
  .field { padding: 0 8px; }
  .field input[type="date"] { min-width: 118px; }
}
