/* Charte admcorp : noir encre #1C1C1E · jaune récompense #FFB23F · blanc cassé #F5F4F0 · Nunito
   Le jaune ne sert qu'au point et aux récompenses, jamais pour du texte sur fond clair. */

@font-face {
  font-family: 'Nunito';
  font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(/fonts/nunito-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url(/fonts/nunito-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

:root {
  color-scheme: light;
  --ink: #1C1C1E;
  --yellow: #FFB23F;
  --paper: #F5F4F0;
  --bg: var(--paper);
  --surface: #FFFFFF;
  --surface-2: #ECEBE6;
  --border: #E2E0D9;
  --text: var(--ink);
  --text-2: #48484C;
  --muted: #737277;
  --accent: var(--ink);
  --accent-ink: var(--paper);
  --series-1: var(--ink);
  --grid: #E6E4DE;
  --good: #1F7A45;
  --bad: #C0362C;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(28,28,30,.04), 0 6px 20px rgba(28,28,30,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: var(--ink); --surface: #26262A; --surface-2: #323237; --border: #3A3A3F;
    --text: var(--paper); --text-2: #CFCEC8; --muted: #9C9B96;
    --accent: var(--paper); --accent-ink: var(--ink); --series-1: var(--paper); --grid: #333338;
    --good: #5CC98A; --bad: #F2837A;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--ink); --surface: #26262A; --surface-2: #323237; --border: #3A3A3F;
  --text: var(--paper); --text-2: #CFCEC8; --muted: #9C9B96;
  --accent: var(--paper); --accent-ink: var(--ink); --series-1: var(--paper); --grid: #333338;
  --good: #5CC98A; --bad: #F2837A;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15.5px/1.5 'Nunito', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; font-weight: 800; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: .95rem; color: var(--text-2); font-weight: 700; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* Point jaune : repère « récompense » */
.dot-y { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: var(--yellow); margin-right: .45em; vertical-align: .05em; flex: none; }

/* Logo : jamais déformé (ratio du viewBox conservé), taille minimale 120 px en horizontal */
.logo { display: block; height: auto; color: var(--text); }
.logo-horizontal { width: 132px; min-width: 120px; }

/* Formulaires */
label { display: block; font-weight: 700; font-size: .85rem; margin: 14px 0 6px; color: var(--text-2); }
input, select {
  width: 100%; padding: 11px 13px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
input:focus, select:focus { outline: 2px solid var(--text); outline-offset: -1px; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px;
}
button.secondary, .btn.secondary { background: var(--surface-2); color: var(--text); }
button.reward-btn { background: var(--yellow); color: var(--ink); }
button.ghost { background: transparent; color: var(--text-2); padding: 8px 10px; }
button:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; margin-top: 18px; }
.error { color: var(--bad); font-size: .9rem; margin-top: 10px; min-height: 1em; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }

/* Écran de connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .panel { width: 100%; max-width: 400px; padding: 28px; }
.auth .logo-horizontal { width: 168px; margin: 0 0 18px; }
.brand { display: flex; align-items: center; padding: 6px 0; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin: 16px 0 8px; }
.tabs button { flex: 1; background: transparent; color: var(--text-2); padding: 8px; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* Mise en page application */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 22px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 4px 12px 22px; }
.nav-btn { justify-content: flex-start; background: transparent; color: var(--text-2); width: 100%; padding: 10px 12px; font-weight: 700; }
.nav-btn.active { background: var(--surface-2); color: var(--text); }
.nav-btn .short { display: none; }
.nav-btn svg { width: 20px; height: 20px; flex: none; }
.sidebar .spacer { flex: 1; }
main { padding: 28px; max-width: 1180px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; z-index: 10;
    flex-direction: row; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar .spacer, .sidebar .logout, .sidebar .shop-label { display: none; }
  .nav-btn { flex: 1; flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 2px; }
  .nav-btn .long { display: none; } .nav-btn .short { display: inline; }
  main { padding: 18px 16px 96px; }
  .mobile-brand { display: block !important; margin-bottom: 18px; }
}
.mobile-brand { display: none; }

/* Segmented control (période) */
.segmented { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 12px; }
.segmented button { background: transparent; color: var(--text-2); padding: 6px 12px; font-size: .85rem; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: .8rem; color: var(--text-2); font-weight: 700; display: flex; align-items: center; }
.kpi .value { font-size: 1.75rem; font-weight: 850; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.delta-up { color: var(--good); } .delta-down { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }
.chart-panel { position: relative; }
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .bar { fill: var(--series-1); }
.chart .bar.dim { opacity: .3; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-1); opacity: .07; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: .8rem; font-weight: 700; padding: 6px 10px; border-radius: 10px;
  transform: translate(-50%, calc(-100% - 10px));
}
details.table-view summary { cursor: pointer; color: var(--text-2); font-size: .85rem; margin-top: 10px; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .72rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--border); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Carte de fidélité (mise en situation « Carte de fidélité » de la charte) */
.loyalty-card {
  --c: #1C1C1E; --ink: #FFFFFF;
  background: var(--c); color: var(--ink); border-radius: 22px; padding: 22px 22px 18px;
  max-width: 420px; display: flex; flex-direction: column; gap: 4px;
  box-shadow: 0 12px 32px rgba(28,28,30,.18);
}
/* Sur fond sombre, un liseré détache la carte noir encre du fond */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .loyalty-card { box-shadow: 0 0 0 1px var(--border); } }
:root[data-theme="dark"] .loyalty-card { box-shadow: 0 0 0 1px var(--border); }
.loyalty-card .logo { color: var(--ink); width: 120px; }
.lc-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.lc-program { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .7; text-align: right; }
.lc-shop { font-size: 1.35rem; font-weight: 850; line-height: 1.2; }
.lc-sub { font-size: .82rem; opacity: .8; }
.lc-body { margin: 16px 0 14px; }
.lc-rewards { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.lc-reward { font-size: .82rem; font-weight: 700; display: flex; align-items: center; opacity: .95; }
.lc-reward b { font-weight: 850; margin-right: 4px; }
/* Paliers non atteints : point en contour ; atteints : point jaune plein */
.lc-rewards .lc-reward:not(.on) .dot-y { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 60%, transparent); }
.lc-rewards .lc-reward:not(.on) { opacity: .75; }
.lc-rewards .lc-reward:only-child .dot-y { background: var(--yellow); box-shadow: none; }
.lc-rewards .lc-reward:only-child { opacity: .95; }
.stamps { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 8px; }
.stamp { aspect-ratio: 1; border-radius: 50%; border: 1.5px solid color-mix(in srgb, var(--ink) 45%, transparent); max-width: 28px; width: 100%; }
.stamp.on { background: var(--ink); border-color: var(--ink); }
.stamp.next { background: var(--yellow); border-color: var(--yellow); }
.stamp.on.reward { background: var(--yellow); border-color: var(--yellow); }
/* Tampon qui donne une récompense intermédiaire (pas encore atteint) */
.stamp.tier { position: relative; }
.stamp.tier::after { content: ""; position: absolute; inset: 32%; border-radius: 50%; background: var(--yellow); }
.points-bar { position: relative; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 22%, transparent); margin: 10px 7px; }
.points-bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 4px; }
.points-bar .tick { position: absolute; top: 50%; width: 10px; height: 10px; border-radius: 50%; transform: translate(-50%, -50%);
  background: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink) 55%, transparent); }
