/* Kwaba Bons cadeaux : design sobre, mobile d'abord, mode sombre automatique. */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --text: #16253a;
  --muted: #5b6b80;
  --border: #dbe4ef;
  --primary: #0b5fa5;
  --primary-hover: #094c85;
  --primary-soft: #e3f0fb;
  --on-primary: #ffffff;
  --success: #1f7a4d;
  --success-soft: #e0f4ea;
  --warn: #9a5b00;
  --warn-soft: #fdf0d5;
  --danger: #b3261e;
  --danger-soft: #fbe4e2;
  --neutral-soft: #e8ecf1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 37, 58, .06), 0 8px 24px rgba(16, 37, 58, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1622;
    --surface: #162233;
    --surface-2: #1c2b40;
    --text: #e6edf6;
    --muted: #9db0c6;
    --border: #2a3b52;
    --primary: #5aa9ec;
    --primary-hover: #7bbcf2;
    --primary-soft: #17324f;
    --on-primary: #08203a;
    --success: #4cc38a;
    --success-soft: #153a2b;
    --warn: #f0b95b;
    --warn-soft: #3d2f12;
    --danger: #ff8a80;
    --danger-soft: #45201d;
    --neutral-soft: #243246;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
}
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-family: var(--mono); }
.wrap { word-break: break-all; }
.back { text-decoration: none; color: var(--muted); }

/* Barre du haut */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar__inner {
  max-width: 1100px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); }
.brand__logo { background: #fff; border-radius: 10px; padding: 3px 6px; border: 1px solid var(--border); display: inline-flex; }
.brand__logo img { display: block; height: 34px; width: auto; }
.brand__text strong { color: var(--primary); }
.nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.nav a, .nav .link { padding: .45rem .8rem; border-radius: 999px; text-decoration: none; color: var(--text); font-weight: 500; }
.nav a:hover, .nav .link:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.nav__logout { margin: 0; }
.link { background: none; border: 0; font: inherit; cursor: pointer; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 2rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.card--narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card--flush { padding: 0; overflow: hidden; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px;
  padding: .55rem 1.1rem; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn--success { background: var(--success); border-color: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(1.08); background: var(--success); color: #fff; }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn--small { min-height: 34px; padding: .25rem .8rem; font-size: .9rem; }
.btn--large { min-height: 54px; font-size: 1.1rem; }
.btn--block { display: flex; width: 100%; margin-bottom: .6rem; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; min-width: 0; }
.field > span { font-size: .9rem; }
.field--grow { flex: 1 1 220px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .6rem .75rem; min-height: 44px; width: 100%;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.row { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .row { grid-template-columns: repeat(3, 1fr); } }
.hint { background: var(--primary-soft); color: var(--primary); border-radius: 10px; padding: .6rem .8rem; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.check input { width: 22px; height: 22px; min-height: 0; }
.filters { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { flex: 0 1 170px; }
.filters .field--grow { flex: 1 1 220px; }

/* Quantités */
.qty-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.qty { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .8rem; background: var(--surface-2); border-radius: 12px; }
.qty__label { font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: .35rem; }
.stepper__btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 1.4rem; cursor: pointer; }
.stepper__btn:hover { background: var(--primary-soft); }
.stepper input { width: 4.2rem; text-align: center; font-weight: 700; font-size: 1.1rem; padding-left: .25rem; padding-right: .25rem; }
.sticky-bar {
  position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .75rem 1rem; margin-top: .5rem;
}

/* Interrupteur */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; min-height: 0; }
.switch__track { position: absolute; inset: 0; border-radius: 999px; background: var(--neutral-soft); border: 1px solid var(--border); transition: background .15s; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + .switch__track { background: var(--success); border-color: var(--success); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Badges et statistiques */
.badge { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .8rem; font-weight: 700; vertical-align: middle; }
.badge--valid { background: var(--success-soft); color: var(--success); }
.badge--pending { background: var(--warn-soft); color: var(--warn); }
.badge--used { background: var(--primary-soft); color: var(--primary); }
.badge--expired { background: var(--neutral-soft); color: var(--muted); }
.badge--revoked { background: var(--danger-soft); color: var(--danger); }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1rem; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(5, 1fr); } }
.stat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: var(--muted); box-shadow: var(--shadow); }
.stat:hover { border-color: var(--primary); }
.stat__n { font-size: 1.8rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat--valid .stat__n { color: var(--success); }
.stat--used .stat__n { color: var(--primary); }
.stat--revoked .stat__n { color: var(--danger); }

/* Tableaux (cartes sur mobile) */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .75rem 1rem; background: var(--surface-2); }
.table td { padding: .7rem 1rem; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table th.center, .table td.center { text-align: center; }
@media (max-width: 859px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: .6rem .4rem; border-top: 1px solid var(--border); }
  .table td { border: 0; padding: .25rem .8rem; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; font-weight: 600; }
}
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; margin: 1rem 0; }

/* Listes, définitions */
.defs { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 1rem; }
.defs dt { color: var(--muted); }
.defs dd { margin: 0; }
.action-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.qrbox { display: flex; gap: 1rem; align-items: center; padding-top: 1rem; }
.qrbox img { background: #fff; border-radius: 8px; padding: 4px; border: 1px solid var(--border); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.timeline li { display: flex; gap: .75rem; flex-wrap: wrap; align-items: baseline; }
.plain { padding-left: 1.2rem; }

/* Notifications */
.notice { padding: .75rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500; }
.notice--ok { background: var(--success-soft); color: var(--success); }
.notice--error { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; padding: 2.5rem 1rem; }
.bigcode { font-size: 3rem; font-weight: 800; color: var(--primary); margin: 0; }

/* Contrôle (public) */
.page-check .container { max-width: 560px; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.scanner { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 1rem; aspect-ratio: 1 / 1; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner[hidden] { display: none; }
.scanner__frame { position: absolute; inset: 15%; border: 3px solid rgba(255,255,255,.9); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scanner__hint { position: absolute; left: 0; right: 0; bottom: .75rem; text-align: center; color: #fff; margin: 0; font-weight: 600; text-shadow: 0 1px 4px #000; }
.result { border-radius: var(--radius); padding: 1.5rem 1rem; text-align: center; margin-bottom: 1rem; }
.result__icon { font-size: 3.2rem; line-height: 1; }
.result__title { font-size: 2rem; margin: .4rem 0; }
.result__sub { margin: 0; font-weight: 500; }
.result--valid { background: var(--success-soft); color: var(--success); }
.result--pending { background: var(--warn-soft); color: var(--warn); }
.result--used { background: var(--primary-soft); color: var(--primary); }
.result--expired { background: var(--neutral-soft); color: var(--muted); }
.result--revoked { background: var(--danger-soft); color: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .topbar, .footer, .nav, .actions, .sticky-bar { display: none !important; } body { background: #fff; } }

/* Aide, listes d'actions */
.toc { display: flex; flex-wrap: wrap; gap: .5rem; }
.toc a { padding: .35rem .8rem; border-radius: 999px; background: var(--surface-2); text-decoration: none; font-weight: 600; font-size: .9rem; }
.prose ol, .prose ul { padding-left: 1.3rem; margin: 0 0 .75rem; }
.prose li { margin-bottom: .4rem; }
.faq dt { font-weight: 700; margin-top: .75rem; }
.faq dd { margin: .15rem 0 0; color: var(--muted); }
form.inline { display: inline; margin: 0; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-left: .25rem; }
