/* ==========================================================================
   CashCAP — charte CAP (reprise de cap-moutier.ch/css/variables.css)
   Mobile first. Chaque écran doit tenir dans un pouce, en marchant.
   ========================================================================== */

:root {
  --cap-red:        #C43B2E;
  --cap-red-dark:   #9E2E23;
  --cap-red-light:  #F2D5D2;
  --jura-blue:      #1B4965;
  --jura-blue-light:#BEE9E8;
  --cream:          #FAF7F2;
  --cream-dark:     #F0EBE3;
  --white:          #FFFFFF;
  --border:         #E4DED4;
  --ink:            #1A1A1A;
  --ink-light:      #6B6B6B;
  --ink-muted:      #9E9E9E;
  --green:          #2D8F5C;
  --green-light:    #D4EDDA;
  --orange:         #E67E22;
  --orange-light:   #FDEBD0;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;

  --font-display: "DM Serif Display", Georgia, serif;
  --font-body: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --transition: .25s cubic-bezier(.4,0,.2,1);
  --max-width: 1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: #fff; padding: .6rem 1rem; z-index: 100;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .75rem clamp(1rem, 4vw, 2rem);
  padding-top: max(.75rem, env(safe-area-inset-top));
  background: var(--white);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar__brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit; }
.brandmark {
  background: var(--cap-red); color: #fff; font-weight: 600;
  font-size: .75rem; letter-spacing: .08em;
  padding: .18rem .5rem; border-radius: var(--radius-sm);
}
.brandname { font-weight: 600; letter-spacing: -.01em; }
.brandname em { font-style: normal; color: var(--ink-muted); font-weight: 400; }

.topbar__nav { display: flex; align-items: center; gap: 1rem; font-size: .875rem; }
.topbar__nav a { color: var(--ink-light); text-decoration: none; }
.topbar__nav a:hover { color: var(--cap-red); }
.inline { display: inline; margin: 0; }
.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: .875rem; color: var(--ink-light);
}
.linkbtn:hover { color: var(--cap-red); }

/* ---------- Layout ---------- */

.shell {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: clamp(1.25rem, 5vw, 2.5rem) clamp(1rem, 4vw, 2rem) 3rem;
  flex: 1;
}
.shell--narrow { max-width: 460px; }
.narrow { max-width: 460px; margin-inline: auto; }
.wide { max-width: 760px; }

.sitefoot {
  display: flex; flex-wrap: wrap; gap: .3rem 1.5rem; justify-content: center;
  padding: 1.25rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  font-size: .8125rem; color: var(--ink-muted);
}
.sitefoot a { color: var(--ink-light); }

/* ---------- Typography ---------- */

h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.85rem, 6vw, 2.5rem); line-height: 1.1;
  margin: 0 0 .5rem; text-wrap: balance;
}
h2 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(1.35rem, 4vw, 1.65rem); line-height: 1.2;
  margin: 2rem 0 .6rem; text-wrap: balance;
}
h3 { font-size: 1.0625rem; font-weight: 600; margin: 1.5rem 0 .4rem; }
p { margin: 0 0 1rem; max-width: 62ch; }
.lead { font-size: 1.0625rem; color: var(--ink-light); }
.muted { color: var(--ink-light); }
.small { font-size: .8125rem; }
a { color: var(--cap-red); text-underline-offset: 2px; }
.mono { font-family: var(--font-mono); }

/* ---------- Stepper ---------- */

.stepper {
  display: flex; gap: .25rem; list-style: none;
  margin: 0 0 1.75rem; padding: 0;
  max-width: 460px; margin-inline: auto;
}
.stepper__item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; position: relative; }
.stepper__item::before {
  content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px;
  background: var(--border); z-index: 0;
}
.stepper__item:first-child::before { display: none; }
.stepper__item--done::before, .stepper__item--current::before { background: var(--cap-red); }
.stepper__dot {
  position: relative; z-index: 1;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: .8125rem; font-weight: 600;
  background: var(--white); border: 2px solid var(--border); color: var(--ink-muted);
}
.stepper__item--done .stepper__dot { background: var(--cap-red); border-color: var(--cap-red); color: #fff; }
.stepper__item--current .stepper__dot { border-color: var(--cap-red); color: var(--cap-red); }
.stepper__label { font-size: .6875rem; color: var(--ink-muted); text-align: center; }
.stepper__item--current .stepper__label { color: var(--cap-red); font-weight: 600; }

/* ---------- Cards ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: clamp(1.15rem, 4vw, 1.75rem);
}
.card + .card { margin-top: 1rem; }
.card__title { font-family: var(--font-display); font-size: 1.25rem; margin: 0 0 .35rem; }

.grid { display: grid; gap: 1rem; }
@media (min-width: 720px) {
  .grid--2 { grid-template-columns: repeat(2, 1fr); }
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
  .grid--4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Forms ---------- */

.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .3rem; }
.field .hint { font-size: .8125rem; color: var(--ink-muted); margin-top: .3rem; }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=tel], textarea, select {
  width: 100%;
  font: inherit;
  font-size: 16px;                 /* 16px prevents the iOS zoom-on-focus jump */
  padding: .7rem .85rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--cap-red);
  box-shadow: 0 0 0 3px var(--cap-red-light);
}
textarea { min-height: 90px; resize: vertical; }

