/* Moniteur de trading — thème clair/sombre, sans dépendance externe */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16191d;
  --muted: #5c6470;
  --border: #dde1e6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);

  --ok: #12703a;      --ok-bg: #e4f5ea;
  --warn: #8a5300;    --warn-bg: #fdf0d8;
  --err: #b42318;     --err-bg: #fde6e3;
  --info: #1d4f91;    --info-bg: #e3edfb;
  --action: #5b34a6;  --action-bg: #eee7fa;
  --neutral: #4a5260; --neutral-bg: #eceef2;

  --line: #1d4f91;
  --line-entry: #b42318;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #171b22;
    --surface-2: #1f242d;
    --text: #e8ebf0;
    --muted: #97a0ad;
    --border: #2a303a;
    --shadow: none;

    --ok: #5fd08a;      --ok-bg: #12291c;
    --warn: #f0b955;    --warn-bg: #2e2410;
    --err: #ff8a80;     --err-bg: #34161a;
    --info: #7db2ff;    --info-bg: #14233a;
    --action: #b69cff;  --action-bg: #241b3d;
    --neutral: #aab2bf; --neutral-bg: #232830;

    --line: #7db2ff;
    --line-entry: #ff8a80;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #171b22;
  --surface-2: #1f242d;
  --text: #e8ebf0;
  --muted: #97a0ad;
  --border: #2a303a;
  --shadow: none;

  --ok: #5fd08a;      --ok-bg: #12291c;
  --warn: #f0b955;    --warn-bg: #2e2410;
  --err: #ff8a80;     --err-bg: #34161a;
  --info: #7db2ff;    --info-bg: #14233a;
  --action: #b69cff;  --action-bg: #241b3d;
  --neutral: #aab2bf; --neutral-bg: #232830;

  --line: #7db2ff;
  --line-entry: #ff8a80;
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.num, .kv dd, .big { font-variant-numeric: tabular-nums; }

/* ---------- Barre du haut ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.brand h1 { margin: 0 6px 0 0; font-size: 17px; font-weight: 650; }

.topbar-right { display: flex; align-items: center; gap: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--neutral);
  border: 1px solid var(--border);
}
.chip[data-tone="ok"]     { background: var(--ok-bg);     color: var(--ok); }
.chip[data-tone="warn"]   { background: var(--warn-bg);   color: var(--warn); }
.chip[data-tone="err"]    { background: var(--err-bg);    color: var(--err); }
.chip[data-tone="info"]   { background: var(--info-bg);   color: var(--info); }
.chip[data-tone="action"] { background: var(--action-bg); color: var(--action); }

.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--neutral); }
.dot[data-tone="ok"]  { background: var(--ok); }
.dot[data-tone="warn"]{ background: var(--warn); }
.dot[data-tone="err"] { background: var(--err); }
.dot.pulse { animation: pulse 1.2s ease-out; }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
@media (prefers-reduced-motion: reduce) { .dot.pulse { animation: none; } }

.btn {
  font: inherit;
  font-size: 13px;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .filter:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }

/* ---------- Mise en page ---------- */

.wrap { max-width: 1200px; margin: 0 auto; padding: 16px; }

.banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--neutral-bg);
  color: var(--neutral);
  margin-bottom: 16px;
}
.banner[data-tone="ok"]     { background: var(--ok-bg);     color: var(--ok); }
.banner[data-tone="warn"]   { background: var(--warn-bg);   color: var(--warn); }
.banner[data-tone="err"]    { background: var(--err-bg);    color: var(--err); }
.banner[data-tone="info"]   { background: var(--info-bg);   color: var(--info); }
.banner[data-tone="action"] { background: var(--action-bg); color: var(--action); }

.banner-icon {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 18px; font-weight: 700;
  background: color-mix(in srgb, currentColor 16%, transparent);
}
.banner h2 { margin: 0 0 2px; font-size: 18px; }
.banner p { margin: 0; color: var(--text); opacity: .85; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.big { margin: 0; font-size: 26px; font-weight: 650; line-height: 1.2; overflow-wrap: anywhere; }
.muted { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.note {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  background: var(--warn-bg);
  color: var(--warn);
}

.kv { margin: 12px 0 0; }
.kv > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.kv > div:first-child { border-top: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--neutral-bg);
  color: var(--neutral);
}
.tag[data-tone="ok"]     { background: var(--ok-bg);     color: var(--ok); }
.tag[data-tone="warn"]   { background: var(--warn-bg);   color: var(--warn); }
.tag[data-tone="err"]    { background: var(--err-bg);    color: var(--err); }
.tag[data-tone="info"]   { background: var(--info-bg);   color: var(--info); }
.tag[data-tone="action"] { background: var(--action-bg); color: var(--action); }

/* ---------- Position ---------- */

.pos-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pnl { font-size: 26px; font-weight: 700; }
.pnl[data-sign="pos"] { color: var(--ok); }
.pnl[data-sign="neg"] { color: var(--err); }

.empty {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
}
.empty b { color: var(--text); }

/* ---------- Graphique ---------- */

.spark { margin-top: 12px; }
.spark svg { display: block; width: 100%; height: auto; }
.spark .axis { font-size: 11px; fill: var(--muted); }
.spark .grid-line { stroke: var(--border); stroke-width: 1; }
.spark .price-line { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .price-area { fill: var(--line); opacity: .10; }
.spark .entry-line { stroke: var(--line-entry); stroke-width: 1.5; stroke-dasharray: 5 4; }
.spark .last-dot { fill: var(--line); }

/* ---------- Journal ---------- */

.journal-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.journal-head h3 { margin: 0; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  font: inherit; font-size: 13px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.filter.is-on { background: var(--text); color: var(--surface); border-color: var(--text); font-weight: 600; }

.events { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow: auto; }
.events li {
  display: grid;
  grid-template-columns: 96px 92px 1fr;
  gap: 4px 12px;
  align-items: start;
  padding: 9px 2px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}
.events li:first-child { border-top: 0; }
.ev-time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.ev-msg { overflow-wrap: anywhere; }
.ev-count { color: var(--muted); font-size: 12px; margin-left: 6px; }

.foot {
  margin-top: 16px;
  display: flex; flex-wrap: wrap; gap: 6px 18px;
  font-size: 12px; color: var(--muted);
}

/* ---------- Mobile ---------- */

@media (max-width: 560px) {
  .wrap { padding: 12px; }
  .big { font-size: 22px; }
  .events li { grid-template-columns: 1fr; gap: 2px; }
  .events li .ev-time { order: 2; }
}
