/* Mise en page : une colonne mobile, deux cartes de solde en haut, gros boutons, navigation fixe en bas.
   Vert et blanc ; le « Je dois » prend une teinte terre cuite pour ne jamais se confondre avec « On me doit ». */
:root {
  --bg: #f2f8f4;
  --surface: #ffffff;
  --surface-2: #e8f3ec;
  --ink: #0e2a1b;
  --muted: #536c5c;
  --line: #d0e1d6;
  --green: #0a7a3f;
  --on-green: #ffffff;
  --green-deep: #05512a;
  --green-soft: #dcf0e3;
  --clay: #a4440f;
  --clay-soft: #f8e6da;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --focus: #0a7a3f;
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Figtree', 'Segoe UI', system-ui, sans-serif;
  --radius: 18px;
  --tap: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #09140f; --surface: #12211a; --surface-2: #182b21; --ink: #e5f2ea; --muted: #94ad9d;
    --line: #26392e; --green: #3fbf7a; --on-green: #04210f; --green-deep: #86e3ae; --green-soft: #153324;
    --clay: #f2a272; --clay-soft: #3a2518; --danger: #ff8f86; --danger-soft: #3d1e1c; --focus: #3fbf7a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #09140f; --surface: #12211a; --surface-2: #182b21; --ink: #e5f2ea; --muted: #94ad9d;
  --line: #26392e; --green: #3fbf7a; --on-green: #04210f; --green-deep: #86e3ae; --green-soft: #153324;
  --clay: #f2a272; --clay-soft: #3a2518; --danger: #ff8f86; --danger-soft: #3d1e1c; --focus: #3fbf7a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 560px; margin: 0 auto; padding-block: 14px 120px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; line-height: 1.15; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* En-tête */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 6px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; letter-spacing: 0.04em; color: var(--green-deep); }
.brand svg { width: 34px; height: 34px; flex: none; }
.top h1 { font-size: 1.5rem; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 14px 0 8px; border: 0; background: transparent; color: var(--green-deep); font-weight: 700; cursor: pointer; border-radius: 12px; }
.back svg { width: 22px; height: 22px; }

/* Boutons */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: var(--tap); padding: 0 20px; border: 2px solid transparent; border-radius: var(--radius); font-weight: 700; font-size: 1.05rem; cursor: pointer; text-align: center; }
.btn svg { width: 24px; height: 24px; flex: none; }
.btn-xl { min-height: 68px; font-size: 1.2rem; }
.btn-primary { background: var(--green); color: var(--on-green); }
.btn-primary:active { background: var(--green-deep); }
.btn-secondary { background: var(--surface); color: var(--green-deep); border-color: var(--green); }
.btn-quiet { background: var(--surface-2); color: var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: grid; gap: 12px; }
.btn-row.two { grid-template-columns: 1fr 1fr; }

/* Cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stack { display: grid; gap: 14px; }
.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--green-soft); color: var(--green-deep); font-size: 0.93rem; }
.notice svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.notice.warn { background: var(--clay-soft); color: var(--clay); }
.notice.bad { background: var(--danger-soft); color: var(--danger); }

/* Solde net */
.net { background: var(--green-deep); color: #fff; border-radius: var(--radius); padding: 18px; }
:root[data-theme="dark"] .net { background: var(--green-soft); color: var(--ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .net { background: var(--green-soft); color: var(--ink); } }
.net small { display: block; opacity: 0.85; font-size: 0.88rem; letter-spacing: 0.06em; text-transform: uppercase; }
.net .num { display: block; font-size: 2.1rem; font-weight: 800; margin-top: 2px; }
.net p { opacity: 0.9; font-size: 0.93rem; margin-top: 2px; }

/* Cartes de solde cliquables */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bal { text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 14px; min-height: 150px; display: grid; align-content: space-between; gap: 8px; cursor: pointer; }
.bal .label { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; }
.bal .label svg { width: 22px; height: 22px; }
.bal .num { font-size: 1.45rem; font-weight: 800; word-break: break-word; }
.bal .sub { font-size: 0.85rem; color: var(--muted); }
.bal-me { border-color: var(--green); } .bal-me .label, .bal-me .num { color: var(--green-deep); }
.bal-owe { border-color: var(--clay); } .bal-owe .label, .bal-owe .num { color: var(--clay); }

/* Jauge version gratuite */
.meter { display: grid; gap: 8px; }
.meter .segs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.meter .seg { height: 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.meter .seg.on { background: var(--green); border-color: var(--green); }
.meter.full .seg.on { background: var(--clay); border-color: var(--clay); }

/* Titres de section */
.sec { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 6px; }
.sec h2 { font-size: 1.2rem; }

/* Lignes de dette */
.rows { display: grid; gap: 10px; }
.row { display: grid; gap: 8px; text-align: left; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; }
.row .line1 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row .who { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.row .amt { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .line2 { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.88rem; flex-wrap: wrap; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.78rem; font-weight: 800; }
.tag-me { background: var(--green-soft); color: var(--green-deep); }
.tag-owe { background: var(--clay-soft); color: var(--clay); }
.tag-done { background: var(--surface-2); color: var(--muted); }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.bar.owe i { background: var(--clay); }
.amt-me { color: var(--green-deep); } .amt-owe { color: var(--clay); }

/* Formulaires */
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; }
.field .hint { font-size: 0.85rem; color: var(--muted); }
.field input, .field textarea { width: 100%; min-height: var(--tap); padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px var(--green-soft); }
.field .err { color: var(--danger); font-size: 0.9rem; font-weight: 600; min-height: 0; }
.field.bad input { border-color: var(--danger); }
.seg2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg2 button { min-height: var(--tap); border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; cursor: pointer; }
.seg2 button[aria-pressed="true"].me { background: var(--green); border-color: var(--green); color: var(--on-green); }
.seg2 button[aria-pressed="true"].owe { background: var(--clay); border-color: var(--clay); color: #fff; }
:root[data-theme="dark"] .seg2 button[aria-pressed="true"].owe { color: #20100a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg2 button[aria-pressed="true"].owe { color: #20100a; } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 46px; padding: 0 18px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--green-soft); border-color: var(--green); color: var(--green-deep); }

/* Détail d'une dette */
.big { display: grid; gap: 4px; }
.big .num { font-size: 2.3rem; font-weight: 800; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fact { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.fact small { display: block; color: var(--muted); font-size: 0.8rem; }
.fact b { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.list { display: grid; gap: 0; }
.item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .l { min-width: 0; overflow-wrap: anywhere; }
.item .r { text-align: right; white-space: nowrap; font-family: var(--font-display); font-weight: 800; font-variant-numeric: tabular-nums; }
.item small { display: block; color: var(--muted); font-weight: 400; font-family: var(--font-body); }

/* États vides, statuts */
.empty { text-align: center; padding: 26px 16px; display: grid; gap: 8px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 1.15rem; }
.status { display: grid; gap: 8px; }
.status li { list-style: none; display: flex; gap: 10px; align-items: flex-start; }
.status ul { margin: 0; padding: 0; display: grid; gap: 8px; }
.dot { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; margin-top: 1px; }
.dot svg { width: 14px; height: 14px; }
.dot.ok { background: var(--green); color: var(--on-green); }
.dot.wait { background: var(--clay-soft); color: var(--clay); border: 1.5px solid var(--clay); }

/* Navigation du bas */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 0 max(4px, env(safe-area-inset-left, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-right, 0px)); }
.nav button { display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 66px; border: 0; background: transparent; color: var(--muted); font-size: 0.72rem; font-weight: 700; cursor: pointer; position: relative; }
.nav button svg { width: 26px; height: 26px; }
.nav button[aria-current="page"] { color: var(--green-deep); }
.nav button[aria-current="page"]::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 4px; border-radius: 0 0 4px 4px; background: var(--green); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 20; max-width: min(520px, calc(100% - 32px)); padding: 14px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

@media (max-width: 360px) {
  .duo { grid-template-columns: 1fr; }
  .btn-row.two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .bal, .row, .chip { transition: transform .08s ease; }
  .btn:active, .bal:active, .row:active { transform: scale(0.985); }
}

/* Connexion, PIN */
.form-err { color: var(--danger); font-weight: 700; min-height: 0; }
.form-err:empty { display: none; }
.form-info { color: var(--green-deep); font-weight: 700; }
.form-info:empty { display: none; }
.field input.pin-input { text-align: center; font-size: 1.6rem; letter-spacing: 0.5em; font-weight: 800; }
.lock-screen { min-height: 70vh; display: grid; align-content: center; gap: 16px; text-align: center; }
.lock-screen .brand { justify-content: center; }
details.more > summary { cursor: pointer; font-weight: 700; color: var(--green-deep); min-height: var(--tap); display: flex; align-items: center; }

/* Abonnement et administration */
a.btn { text-decoration: none; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 99px; font-weight: 800; font-size: 0.82rem; white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green-deep); }
.badge.soon { background: var(--clay-soft); color: var(--clay); }
.badge.ended { background: var(--danger-soft); color: var(--danger); }
.badge.never { background: var(--surface-2); color: var(--muted); }
.urow { border-left: 6px solid var(--line); }
.urow.ok { border-left-color: var(--green); }
.urow.soon { border-left-color: var(--clay); }
.urow.ended { border-left-color: var(--danger); }
.urow .mail { overflow-wrap: anywhere; min-width: 0; }
.urow .sec { align-items: flex-start; gap: 10px; }
.apanel { border-top: 1px solid var(--line); padding-top: 14px; }
.field input[type="search"] { width: 100%; min-height: var(--tap); padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
#adm-pay:empty { display: none; }
.logo-mark { width: 34px; height: 34px; border-radius: 9px; display: block; flex: none; }
[hidden] { display: none !important; }