.checkline { display: flex; gap: .65rem; align-items: flex-start; font-size: .9375rem; }
.checkline input { margin-top: .25rem; width: 18px; height: 18px; accent-color: var(--cap-red); flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600; font-size: 1rem;
  padding: .8rem 1.4rem;
  min-height: 48px;                /* comfortable thumb target */
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--cap-red); color: #fff;
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), transform var(--transition);
}
.btn:hover { background: var(--cap-red-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--cap-red); border-color: var(--border); }
.btn--ghost:hover { background: var(--cream-dark); color: var(--cap-red-dark); }
.btn--quiet { background: var(--cream-dark); color: var(--ink); }
.btn--quiet:hover { background: var(--border); }
.btn--danger { background: var(--cap-red); }
.btn--sm { min-height: 36px; padding: .4rem .8rem; font-size: .875rem; }

.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.25rem; }
.actions--end { justify-content: flex-end; }

/* ---------- Flash / alerts ---------- */

.flash {
  padding: .8rem 1rem; border-radius: var(--radius-sm);
  margin-bottom: 1.25rem; font-size: .9375rem;
  border: 1px solid transparent;
}
.flash--ok    { background: var(--green-light); border-color: #b9dfc7; color: #1d5c3a; }
.flash--error { background: var(--cap-red-light); border-color: #e3b3ad; color: var(--cap-red-dark); }

.alert { padding: .8rem 1rem; border-radius: var(--radius-sm); font-size: .9375rem; margin-bottom: 1.15rem; }
.alert--error { background: var(--cap-red-light); color: var(--cap-red-dark); }
.alert--info  { background: var(--jura-blue-light); color: var(--jura-blue); }
.alert--warn  { background: var(--orange-light); color: #8a4b0d; }

/* ---------- Gauge ---------- */

.gauge__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .4rem; }
.gauge__name { font-weight: 600; font-size: .9375rem; }
.gauge__fig { font-family: var(--font-mono); font-size: .8125rem; color: var(--ink-light); }
.gauge__bar {
  height: 12px; border-radius: 999px; overflow: hidden;
  background: var(--cream-dark); border: 1px solid var(--border);
  display: flex;
}
.gauge__used { height: 100%; background: var(--green); transition: width .6s ease; }
.gauge__reserved { height: 100%; background: var(--orange); opacity: .55; }
.gauge--low .gauge__used { background: var(--orange); }
.gauge--empty .gauge__used { background: var(--cap-red); }
.gauge__thanks { font-size: .8125rem; color: var(--ink-light); font-style: italic; margin-top: .5rem; }

/* ---------- Balance ---------- */

.balance { text-align: center; padding: 1.5rem 1rem; }
.balance__value {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 12vw, 3.5rem);
  line-height: 1; color: var(--cap-red);
}
.balance__label { font-size: .875rem; color: var(--ink-light); margin-top: .35rem; }
.balance__sub { font-size: .8125rem; color: var(--ink-muted); margin-top: .5rem; }

/* ---------- Role choice ---------- */

.choices { display: grid; gap: .85rem; margin: 1.25rem 0; }
.choice {
  display: block; text-align: left; width: 100%;
  background: var(--white); border: 2px solid var(--border);
  border-radius: var(--radius-md); padding: 1.1rem 1.2rem;
  cursor: pointer; font: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.choice:hover { border-color: var(--cap-red); box-shadow: var(--shadow-sm); }
.choice__title { font-weight: 600; font-size: 1.0625rem; margin-bottom: .2rem; }
.choice__desc { font-size: .875rem; color: var(--ink-light); }

/* ---------- Enseigne picker ---------- */

.picker { position: relative; }
.picker__results {
  list-style: none; margin: .5rem 0 0; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--white); max-height: 300px; overflow-y: auto;
}
.picker__results:empty { display: none; }
.picker__opt {
  display: block; width: 100%; text-align: left; font: inherit;
  padding: .65rem .85rem; background: none; border: 0; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.picker__opt:last-child { border-bottom: 0; }
.picker__opt:hover, .picker__opt:focus { background: var(--cream-dark); outline: none; }
.picker__name { font-weight: 500; }
.picker__meta { font-size: .8125rem; color: var(--ink-muted); }

.selected {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .85rem 1rem; background: var(--cream-dark);
  border-radius: var(--radius-sm); margin-bottom: 1rem;
}

/* ---------- Tables (committee) ---------- */

.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--white); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-light); background: var(--cream-dark); white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td .mono { font-size: .8125rem; }

