:root {
  --ink: #10151c;
  --panel: #161d27;
  --panel-2: #1c2531;
  --line: #263243;
  --text: #e6ebf2;
  --muted: #8a97a8;
  --faint: #5d6a7c;
  --gold: #d9b25f;
  --gold-ink: #231a05;
  --gain: #2fbf8f;
  --loss: #ef5d6b;
  --warn: #e9a23b;
  --info: #7c9cff;
  --radius: 10px;
  --radius-s: 6px;
  font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--text); font-size: 15px; line-height: 1.45; }
body { font-variant-numeric: tabular-nums; }
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.small { font-size: .85rem; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(360px, 100%); display: grid; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand.big { font-size: 2rem; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background:
  linear-gradient(135deg, transparent 45%, var(--ink) 45% 55%, transparent 55%), var(--gold); flex: none; }
.brand.big .brand-mark { width: 32px; height: 32px; }
.err { color: var(--loss); min-height: 1.2em; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
  border-right: 1px solid var(--line); background: var(--ink); }
.side .brand { padding: 4px 10px 18px; }
.side a:not(.brand) { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-s);
  color: var(--muted); font-weight: 500; }
.side a:not(.brand):hover { background: var(--panel); color: var(--text); text-decoration: none; }
.side a.active { background: var(--panel-2); color: var(--text); }
.side a.active svg { stroke: var(--gold); }
.side svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side .nav-gate { margin-top: 10px; border: 1px solid var(--line); }
.side .nav-bottom { margin-top: auto; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; padding: 14px 28px; background: rgba(16, 21, 28, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.view { padding: 24px 28px 60px; max-width: 1400px; }

/* ---------------------------------------------------------------- form controls */
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; }
textarea { width: 100%; min-height: 110px; resize: vertical; }
label { display: grid; gap: 5px; font-size: .85rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); font-size: .95rem; }
.btn { font: inherit; font-weight: 600; font-size: .9rem; border-radius: var(--radius-s); padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--loss); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.grid-form .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; color: var(--text); font-size: .95rem; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--gold); }

/* ---------------------------------------------------------------- blocks */
.section { margin-bottom: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.cols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.cols-2-1 { display: grid; gap: 20px; grid-template-columns: 2fr 1fr; align-items: start; }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 200px; }

/* KPI strip: une seule bande, séparée par des filets */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.kpi { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.kpi .v { font-size: 1.45rem; font-weight: 600; letter-spacing: -0.02em; }
.kpi .l { color: var(--muted); font-size: .82rem; }
.kpi .s { color: var(--faint); font-size: .78rem; }
.kpi.hero { grid-column: span 2; }
.kpi.hero .v { font-size: 1.9rem; }

/* Carte garde-fous */
.guard { display: grid; gap: 10px; }
.guard .state { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--gain); }
.dot.warn { background: var(--warn); } .dot.stop { background: var(--loss); }
.meter { display: flex; gap: 4px; }
.meter i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.meter i.on { background: var(--gold); } .meter i.bad { background: var(--loss); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; background: var(--panel); position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--panel); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); color: var(--muted); }
.pill.long { color: var(--gain); border-color: rgba(47,191,143,.35); }
.pill.short { color: var(--loss); border-color: rgba(239,93,107,.35); }
.pill.win { background: rgba(47,191,143,.14); color: var(--gain); border-color: transparent; }
.pill.loss { background: rgba(239,93,107,.14); color: var(--loss); border-color: transparent; }
.pill.be, .pill.open { color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--panel-2); color: var(--muted); font-size: .78rem; margin: 0 4px 2px 0; }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.bar-cell .b { height: 8px; border-radius: 2px; }

