/* Charte : violet Artisan Pâtissier de France + bleu/rouge du logo */
:root {
  --violet: #631e67;
  --violet-dark: #4a144d;
  --violet-soft: #f4ecf5;
  --bleu: #0a7cc1;
  --rouge: #c8102e;
  --gris: #7a6a78;
  --ok: #1d7a46;
  --ok-soft: #e6f4ec;
  --warn: #a36100;
  --warn-soft: #fff3df;
  --err: #b3261e;
  --err-soft: #fdeceb;
  --bg: #faf8fa;
  --card: #ffffff;
  --text: #2a1d2b;
  --muted: #6f6370;
  --line: #e6dde7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 20, 60, .06), 0 4px 16px rgba(60, 20, 60, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--violet); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* barre supérieure */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--violet); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
.topbar .title { flex: 1; min-width: 0; }
.topbar .title b { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title span { font-size: .8rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.topbar button.icon { background: rgba(255,255,255,.15); border: 0; color: #fff; border-radius: 10px; padding: 8px 10px; }
.netpill { font-size: .75rem; padding: 4px 9px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.netpill.off { background: #fff; color: var(--rouge); font-weight: 600; }
.netpill.pending { background: #ffd58a; color: #4a2c00; font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 90px); }
main.wide { max-width: 1200px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }

/* boutons */
.btn {
  appearance: none; border: 1px solid transparent; border-radius: 12px;
  padding: 12px 16px; font-weight: 600; cursor: pointer; background: var(--violet); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--violet); border-color: var(--violet); }
.btn.ghost { background: transparent; color: var(--violet); border-color: var(--line); }
.btn.ok { background: var(--ok); }
.btn.danger { background: #fff; color: var(--err); border-color: var(--err); }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: .85rem; border-radius: 9px; }
.btn.block { width: 100%; }

/* formulaires */
label.f { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--violet); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 96px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* badges */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--violet-soft); color: var(--violet); letter-spacing: .02em; }
.badge.pro { background: #e3f0fa; color: #075a8c; }
.badge.amat { background: #fbe7ea; color: #9b0c23; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.grey { background: #eee; color: #555; }

/* listes de passages (jury) */
.entry {
  display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 12px; background: #fff;
  border: 1px solid var(--line); cursor: pointer; width: 100%; text-align: left;
}
.entry + .entry { margin-top: 8px; }
.entry .num {
  width: 52px; height: 52px; border-radius: 12px; background: var(--violet-soft); color: var(--violet);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.3rem; flex: none;
}
.entry.done .num { background: var(--ok-soft); color: var(--ok); }
.entry.draft .num { background: var(--warn-soft); color: var(--warn); }
.entry .info { flex: 1; min-width: 0; }
.entry .info b { display: block; }
.entry .score { font-weight: 800; font-size: 1.1rem; color: var(--violet); }

/* fiche de notation */
.crit { padding: 14px 0; border-bottom: 1px solid var(--line); }
.crit:last-of-type { border-bottom: 0; }
.crit .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.crit .head b { font-size: 1rem; }
.crit .max { color: var(--muted); font-weight: 600; white-space: nowrap; }
.crit .details { font-size: .85rem; color: var(--muted); margin: 2px 0 10px; }
.crit .ctrl { display: flex; align-items: center; gap: 10px; }
.crit .ctrl input[type=number] { width: 110px; font-size: 1.5rem; font-weight: 800; text-align: center; padding: 8px; }
.crit .ctrl input[type=range] { flex: 1; accent-color: var(--violet); height: 34px; }
.stepper { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 1.3rem; font-weight: 700; color: var(--violet); flex: none; }
.totalbar {
  display: flex; justify-content: space-between; align-items: center; background: var(--violet); color: #fff;
  border-radius: 12px; padding: 14px 16px; margin: 14px 0; font-weight: 700;
}
.totalbar .t { font-size: 1.6rem; }
.lockbox { background: var(--ok-soft); color: var(--ok); border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.closedbox { background: #eee; color: #444; border-radius: 12px; padding: 12px 14px; font-weight: 600; }
.errbox { background: var(--err-soft); color: var(--err); border-radius: 12px; padding: 12px 14px; }

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px); display: flex; gap: 10px; justify-content: center;
}
.bottombar > * { max-width: 360px; flex: 1; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 86px); transform: translateX(-50%);
  background: #2a1d2b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 100;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }

/* modale */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 10, 30, .5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .modal-bg { align-items: center; } }
.modal { background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); }
@media (min-width: 700px) { .modal { border-radius: 18px; } }
.modal h2 { margin-bottom: 12px; }

/* écran d'accueil / connexion */
.hero { text-align: center; padding: 24px 8px; }
.hero img { width: 180px; max-width: 60%; }

/* back office */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: calc(env(safe-area-inset-top) + 58px); z-index: 19; scrollbar-width: none; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; border-radius: 99px; font-weight: 600; color: var(--muted); white-space: nowrap; cursor: pointer; }
.tabs button.on { background: var(--violet); color: #fff; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.qrbox { background: #fff; padding: 10px; border-radius: 12px; display: inline-block; line-height: 0; }
.qrbox svg, .qrbox img { width: 100%; height: auto; }
.juries-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.jury-card { text-align: center; }
.jury-card .qrbox { width: 170px; }
.code { font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: .08em; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); }
.chk { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.chk input { width: 22px; height: 22px; accent-color: var(--violet); }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi .card b { font-size: 1.6rem; display: block; color: var(--violet); }

/* podium */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; padding: 20px 0 0; }
.podium .step { flex: 1; max-width: 220px; text-align: center; }
.podium .block { border-radius: 12px 12px 0 0; color: #fff; font-weight: 800; font-size: 2rem; display: flex; align-items: center; justify-content: center; }
.podium .p1 .block { background: #c9a227; height: 170px; }
.podium .p2 .block { background: #9aa0a6; height: 125px; }
.podium .p3 .block { background: #b0703c; height: 95px; }
.podium .who { font-weight: 700; margin-bottom: 4px; }
.podium .pts { color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.fullscreen-qr { position: fixed; inset: 0; background: #fff; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.fullscreen-qr .qrbox { width: min(80vw, 60vh); }

@media print {
  .topbar, .tabs, .bottombar, .noprint { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
  .juries-grid { grid-template-columns: repeat(3, 1fr); }
  .jury-card { break-inside: avoid; border: 1px solid #ccc; }
}
