:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series: #2a78d6;
  --loss: #e34948;
  --up: #006300;
  --down: #d03b3b;
  --live: #0ca30c;
  --shadow: 0 12px 40px rgba(11, 11, 11, 0.18);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series: #3987e5;
    --loss: #e66767;
    --up: #0ca30c;
    --down: #e66767;
    --shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--series); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

.top, .tabbar, main, .foot { max-width: 1480px; margin: 0 auto; padding-inline: 20px; }

/* En-tête */
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; padding-block: 20px 16px; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--text-2); }
.status { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 0; }
.status div { min-width: 0; }
.status dt { color: var(--muted); font-size: 12px; white-space: nowrap; }
.status dd { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.status dd small { font-weight: 400; color: var(--text-2); font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.on { background: var(--live); }
.dot.off { background: var(--down); }

/* Onglets */
.tabbar { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; min-width: 0; margin-bottom: -1px; }
.logout { border: 0; background: none; padding: 6px 0; color: var(--text-2); white-space: nowrap; text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 3px; }
.logout:hover { color: var(--text); }
.tabs button {
  border: 0; background: none; padding: 10px 14px; color: var(--text-2); white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.count { color: var(--muted); font-weight: 400; }

main { padding-block: 16px 32px; }
.hint { color: var(--text-2); margin: 0 0 12px; max-width: 70ch; }
.foot { color: var(--muted); font-size: 12px; padding-block: 0 24px; }

/* Barre d'outils */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button { border: 0; background: none; padding: 6px 12px; color: var(--text-2); white-space: nowrap; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
input[type="search"], input[type="text"], input[type="password"] {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 6px 10px; min-width: 0;
}
input::placeholder { color: var(--muted); }
#search { width: 200px; }
.analyze { display: flex; gap: 6px; margin-left: auto; }
.analyze input { width: 250px; font-family: var(--mono); font-size: 13px; }
.btn, .analyze button {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 6px 12px; white-space: nowrap;
}
.btn:hover, .analyze button:hover { background: var(--surface-2); }
.btn.primary { background: var(--text); color: var(--page); border-color: var(--text); font-weight: 600; }

/* Tableaux */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow-x: auto; }
.table-wrap.narrow { max-width: 760px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; text-align: left; white-space: nowrap; }
th { font-size: 12px; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
td { border-bottom: 1px solid var(--grid); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th[aria-sort] { color: var(--text); font-weight: 650; }
#ranking tbody tr, #signals tbody tr { cursor: pointer; }
#ranking tbody tr:hover, #signals tbody tr:hover { background: var(--surface-2); }
.empty { padding: 40px 20px; text-align: center; color: var(--text-2); white-space: normal; }
.addr { font-family: var(--mono); font-size: 13px; }
.up { color: var(--up); }
.down { color: var(--down); }
.dim { color: var(--muted); }

.star { border: 0; background: none; padding: 2px 4px; font-size: 16px; line-height: 1; color: var(--muted); border-radius: 4px; }
.star:hover { color: var(--text); }
.star.on { color: var(--text); }

.score { display: inline-flex; align-items: center; gap: 8px; }
.score b { min-width: 2.2em; text-align: right; font-weight: 650; }
.meter { width: 44px; height: 4px; border-radius: 2px; background: var(--grid); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--series); border-radius: 2px; }

.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.verdict::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--muted); }
.verdict.copier::before { background: var(--live); }
.verdict.ecarter::before { background: var(--down); }
.review p { margin: 0 0 8px; max-width: 68ch; }
.review-head small { margin-left: 6px; }
.review-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 24px; }
.review h4 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 4px 0; }
.review ul { margin: 0; padding-left: 18px; }
.review li { margin: 2px 0; }
.profile::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--muted); }
.profile.bad::before { background: var(--down); }
.profile.good::before { background: var(--live); }
.profiles { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; align-items: baseline; }
.profiles dd { margin: 0; color: var(--text-2); }
select { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); padding: 6px 10px; font: inherit; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; }
tr.strong td { font-weight: 600; border-top: 1px solid var(--axis); }
.panel h3 { font-size: 15px; margin: 24px 0 8px; }
.panel h3 small { font-weight: 400; font-size: 13px; color: var(--muted); }
.tiles.wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tiles.wide .tile .s { white-space: normal; }
.note.warn { color: var(--down); }
.spark { display: block; }
.spark path { fill: none; stroke: var(--series); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark line { stroke: var(--axis); stroke-width: 1; }

.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; color: var(--text-2); }

/* Wallets suivis */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.card-head .addr { font-size: 14px; font-weight: 600; border: 0; background: none; padding: 0; text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 3px; }
.card-head .spacer { flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); font-size: 13px; margin-bottom: 10px; }
.card-meta b { color: var(--text); font-weight: 600; }
.card table { font-size: 13px; }
.card th, .card td { padding: 5px 8px; }
.card th:first-child, .card td:first-child { padding-left: 0; }
.card th:last-child, .card td:last-child { padding-right: 0; }
.card th { position: static; background: none; }
.card .scroll { overflow-x: auto; }
.card-foot { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--grid); color: var(--text-2); font-size: 13px; }

/* Fiche wallet */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 10; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100%); z-index: 11;
  background: var(--page); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  overflow-y: auto; padding: 20px 24px 40px;
}
.drawer-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.drawer-head h2 { margin: 0; font-family: var(--mono); font-size: 14px; font-weight: 600; overflow-wrap: anywhere; flex: 1; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; align-items: center; }
.drawer h3 { font-size: 13px; font-weight: 600; margin: 24px 0 8px; }
.drawer h3 small { font-weight: 400; color: var(--muted); }
.note { color: var(--text-2); margin: 8px 0; max-width: 68ch; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 18px; font-weight: 600; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .s { font-size: 12px; color: var(--text-2); }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.box.flush { padding: 0; overflow-x: auto; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series); opacity: 0.1; }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .marker { fill: var(--series); stroke: var(--surface); stroke-width: 2; }

.bars { display: grid; grid-template-columns: max-content 1fr max-content; gap: 6px 12px; align-items: center; }
.bars .track { position: relative; height: 14px; }
.bars .track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.bars .bar { position: absolute; top: 2px; height: 10px; min-width: 2px; }
.bars .bar.pos { left: 50%; background: var(--series); border-radius: 0 4px 4px 0; }
.bars .bar.neg { right: 50%; background: var(--loss); border-radius: 4px 0 0 4px; }
.bars .val { text-align: right; font-variant-numeric: tabular-nums; }

.parts { display: grid; grid-template-columns: 1fr 80px max-content; gap: 6px 12px; align-items: center; }
.parts .meter { width: 80px; }
.parts .pts { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; font-variant-numeric: tabular-nums;
}
.tooltip .t { color: var(--muted); margin-bottom: 2px; }
.tooltip b { font-size: 14px; }

/* Connexion */
.login { position: fixed; inset: 0; z-index: 30; background: var(--page); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.login form { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; display: grid; gap: 10px; }
.login h2 { margin: 0 0 6px; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }
.login label { font-size: 13px; color: var(--text-2); }
.login input { width: 100%; padding: 9px 10px; font-family: var(--mono); background: var(--page); }
.login .btn { padding: 9px 12px; }
.login-error { margin: 0; color: var(--down); min-height: 1.45em; }
.login-hint { margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .top, .tabbar, main, .foot { padding-inline: 12px; }
  .analyze { margin-left: 0; width: 100%; }
  .analyze input { flex: 1; width: auto; }
  #search { flex: 1; }
  .cards { grid-template-columns: 1fr; }
  .drawer { padding: 16px 14px 32px; }
}