/* Highlights */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.fact { background: var(--panel); padding: 14px 16px; }
.fact .l { color: var(--muted); font-size: .82rem; }
.fact .v { font-weight: 600; font-size: 1.05rem; margin-top: 2px; }
.insights { display: grid; gap: 8px; }
.insight { padding: 10px 14px 10px 16px; border-left: 3px solid var(--info); background: var(--panel); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.insight.warn { border-color: var(--warn); } .insight.bad { border-color: var(--loss); } .insight.good { border-color: var(--gain); }

/* Calendar */
.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr) 110px; gap: 6px; }
.cal .dow { color: var(--muted); font-size: .8rem; padding: 0 6px; }
.cal .cell { min-height: 92px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 8px; background: var(--panel);
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
.cal .cell:hover { border-color: var(--faint); }
.cal .cell.out { opacity: .3; cursor: default; background: transparent; }
.cal .cell.today { border-color: var(--gold); }
.cal .cell .d { font-size: .8rem; color: var(--muted); display: flex; justify-content: space-between; }
.cal .cell .p { font-weight: 600; margin-top: auto; }
.cal .cell.pos { background: linear-gradient(0deg, rgba(47,191,143,.18), rgba(47,191,143,.05)); border-color: rgba(47,191,143,.35); }
.cal .cell.neg { background: linear-gradient(0deg, rgba(239,93,107,.18), rgba(239,93,107,.05)); border-color: rgba(239,93,107,.35); }
.cal .week { border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 7px 8px; font-size: .82rem; display: flex; flex-direction: column; justify-content: center; }

/* Checklist gate */
.gate { max-width: 760px; }
.steps { display: grid; gap: 10px; margin: 18px 0; }
.step { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px 16px; display: grid;
  grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; }
.step .n { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: .85rem; color: var(--muted); }
.step.done .n { background: var(--gain); border-color: var(--gain); color: var(--ink); }
.step.current { border-color: var(--gold); }
.step.current .n { border-color: var(--gold); color: var(--gold); }
.step.locked { opacity: .38; }
.step.failed { border-color: var(--loss); }
.step.failed .n { background: var(--loss); border-color: var(--loss); color: var(--ink); }
.step .body { display: grid; gap: 4px; }
.step .body .muted { font-size: .85rem; }
.gate-result { border-radius: var(--radius); padding: 22px; border: 1px solid var(--line); background: var(--panel); }
.gate-result.ok { border-color: var(--gain); background: linear-gradient(180deg, rgba(47,191,143,.14), var(--panel)); }
.gate-result.no { border-color: var(--loss); background: linear-gradient(180deg, rgba(239,93,107,.14), var(--panel)); }
.gate-result .big { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }

/* Trade detail */
.detail-head { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.detail-head .title { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.detail-head .title .sym { font-size: 1.6rem; font-weight: 700; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kv > div { padding: 10px 14px; box-shadow: 1px 1px 0 var(--line); }
.kv .l { color: var(--muted); font-size: .8rem; }
.kv .v { font-weight: 600; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.shot { position: relative; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--panel); }
.shot img { display: block; width: 100%; height: 130px; object-fit: cover; cursor: zoom-in; }
.shot button { position: absolute; top: 6px; right: 6px; }
.drop { border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 16px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--gold); color: var(--text); }
.stars button { background: none; border: 0; font-size: 1.3rem; color: var(--line); cursor: pointer; padding: 0 2px; }
.stars button.on { color: var(--gold); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-weight: 500;
  padding: 10px 14px; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }

/* Modal & toast */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink); color: var(--text); padding: 0;
  width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: rgba(5, 8, 12, .7); }
#modal-body { padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: var(--radius-s); z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.bad { border-color: var(--loss); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .btn { margin-top: 12px; }
code, .code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .85em; background: var(--panel-2);
  padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.steps-list { padding-left: 20px; margin: 8px 0; }
.steps-list li { margin: 6px 0; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) { .cols-2-1 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; z-index: 20; padding: 6px;
    border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; gap: 0; }
  .side .brand, .side .nav-bottom span, .side a span { display: none; }
  .side a:not(.brand) { flex: 1; justify-content: center; padding: 10px; }
  .side .nav-gate { margin-top: 0; }
  .side .nav-bottom { margin-top: 0; }
  .topbar { padding: 12px 16px; }
  .view { padding: 16px 16px 90px; }
  .cal { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .cal .week { display: none; }
  .cal .cell { min-height: 58px; padding: 4px; font-size: .75rem; }
  .cal .cell .n2 { display: none; }
  .step { grid-template-columns: 28px 1fr; }
  .step .act { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
