:root {
  --accent: #1aa88a;
  --accent-ink: #fff;
  --ink: #1d2327;
  --muted: #5f6b73;
  --bg: #f4f6f7;
  --card: #fff;
  --line: #d9dfe3;
  --danger: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

button {
  font: inherit; padding: .65rem 1rem; border: 0; border-radius: .5rem;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
button:disabled { opacity: .6; cursor: wait; }
input { font: inherit; padding: .6rem; border: 1px solid var(--line); border-radius: .5rem; width: 100%; }
label { display: grid; gap: .3rem; margin-bottom: .9rem; }
code { word-break: break-all; }
.small { font-size: .85rem; color: var(--muted); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { background: var(--card); padding: 1.5rem; border-radius: .8rem; width: min(100%, 26rem);
  box-shadow: 0 2px 12px rgb(0 0 0 / .06); }
.card h1 { margin-top: 0; }
.card form button, .card section button { width: 100%; }
#enroll-qr { display: block; margin: 0 auto 1rem; background: #fff; }
.codes { font-family: ui-monospace, monospace; columns: 2; }
.message { color: var(--danger); }
details { margin-bottom: .9rem; }

.topbar { display: flex; gap: 1rem; align-items: center; padding: .75rem 1rem; background: var(--card);
  border-bottom: 1px solid var(--line); }
.topbar #who { margin-left: auto; color: var(--muted); }
.content { padding: 1rem; max-width: 60rem; margin: 0 auto; }

/* --- Commun ---------------------------------------------------------------- */
button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.wide { width: 100%; }
a.button { display: inline-block; padding: .65rem 1rem; border-radius: .5rem; background: var(--accent);
  color: var(--accent-ink); text-decoration: none; }
textarea, select { font: inherit; padding: .6rem; border: 1px solid var(--line); border-radius: .5rem; width: 100%; }
textarea { resize: vertical; }
.panel { background: var(--card); border-radius: .8rem; padding: 1rem; margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / .06); }
.panel > * + * { margin-top: 1rem; }
.row { display: flex; gap: .75rem; }
.row > * { flex: 1; }
.notice { background: #fff4e5; border-left: 4px solid #e8a33d; padding: .6rem .8rem; border-radius: .3rem; }
.success { background: #e7f6f1; border-left: 4px solid var(--accent); padding: .6rem .8rem; border-radius: .3rem; }
.warnings { color: #8a5a00; font-size: .9rem; padding-left: 1.2rem; }
.back { font-size: 1.4rem; text-decoration: none; color: var(--ink); }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* --- Scanner --------------------------------------------------------------- */
#reader { width: 100%; max-width: 30rem; margin: 0 auto 1rem; border-radius: .5rem; overflow: hidden; }
#reader video { width: 100% !important; display: block; }

/* --- Score (esprit sqm.app) ------------------------------------------------ */
.score-head .total { font-size: 2.6rem; font-weight: 600; line-height: 1.1; }
.score-head .series { font-size: 1.3rem; color: var(--muted); }
.score-head .series span + span { border-left: 1px solid var(--muted); margin-left: .35rem; padding-left: .35rem; }
.score-head .mean { font-size: 1.3rem; color: var(--muted); }

/* --- Liste des séances ----------------------------------------------------- */
.session-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.session-item { display: flex; justify-content: space-between; gap: 1rem; align-items: center;
  background: var(--card); padding: .8rem 1rem; border-radius: .6rem; box-shadow: 0 1px 6px rgb(0 0 0 / .05); }
.session-item .when { font-weight: 600; }
.session-item .score { text-align: right; }
.session-item .total { font-size: 1.3rem; font-weight: 600; }

/* --- Liste : séances cliquables ------------------------------------------- */
a.session-item { color: inherit; text-decoration: none; }
a.session-item:hover, a.session-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- Page séance ------------------------------------------------------------- */
button.danger { background: var(--danger); color: #fff; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; background: #6ee0c2;
  padding: .7rem; border-radius: .8rem; margin-bottom: 1rem; }
.segmented { display: inline-flex; border: 1px solid #2e6b5c; border-radius: .5rem; overflow: hidden; }
.segmented button { border-radius: 0; background: transparent; color: var(--ink); padding: .55rem .9rem; }
.segmented button[aria-pressed="true"] { background: #eef1f2; }
.segmented button[aria-pressed="true"]::before { content: "✓ "; }
.icon-toggle { background: transparent; color: var(--ink); border: 1px solid #2e6b5c; padding: .55rem .8rem; }
.icon-toggle[aria-pressed="true"] { background: #eef1f2; }
.icon-toggle[aria-pressed="true"]::before { content: "✓ "; }
#edit-open { margin-left: auto; }

.score-card { border: 2px solid #6ee0c2; }
.score-card .total .star, .series-side .star, .shot .star { font-weight: 700; }
.notes { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .8rem 0 0; font-size: .9rem; }
.notes dt { color: var(--muted); }
.notes dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.tabs { display: flex; gap: .2rem; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 1rem;
  scrollbar-width: thin; }
.tabs a { padding: .7rem .9rem; white-space: nowrap; color: var(--ink); text-decoration: none;
  border-bottom: 3px solid transparent; }
.tabs a[aria-selected="true"] { border-bottom-color: var(--accent); background: #e7f6f1; }

/* Cibles SVG (unité : mm) */
.target-panel { display: flex; justify-content: center; }
svg.target { width: 100%; max-width: 32rem; height: auto; display: block; background: #fff; }
.target .ring { fill: #fff; stroke: #1d2327; stroke-width: .12; }
.target .black { fill: #111; }
.target .ring-white { fill: none; stroke: #fff; stroke-width: .12; }
.target .ring-label { font-size: 1.35px; fill: #1d2327; text-anchor: middle; dominant-baseline: central;
  font-family: system-ui, sans-serif; }
.target .ring-label.on-black { fill: #fff; }
.target .impact circle { fill: #6ee0c2; fill-opacity: .92; stroke: #fff; stroke-width: .2; }
.target .impact text { fill: #fff; font-size: 2.3px; font-weight: 700; text-anchor: middle; dominant-baseline: central;
  font-family: system-ui, sans-serif; paint-order: stroke; stroke: #2a9d82; stroke-width: .25; }
.target .group circle { fill: none; stroke: #d0466a; stroke-width: .45; stroke-opacity: .85; }
.target .group path { stroke: #d0466a; stroke-width: .6; stroke-linecap: round; }

.series-card { display: grid; grid-template-columns: 1fr auto; gap: .8rem 1rem; align-items: start; }
.series-card > * + * { margin-top: 0; }
.series-target { grid-column: 1 / -1; display: flex; justify-content: center; }
.shot-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .6rem .4rem; }
.shot { display: grid; gap: .1rem; }
.shot .no { font-size: .75rem; color: var(--muted); }
.shot .val { font-size: 1.05rem; }
.shot .dir { display: flex; align-items: center; gap: .2rem; }
svg.arrow { width: 1rem; height: 1rem; fill: #555; }
svg.arrow .shaft { stroke: #555; stroke-width: 2.2; fill: none; }
.series-side .name { font-size: 1.1rem; }
.series-side .total { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.series-side .inner, .series-side .mean { color: var(--muted); }

/* Statistiques */
.panel h2 { font-size: 1rem; text-align: center; color: var(--muted); margin: 0 0 .5rem; }
.chart-box { position: relative; height: 18rem; }
.chart-box.tall { height: 22rem; }
.split { margin-top: 1rem; }
.split h3 { text-align: center; margin: 0 0 .3rem; font-size: 1rem; }
.split-labels { display: flex; justify-content: space-between; }
.split-labels.pct { font-weight: 700; color: var(--muted); }
.split-bar { display: flex; gap: .3rem; height: .9rem; }
.split-bar .half { flex: 1; background: #eef1f2; border-radius: .4rem; display: flex; overflow: hidden; }
.split-bar .left { justify-content: flex-end; }
.split-bar .left .fill { background: #555; }
.split-bar .right .fill { background: var(--accent); }
.facts { margin: 0; padding-left: 1.2rem; display: grid; gap: .3rem; }

/* Fenêtres de modification / confirmation */
dialog.sheet { border: 0; border-radius: .8rem; padding: 1.2rem; width: min(100% - 2rem, 30rem);
  box-shadow: 0 8px 30px rgb(0 0 0 / .2); }
dialog.sheet::backdrop { background: rgb(0 0 0 / .4); }
dialog.sheet h2 { margin-top: 0; }
dialog.sheet hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* --- Progression ------------------------------------------------------------- */
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
a.button.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .6rem; }
.filters > * + * { margin-top: 0; }
.filters label { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .8rem; margin-bottom: .6rem; }
.stat-card { display: grid; gap: .15rem; background: var(--card); border-radius: .8rem; padding: .9rem 1rem;
  box-shadow: 0 2px 12px rgb(0 0 0 / .06); color: inherit; text-decoration: none; }
a.stat-card:hover, a.stat-card:focus-visible { outline: 2px solid var(--accent); }
.stat-card .label { color: var(--muted); font-size: .9rem; }
.stat-card .value { font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stat-card .delta { font-size: .9rem; color: var(--muted); }
.stat-card .delta.up { color: #13805f; }
.stat-card .delta.down { color: var(--danger); }
.stat-card .sub { font-size: .8rem; color: var(--muted); }
.center { text-align: center; }
label.inline { display: flex; align-items: center; gap: .5rem; justify-content: center; font-size: .9rem; }
label.inline select { width: auto; padding: .3rem .5rem; }
.exports .row a { text-align: center; }

/* Essais (hors statistiques) */
.section-title { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
.section-title .small { font-weight: normal; }
#trials .series-card { border: 1px dashed var(--muted); }

/* Trophées du podium (liste des séances) */
.trophy { width: 1.5rem; height: 1.5rem; vertical-align: -.3rem; margin-right: .4rem; }
.trophy .cup { stroke-width: .8; stroke-linejoin: round; }
.trophy .handle { fill: none; stroke-width: 1.6; }
.trophy.gold .cup { fill: #f5c518; stroke: #a67c00; }
.trophy.gold .handle { stroke: #a67c00; }
.trophy.silver .cup { fill: #d4d7dc; stroke: #7d838c; }
.trophy.silver .handle { stroke: #7d838c; }
.trophy.bronze .cup { fill: #d9894a; stroke: #8a4b1c; }
.trophy.bronze .handle { stroke: #8a4b1c; }

/* --- Progression (refonte) ------------------------------------------------------ */
.stat-card .unit { font-size: .85rem; }
.progress .chart-panel h3 { font-size: .9rem; font-weight: 600; text-align: center; color: var(--muted); margin: .4rem 0 0; }
.chart-box.short { height: 13rem; }
.explain { font-size: .9rem; color: var(--muted); margin: .4rem 0 0; line-height: 1.4; }
.options { border: 0; display: grid; gap: .3rem; }
.options legend { font-weight: 600; padding: 0; margin-bottom: .3rem; }
label.check { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; }
label.check input { width: auto; margin: 0; }
details.more > summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
details.more[open] > summary { margin-bottom: .6rem; }
details.more .chart-panel { padding-top: .8rem; border-top: 1px solid rgb(0 0 0 / .08); }
.heat-legend { display: flex; align-items: center; gap: .5rem; justify-content: center; font-size: .8rem; color: var(--muted); }
.heat-legend .bar { width: 9rem; height: .7rem; border-radius: .35rem;
  background: linear-gradient(90deg, hsl(92 85% 62%), hsl(88 75% 46%), hsl(56 95% 50%), hsl(30 95% 50%), hsl(3 85% 45%)); }

/* Compétition */
.badge-competition { display: inline-block; font-size: .75rem; font-weight: 600; color: #fff; background: #2f5fb3;
  border-radius: .3rem; padding: .05rem .4rem; vertical-align: .1rem; }
.competition-icon { width: 1.1rem; height: 1.1rem; vertical-align: -.2rem; margin-left: .35rem; }
.competition-icon .pole { stroke: #3c4147; stroke-width: 1.6; stroke-linecap: round; }
.competition-icon .flag { fill: #2f5fb3; }

/* --- Cartons papier --------------------------------------------------------------- */
.file-button { position: relative; overflow: hidden; display: inline-flex; justify-content: center; align-items: center; cursor: pointer; }
.file-button input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.cartons progress { width: 100%; height: 1.2rem; }
.totals .total-line { display: flex; justify-content: center; align-items: baseline; gap: .6rem; }
.totals .total { font-size: 2rem; font-weight: 700; }
.totals .series { display: flex; flex-wrap: wrap; gap: .4rem .9rem; justify-content: center; font-variant-numeric: tabular-nums; }
.carton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.carton-tile { display: grid; gap: .25rem; padding: .4rem; background: var(--card); color: inherit; border: 2px solid transparent;
  border-radius: .7rem; text-align: left; font: inherit; cursor: pointer; box-shadow: 0 1px 4px rgb(0 0 0 / .06); }
.carton-tile.doubtful { border-color: #f08c00; background: #fff4e5; }
.carton-tile.error { border-color: var(--danger); }
.carton-tile.validated .score::after { content: " ✓"; color: #13805f; }
.carton-tile .tile-head { display: flex; justify-content: space-between; font-weight: 600; }
.carton-tile .score { font-variant-numeric: tabular-nums; }
.carton-tile .why { font-size: .75rem; color: #a35a00; line-height: 1.2; }
.carton-svg { width: 100%; height: auto; display: block; border-radius: .4rem; background: #eee; }
.carton-svg .ring-theory { fill: none; stroke: #e03131; stroke-width: .08; opacity: .8; }
.carton-svg .hole-detected { fill: none; stroke: #2f9e44; stroke-width: .25; }
.carton-svg .hole-placed { stroke: #c2255c; stroke-width: .3; }
.carton-svg .no-photo { fill: #f1f3f5; }
.carton-svg .no-photo-text { font-size: 4px; text-anchor: middle; dominant-baseline: central; fill: #868e96; }
.carton-sheet { max-width: 34rem; }
.carton-big .carton-svg { max-height: 60vh; }
.stamp-box { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
.stamp-box img { height: 3rem; width: auto; border-radius: .3rem; border: 1px solid var(--line); }
.badge-paper { display: inline-block; font-size: .75rem; font-weight: 600; color: #fff; background: #8a6d3b;
  border-radius: .3rem; padding: .05rem .4rem; vertical-align: .1rem; }
.session-cartons { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: .5rem; }
.session-cartons figure { margin: 0; text-align: center; font-size: .8rem; }
.session-cartons img { width: 100%; height: auto; border-radius: .4rem; display: block; }
