:root {
  --abyss: #0B2436;
  --deep: #123348;
  --line: #24506A;
  --foam: #E6F0F3;
  --mist: #8FB0BF;
  --kelp: #3FD0A0;
  --coral: #FF7E67;
  --buoy: #FFC53D;
  --radius-lg: 18px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--abyss);
  color: var(--foam);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
}
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1rem; font-weight: 600; margin: 28px 0 10px; color: var(--mist); }
.muted { color: var(--mist); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.gain { color: var(--kelp); }
.loss { color: var(--coral); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--buoy); outline-offset: 2px; }

/* Barre du haut */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 52px; }
.bar h1 { flex: 1; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: none; border: 0; border-radius: 50%; cursor: pointer;
}
.icon-btn:active { background: var(--deep); }
.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Réel / Simulation */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--deep); padding: 4px; border-radius: 999px; margin: 8px 0 18px;
}
.segmented button {
  border: 0; background: none; padding: 10px; border-radius: 999px; cursor: pointer; color: var(--mist);
}
.segmented button[aria-selected="true"] { background: var(--foam); color: var(--abyss); font-weight: 600; }

/* Cartes des bots */
.bot {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--deep); border: 1px solid transparent; border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 12px;
}
.bot:active { border-color: var(--line); }
.bot-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.bot-name { font-weight: 600; }
.status { font-size: 0.8rem; color: var(--mist); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mist); }
.dot.on { background: var(--kelp); box-shadow: 0 0 0 3px rgba(63, 208, 160, .18); }
.dot.off { background: var(--coral); }
.pnl { font-size: 2.1rem; font-weight: 650; letter-spacing: -0.02em; margin: 6px 0 2px; }
.pnl small { font-size: 1rem; font-weight: 500; margin-left: 6px; }
.position { font-size: 0.92rem; }
.decision {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 0.88rem; color: var(--mist);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tag {
  display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 1px 8px; border-radius: 6px;
  margin-right: 6px; color: var(--abyss); background: var(--mist);
}
.tag.BUY { background: var(--kelp); }
.tag.SELL { background: var(--coral); }
.tag.HOLD { background: var(--mist); }
.empty { background: var(--deep); border-radius: var(--radius-lg); padding: 18px; color: var(--mist); margin-bottom: 12px; }

/* Détail */
.hero { margin: 4px 0 16px; }
.hero .pnl { font-size: 2.6rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--deep); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat b { display: block; font-size: 1.15rem; font-weight: 600; }
.stat span { font-size: 0.8rem; color: var(--mist); }
.chart { background: var(--deep); border-radius: var(--radius-lg); padding: 12px 8px 6px; }
.chart svg { display: block; width: 100%; height: 190px; }
.legend { display: flex; gap: 16px; font-size: 0.8rem; color: var(--mist); padding: 6px 10px 4px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.trade { border-bottom: 1px solid var(--line); padding: 12px 2px; }
.trade:last-child { border-bottom: 0; }
.trade-top { display: flex; justify-content: space-between; gap: 12px; }
.trade-reason { font-size: 0.85rem; color: var(--mist); margin-top: 4px; }

/* Connexion */
#login { padding-top: 12vh; text-align: center; }
.login-icon { border-radius: 18px; margin-bottom: 14px; }
#login p { max-width: 32ch; margin: 8px auto 24px; }
form { text-align: left; max-width: 340px; margin: 0 auto; }
label { display: block; font-size: 0.9rem; margin-bottom: 6px; color: var(--mist); }
input {
  width: 100%; padding: 14px; font: inherit; color: var(--foam);
  background: var(--deep); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
form button {
  width: 100%; margin-top: 14px; padding: 14px; border: 0; border-radius: var(--radius-sm);
  background: var(--buoy); color: var(--abyss); font-weight: 650; cursor: pointer;
}
.error { color: var(--coral); min-height: 1.4em; font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) { .spin svg { animation: none; } }
.legend .k-buy { background: var(--kelp); }
.legend .k-sell { background: var(--coral); }

/* Solde Kraken */
.wallet { background: var(--foam); color: var(--abyss); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 12px; }
.wallet .muted, .wallet small { color: #4A6B7C; }
.wallet-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.wallet-total { font-size: 2.3rem; font-weight: 700; letter-spacing: -0.02em; margin: 2px 0 8px; }
.assets { list-style: none; margin: 0; padding: 0; }
.assets li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid #C9DAE1; }
.hint { background: var(--deep); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; color: var(--mist); }
.hint.error { color: var(--coral); }

/* Courbe globale */
.overview { background: var(--deep); border-radius: var(--radius-lg); padding: 14px 10px 6px; margin-bottom: 18px; }
.ov-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 8px 8px; }
.ov-head b { font-size: 1.15rem; }
.overview svg, .chart svg { display: block; width: 100%; }
.overview svg { height: 150px; }
.legend .spacer { flex: 1; }
.chart-empty { padding: 30px 0; }

/* Banc d'essai et niveaux TP/SL */
.segmented { grid-template-columns: 1fr 1fr 1fr; }
.segmented button { font-size: 0.92rem; padding: 10px 4px; }
.levels { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.lv { font-size: 0.8rem; padding: 3px 9px; border-radius: 6px; border: 1px dashed; }
.lv.tp { color: var(--kelp); border-color: var(--kelp); }
.lv.sl { color: var(--coral); border-color: var(--coral); }
.legend .k-lines { background: none; border: 1px dashed var(--mist); border-radius: 2px; }
.legend .k-bot { background: var(--buoy); }
.legend .k-hold { background: var(--mist); }
.bt-intro { background: var(--deep); border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 12px; }
.bt-ref { display: flex; justify-content: space-between; align-items: baseline; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.bt-ref b { font-size: 1.2rem; }
.bt-note { margin-top: 4px; }
.verdict { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; color: var(--abyss); white-space: nowrap; }
.verdict.good { background: var(--kelp); }
.verdict.mixed { background: var(--buoy); }
.verdict.bad { background: var(--coral); }
.verdict-line { display: flex; gap: 10px; align-items: baseline; font-size: 0.92rem; }
.half { background: var(--deep); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 8px; }
.half-row { display: flex; justify-content: space-between; margin-top: 4px; }
.legend { flex-wrap: wrap; row-gap: 4px; }
.legend span { white-space: nowrap; }
.bt-ref { gap: 12px; }
