:root {
  --bg: #0b0d11;
  --surface: #12151b;
  --surface-2: #181c24;
  --border: #232833;
  --text: #e6e8ee;
  --muted: #8b93a5;
  --faint: #5b6375;
  --pos: #3ecf8e;
  --neg: #f0616d;
  --warn: #e8b04a;
  --accent: #7aa2ff;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }

/* --- barre du haut ------------------------------------------------------ */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px;
  background: rgba(11, 13, 17, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 650; letter-spacing: .01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.ok .dot { background: var(--pos); box-shadow: 0 0 0 3px rgba(62, 207, 142, .15); }
.status.warn .dot { background: var(--warn); }
.status.err .dot { background: var(--neg); }

.btn {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.btn:hover { border-color: var(--faint); }
.btn.icon { padding: 4px 10px; font-size: 16px; line-height: 1; }

main { max-width: 1320px; margin: 0 auto; padding: 20px 24px 60px; }

/* --- filtre par bot ------------------------------------------------------ */

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  font: inherit; font-size: 13px; color: var(--muted);
  background: transparent; border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 14px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); background: var(--surface-2); border-color: var(--faint); }

/* --- indicateurs -------------------------------------------------------- */

.kpis {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-family: var(--mono); font-size: 21px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-value .ccy { font-size: 12px; font-weight: 500; color: var(--faint); margin-left: 5px; }
.kpi-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* --- panneaux ----------------------------------------------------------- */

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
h2 { margin: 0; font-size: 15px; font-weight: 600; }
.count { color: var(--faint); font-weight: 500; margin-left: 4px; }
.note { margin: 10px 0 0; font-size: 12px; color: var(--faint); }
.empty { padding: 28px 8px; text-align: center; color: var(--faint); }

/* --- cartes bots -------------------------------------------------------- */

.bots { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.bot {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
}
.bot-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.bot-name { font-weight: 600; }
.bot-strategy { font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.badge.running { color: var(--pos); border-color: rgba(62, 207, 142, .35); }
.badge.stopped, .badge.offline { color: var(--neg); border-color: rgba(240, 97, 109, .35); }
.badge.dry { color: var(--warn); border-color: rgba(232, 176, 74, .35); }
.bot-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin-top: 14px;
}
.stat-label { font-size: 11px; color: var(--faint); }
.stat-value { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.bot-error { margin-top: 10px; font-size: 12px; color: var(--neg); }

/* --- tableaux ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--faint);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
th.r, td.r { text-align: right; }
.side { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.side.long { color: var(--pos); background: rgba(62, 207, 142, .12); }
.side.short { color: var(--neg); background: rgba(240, 97, 109, .12); }

input[type=search] {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; width: 200px;
}
input[type=search]:focus { outline: none; border-color: var(--accent); }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.pager .btn:disabled { opacity: .4; cursor: default; }

/* --- calendrier --------------------------------------------------------- */

.month-nav { display: flex; align-items: center; gap: 10px; }
#month-label { min-width: 120px; text-align: center; font-weight: 500; text-transform: capitalize; }
.month-summary { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.month-summary b { color: var(--text); font-family: var(--mono); font-weight: 600; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { font-size: 11px; color: var(--faint); text-align: center; padding-bottom: 2px; }
.cal-day {
  min-height: 74px; border-radius: 8px; padding: 7px 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: space-between;
}
.cal-day.blank { background: transparent; border-color: transparent; }
.cal-day.today { border-color: var(--accent); }
.cal-date { font-size: 12px; color: var(--muted); }
.cal-pnl { font-family: var(--mono); font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.cal-trades { font-size: 11px; color: var(--faint); text-align: right; }

@media (max-width: 720px) {
  .topbar { padding: 10px 16px; }
  main { padding: 16px 16px 48px; }
  .brand-sub { display: none; }
  .bots { grid-template-columns: 1fr; }
  .calendar { gap: 3px; }
  .cal-day { min-height: 54px; padding: 4px 5px; }
  .cal-pnl { font-size: 10px; }
  .cal-trades { display: none; }
  input[type=search] { width: 100%; }
}
