:root {
  --bg: #0E1116; --panel: #161B22; --line: #262D36; --line-soft: #222932; --raised: #21262D; --raised-line: #3A434E;
  --text: #E6EDF3; --text-2: #C9D1D9; --muted: #9DA7B3;
  --gain: #3FB8FF; --gain-strong: #1F6FEB; --gain-line: #1E4E7A;
  --loss: #FFB86B; --loss-line: #5A3B16; --loss-bg: #2A1C0B;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }
a { color: #7CC8FF; } a:hover { color: #B5DFFF; }
h1, h2 { margin: 0; }
h2 { font-size: 15px; font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.gain { color: var(--gain); } .loss { color: var(--loss); }
.small { font-size: 12px; }
.shell { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
/* Aucun bloc ne doit forcer la page à dépasser l'écran (téléphone) : seuls les tableaux défilent, dans leur cadre. */
.shell > *, .row > *, .kpis > *, .grid-2 > *, .grid-3 > * { min-width: 0; }
.loading { color: var(--muted); padding: 40px 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 12px; }
.panel-head .push { margin-left: auto; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--gain-strong); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-name { font-weight: 700; font-size: 16px; }
.topbar .grow { margin-right: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.badge { font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--raised-line); color: var(--text-2); }
.badge-warn { color: var(--loss); border-color: var(--loss-line); background: var(--loss-bg); }
.badge-live { color: var(--gain); border-color: var(--gain-line); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.dot.ok { background: var(--gain); } .dot.bad { background: var(--loss); }

.btn { font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--raised-line); border-radius: 8px; padding: 8px 12px; min-height: 38px; cursor: pointer; }
.btn:hover { border-color: #56606C; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }
.btn-primary { background: var(--gain-strong); border-color: var(--gain-strong); color: #fff; font-weight: 600; }
.btn-danger { color: var(--loss); border-color: var(--loss-line); background: transparent; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-small { padding: 5px 10px; min-height: 32px; font-size: 12px; }
.btn-block { width: 100%; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.seg .btn { border: 0; background: transparent; color: var(--muted); min-height: 34px; }
.seg .btn[aria-pressed="true"] { background: var(--text); color: var(--bg); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; display: flex; flex-direction: column; gap: 4px; }
.kpi-group { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.kpi-label { font-size: 12px; color: var(--text-2); }
.kpi-value { font-family: var(--mono); font-size: 22px; font-weight: 600; overflow-wrap: anywhere; }
.kpi-sub { font-size: 12px; color: var(--muted); }

.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.main-col { flex: 999 1 min(640px, 100%); min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.side-col { flex: 1 1 min(340px, 100%); min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 16px; }
@media (max-width: 520px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .shell { padding: 12px 12px 32px; gap: 12px; }
  .panel { padding: 12px; }
  .topbar { padding: 10px 12px; gap: 10px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 11px; }
  .kpi-value { font-size: 17px; }
  .seg { flex-wrap: wrap; }
  .seg .btn { padding: 6px 10px; }
  .bars { gap: 4px; height: 140px; }
  .bars-labels { gap: 4px; }
  .bars-labels > div { font-size: 9px; }
  .lat-bars { gap: 2px; }
  .funnel-row .label { width: 110px; font-size: 12px; }
  .panel-head .push { margin-left: 0; width: 100%; }
  .panel-head .push input { width: 100%; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

.table-box { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 10px; white-space: nowrap; }
th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-transform: inherit; letter-spacing: inherit; }
th button[aria-sort] { color: var(--text); }
td { padding: 9px 10px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
td.num, th.num { text-align: right; font-family: var(--mono); }
tr.clickable:hover td { background: #1A2029; }
.kol-link { color: var(--text); font-weight: 600; text-decoration: underline; text-decoration-color: var(--raised-line); text-underline-offset: 3px; }
.bar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--gain); }
.bar.thick { height: 10px; border-radius: 5px; }
.bar.funnel { height: 22px; border-radius: 5px; }
.pill { font-size: 12px; border: 1px solid var(--raised-line); border-radius: 999px; padding: 3px 9px; white-space: nowrap; color: var(--muted); }
.pill.on { color: var(--gain); border-color: var(--gain-line); }
.pill.warn { color: var(--loss); border-color: var(--loss-line); }

.chart { width: 100%; display: block; }
.chart-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 6px; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 170px; }
.bars > div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.bars .fill { width: 100%; border-radius: 5px 5px 0 0; background: var(--gain-strong); min-height: 2px; }
.bars .fill.loss { background: #B26A1D; }
.bars-labels { display: flex; gap: 8px; margin-top: 6px; }
.bars-labels > div { flex: 1; text-align: center; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.lat-bars { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 130px; border-bottom: 1px solid #2D3540; }
.lat-bars .threshold { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--loss); }
.lat-bars .fill { flex: 1; border-radius: 3px 3px 0 0; background: #3A6EA5; min-height: 2px; }
.lat-bars .fill.loss { background: var(--loss); }

.form { display: flex; flex-direction: column; gap: 10px; }
.form label { font-size: 12px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid #2D3540; border-radius: 8px; padding: 9px 10px; min-height: 40px; }
textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.check input { width: 18px; height: 18px; min-height: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.position { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.position-head { display: flex; align-items: center; gap: 8px; }
.position-head .push { margin-left: auto; font-family: var(--mono); font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs a { color: var(--text); background: var(--panel); border: 1px solid var(--line); text-decoration: none; border-radius: 8px; padding: 9px 14px; }
.funnel-row { display: flex; align-items: center; gap: 10px; }
.funnel-row .label { width: 160px; font-size: 13px; color: var(--text-2); }
.funnel-row .bar { flex: 1; }
.funnel-row .count { width: 44px; text-align: right; font-family: var(--mono); }
.missed-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 9px 0; border-top: 1px solid var(--line-soft); }
.missed-row .push { margin-left: auto; font-size: 13px; color: var(--text-2); }
.avatar { width: 44px; height: 44px; border-radius: 10px; background: var(--gain-strong); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; flex: none; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; background: var(--raised); border: 1px solid var(--raised-line); color: var(--text); padding: 12px 16px; border-radius: 10px; white-space: pre-line; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4); }

.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 22px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-message { margin: 0; padding: 10px 12px; border-radius: 8px; color: var(--loss); background: var(--loss-bg); border: 1px solid var(--loss-line); }
.login-note { margin: 0; font-size: 12px; color: var(--muted); }
