:root {
  --bg: #0f1420; --bg2: #161d2d; --card: #1b2336; --line: #2a3550; --text: #e7ecf5; --muted: #8d9ab3;
  --accent: #f5c542; --accent2: #3d7bff; --up: #2fbf71; --down: #ff5d5d; --warn: #ffb020; --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 14px; }
a { color: var(--accent2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .3px; font-size: 18px; }
.brand.big { font-size: 26px; justify-content: center; }
.logo-dot { width: 18px; height: 18px; border-radius: 50%; background: linear-gradient(#ff5d5d 0 46%, #111 46% 54%, #fff 54%); border: 2px solid #111; box-shadow: 0 0 0 2px #fff2; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 18px;
  background: rgba(15,20,32,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.kpis { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; min-width: 110px; }
.kpi > span { display: block; font-size: 11px; color: var(--muted); }
.kpi b { font-size: 16px; }
.pill { border: 1px solid var(--line); background: var(--bg2); color: var(--muted); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.pill.scanning { color: var(--accent2); border-color: var(--accent2); }
.pill.challenge { color: #111; background: var(--warn); border-color: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.logout { margin: 0; }

.tabs { display: flex; gap: 4px; padding: 8px 18px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; cursor: pointer; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
main { padding: 16px 18px 60px; max-width: 1600px; margin: 0 auto; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
input, select, textarea { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font: inherit; }
input[type=search] { min-width: 240px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; margin: 8px 0; min-width: 0; }
label input:not([type=checkbox]), label select { width: 100%; min-width: 0; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); margin: 0; }
.btn { background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #1a1400; border-color: var(--accent); }
.btn.danger { color: var(--down); border-color: #5a2a33; }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.set-group { margin-bottom: 22px; }
.set-head { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 10px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); }
.set-head h3 { margin: 0; font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 165px), 1fr)); gap: calc(var(--tile, 165px) / 12); }
body.compact .tile .body { padding: 5px 6px 6px; }
body.compact .tile .meta { display: none; }
body.compact .tile .name { font-size: 11px; }
body.compact .tile .price { font-size: 13px; }
.size-ctl input { width: 110px; accent-color: var(--accent); }
.copies-head { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.copies-head h3 { margin: 0; font-size: 14px; }
.table.copies input, .table.copies select { padding: 5px 7px; width: 100%; min-width: 70px; }
.table.copies td { padding: 4px 4px; }
.badge.count { background: var(--accent); color: #1a1400; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative; transition: transform .12s, border-color .12s; display: flex; flex-direction: column; }
.tile:hover { transform: translateY(-2px); border-color: #3c4a6c; }
.tile .img { aspect-ratio: 444/620; background: #111827; display: block; width: 100%; object-fit: cover; }
.tile .body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; }
.tile .name { font-weight: 700; font-size: 13px; line-height: 1.25; }
.tile .meta { font-size: 11px; color: var(--muted); }
.tile .price { display: flex; align-items: baseline; gap: 6px; font-size: 16px; font-weight: 800; }
.tile .price small { font-size: 11px; font-weight: 600; }
.badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; }
.badge.cond { background: #2b3a5f; }
.badge.ed1 { background: #111; border: 1px solid #fff5; }
.badge.deal { background: var(--up); color: #062; }
.badge.alert { background: var(--warn); color: #111; }
.badge.untracked { background: #444; }
.up { color: var(--up); } .down { color: var(--down); } .flat { color: var(--muted); }
.gain-pos { color: var(--up); } .gain-neg { color: var(--down); }
.src-guide { color: var(--muted); font-size: 10px; font-weight: 600; }
.add-btn { position: absolute; bottom: 8px; right: 8px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 8px; font-size: 16px; }
.panel h3 { margin: 14px 0 4px; font-size: 13px; color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; }
.settings-grid .panel { margin: 0; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 13px; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 38px; height: 22px; border-radius: 99px; background: #39445f; position: relative; flex: none; transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .15s; }
.switch input:checked + span { background: var(--up); }
.switch input:checked + span::after { left: 19px; }

.live-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; max-width: 1280px; }
.live-wrap img { width: 100%; display: block; cursor: crosshair; min-height: 120px; }

.modal { border: 0; padding: 0; background: transparent; color: var(--text); max-width: min(1100px, 96vw); width: 100%; }
.modal.small { max-width: 520px; }
.modal::backdrop { background: rgba(5,8,14,.7); backdrop-filter: blur(3px); }
.modal-inner { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 20px; position: relative; box-shadow: var(--shadow); }
.close { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-grid { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.modal-left img { width: 100%; border-radius: 14px; display: block; margin-bottom: 10px; background: #111827; aspect-ratio: 444/620; object-fit: cover; }
.modal-right h2 { margin: 0; }
.price-table { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 12px 0 8px; }
.price-cell { background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 6px 8px; text-align: center;
  color: var(--text); font: inherit; cursor: pointer; position: relative; overflow: hidden; transition: opacity .15s; }
.price-cell::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--cc, transparent); }
.price-cell.off::after { opacity: .2; }
.price-cell.off b, .price-cell.off span { opacity: .55; }
.price-cell:hover { border-color: var(--cc, var(--line)); }
.price-cell .cc { color: var(--cc); font-weight: 600; }
.price-cell b { display: block; font-size: 15px; }
.price-cell span { font-size: 11px; color: var(--muted); }
.price-cell.mine { border-color: var(--accent); }
.guide { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.guide b { color: var(--text); }
.chart-legend { align-items: center; }
.chart-box { height: 220px; position: relative; }
.chart-legend { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chart-legend button { font-size: 11px; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--line); background: none; color: var(--text); cursor: pointer; }
.chart-legend button.off { opacity: .35; }
.edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; align-items: end; margin-top: 6px; }
textarea { width: 100%; resize: vertical; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table img { width: 38px; border-radius: 4px; }
.events { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; max-height: 420px; overflow: auto; }
.events div { padding: 3px 0; border-bottom: 1px solid #ffffff08; }
.lvl-warn { color: var(--warn); } .lvl-error { color: var(--down); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #273250; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; box-shadow: var(--shadow); }
#toast.show { opacity: 1; }

.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #1d2a4a, var(--bg) 60%); }
.login-card { width: min(360px, 92vw); background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 26px; box-shadow: var(--shadow); text-align: center; }
.login-card label { text-align: left; }
.login-card input { font-size: 16px; }
.alert { background: #3a1d24; color: #ffb3b3; border: 1px solid #6b2a35; padding: 8px 10px; border-radius: 8px; margin: 8px 0; font-size: 13px; }

@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .brand { order: 1; flex: 1; }
  #live-pill { order: 2; max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logout { order: 3; }
  .kpis { order: 4; flex: 1 1 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .kpi { min-width: 0; padding: 4px 6px; }
  .kpi > span { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .kpi b { font-size: 13px; white-space: nowrap; }
  main { padding: 12px 12px 60px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(calc(var(--tile, 165px) * .85), 1fr)); }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-left img { max-width: 240px; margin: 0 auto 10px; }
  .price-table { grid-template-columns: repeat(3, 1fr); }
  .edit-grid { grid-template-columns: 1fr 1fr; }
  input[type=search] { min-width: 0; flex: 1 1 100%; }
}

.activity { z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0;
  padding: 10px 18px 14px; background: #17213a; border-bottom: 1px solid var(--line); position: relative; }
.activity.warn { background: #3a2c0f; }
.activity .act-text { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; flex: 1; }
.activity .act-actions { display: flex; gap: 6px; }
.activity .act-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #ffffff10; }
.activity .act-bar div { height: 100%; background: var(--accent2); transition: width .5s; }
.activity.warn .act-bar div { background: var(--warn); }
.activity .act-bar div.indet { width: 30% !important; animation: indet 1.4s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }
.steps { padding-left: 18px; margin: 6px 0 10px; color: var(--text); }
.steps li { margin: 4px 0; }
#device-bar.activity { border-top: 1px solid var(--line); }
.sel-bar { position: sticky; top: 66px; z-index: 12; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px;
  margin-bottom: 14px; background: #1f2a47; border: 1px solid var(--accent2); border-radius: 12px; box-shadow: var(--shadow); }
.tile.selecting { outline: 2px dashed transparent; }
.tile.selected { outline: 3px solid var(--accent2); outline-offset: -1px; }
.tile.selecting .img { opacity: .75; }
.tile.selected .img { opacity: 1; }
.sel-box { position: absolute; z-index: 3; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 7px; background: #0f1420d0;
  border: 2px solid #fff8; color: #fff; display: grid; place-items: center; font-weight: 900; }
.tile.selected .sel-box { background: var(--accent2); border-color: var(--accent2); }
.btn.primary-outline { border-color: var(--accent2); color: var(--accent2); }
.scope-pick { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 10px 0; }
.scope-pick > span:first-child { flex-basis: 100%; }
.badge.traque { background: #3a2c0f; }
.chips { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.chips button { background: var(--bg2); color: var(--muted); border: 0; padding: 7px 13px; cursor: pointer; font-weight: 600; border-right: 1px solid var(--line); }
.chips button:last-child { border-right: 0; }
.chips button.active { background: var(--accent); color: #1a1400; }
.evo-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi.big { padding: 12px 14px; background: var(--card); }
.kpi.big b { font-size: 22px; display: block; margin-top: 2px; }
.kpi.big small { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi.link { cursor: pointer; } .kpi.link:hover { border-color: var(--accent2); }
.chart-box.tall { height: 300px; }
.evo-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.evo-cols .panel { margin-bottom: 16px; }
.mover { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mover:hover { background: #ffffff06; }
.mover img { width: 40px; border-radius: 4px; }
.mv-name { display: flex; flex-direction: column; min-width: 0; }
.mv-name b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-prices { white-space: nowrap; text-align: right; }
.mv-delta { display: flex; flex-direction: column; align-items: flex-end; min-width: 86px; }
.setbar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 12px; align-items: center; padding: 5px 0; }
.sb-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-track { height: 10px; background: #ffffff0d; border-radius: 6px; overflow: hidden; }
.sb-track div { height: 100%; background: var(--accent2); border-radius: 0 4px 4px 0; }
.sb-val { white-space: nowrap; text-align: right; min-width: 130px; }
@media (max-width: 760px) {
  .evo-cols { grid-template-columns: 1fr; }
  .mover { grid-template-columns: 34px 1fr auto; }
  .mv-prices { display: none; }
  .setbar { grid-template-columns: 1fr auto; }
  .sb-track { grid-column: 1 / -1; order: 3; }
}
.panel-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.panel-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
.table.perf td, .table.perf th { white-space: nowrap; }
.table.perf td:nth-child(2) { white-space: normal; min-width: 180px; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover, .table th.sorted { color: var(--text); }
.table tfoot td { border-bottom: 0; padding-top: 10px; }
/* objectif atteint : contour doré */
.badge.traque.hit { background: var(--warn); color: #111; }
.tile.target-hit { border-color: #f5c542; box-shadow: 0 0 0 2px #f5c542, 0 0 18px #f5c54255; }
.table tr.target-hit td { background: #f5c54214; border-top: 1px solid #f5c54288; border-bottom: 1px solid #f5c54288; }
.table tr.target-hit td:first-child { box-shadow: inset 4px 0 0 #f5c542; }
.hit-label { color: #f5c542; }
/* fiche carte */
.m-num { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 6px; white-space: nowrap; }
.copy-actions { white-space: nowrap; text-align: right; }
.edit-grid.two { grid-template-columns: 1fr 1fr; }
.chart-box.small-chart { height: 150px; margin-top: 6px; }
.modal-inner { max-height: 92vh; overflow-y: auto; overflow-x: hidden; }
@media (max-width: 760px) {
  .modal { max-width: 100vw; margin: 0; max-height: 100dvh; }
  .modal-inner { padding: 14px 12px; border-radius: 14px; max-height: 100dvh; }
  .modal-grid { gap: 12px; }
  .modal-left { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: end; }
  .modal-left img { max-width: 110px; margin: 0; }
  .modal-right h2 { font-size: 18px; padding-right: 26px; }
  .m-num { display: inline; font-size: 12px; margin-left: 4px; white-space: normal; }
  .price-table { grid-template-columns: repeat(3, 1fr); }
  .chart-box { height: 180px; }
  .table.copies thead { display: none; }
  .table.copies, .table.copies tbody { display: block; width: 100%; }
  .table.copies tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px; margin-bottom: 8px;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
  .table.copies td { border: 0; padding: 0; min-width: 0; }
  .table.copies td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  .table.copies .copy-n { grid-column: 1 / -1; }
  .table.copies .copy-actions { grid-column: 1 / -1; text-align: left; display: flex; gap: 6px; }
  .table.copies input, .table.copies select { min-width: 0; width: 100%; }
  .edit-grid, .edit-grid.two { grid-template-columns: 1fr 1fr; }
  .modal .row .btn { flex: 1 1 auto; }
}
.row label.grow { flex: 1; min-width: 160px; margin: 0; }
#proxy-test-result { margin-top: 8px; line-height: 1.6; }

.tile .price.up { color: var(--up, #2fbf71); }
.tile .price.down { color: var(--down, #ff5d5d); }
