/* Charte Colora : blanc + orange, ou noir + orange */
:root {
  color-scheme: light;
  --bg: #f7f7f7;
  --surface: #ffffff;
  --ink: #000000;
  --muted: #5f5f5f;
  --line: #e2e2e2;
  --accent: #ff6b00;        /* orange Colora : fonds, boutons */
  --accent-ink: #000000;    /* texte posé sur l'orange */
  --accent-text: #c44f00;   /* orange lisible pour du texte sur fond blanc */
  --accent-soft: #fff0e5;
  --danger: #c62828;
  --st-cours: var(--accent-text); --st-cours-bg: var(--accent-soft);
  --st-attente: #1f5fbf; --st-attente-bg: #e5eefc;
  --st-paye: #137a4c;    --st-paye-bg: #e0f4ea;
  --st-intr: #666666;    --st-intr-bg: #eeeeee;
  --font-d: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font: 'Figtree', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 14px;
  --stub: 118px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --surface: #141414; --ink: #ffffff; --muted: #a8a8a8; --line: #2c2c2c;
    --accent: #ff7a1a; --accent-ink: #000000; --accent-text: #ff8c3a; --accent-soft: #2b1606;
    --danger: #ff6b6b;
    --st-attente: #7fa9ff; --st-attente-bg: #13213d;
    --st-paye: #4fd08f;    --st-paye-bg: #0f2c1e;
    --st-intr: #a0a0a0;    --st-intr-bg: #222222;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --surface: #141414; --ink: #ffffff; --muted: #a8a8a8; --line: #2c2c2c;
  --accent: #ff7a1a; --accent-ink: #000000; --accent-text: #ff8c3a; --accent-soft: #2b1606;
  --danger: #ff6b6b;
  --st-attente: #7fa9ff; --st-attente-bg: #13213d;
  --st-paye: #4fd08f;    --st-paye-bg: #0f2c1e;
  --st-intr: #a0a0a0;    --st-intr-bg: #222222;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
}
h1, h2, h3 { font-family: var(--font-d); font-weight: 700; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0; }
code { font-size: .9em; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* --- Barre du haut ------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font: 700 1.35rem/1 var(--font-d); color: var(--ink); text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand b { font-weight: 700; }
.brand span, .login h1 span { font-weight: 500; color: var(--accent-text); }
.brand .logo { height: 32px; width: auto; display: block; }
.brand.has-logo b { display: none; }
.tabs { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.tabs a { white-space: nowrap; }
@media (min-width: 761px) { .topbar { flex-wrap: nowrap; gap: 16px; } .who { flex-shrink: 0; } }
@media (min-width: 761px) and (max-width: 1260px) { .who #userName { display: none; } .tabs a { padding: 8px 11px; } }
.tabs a {
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 600;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--surface); }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
#themeBtn { width: 34px; padding: 0; font-size: 1.05rem; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.live-dot.on { background: var(--st-paye); box-shadow: 0 0 0 3px var(--st-paye-bg); }

.view { max-width: 1080px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 40px) 80px; display: grid; gap: 40px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

/* --- Boutons et champs -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0 18px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font: 600 .95rem var(--font); text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { border-color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: .88rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink);
  font: 400 1rem var(--font);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
textarea { resize: vertical; }
.form-error { color: var(--danger); font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.empty { padding: 32px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--r); }

/* --- Vue d'ensemble : une bande-billet découpée en 4 ------------------- */
.overview {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-radius: var(--r);
  border: 1px solid var(--line);
}
.kpi { display: grid; gap: 2px; padding: 22px 24px; position: relative; }
.kpi + .kpi { border-left: 2px dashed var(--line); }
.k-label { color: var(--muted); font-weight: 600; font-size: .9rem; }
.k-value { font: 700 clamp(1.6rem, 3vw, 2.1rem)/1.1 var(--font-d); font-variant-numeric: tabular-nums; }
.k-sub { color: var(--muted); font-size: .85rem; }
.kpi.warn .k-sub { color: var(--danger); font-weight: 600; }

/* --- Le billet : talon détachable + corps ------------------------------- */
.list { display: grid; gap: 14px; }
.ticket {
  --c: var(--st-cours); --cb: var(--st-cours-bg);
  position: relative;
  display: grid; grid-template-columns: var(--stub) 1fr;
  background: var(--surface);
  border-radius: var(--r);
  border: 1px solid var(--line);
}
.ticket.s-attente_paiement { --c: var(--st-attente); --cb: var(--st-attente-bg); }
.ticket.s-paye { --c: var(--st-paye); --cb: var(--st-paye-bg); }
.ticket.s-introuvable { --c: var(--st-intr); --cb: var(--st-intr-bg); }
/* encoches du billet */
.ticket::before, .ticket::after {
  content: ''; position: absolute; left: calc(var(--stub) - 10px);
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line);
}
.ticket::before { top: -11px; clip-path: inset(50% 0 0 0); }
.ticket::after { bottom: -11px; clip-path: inset(0 0 50% 0); }
.stub {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 18px 16px;
  background: var(--cb); color: var(--c);
  border-radius: var(--r) 0 0 var(--r);
  border-right: 2px dashed var(--line);
}
.num { font: 700 1.6rem/1 var(--font-d); font-variant-numeric: tabular-nums; }
.badge { font-weight: 700; font-size: .8rem; line-height: 1.25; }
.late { margin-top: auto; white-space: nowrap; padding: 2px 8px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; }
.ticket.is-late { border-color: var(--danger); }
.body { padding: 16px 20px; display: grid; gap: 6px; min-width: 0; }
.body-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.body h3 { overflow-wrap: anywhere; }
.seller { flex-shrink: 0; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: .85rem; }
.figures { font-variant-numeric: tabular-nums; }
.figures .eq { color: var(--muted); }
.cashed { margin-left: 8px; color: var(--st-paye); font-weight: 700; }
.details { color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 10px; border-left: 3px solid var(--line); }
.meta { color: var(--muted); font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.client { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.client a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.client a:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { padding: 2px 10px; border-radius: 6px; border: 1px solid var(--line); font-size: .85rem; font-weight: 600; }
.found { font-size: .75rem; font-weight: 700; line-height: 1.25; color: var(--ink); }

/* --- Formulaire nouvelle demande ----------------------------------------- */
.reqform {
  margin-top: 16px; padding: 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
  background: var(--surface); border-radius: var(--r); border: 1px solid var(--line);
}
.reqform .full { grid-column: 1 / -1; }
.sellers { grid-column: 1 / -1; border: 0; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.sellers legend { font-weight: 600; font-size: .92rem; margin-bottom: 8px; }
.group { border: 0; margin: 0; padding: 16px; border-radius: 12px; background: var(--bg); display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.group legend { float: left; width: 100%; grid-column: 1 / -1; font: 700 1rem var(--font-d); margin-bottom: 2px; }
.group input { background: var(--surface); }
.hint { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; }
.choice { border: 0; margin: 0; padding: 0; display: grid; gap: 10px; }
.choice legend { font-weight: 600; font-size: .92rem; margin-bottom: 8px; }
.choice-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.choice-label { width: 82px; color: var(--muted); font-size: .88rem; font-weight: 600; }
.pill { display: inline-flex; cursor: pointer; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { padding: 8px 18px; border-radius: 999px; border: 1.5px solid var(--line); font-weight: 600; }
.pill input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.pill input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.recap {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 16px;
  padding: 16px 20px; border-radius: 12px; background: var(--accent-soft);
}
.recap-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.recap-calc { grid-row: 2; font-variant-numeric: tabular-nums; }
.recap-total { grid-column: 2; grid-row: 1 / span 2; font: 700 2rem/1 var(--font-d); color: var(--accent-text); font-variant-numeric: tabular-nums; }
.recap .recap-label:last-child { grid-column: 2; text-align: right; }

.bank { padding: 18px 22px; background: var(--surface); border-radius: var(--r); border: 1px solid var(--line); border-left: 4px solid var(--accent); }
.bank-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.bank dl { margin: 0; display: grid; gap: 4px; }
.bank dl > div { display: grid; grid-template-columns: 90px 1fr auto; align-items: center; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.bank dt { color: var(--muted); font-weight: 600; font-size: .88rem; }
.bank dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ping-form { display: grid; gap: 10px; margin-top: 6px; }
.bankform { grid-template-columns: 1fr 1fr; }
.bankform h3, .bankform > p, .bankform .full, .bankform .btn { grid-column: 1 / -1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: transparent; color: var(--muted); font: 600 .88rem var(--font); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }

/* --- Classement ----------------------------------------------------------- */
.lead { color: var(--muted); margin-top: -8px; margin-bottom: 32px; }
.podium { border-bottom: 3px solid var(--ink); display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 12px; max-width: 720px; margin: 0 auto; }
.step { display: grid; justify-items: center; text-align: center; gap: 2px; }
.who-name { font: 700 1.2rem var(--font-d); }
.who-ca { font: 700 clamp(1.15rem, 3vw, 1.6rem)/1.2 var(--font-d); font-variant-numeric: tabular-nums; }
.who-sub { color: var(--muted); font-size: .8rem; margin-bottom: 10px; }
.block {
  width: 100%; display: grid; place-items: start center; padding-top: 14px;
  border-radius: 12px 12px 0 0;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0;
  font: 700 2.4rem/1 var(--font-d); color: var(--muted);
  overflow: hidden;
}
.p1 .block { height: 190px; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.p2 .block { height: 140px; }
.p3 .block { height: 100px; }
.rest { list-style: none; padding: 0; margin: 24px auto 0; max-width: 720px; display: grid; gap: 6px; }
.rest li { display: flex; justify-content: space-between; padding: 10px 16px; background: var(--surface); border-radius: 10px; border: 1px solid var(--line); }
.note { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 24px; }

/* --- Admin ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r); border: 1px solid var(--line); }
.admin-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .85rem; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table input:not([type=checkbox]), .admin-table select { padding: 6px 10px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table select { min-width: 104px; }
.table-note { font-size: .85rem; margin-top: 10px; }

.panel > .btn { justify-self: start; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.check input { width: auto; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--st-cours-bg); color: var(--st-cours); font-size: .75rem; font-weight: 700; }
.panel { padding: 22px; background: var(--surface); border-radius: var(--r); border: 1px solid var(--line); display: grid; gap: 12px; align-content: start; }
.addform { margin-top: 16px; grid-template-columns: repeat(4, 1fr); align-items: end; }
.addform h3 { grid-column: 1 / -1; }
.addform .btn { grid-column: 1 / -1; justify-self: start; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Dialogue et toast ---------------------------------------------------- */
dialog { border: 0; border-radius: var(--r); padding: 0; width: min(440px, calc(100% - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dlg { padding: 24px; display: grid; gap: 14px; }
.dlg p { color: var(--muted); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--surface); font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #fff; }

/* --- Connexion ------------------------------------------------------------ */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-ticket { --c: var(--accent); --cb: var(--accent); width: min(460px, 100%); }
.login-ticket { position: relative; display: grid; grid-template-columns: 84px 1fr; background: var(--surface); border-radius: var(--r); border: 1px solid var(--line); }
.login-ticket .stub { background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; border-right-color: var(--surface); }
.login-ticket .logo { width: 56px; height: auto; }
.brand-mark { font: 700 2.6rem/1 var(--font-d); }
.login-ticket .body { padding: 28px; gap: 14px; }
.login h1 { font-size: 1.7rem; }

/* --- Mobile --------------------------------------------------------------- */
@media (max-width: 760px) {
  :root { --stub: 82px; }
  .topbar { gap: 10px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .tabs a { padding: 8px 12px; white-space: nowrap; }
  .late { font-size: .7rem; padding: 2px 6px; }
  .who { margin-left: auto; font-size: .9rem; }
  .who #userName { display: none; }
  .overview { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 16px; }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 2px dashed var(--line); }
  .stub { padding: 14px 10px; }
  .num { font-size: 1.3rem; }
  .body { padding: 14px; }
  .body-head { flex-direction: column; gap: 4px; }
  .reqform { grid-template-columns: 1fr; padding: 18px; }
  .group { grid-template-columns: 1fr; padding: 14px; }
  .choice-label { width: 100%; }
  .addform, .admin-grid, .bankform { grid-template-columns: 1fr; }
  .bank dl > div { grid-template-columns: 1fr auto; }
  .bank dt { grid-column: 1 / -1; }
  .p1 .block { height: 140px; } .p2 .block { height: 100px; } .p3 .block { height: 72px; }
  .who-name { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
