:root {
  --ink: #1A2238;
  --mist: #EDF0F5;
  --paper: #FFFFFF;
  --star: #F2B300;
  --ok: #1D7A4E;
  --err: #B3261E;
  --muted: #5B6478;
  --line: #D5DAE3;
  --display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--mist); color: var(--ink); font: 400 1.0625rem/1.55 var(--body); }

.top { padding: 1rem 1.25rem; }
.logo { font: 800 1.35rem/1 var(--display); color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.wrap { max-width: 34rem; margin: 0 auto; padding: 0.5rem 1.25rem 4rem; }
.wrap:has(table) { max-width: 60rem; }

h1 { font: 800 clamp(1.9rem, 7vw, 2.6rem)/1.05 var(--display); letter-spacing: -0.03em; margin: 0.75rem 0 1rem; }
.lead { font-size: 1.2rem; }
.muted, small { color: var(--muted); }
small { display: block; font-size: 0.9rem; margin-top: 0.35rem; }
a { color: var(--ink); text-underline-offset: 3px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.08em; }

/* La carte physique : l'élément signature */
.card-visual {
  position: relative; aspect-ratio: 85.6 / 54; max-width: 20rem; margin: 0.5rem 0 1.5rem;
  background: var(--ink); color: #fff; border-radius: 16px; padding: 1.25rem 1.4rem;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 18px 40px -18px rgba(26, 34, 56, 0.55);
  transform: rotate(-3deg);
}
.card-brand { font: 800 1.3rem/1 var(--display); letter-spacing: -0.02em; }
.card-mark { color: var(--star); font-size: 1.7rem; letter-spacing: 0.15em; }
.card-visual--facebook { background: #1877F2; }
.card-visual--instagram { background: linear-gradient(135deg, #F58529 0%, #DD2A7B 55%, #8134AF 100%); }
.card-visual--facebook .card-mark, .card-visual--instagram .card-mark {
  color: #fff; font: 800 2rem/1 var(--display); letter-spacing: -0.02em;
}
.card-num { font-family: ui-monospace, Menlo, monospace; opacity: 0.75; font-size: 0.95rem; }
@media (prefers-reduced-motion: no-preference) {
  .card-visual { animation: land 0.6s cubic-bezier(.2,.8,.2,1) both; }
  @keyframes land { from { transform: rotate(-9deg) translateY(12px); opacity: 0; } }
}

/* Formulaires */
.form { display: grid; gap: 1.1rem; margin: 1.25rem 0; }
.form-inline { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem; }
.form-inline .field { flex: 1 1 6rem; }
fieldset { border: 0; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 1.1rem; }
legend { font: 600 1.1rem/1.3 var(--display); margin-bottom: 0.9rem; padding: 0; }
label { display: block; font-weight: 600; margin-bottom: 0.35rem; }
input:not([type=hidden]), select {
  width: 100%; font: inherit; color: var(--ink); background: var(--paper);
  border: 1.5px solid var(--line); border-radius: 10px; padding: 0.75rem 0.9rem;
}
input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(242, 179, 0, 0.45); }

.btn {
  display: inline-block; font: 600 1.05rem/1 var(--body); color: #fff; background: var(--ink);
  border: 0; border-radius: 999px; padding: 1rem 1.6rem; text-decoration: none; cursor: pointer; text-align: center;
}
.btn:hover { background: #2B3656; }
.btn:focus-visible, .link:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid var(--star); outline-offset: 2px; }
.btn-small { padding: 0.6rem 1rem; font-size: 0.95rem; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link.danger { color: var(--err); }
.actions { margin: 1.5rem 0; display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* Recherche d'établissement */
.search { position: relative; }
.search-results {
  list-style: none; margin: 0.35rem 0 0; padding: 0.35rem; background: var(--paper);
  border: 1.5px solid var(--ink); border-radius: 10px; max-height: 20rem; overflow-y: auto;
}
.search-results button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px;
  padding: 0.65rem 0.7rem; font: inherit; color: var(--ink); cursor: pointer;
}
.search-results button:hover, .search-results button:focus-visible { background: var(--mist); outline: none; }
.search-results strong, .picked strong { display: block; }
.search-results span, .picked span { display: block; color: var(--muted); font-size: 0.92rem; }
.search-msg { padding: 0.65rem 0.7rem; color: var(--muted); }
.picked {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 0.6rem;
  background: var(--paper); border-left: 4px solid var(--star); border-radius: 4px 10px 10px 4px; padding: 0.8rem 1rem;
}
.picked[hidden] { display: none; }

/* Messages */
.flash { padding: 0.85rem 1rem; border-radius: 10px; background: var(--paper); border-left: 4px solid var(--ok); }
.flash-err { border-left-color: var(--err); }

/* Espace client */
.head-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.cards { list-style: none; padding: 0; margin: 1.5rem 0; display: grid; gap: 0.75rem; }
.cardrow {
  background: var(--paper); border-radius: 12px; padding: 1rem 1.1rem;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.cardrow strong, .cardrow .muted { display: block; }
.cardrow .num { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; color: var(--muted); }
.cardrow-side { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.scans b { font: 800 1.4rem/1 var(--display); }
.panel { border-top: 1.5px solid var(--line); padding: 1rem 0; }
.panel summary { font-weight: 600; cursor: pointer; }

/* Admin */
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.65rem 0.8rem; border-bottom: 1px solid var(--mist); vertical-align: top; }
th { font-weight: 600; color: var(--muted); }
.row-actions { display: flex; gap: 0.8rem; white-space: nowrap; }
.row-actions form { margin: 0; }
.tag { font-family: var(--body); letter-spacing: 0; font-size: 0.8rem; color: var(--err); }
.search-admin { margin-top: 1.5rem; }
