:root {
  --surface: #FAF8F4;
  --raised: #FFFFFF;
  --line: #D9D3C7;
  --line-strong: #8C8577;
  --ink: #16213A;
  --muted: #5B6275;
  --sidebar-text: #B9C2D8;
  --indigo: #233D91;
  --indigo-soft: #E9EDF8;
  --paid: #1E6B45;
  --paid-soft: #E8F4EC;
  --due: #8A4B00;
  --due-soft: #FDF1DC;
  --late: #A8261B;
  --late-soft: #FCEBE9;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 24px; }
body { min-height: 100vh; }
button, input { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--indigo); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.banner { background: #FDF1DC; color: #8A4B00; font-size: 13px; line-height: 18px; text-align: center; padding: 4px 8px; font-weight: 600; }

/* ---------- Structure ---------- */
.app { min-height: calc(100vh - 26px); display: flex; flex-direction: column; }
.layout { flex: 1; display: flex; flex-direction: column; }
.sidebar { display: none; }
.content { flex: 1; display: flex; flex-direction: column; }
.topbar { background: var(--ink); padding: 14px 16px 12px; }
.topbar .sigle { font-size: 18px; line-height: 24px; font-weight: 700; color: #fff; }
.topbar .who { font-size: 14px; line-height: 20px; color: var(--sidebar-text); }
.backbar { background: var(--raised); border-bottom: 1px solid var(--line); height: 56px; display: flex; align-items: center; padding: 0 8px; position: sticky; top: 0; z-index: 2; }
.back { display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 8px; font-weight: 600; text-decoration: none; background: none; border: 0; color: var(--indigo); cursor: pointer; }
main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 18px 16px 96px; display: flex; flex-direction: column; gap: 16px; }
h1 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 700; }
h2 { margin: 0; font-size: 17px; line-height: 24px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; line-height: 20px; }
.label { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: 64px; background: var(--raised); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); z-index: 3; padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; color: var(--muted); font-size: 14px; border-top: 3px solid transparent; }
.tabbar a.on { color: var(--indigo); font-weight: 700; border-top-color: var(--indigo); }
.count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--indigo); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- Éléments ---------- */
.card { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile .amount { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.verify { display: none; }
.green { color: var(--paid); } .brown { color: var(--due); } .red { color: var(--late); }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 56px; padding: 8px 16px; border-radius: 12px; font-size: 17px; line-height: 22px; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; border: 0; }
.btn.primary { background: var(--indigo); color: #fff; }
.btn.danger { background: var(--late); color: #fff; }
.btn.outline { background: var(--raised); color: var(--ink); border: 1px solid var(--line-strong); font-size: 16px; }
.btn.outline-indigo { background: var(--raised); color: var(--indigo); border: 2px solid var(--indigo); }
.btn.outline-red { background: var(--raised); color: var(--late); border: 2px solid var(--late); }
.btn small { display: block; font-size: 14px; font-weight: 400; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-col .sub { flex-direction: column; gap: 0; }
.linkbtn { background: none; border: 0; padding: 10px; color: var(--indigo); font-weight: 600; text-decoration: underline; cursor: pointer; font-size: 15px; }

.action { background: var(--indigo-soft); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.rows { display: flex; flex-direction: column; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 8px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .go { color: var(--indigo); font-weight: 600; white-space: nowrap; }
.row .extra { display: none; }

.pill { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--paid-soft); color: var(--paid); }
.pill.late { background: var(--late-soft); color: var(--late); }

.due-box { background: var(--due-soft); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.big { font-size: 30px; line-height: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ok-box { background: var(--paid-soft); border-radius: 12px; padding: 20px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.check { width: 56px; height: 56px; border-radius: 999px; background: var(--paid); color: #fff; display: flex; align-items: center; justify-content: center; }

.field { display: flex; flex-direction: column; gap: 6px; }
.step { font-weight: 600; }
.input { height: 52px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 14px; background: var(--raised); font-size: 18px; width: 100%; }
.input.amount { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.amount-row { display: flex; align-items: center; gap: 10px; }
.amount-row span { font-weight: 600; font-size: 17px; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choices.list { grid-template-columns: 1fr; }
.choice { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 12px; border: 1px solid var(--line-strong); background: var(--raised); border-radius: 12px; cursor: pointer; font-size: 15px; line-height: 20px; }
.choices.list .choice { min-height: 56px; font-size: 16px; }
.choice input { width: 20px; height: 20px; margin: 0; accent-color: var(--indigo); flex-shrink: 0; }
.choice.on { border: 2px solid var(--indigo); background: var(--indigo-soft); font-weight: 600; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--raised); font-size: 14px; cursor: pointer; }
.chip.on { border: 2px solid var(--indigo); background: var(--indigo-soft); color: var(--indigo); font-weight: 600; }
.chip.on.red { border-color: var(--late); background: var(--late-soft); color: var(--late); }
.recap { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.warn { background: var(--due-soft); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.compare > div { border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.compare .was { background: var(--raised); border: 1px solid var(--line); }
.compare .now { background: var(--due-soft); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.facts .wide { grid-column: span 2; }
details.old { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; }
details.old summary { min-height: 52px; display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
details.old summary::-webkit-details-marker { display: none; }
details.old .inner { padding-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.pay-line { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pay-line:last-child { border-bottom: 0; }

.member-head { background: var(--raised); border-bottom: 1px solid var(--line); padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.copy-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line); }
.copy-line:last-child { border-bottom: 0; }
.copy-btn { height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--raised); font-weight: 600; cursor: pointer; }
.idcard { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 20px 18px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.qr { width: 168px; height: 168px; display: grid; grid-template-columns: repeat(21, 1fr); background: #fff; padding: 6px; border: 1px solid var(--line); border-radius: 6px; }
.qr i { display: block; }
.qr i.b { background: var(--ink); }

/* Feuille (panneau du bas) */
.veil { position: fixed; inset: 0; background: rgba(22, 33, 58, 0.45); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; max-height: 88vh; overflow: auto; }
.wa { background: #E7F7EE; border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.wa .bubble { background: #fff; border-radius: 10px; padding: 10px 12px; white-space: pre-line; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; max-width: calc(100% - 32px); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; }
.toast.show { opacity: 1; }

/* ---------- Ordinateur ---------- */
@media (min-width: 1024px) {
  .layout { flex-direction: row; }
  .sidebar { display: flex; flex-direction: column; width: 248px; flex-shrink: 0; background: var(--ink); padding: 24px 0; position: sticky; top: 0; height: 100vh; }
  .sidebar .org { padding: 0 20px 20px; border-bottom: 1px solid #2C3854; display: flex; flex-direction: column; gap: 4px; }
  .sidebar .org b { color: #fff; font-size: 18px; }
  .sidebar .org span { color: var(--sidebar-text); font-size: 14px; line-height: 20px; }
  .sidebar nav { display: flex; flex-direction: column; padding-top: 12px; }
  .sidebar nav a { height: 48px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; text-decoration: none; color: var(--sidebar-text); border-left: 3px solid transparent; }
  .sidebar nav a.on { color: #fff; font-weight: 600; background: #1E2A47; border-left-color: var(--indigo); padding-left: 17px; }
  .topbar, .tabbar { display: none; }
  main { max-width: 1040px; padding: 32px 40px 48px; }
  main.narrow { max-width: 600px; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile.verify { display: flex; background: var(--indigo-soft); border-color: var(--indigo-soft); }
  .tile .amount { font-size: 28px; line-height: 34px; }
  .home-action { display: none; }
  .row .extra { display: block; width: 150px; }
  .toast { bottom: 24px; }
  .veil { align-items: center; }
  .sheet { border-radius: 16px; }
}
