/* Prototype Récupérathèque
   Direction : l'étiquette d'inventaire. Encre sombre sur papier brut,
   bleu de travail pour l'interface, jaune signal pour le solde.
   Peu d'aplats de couleur : les cartes doivent coûter peu d'encre. */

:root {
  --ink:    #16211b;
  --paper:  #e6e7e0;
  --card:   #fcfcf9;
  --blue:   #2c4a72;
  --signal: #e4b23c;
  --credit: #2f6b4a;
  --debit:  #a8402a;
  --line:   rgba(22, 33, 27, .22);
  --sans:   system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:   ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 46rem; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* ---------- chrome ---------- */

.topbar {
  background: var(--blue);
  color: #fff;
  padding: .7rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  align-items: baseline;
}
.topbar b { font-size: .95rem; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button {
  color: #fff;
  font: inherit;
  font-size: .85rem;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.eyebrow {
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(22, 33, 27, .6);
  margin: 1.6rem 0 .4rem;
}
h1 { font-size: 1.5rem; letter-spacing: -.01em; margin: .2rem 0 1rem; }

.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a {
  padding: .35rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  font-size: .85rem;
}
.tabs a[aria-current] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- blocs ---------- */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.panel h2 { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; margin: 0 0 .8rem; }

label { display: block; font-size: .8rem; letter-spacing: .04em; margin-bottom: .2rem; }
input[type=text], input[type=password], input[type=number], select {
  font: inherit;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  max-width: 22rem;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .8rem; }
.row > * { flex: 1 1 8rem; }

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: .6rem 1rem;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn-ghost { background: transparent; color: var(--ink); }
.btn-credit { background: var(--credit); border-color: var(--credit); color: #fff; }
.btn-debit  { background: var(--debit);  border-color: var(--debit);  color: #fff; }

/* ---------- listes ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a.item {
  display: flex;
  gap: .8rem;
  align-items: baseline;
  padding: .7rem .2rem;
  text-decoration: none;
  color: inherit;
}
.list a.item:hover { background: rgba(44, 74, 114, .07); }
.num { font-family: var(--mono); font-size: .8rem; color: rgba(22,33,27,.55); }
.grow { flex: 1; }
.amount { font-family: var(--mono); font-weight: 600; white-space: nowrap; }
.amount.neg { color: var(--debit); }

.ops { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.ops li { display: flex; gap: .7rem; padding: .45rem 0; border-top: 1px dotted var(--line); }
.ops .when { font-family: var(--mono); font-size: .78rem; color: rgba(22,33,27,.55); white-space: nowrap; }
.empty { color: rgba(22,33,27,.55); font-size: .9rem; }

/* ---------- la carte de membre ----------
   Toutes les dimensions dérivent de --u pour que la carte soit
   exactement au format CR80 (85,6 x 54 mm) à l'impression et
   qu'elle se réduise proprement sur un écran étroit. */

.card {
  --u: min(1mm, calc((100vw - 2.5rem) / 86));
  position: relative;
  width: calc(85.6 * var(--u));
  height: calc(54 * var(--u));
  padding: calc(4 * var(--u)) calc(4 * var(--u)) calc(3.5 * var(--u)) calc(8 * var(--u));
  background: var(--card);
  border: calc(.35 * var(--u)) solid var(--ink);
  border-radius: calc(3 * var(--u));
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
/* bande perforée : le clin d'oeil à l'étiquette agrafée sur une planche */
.card::before {
  content: "";
  position: absolute;
  left: calc(3 * var(--u));
  top: calc(5 * var(--u));
  bottom: calc(5 * var(--u));
  width: calc(1.4 * var(--u));
  background-image: radial-gradient(var(--ink) 40%, transparent 42%);
  background-size: calc(1.4 * var(--u)) calc(4 * var(--u));
  opacity: .5;
}
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: calc(2 * var(--u)); }
.card-shop {
  font-size: calc(2.5 * var(--u));
  letter-spacing: .13em;
  text-transform: uppercase;
  font-weight: 700;
  line-height: 1.1;
}
.card-num { font-family: var(--mono); font-size: calc(3 * var(--u)); letter-spacing: .05em; }
.card-name {
  align-self: center;
  font-size: calc(5 * var(--u));
  font-weight: 600;
  line-height: 1.15;
  padding-right: calc(27 * var(--u));
}
.card-blank {
  align-self: center;
  padding-right: calc(27 * var(--u));
  border-bottom: calc(.3 * var(--u)) dotted var(--ink);
  height: calc(7 * var(--u));
}
.card-foot { display: flex; align-items: flex-end; gap: calc(2 * var(--u)); }
.card-label {
  font-size: calc(2.1 * var(--u));
  letter-spacing: .14em;
  text-transform: uppercase;
  opacity: .65;
}
.card-hint { font-size: calc(2.6 * var(--u)); line-height: 1.25; padding-right: calc(27 * var(--u)); }
.card-host { font-family: var(--mono); font-size: calc(2.2 * var(--u)); opacity: .6; margin-top: calc(1 * var(--u)); }
.card-qr {
  position: absolute;
  right: calc(4 * var(--u));
  bottom: calc(4 * var(--u));
  width: calc(22 * var(--u));
  height: calc(22 * var(--u));
}
.card-qr svg { width: 100%; height: 100%; display: block; }

/* ---------- page publique ---------- */

.public { padding: 1.2rem 1rem 3rem; max-width: 30rem; margin: 0 auto; }
.big-balance {
  font-family: var(--mono);
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  margin: .2rem 0 .1rem;
  background: linear-gradient(transparent 62%, var(--signal) 62%);
  display: inline;
  padding: 0 .1em;
}
.hint { font-size: .85rem; color: rgba(22,33,27,.6); }

/* ---------- planche d'impression ---------- */

.sheet {
  display: grid;
  grid-template-columns: repeat(2, 85.6mm);
  gap: 6mm 8mm;
  justify-content: center;
  padding: 1rem 0;
}
.sheet .card { --u: 1mm; }

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { background: #fff; }
  .no-print { display: none !important; }
  .sheet { padding: 0; gap: 5mm 8mm; }
  .card { break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

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

/* ---------- ajouts de la version complète ---------- */

.muted { color: rgba(22,33,27,.55); font-size: .85rem; }
.topbar .muted { color: rgba(255,255,255,.75); }

.notice {
  background: #fcfcf9;
  border: 1px solid var(--blue);
  border-left: 4px solid var(--blue);
  border-radius: 3px;
  padding: .7rem .9rem;
  margin: 0 0 1rem;
  font-size: .92rem;
}

.panel.danger { border-color: rgba(168, 64, 42, .5); }
.panel.danger h2 { color: var(--debit); }

.danger-link { color: var(--debit); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; }

.tag {
  display: inline-block;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .05rem .5rem;
  vertical-align: .1em;
  color: rgba(22,33,27,.65);
}

.list .item { display: flex; gap: .8rem; align-items: baseline; padding: .7rem .2rem; }
.list div.item { color: inherit; }
.list .item a { color: inherit; }
.mini-logo { width: 1.6rem; height: 1.6rem; object-fit: contain; align-self: center; }

textarea {
  font: inherit;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  width: 100%;
  max-width: 22rem;
  resize: vertical;
}
code { font-family: var(--mono); font-size: .85em; word-break: break-all; }

/* logo sur la carte */
.card-logo {
  width: calc(8 * var(--u));
  height: calc(8 * var(--u));
  object-fit: contain;
  flex: 0 0 auto;
}
.card-top { align-items: center; }
.card-shop { flex: 1; }

/* ---------- journal replié ---------- */

.currency-name {
  font-size: 1.05rem;
  letter-spacing: .02em;
  color: rgba(22, 33, 27, .65);
  margin-left: .35rem;
}

details.more { margin: .2rem 0 1rem; }
details.more > summary {
  display: inline-block;
  cursor: pointer;
  list-style: none;
  font-size: .82rem;
  letter-spacing: .04em;
  padding: .35rem .8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--blue);
  background: #fcfcf9;
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: " ▾"; }
details.more[open] > summary::after { content: " ▴"; }
details.more > summary:hover { border-color: var(--blue); }
details.more .ops { margin-top: .4rem; }
