/* TRUalea — charte TRUvector */
:root {
  --bg: #0b1020; --bg2: #0f1629; --card: #131b30; --card2: #1a2440; --line: #26314f;
  --txt: #e8ecf6; --mut: #8a96b4; --acc: #f0b93a; --acc-ink: #1a1405;
  --ok: #3ccf8e; --warn: #f5a524; --bad: #ff5d6c; --blue: #5aa9ff;
  --c1: #5aa9ff; --c2: #f0b93a; --c3: #3ccf8e; --c4: #c38bff; --c5: #ff7a90; --c6: #8a96b4;
  --radius: 14px; --shadow: 0 8px 30px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb; --bg2: #eaeef7; --card: #ffffff; --card2: #f1f4fa; --line: #d9dfec;
    --txt: #141a2b; --mut: #5b6684; --acc: #8a5f00; --acc-ink: #fff;
    --ok: #0b6b45; --warn: #8a5300; --bad: #a81d2f; --blue: #1a5fb4;
    --c1: #1f6fd1; --c2: #b9820a; --c3: #12895a; --c4: #7b3fd0; --c5: #c9283a; --c6: #5b6684;
    --shadow: 0 6px 20px rgba(20, 30, 60, .08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg2: #eaeef7; --card: #ffffff; --card2: #f1f4fa; --line: #d9dfec;
  --txt: #141a2b; --mut: #5b6684; --acc: #8a5f00; --acc-ink: #fff;
  --ok: #0b6b45; --warn: #8a5300; --bad: #a81d2f; --blue: #1a5fb4;
  --c1: #1f6fd1; --c2: #b9820a; --c3: #12895a; --c4: #7b3fd0; --c5: #c9283a; --c6: #5b6684;
  --shadow: 0 6px 20px rgba(20, 30, 60, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html { background: var(--bg); }
body {
  margin: 0; background: radial-gradient(1200px 600px at 10% -10%, var(--bg2), transparent) no-repeat, var(--bg);
  color: var(--txt); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--blue); }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: .98rem; margin: 0 0 10px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--acc); color: var(--acc-ink); padding: 6px 10px; border-radius: 8px; z-index: 10; }

/* Barre du haut */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; max-width: 1180px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-weight: 800; font-size: 1.35rem; letter-spacing: -.5px; line-height: 1.1; }
.logo span { color: var(--acc); }
.tagline { color: var(--mut); font-size: .78rem; }
.top-actions { min-width: 0; display: flex; align-items: center; gap: 8px; }
.icon-btn { flex: none; background: var(--card); color: var(--txt); border: 1px solid var(--line); border-radius: 10px; height: 36px; min-width: 40px; padding: 0 10px; cursor: pointer; font-weight: 600; }
.icon-btn:hover { border-color: var(--acc); }
.badge { min-width: 0; flex: 0 1 auto; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .8rem; color: var(--mut); white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }
.badge b { color: var(--txt); }

/* Onglets */
.tabs { position: sticky; top: 0; z-index: 5; display: flex; gap: 4px; overflow-x: auto; padding: 8px 20px; max-width: 1180px; width: 100%; margin: 0 auto; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; background: transparent; color: var(--mut); border: 1px solid transparent; border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.tabs button:hover { color: var(--txt); }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--txt); border-color: var(--line); box-shadow: inset 0 -2px 0 var(--acc); }
.tabs button.disabled { font-weight: 500; text-decoration: underline dotted; text-underline-offset: 4px; }

main { flex: 1; max-width: 1180px; width: 100%; margin: 0 auto; padding: 8px 20px 40px; }
.panel { animation: fade .2s ease; }
@media (prefers-reduced-motion: reduce) { .panel { animation: none; } * { scroll-behavior: auto !important; } }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cartes et grilles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.grid2e { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .v { font-size: 1.35rem; font-weight: 750; }
.kpi .l { color: var(--mut); font-size: .8rem; }
@media (max-width: 860px) { .grid2, .grid2e, .grid3 { grid-template-columns: minmax(0, 1fr); } }

/* Formulaires */
.field { min-width: 0; display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: .85rem; color: var(--mut); }
.field > span { font-weight: 600; }
input, select, textarea { width: 100%; font: inherit; color: var(--txt); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, button:focus-visible, .dropzone:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 520px) { .row4, .row3 { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: .9rem; cursor: pointer; }
.check input { flex: none; width: 18px; height: 18px; accent-color: var(--acc); }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.grow { flex: 1; }
.btn { font: inherit; font-weight: 650; border: 1px solid var(--acc); background: var(--acc); color: var(--acc-ink); border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--txt); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: var(--acc); }
.btn.danger { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; background: transparent; color: var(--mut); border: 0; padding: 7px 12px; cursor: pointer; }
.seg button.on { background: var(--acc); color: var(--acc-ink); font-weight: 650; }

.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 16px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; cursor: pointer; transition: .15s; background: var(--card2); }
.dropzone:hover, .dropzone.over { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 8%, var(--card2)); }
.drop-icon { font-size: 1.8rem; color: var(--acc); }
.dropzone span { color: var(--mut); font-size: .85rem; }

