/* ========================================================================
   Cagnotte — système de design
   Direction : sombre chaud (charbon vert-encre), accent OR pour l'argent,
   vert = reçoit, corail = doit. Signature = jauge de tableau de bord.
   Typo : Space Grotesk (titres + montants), Inter (texte).
   ======================================================================== */

:root {
  --bg:        #0E1413;
  --surface:   #141C1B;
  --surface-2: #1B2524;
  --line:      #26312F;
  --line-soft: #1E2827;
  --text:      #EAF1EE;
  --muted:     #8E9E9A;
  --muted-2:   #6E7C79;
  --gold:      #E7B24C;
  --gold-soft: rgba(231,178,76,.14);
  --gold-line: rgba(231,178,76,.35);
  --pos:       #5FC08C;
  --pos-soft:  rgba(95,192,140,.14);
  --neg:       #ED7C5B;
  --neg-soft:  rgba(237,124,91,.14);
  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -12px rgba(0,0,0,.6);
  --font-disp: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 50% -10%, #16211F 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
body::selection, ::selection { background: var(--gold-soft); }

.wrap { max-width: 560px; margin: 0 auto; padding: 22px 16px 60px; }
.wrap-lg { max-width: 900px; }

/* ---- Typographie ---- */
h1, h2, h3 { font-family: var(--font-disp); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
.eyebrow {
  font-family: var(--font-disp);
  font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 6px;
}
.sub { color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.mono-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---- En-tête d'app ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #F2C868, var(--gold));
  box-shadow: 0 0 0 4px var(--gold-soft);
}
.brand .name { font-family: var(--font-disp); font-weight: 600; letter-spacing: -.01em; font-size: 15px; }
.brand .name span { color: var(--muted); font-weight: 400; }

/* ---- Cartes ---- */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* ---- Jauge signature (tableau de bord) ---- */
.gauge-card { text-align: center; padding-top: 26px; }
.gauge { position: relative; width: 260px; max-width: 78%; margin: 0 auto 4px; }
.gauge svg { width: 100%; height: auto; display: block; overflow: visible; }
.gauge-track { fill: none; stroke: var(--line); stroke-width: 14; stroke-linecap: round; }
.gauge-fill  { fill: none; stroke: url(#gaugeGrad); stroke-width: 14; stroke-linecap: round;
               transition: stroke-dashoffset .8s cubic-bezier(.2,.7,.2,1); }
.gauge-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; padding-bottom: 6px;
}
.gauge-amount { font-family: var(--font-disp); font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.gauge-amount.neg { color: var(--neg); }
.gauge-label { color: var(--muted); font-size: 12.5px; margin-top: 6px; letter-spacing: .02em; }
.gauge-ends { display: flex; justify-content: space-between; width: 100%; margin-top: 2px; color: var(--muted-2); font-size: 11.5px; }

/* ---- Chip position personnelle ---- */
.position-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; margin-top: 14px;
}
.position-chip.recoit { background: var(--pos-soft); color: var(--pos); border-color: rgba(95,192,140,.3); }
.position-chip.doit   { background: var(--neg-soft); color: var(--neg); border-color: rgba(237,124,91,.3); }
.position-chip .amt { font-variant-numeric: tabular-nums; }

/* ---- Boutons ---- */
button, .btn {
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 13px 16px; cursor: pointer; width: 100%;
  transition: transform .06s ease, background .15s ease, border-color .15s;
  color: #12100A;
  background: linear-gradient(180deg, #F0C264, var(--gold));
}
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.ghost, .btn.ghost {
  background: transparent; color: var(--text); border-color: var(--line);
}
button.ghost:hover { border-color: var(--gold-line); }
button.subtle {
  background: var(--surface-2); color: var(--text); border-color: var(--line);
}
button.danger { background: transparent; color: var(--neg); border-color: rgba(237,124,91,.4); }
button.sm { width: auto; padding: 8px 13px; font-size: 13.5px; border-radius: 9px; }
.btn-row { display: flex; gap: 10px; }
.btn-row button { width: auto; flex: 1; }

/* ---- Champs ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 13px; font-size: 15px; font-family: inherit;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold-line);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
textarea { resize: vertical; min-height: 64px; }
select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--muted) 50%),
  linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

/* NIP */
.nip-input {
  text-align: center; letter-spacing: 14px; font-family: var(--font-disp);
  font-size: 26px; font-weight: 600; padding-left: 14px;
}

/* ---- Listes (dépenses, participants, dépôts) ---- */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 14.5px; }
.row .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.row .amt { font-family: var(--font-disp); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; white-space: nowrap; }
.amt.pos { color: var(--pos); } .amt.neg { color: var(--neg); }

.cat-ico {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 18px;
  background: var(--surface-2); border: 1px solid var(--line);
}

/* ---- Pastilles / badges ---- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.tag.gold { color: var(--gold); border-color: var(--gold-line); background: var(--gold-soft); }
.tag.pos  { color: var(--pos); border-color: rgba(95,192,140,.3); background: var(--pos-soft); }
.tag.neg  { color: var(--neg); border-color: rgba(237,124,91,.3); background: var(--neg-soft); }
.tag.muted{ opacity: .8; }

/* ---- Divers ---- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-family: var(--font-disp); font-size: 20px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }

.err { color: var(--neg); font-size: 13.5px; margin-top: 10px; min-height: 18px; }
.hint { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }
.mt { margin-top: 14px; } .mt-s { margin-top: 8px; }
.divider { height: 1px; background: var(--line-soft); margin: 16px 0; border: 0; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.checks label {
  display: inline-flex; align-items: center; gap: 7px; margin: 0;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 8px 12px; border-radius: 10px; font-size: 14px; cursor: pointer; user-select: none;
}
.checks label.on { border-color: var(--gold-line); background: var(--gold-soft); }
.checks input { width: auto; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .6; }

/* ---- Modale ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(6,10,9,.72); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 12px;
}
.modal {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow); animation: rise .22s cubic-bezier(.2,.7,.2,1);
}
@media (min-width: 560px) { .overlay { align-items: center; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); border: 1px solid var(--gold-line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Jauge fine (barre) pour la carte solde secondaire ---- */
.bar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #F2C868); transition: width .6s; }
.bar.over > i { background: linear-gradient(90deg, var(--neg), #F0997C); }

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

/* Accessibilité focus clavier */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