.points-bar .tick.on { background: var(--yellow); box-shadow: 0 0 0 2px var(--c); }
.points-bar .head { position: absolute; top: 50%; width: 16px; height: 16px; border-radius: 50%; background: var(--yellow); transform: translate(-50%, -50%); }

/* Jauge en anneau (« l'anneau devient la jauge de l'app ») */
.gauge { text-align: center; }
.gauge svg { width: 150px; display: block; margin: 0 auto 8px; }
.gauge .track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.gauge .progress { fill: none; stroke: var(--text); stroke-width: 10; stroke-linecap: round; }
.gauge .head { fill: var(--yellow); stroke: var(--surface); stroke-width: 3; }
.gauge text { fill: var(--text); font-size: 22px; font-weight: 850; font-family: inherit; }
.gauge-title { font-weight: 850; font-size: 1.05rem; }
.gauge-sub { color: var(--muted); font-size: .85rem; }

/* Création de carte */
.builder { display: grid; grid-template-columns: 1fr 420px; gap: 28px; align-items: start; }
@media (max-width: 980px) { .builder { grid-template-columns: 1fr; } .builder .preview { order: -1; } }
.preview { position: sticky; top: 20px; }
.type-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-choice button { flex-direction: column; align-items: flex-start; text-align: left; background: var(--surface); color: var(--text); border: 2px solid var(--border); padding: 14px; font-weight: 400; }
.type-choice button strong { font-size: 1rem; font-weight: 800; }
.type-choice button.active { border-color: var(--text); background: var(--surface-2); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 34px; height: 34px; border-radius: 50%; padding: 0; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Caisse */
.till { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .till { grid-template-columns: 1fr; } }
#reader { border-radius: 14px; overflow: hidden; margin-top: 12px; }
#reader video { border-radius: 14px; }
.code-input { display: flex; gap: 8px; }
.code-input input { text-transform: uppercase; letter-spacing: .15em; font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 800; z-index: 20; box-shadow: var(--shadow); }
.share { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; }
.share .qr { background: #fff; padding: 10px; border-radius: 14px; }
@media (max-width: 560px) { .share { grid-template-columns: 1fr; } .share .qr { max-width: 220px; } }

/* Page client */
.client { max-width: 440px; margin: 0 auto; padding: 24px 16px 40px; }
.client .loyalty-card { margin: 0 auto; }
.client .gauge-panel { margin-top: 16px; padding: 22px 20px; }
.client .qr-box { background: #fff; border-radius: 18px; padding: 16px; margin: 16px auto 0; max-width: 260px; text-align: center; color: var(--ink); }
.client .qr-box .code { font-weight: 850; letter-spacing: .2em; font-size: 1.15rem; margin-top: 6px; }
.client-footer { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 26px; color: var(--muted); font-size: .8rem; }
.client-footer .logo { width: 16px; color: var(--text); }
.banner { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-top: 16px; font-size: .9rem; }
.banner.ready { background: var(--yellow); border-color: var(--yellow); color: var(--ink); font-weight: 800; }

/* Boutons wallet (remplacez-les par les badges officiels Apple/Google avant la mise en production) */
.wallet-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.wallet-btn {
  display: inline-flex; align-items: center; gap: 10px; min-width: 170px; padding: 8px 16px;
  background: #000; color: #fff; border-radius: 10px; text-decoration: none; border: 1px solid #444;
  font-weight: 700; font-size: 1rem; line-height: 1.1;
}
.wallet-btn svg { width: 26px; height: 26px; flex: none; }
.wallet-btn small { display: block; font-size: .7rem; font-weight: 400; opacity: .85; }

/* Application Android : adresse du serveur sur l'écran de connexion */
.server-field { margin-top: 14px; }
.server-field summary { cursor: pointer; font-weight: 700; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; overflow-wrap: anywhere; }
/* Barre d'état / encoche du téléphone */
body { padding-top: env(safe-area-inset-top); }

/* Bandeau « Installer sur l'écran d'accueil » (iPhone, Safari) */
.install-hint {
  display: flex; align-items: center; gap: 12px; width: 100%; max-width: 400px; margin: 0 auto 14px;
  background: var(--ink); color: var(--paper); border-radius: 16px; padding: 12px 8px 12px 14px; font-size: .88rem; line-height: 1.35;
}
.install-hint .logo { width: 28px; flex: none; color: var(--paper); }
.install-hint svg[aria-label="Partager"] { width: 16px; height: 16px; vertical-align: -3px; }
.install-hint button { color: var(--paper); padding: 6px 10px; flex: none; }
main .install-hint { max-width: none; }
.auth { align-content: center; }

/* Validation d'un passage par le client */
.checkin-panel h1 { font-size: 1.5rem; margin: 2px 0 6px; }
.checkin-shop { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.checkin-panel input[name=amount] { font-size: 1.6rem; font-weight: 800; text-align: center; padding: 14px; }
.checkin-ok { text-align: center; margin: 8px 0 20px; }
.checkin-ok svg { width: 76px; height: 76px; }
.checkin-ok circle { fill: var(--text); }
.checkin-ok path { fill: none; stroke: var(--yellow); stroke-width: 4.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 40; stroke-dashoffset: 40; animation: tick .45s .15s ease-out forwards; }
@keyframes tick { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .checkin-ok path { animation: none; stroke-dashoffset: 0; } }
.checkin-ok h1 { font-size: 1.6rem; margin: 10px 0 2px; }
.checkin-ok p { margin: 0; color: var(--text-2); font-weight: 700; }
.client .btn-block { margin-top: 16px; }

/* Réglages de validation */
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; color: var(--text); margin: 6px 0 2px; cursor: pointer; }
label.check input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--text); }
select:disabled, input:disabled { opacity: .5; }

/* Caisse rapide */
.quick { max-width: 520px; }
.amount-field { position: relative; }
.amount-field input { font-size: 2.2rem; font-weight: 850; text-align: center; padding: 16px 44px 16px 16px; }
.amount-field span { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); font-size: 1.6rem; font-weight: 800; color: var(--muted); }
.qr-overlay { position: fixed; inset: 0; z-index: 30; background: var(--ink); display: grid; place-items: center; padding: 20px; }
.qr-sheet { background: var(--paper); color: var(--ink); border-radius: 28px; padding: 28px 24px; width: 100%; max-width: 420px; text-align: center; }
.qr-sheet .checkin-ok circle { fill: var(--ink); }
.qr-sheet .checkin-ok p { color: #48484C; }
.qr-sheet button { width: 100%; margin-top: 8px; }
.qr-sheet button.secondary { background: #ECEBE6; color: var(--ink); }
.qr-amount { font-size: 2.4rem; font-weight: 900; letter-spacing: -.01em; }
.qr-big { background: #fff; border-radius: 18px; padding: 14px; margin: 14px auto; max-width: 320px; transition: opacity .3s; }
.qr-big svg { display: block; width: 100%; height: auto; }
.qr-hint { margin: 0; font-weight: 700; }
.qr-timer { margin: 4px 0 8px; color: #737277; font-variant-numeric: tabular-nums; }

/* Derniers passages */
.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.tx-list li:last-child { border-bottom: 0; }
.tx-main { flex: 1; min-width: 0; }
.tx-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tx-meta { font-size: .85rem; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tx-list li.voided .tx-who strong, .tx-list li.voided .tx-meta { text-decoration: line-through; color: var(--muted); }
.src { display: inline-block; font-size: .75rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.src-self { box-shadow: inset 0 0 0 1.5px var(--text-2); background: transparent; }
button.small { font-size: .8rem; padding: 8px 12px; flex: none; }

/* Liste des récompenses (paliers) */
.reward-list { list-style: none; margin: 16px 0 0; padding: 0; text-align: left; }
.reward-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.reward-list .dot-y { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); margin: 0; }
.reward-list li.on .dot-y { background: var(--yellow); box-shadow: none; }
.reward-list .rl-label { flex: 1; font-weight: 700; }
.reward-list .rl-pts { font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.reward-list li.on .rl-pts { color: var(--text); font-weight: 800; }
.tier-row { display: grid; grid-template-columns: 136px 1fr auto; gap: 8px; align-items: center; margin-top: 8px; }
.tier-row .pts { position: relative; }
.tier-row .pts input { padding-right: 68px; }
.tier-row .pts span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .85rem; font-weight: 700; }
.reward-btns { display: grid; gap: 8px; margin-top: 14px; }
.reward-btns .reward-btn { margin: 0; }