.muted { color: var(--mut); }
.small { font-size: .82rem; }
.saved-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.saved-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); }
.saved-item .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Boules */
.balls { display: inline-flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.ball { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 750; font-size: .85rem; background: var(--card2); border: 1.5px solid var(--blue); color: var(--txt); font-variant-numeric: tabular-nums; }
.ball.bonus { border-color: var(--acc); color: var(--acc); }
.ball.sm { width: 24px; height: 24px; font-size: .75rem; }
.ball.hit { background: var(--ok); border-color: var(--ok); color: #04150d; }
.plus { color: var(--mut); margin: 0 2px; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--mut); font-weight: 650; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--txt); }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 170px; }
tr.hl td { background: color-mix(in srgb, var(--acc) 10%, transparent); }
.scroll-y { max-height: 420px; overflow: auto; }

/* Alertes / verdicts */
.alert { border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: var(--card); }
.alert.ok { border-left-color: var(--ok); }
.alert.warn { border-left-color: var(--warn); }
.alert.bad { border-left-color: var(--bad); }
.alert p { margin: 4px 0 0; }
.verdict { display: flex; gap: 14px; align-items: center; }
.verdict .big { font-size: 2rem; line-height: 1; }
.verdict h3 { margin: 0; font-size: 1.1rem; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .75rem; font-weight: 700; }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.watch { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.bias { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }

.progress { height: 6px; background: var(--card2); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress > div { height: 100%; width: 0; background: var(--acc); transition: width .15s; }

canvas { width: 100%; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .8rem; color: var(--mut); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .dash { width: 16px; height: 0; border-top: 2px dashed var(--txt); border-radius: 0; vertical-align: 3px; }
.chart-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--txt); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: .78rem; box-shadow: var(--shadow); white-space: nowrap; }

/* Calendrier */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .dow { text-align: center; font-size: .72rem; color: var(--mut); font-weight: 650; padding-bottom: 2px; }
.cal .day { aspect-ratio: 1.3; border-radius: 8px; background: var(--card2); display: flex; align-items: flex-start; justify-content: flex-end; padding: 4px 6px; font-size: .78rem; color: var(--mut); position: relative; }
.cal .day.out { background: transparent; border: 1px dashed var(--line); color: var(--mut); }
.cal .day.out.past { background: color-mix(in srgb, var(--blue) 12%, transparent); }
.cal .day.past { background: color-mix(in srgb, var(--blue) 22%, var(--card2)); color: var(--txt); }
.cal .day.next { background: var(--acc); color: var(--acc-ink); font-weight: 750; }
.cal .day.risk { background: color-mix(in srgb, var(--warn) 35%, var(--card2)); color: var(--txt); }
.cal .day.today { outline: 2px solid var(--txt); }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.next-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.next-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); }
.conf { font-variant-numeric: tabular-nums; color: var(--mut); font-size: .85rem; }

.empty { text-align: center; padding: 50px 20px; color: var(--mut); }
.empty .big { font-size: 2.4rem; margin-bottom: 6px; }
.grids { display: flex; flex-direction: column; gap: 8px; }
.grid-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); flex-wrap: wrap; }
.grid-item .idx { color: var(--mut); width: 22px; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--mut); font-weight: 600; }
details p { margin: 8px 0; }
.footer { border-top: 1px solid var(--line); padding: 16px 20px 26px; font-size: .8rem; max-width: 1180px; width: 100%; margin: 0 auto; }
.footer p { margin: 4px 0; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--txt); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 60; font-weight: 600; max-width: calc(100vw - 32px); }

@media (max-width: 600px) {
  .topbar, .tabs, main { padding-left: 16px; padding-right: 16px; }
  .tagline { display: none; }
  .topbar { gap: 8px; }
  .badge { max-width: 34vw; }
  .card { padding: 14px; }
  .ball { width: 27px; height: 27px; font-size: .8rem; }
  .hide-sm { display: none; }
  th, td { padding: 6px 5px; }
  td.wrap { min-width: 130px; }
}
.icon-btn svg { width: 18px; height: 18px; vertical-align: middle; }
.btn-row select, .btn-row input[type="date"] { width: auto; }

@media print {
  .topbar .top-actions, .tabs, .footer, .btn, .btn-row, .dropzone { display: none !important; }
  body { background: #fff; color: #000; }
  .panel[hidden] { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* v2 : carnet, calculs */
.tickets { display: flex; flex-direction: column; gap: 10px; }
.ticket { border: 1px solid var(--line); border-radius: 12px; background: var(--card2); padding: 10px 12px; }
.ticket-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-head .grow { min-width: 200px; }
.ticket-status { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.ticket details { margin-top: 8px; }
input.manual, input.pay { width: 110px; padding: 5px 8px; text-align: right; }
.keno-table input { width: 58px; padding: 4px 5px; text-align: right; }
.keno-table th, .keno-table td { padding: 3px 2px; }
#rg-banner .alert { margin-bottom: 10px; }
#rg-banner:empty { display: none; }

textarea { color: var(--txt); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
textarea:focus { outline: 2px solid var(--acc); outline-offset: 1px; }

/* v3 : labo, apprendre, mode présentation */
.scenario-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.scenario-q { font-size: 1.25rem; margin: 12px 0; }
.scenario-card details p { font-size: 1.02rem; }
input[type="range"] { padding: 0; accent-color: var(--acc); background: transparent; border: 0; }
body.present .topbar, body.present .tabs, body.present .footer, body.present #rg-banner { display: none; }
body.present main { max-width: 1400px; }
body.present .card { font-size: 1.15rem; }
body.present .scenario-q { font-size: 2rem; line-height: 1.25; }
body.present .scenario-card { min-height: 60vh; display: flex; flex-direction: column; justify-content: center; }
body.present .scenario-card details p { font-size: 1.4rem; }

.lang-select { width: auto; padding: 0 6px; font-weight: 600; }