.tag {
  display: inline-block; font-size: .6875rem; font-weight: 600;
  padding: .12rem .45rem; border-radius: 999px; white-space: nowrap;
}
.tag--ok      { background: var(--green-light); color: #1d5c3a; }
.tag--wait    { background: var(--orange-light); color: #8a4b0d; }
.tag--off     { background: var(--cap-red-light); color: var(--cap-red-dark); }
.tag--neutral { background: var(--cream-dark); color: var(--ink-light); }

.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a {
  padding: .35rem .8rem; border-radius: 999px; text-decoration: none;
  font-size: .875rem; background: var(--cream-dark); color: var(--ink-light);
}
.tabs a.is-active { background: var(--cap-red); color: #fff; }

.stat { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem 1.1rem; }
.stat__value { font-family: var(--font-display); font-size: 1.85rem; line-height: 1; }
.stat__label { font-size: .8125rem; color: var(--ink-light); margin-top: .3rem; }
.stat--alert .stat__value { color: var(--cap-red); }

.searchrow { display: flex; gap: .5rem; margin-bottom: 1rem; }
.searchrow input { flex: 1; }

details.rowform { margin-top: .4rem; }
details.rowform summary { cursor: pointer; font-size: .8125rem; color: var(--cap-red); }
details.rowform .inner { margin-top: .5rem; display: grid; gap: .5rem; }

/* ---------- Utilities ---------- */

.stack > * + * { margin-top: 1rem; }
.center { text-align: center; }
.hr { height: 1px; background: var(--border); border: 0; margin: 1.75rem 0; }
.badge-soon {
  font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  background: var(--jura-blue-light); color: var(--jura-blue);
  padding: .15rem .45rem; border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Scan et quittances
   ========================================================================== */

.btn--scan { min-height: 60px; font-size: 1.0625rem; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 2.25rem 1.25rem;
  border: 2px dashed var(--border-firm, #CFC5B8);
  border-radius: var(--radius-md);
  background: var(--cream-dark);
  cursor: pointer; text-align: center;
  transition: border-color var(--transition), background var(--transition);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--cap-red); background: var(--cap-red-light); }
.dropzone__icon { color: var(--cap-red); line-height: 0; }
.dropzone__title { font-weight: 600; font-size: 1.0625rem; }
.dropzone__hint { font-size: .8125rem; color: var(--ink-light); max-width: 30ch; }

.preview {
  display: block; width: 100%; max-height: 60vh; object-fit: contain;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--cream-dark);
}
#preview-wrap .actions { justify-content: space-between; }

/* Receipt list */

.receiptlist { list-style: none; margin: 0; padding: 0; }
.receiptlist--flush { margin: 0 -.35rem; }
.receiptlist li + li { border-top: 1px solid var(--border); }

.receiptrow {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .85rem .35rem; text-decoration: none; color: inherit;
}
.receiptrow:hover { background: var(--cream-dark); }
.receiptrow__main { display: flex; flex-direction: column; gap: .12rem; min-width: 0; }
.receiptrow__name {
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.receiptrow__meta { font-size: .8125rem; color: var(--ink-light); }
.receiptrow__side { display: flex; align-items: center; gap: .5rem; flex: none; }
.receiptrow__reward { font-weight: 600; color: var(--green); font-size: .9375rem; }

/* Committee review */

.reviewcard { display: grid; grid-template-columns: 200px 1fr; gap: 1.25rem; margin-bottom: 1rem; }
.reviewcard__img img {
  width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--cream-dark);
}
.reviewcard__head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  flex-wrap: wrap; margin-bottom: .5rem;
}
.reviewform .reject-code { width: auto; min-width: 180px; }
@media (max-width: 700px) {
  .reviewcard { grid-template-columns: 1fr; }
  .reviewcard__img img { max-height: 240px; object-fit: contain; }
}

/* Merchant history bar */

.minibar {
  display: block; height: 8px; border-radius: 999px;
  background: var(--cap-red); opacity: .8; min-width: 2px;
}
