/* ==========================================================
   Copy Trading Polymarket — dashboard
   Palette : rôles clairs/sombres (voir tokens ci-dessous)
   ========================================================== */

:root {
    --page:           #f9f9f7;
    --surface:        #fcfcfb;
    --ink:            #0b0b0b;
    --ink-2:          #52514e;
    --muted:          #898781;
    --hairline:       rgba(11, 11, 11, 0.10);
    --grid:           #e1e0d9;
    --good:           #0ca30c;
    --good-text:      #006300;
    --warn:           #fab219;
    --critical:       #d03b3b;
    --critical-text:  #a32b2b;
    --accent:         #2a78d6;
    --row-hover:      rgba(11, 11, 11, 0.04);
}

@media (prefers-color-scheme: dark) {
    :root {
        --page:           #0d0d0d;
        --surface:        #1a1a19;
        --ink:            #ffffff;
        --ink-2:          #c3c2b7;
        --muted:          #898781;
        --hairline:       rgba(255, 255, 255, 0.10);
        --grid:           #2c2c2a;
        --good:           #0ca30c;
        --good-text:      #0ca30c;
        --warn:           #fab219;
        --critical:       #d03b3b;
        --critical-text:  #e66767;
        --accent:         #3987e5;
        --row-hover:      rgba(255, 255, 255, 0.04);
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

:root { color-scheme: light dark; }

html { background: var(--page); }

body {
    min-height: 100vh;
    background: var(--page);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- Header ---------- */
.topbar {
    display: flex; flex-wrap: wrap; gap: 12px;
    align-items: center; justify-content: space-between;
    padding: 4px 2px 16px;
}
.brand h1 { font-size: 20px; font-weight: 650; }
.target-line { margin-top: 4px; color: var(--ink-2); font-size: 13px; }
.target-line a { color: var(--accent); font-weight: 600; text-decoration: none; }
.target-line a:hover { text-decoration: underline; }
.addr { color: var(--muted); font-size: 12px; margin-left: 6px; }
.sep { margin: 0 6px; color: var(--muted); }

.badge {
    display: inline-block; margin-left: 8px; padding: 1px 8px;
    border-radius: 10px; font-size: 11px; font-weight: 700;
}
.badge-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.controls { display: flex; align-items: center; gap: 10px; }

.pill {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--hairline); background: var(--surface);
    font-size: 12px; font-weight: 650;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill-on  .dot { background: var(--good); }
.pill-on  { color: var(--good-text); }
.pill-off .dot { background: var(--critical); }
.pill-off { color: var(--critical-text); }

.uptime { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.btn {
    border: 1px solid var(--hairline); border-radius: 8px;
    background: var(--surface); color: var(--ink);
    padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-danger  { background: var(--critical); border-color: transparent; color: #fff; }
.btn-ghost   { background: transparent; color: var(--ink-2); }
.btn-sm      { padding: 4px 10px; font-size: 12px; }

/* ---------- Bandeau d'erreur ---------- */
.error-banner {
    border: 1px solid var(--critical);
    background: color-mix(in srgb, var(--critical) 10%, transparent);
    color: var(--critical-text);
    border-radius: 10px; padding: 10px 14px; margin-bottom: 16px;
    font-size: 13px; white-space: pre-wrap;
}

/* ---------- Stat tiles ---------- */
.tiles {
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: 18px;
}
.tile {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 12px 14px;
}
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 26px; font-weight: 650; margin-top: 2px; }
.tile-value.good { color: var(--good-text); }
.tile-value.bad  { color: var(--critical-text); }
.tile-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Badge de source de detection */
.src {
    display: inline-block; padding: 1px 7px; border-radius: 6px;
    font-size: 11px; font-weight: 650; white-space: nowrap;
}
.src-onchain  { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.src-activity { background: color-mix(in srgb, var(--muted) 20%, transparent); color: var(--ink-2); }
.src-other    { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }

/* ---------- Panels ---------- */
.panel {
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 18px;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
}
.panel-head h2 { font-size: 15px; font-weight: 650; }

/* ---------- Table ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
    padding: 6px 10px; border-bottom: 1px solid var(--grid);
    white-space: nowrap;
}
tbody td {
    padding: 7px 10px; border-bottom: 1px solid var(--grid);
    vertical-align: top;
}
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.time { color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
td.market { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.outcome { color: var(--ink-2); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

.status {
    display: inline-flex; align-items: center; gap: 6px;
    font-weight: 650; font-size: 12px; white-space: nowrap;
}
.status .ico { font-weight: 800; }
.status-ok   { color: var(--good-text); }
.status-miss { color: var(--critical-text); }
.status-err  { color: var(--warn); }
.status-sell { color: var(--muted); }
.status-reason { display: block; color: var(--muted); font-weight: 400; font-size: 11px; margin-top: 1px; white-space: normal; }

/* ---------- Logs ---------- */
.log-box {
    background: var(--page);
    border: 1px solid var(--grid);
    border-radius: 8px;
    padding: 10px 12px;
    max-height: 380px; overflow-y: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; line-height: 1.5;
    color: var(--ink-2);
    white-space: pre-wrap; word-break: break-word;
}

.foot { color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 640px) {
    .tile-value { font-size: 21px; }
    .brand h1 { font-size: 17px; }
}
