:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --card: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.1);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-2: #f43f5e;
  --green: #4ade80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, var(--bg), var(--bg-alt));
  color: var(--text);
}

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.topnav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.5rem;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}
.topnav a { color: var(--text); text-decoration: none; opacity: 0.85; }
.topnav a:hover { opacity: 1; }
.topnav .brand { font-weight: 700; margin-right: auto; opacity: 1; }
.topnav .logout { color: var(--accent-2); }

h1 { margin-top: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}
/* Repère temporaire (2s, retiré en JS) quand une carte est rejointe depuis un menu déroulant de
   navigation — voir bet-picker sur /my-bets. */
.bet-card-highlight { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow 0.3s; }
.centered { max-width: 380px; margin: 4rem auto; }

form.inline-form { display: inline-block; margin-bottom: 1rem; }
label { display: block; margin-bottom: 1rem; font-size: 0.9rem; color: var(--muted); }
input[type=text], input[type=password] {
  display: block; width: 100%; margin-top: 0.35rem;
  padding: 0.6rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(0,0,0,0.2); color: var(--text);
}

button {
  cursor: pointer;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  font-weight: 600;
}
button:hover { filter: brightness(1.1); }
button.toggle-on { background: var(--green); color: #06280f; }
button.toggle-off { background: rgba(255,255,255,0.1); }

.notice { color: var(--green); }
.error { color: var(--accent-2); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
}
.country-card {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.country-card:hover { border-color: var(--accent); }
.country-card img { width: 24px; height: 18px; object-fit: cover; border-radius: 3px; }

.league-block { margin-bottom: 2rem; }

.stats-panel { margin: 1rem 0 1.5rem; }
.stats-panel h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.stats-panel h2 small { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}
.stat-card {
  display: flex; flex-direction: column; gap: 0.15rem;
  padding: 1rem 1.25rem; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
}
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-sub { color: var(--muted); font-size: 0.8rem; }
.stat-detail { margin-top: 0.4rem; font-size: 0.85rem; color: var(--text); opacity: 0.85; }

table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 600; }

.period-toggle { display: flex; gap: 1.5rem; margin-bottom: 1rem; font-size: 0.95rem; }
.period-option { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.period-option input { accent-color: var(--accent); }

.threshold-panel { display: flex; gap: 2.5rem; flex-wrap: wrap; margin: 1rem 0 1rem; }
.threshold-side {
  flex: 1; min-width: 240px;
  padding: 1rem 1.25rem; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
}
.threshold-side h3 { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.threshold-group { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.9rem; }
.threshold-group:last-child { margin-bottom: 0; }
.threshold-label { color: var(--text); font-size: 0.9rem; }
.threshold-label-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text); }
.filter-checkbox { accent-color: var(--accent); cursor: pointer; }
.threshold-group.inactive { opacity: 0.4; }
.threshold-group.inactive .threshold-label { text-decoration: line-through; }
.direction-select {
  background: rgba(0,0,0,0.25);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  font-size: 0.85rem;
}
.threshold-label output,
.threshold-label-row output {
  display: inline-block;
  min-width: 2.2em;
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.threshold-group input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}
.hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 1.5rem; }

td.threshold-hit { color: var(--green); font-weight: 700; }

.team-form { margin-top: 0.25rem; }
.form-line { color: var(--muted); font-size: 0.78rem; line-height: 1.4; }

.backtest-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}
.badge-miss { background: rgba(244,63,94,0.15); color: var(--accent-2); border-color: rgba(244,63,94,0.3); }

.filter-block {
  margin: 1rem 0 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--border);
}
.filter-block h3 { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

details.filter-block > summary {
  cursor: pointer;
  list-style: none;
}
details.filter-block > summary::-webkit-details-marker { display: none; }
details.filter-block > summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.7em;
  color: var(--muted);
  transition: transform 0.15s ease;
}
details.filter-block[open] > summary::before { transform: rotate(90deg); }
details.filter-block > summary h3 { margin: 0; }
.filter-rate-active-flag { color: var(--accent); text-transform: none; letter-spacing: normal; }
.link-button {
  background: none; border: none; color: var(--accent);
  font-size: 0.8rem; text-transform: none; letter-spacing: normal;
  cursor: pointer; padding: 0; text-decoration: underline;
}
.country-checkboxes { display: flex; flex-wrap: wrap; gap: 0.6rem 1.5rem; }
.country-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; cursor: pointer; }
.country-check input { accent-color: var(--accent); }
.league-subcheck { flex-basis: 100%; margin: -0.3rem 0 0 1.6rem; font-size: 0.8rem; }
.league-subcheck summary { color: var(--muted); cursor: pointer; }
.league-check { display: flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0 0.2rem 0.5rem; cursor: pointer; }
.league-check input { accent-color: var(--accent); }
.date-range { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.date-range label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text); }
.date-range input[type=date] {
  background: rgba(0,0,0,0.25); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.5rem;
}

.badge-signal {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  background: rgba(74,222,128,0.15);
  color: var(--green);
  border: 1px solid rgba(74,222,128,0.3);
  font-size: 0.8rem;
}

.last5-check { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 4px; cursor: pointer; }
.last5-check input { margin-right: 4px; }

.preset-item { display: inline-flex; align-items: center; gap: 4px; background: #1c1c1c; border: 1px solid #444; border-radius: 4px; padding: 4px 8px; margin: 2px; }
.preset-link { text-decoration: none; }
.preset-delete { color: #c33; padding: 0 2px; }
#save-preset-btn { cursor: pointer; }

/* Match qui valide AUSSI une (ou plusieurs) stratégie(s) liée(s) (voir "Lier à" au moment de la
   sauvegarde) — ne change rien au filtrage, juste un repère visuel. tr.linked-match (sans suffixe)
   reste utilisée telle quelle par /opportunities (une seule stratégie liée là-bas, jamais renommée
   côté JS) — NE PAS la retirer même si /backtest ne s'en sert plus. /backtest, lui, distingue une
   couleur par stratégie liée (cycle sur 5 si plus de stratégies liées que de couleurs, voir
   LINKED_MATCH_CLASSES dans backtest.phtml), et une couleur À PART (linked-match-both) dès que 2
   stratégies liées ou plus valident LE MÊME match en même temps — le titre (tooltip) posé sur la
   ligne liste alors les noms exacts, la couleur seule ne les distinguant plus dans ce cas. */
tr.linked-match, tr.linked-match-1 { background: rgba(250, 204, 21, 0.12); }
tr.linked-match:hover, tr.linked-match-1:hover { background: rgba(250, 204, 21, 0.2); }
tr.linked-match-2 { background: rgba(59, 130, 246, 0.12); }
tr.linked-match-2:hover { background: rgba(59, 130, 246, 0.2); }
tr.linked-match-3 { background: rgba(74, 222, 128, 0.12); }
tr.linked-match-3:hover { background: rgba(74, 222, 128, 0.2); }
tr.linked-match-4 { background: rgba(251, 146, 60, 0.14); }
tr.linked-match-4:hover { background: rgba(251, 146, 60, 0.22); }
tr.linked-match-5 { background: rgba(45, 212, 191, 0.14); }
tr.linked-match-5:hover { background: rgba(45, 212, 191, 0.22); }
tr.linked-match-both { background: rgba(217, 70, 239, 0.16); }
tr.linked-match-both:hover { background: rgba(217, 70, 239, 0.24); }
