/* ---------- Thème ---------- */
:root {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --line: #e6e8ec; --line-strong: #d5d9e0;
  --text: #191b20; --text-2: #5f6673; --text-3: #8a909c;
  --accent: #257de0; --accent-ink: #ffffff; --accent-soft: #e8f1fd;
  --series-1: #257de0; --series-2: #f47230; --series-3: #00b894;
  --good: #0a8a1f; --good-soft: #e7f6ea; --warn: #a86500; --warn-soft: #fff4e0; --bad: #c62f30; --bad-soft: #fdecec;
  --grid: #eceef2; --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --radius: 12px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1115; --surface: #191919; --surface-2: #1f2024; --line: #2a2c31; --line-strong: #3a3d44;
  --text: #efefef; --text-2: #a4a9b3; --text-3: #7c818b;
  --accent: #338ced; --accent-ink: #ffffff; --accent-soft: #16263b;
  --series-1: #338ced; --series-2: #e76624; --series-3: #00a888;
  --good: #33c24a; --good-soft: #13281a; --warn: #f0a93a; --warn-soft: #2d2412; --bad: #ef6b6c; --bad-soft: #321819;
  --grid: #26282d; --shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f1115; --surface: #191919; --surface-2: #1f2024; --line: #2a2c31; --line-strong: #3a3d44;
    --text: #efefef; --text-2: #a4a9b3; --text-3: #7c818b;
    --accent: #338ced; --accent-ink: #ffffff; --accent-soft: #16263b;
    --series-1: #338ced; --series-2: #e76624; --series-3: #00a888;
    --good: #33c24a; --good-soft: #13281a; --warn: #f0a93a; --warn-soft: #2d2412; --bad: #ef6b6c; --bad-soft: #321819;
    --grid: #26282d; --shadow: none;
  }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14.5px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { align-self: start; position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--line);
  background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; color: var(--text); }
.brand img { width: 28px; height: 28px; border-radius: 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.side .spacer { flex: 1; }
.main { padding: 28px 32px 60px; max-width: 1320px; width: 100%; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head .sub { color: var(--text-2); margin-top: 2px; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 18px 14px calc(86px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px;
    color: var(--text-3); padding: 4px 0; position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .dot { position: absolute; top: 0; left: 55%; background: var(--bad); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; }
  h1 { font-size: 19px; }
}

/* ---------- Composants ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
:not(.grid) > .card + .card { margin-top: 16px; }
.ic { width: 18px; height: 18px; flex: none; }
.alert .ic { margin-top: 1px; }
.empty .ic { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.g-2 { grid-template-columns: 1.6fr 1fr; }
.g-2e { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .g-2, .g-2e { grid-template-columns: 1fr; } }

.kpi .label { color: var(--text-2); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.kpi .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.delta { font-size: 12.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; display: inline-flex; gap: 3px; align-items: center; }
.delta.up { background: var(--good-soft); color: var(--good); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.delta.flat { background: var(--surface-2); color: var(--text-2); }
.kpi .foot { font-size: 12.5px; color: var(--text-3); }

.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 9px;
  border: 1px solid transparent; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  background: var(--accent); color: var(--accent-ink); }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn.sec { background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--line-strong); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg button { padding: 5px 11px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 550; border: 0; background: none; cursor: pointer; font-family: inherit; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg .on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
:root[data-theme="dark"] .seg .on { background: var(--line-strong); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 10px; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-2); }
label > input, label > select, label > textarea { margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters > label { flex: 1 1 150px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 0 0 14px; }
legend { font-weight: 600; font-size: 13px; padding: 0 6px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface); }
td.n, th.n { text-align: right; white-space: nowrap; }
tbody tr:hover td { background: var(--surface-2); }
tr.ignore td { opacity: .5; }
tfoot td { font-weight: 650; border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.cell-main { font-weight: 550; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--text-3); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.pill.a_valider { background: var(--warn-soft); color: var(--warn); }
.pill.valide, .pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--accent-soft); color: var(--accent); }
.badge { background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }

.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.alert.err { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--good-soft); color: var(--good); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; padding: 40px 10px; color: var(--text-2); }
.empty svg { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 8px; }

/* Barres horizontales (catégories) */
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; gap: 8px; }
.hbar .top span:last-child { font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.hbar .track { height: 8px; background: var(--grid); border-radius: 99px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 99px; min-width: 4px; }

/* Graphiques SVG */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .zero { stroke: var(--line-strong); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hover-band { fill: var(--text); fill-opacity: .06; }
.chart .crosshair { stroke: var(--text-3); stroke-dasharray: 3 3; }
.chart .direct { fill: var(--text-2); font-size: 11.5px; font-weight: 600; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 9px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.14); min-width: 150px;
  opacity: 0; transition: opacity .08s; z-index: 5; }
.tip.on { opacity: 1; }
.tip b { display: block; margin-bottom: 4px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.sr-table { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Listes */
.list { display: flex; flex-direction: column; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list .item:last-child { border-bottom: 0; }
.datebox { width: 46px; flex: none; text-align: center; border: 1px solid var(--line); border-radius: 9px; padding: 4px 0; line-height: 1.15; }
.datebox .d { font-size: 17px; font-weight: 700; }
.datebox .m { font-size: 10.5px; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.list .grow { flex: 1; min-width: 0; }
.list .right { text-align: right; font-variant-numeric: tabular-nums; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.preview { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); object-fit: contain; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--text-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.theme-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 150px)); gap: 12px; }
.theme-choice button { border: 2px solid var(--line); border-radius: 12px; background: var(--surface); padding: 10px; cursor: pointer; color: var(--text); font: inherit; font-weight: 550; }
.theme-choice button.on { border-color: var(--accent); }
.theme-choice .sw { height: 56px; border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--line); }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 860px) { .sticky-actions { bottom: calc(66px + env(safe-area-inset-bottom)); } .hide-m { display: none; } }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 28px; }
.syncing svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }
@media (max-width: 860px) {
  .g-kpi { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 20px; }
  .kpi .foot .delta + * { display: block; }
  .head { margin-bottom: 14px; }
}
.seat-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.seat { font-size: 11.5px; font-weight: 550; padding: 2px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.seats-table td { padding: 4px 4px; border-bottom: 0; }
.seats-table input { min-height: 32px; padding: 5px 8px; min-width: 64px; font-size: 13px; }
.seats-table td:first-child input { min-width: 120px; }
.seats-table tbody tr:hover td { background: none; }
