/* Izibara PWA — direction A « Fintech lumineux ». Tokens = design-system/izibara-pwa/MASTER.md (charte izibara.com) */
@font-face { font-family: "Switzer"; src: url("fonts/switzer-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("fonts/switzer-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("fonts/switzer-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Switzer"; src: url("fonts/switzer-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("fonts/baloo2-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --green: #24D366; --green-dark: #1DA851; --green-deep: #0E7A3A; --on-green: #0A0A0A;
  --brand: #0A5C36; --brand-2: #0E7A3A;
  --bg: #F5F5F5; --surface: #FFFFFF; --bg-soft: #F0F0F0;
  --text: #0A0A0A; --text-soft: #737373; --border: #E5E5E5;
  --ok: #0E7A3A; --ok-bg: #E6F8EC;
  --warning: #B96F28; --warn-bg: #FFF1DE;
  --danger: #C0392B; --danger-bg: #FCE9E6;
  --radius: 20px; --shadow: 0 1px 2px rgba(10,10,10,.04), 0 8px 24px rgba(10,10,10,.06);
  --head: rgba(245,245,245,.85); --nav: rgba(255,255,255,.92);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ok: #3BF07A; --ok-bg: rgba(59,240,122,.12); --brand: #FFFFFF; --brand-2: #0E7A3A;
    --bg: #0A0A0A; --surface: #171717; --bg-soft: #1F1F1F;
    --text: #F5F5F5; --text-soft: #A3A3A3; --border: #262626;
    --warning: #E39A52; --warn-bg: rgba(227,154,82,.14);
    --danger: #EF6A5B; --danger-bg: rgba(239,106,91,.14);
    --shadow: none; --head: rgba(10,10,10,.85); --nav: rgba(23,23,23,.94);
  }
}

* { box-sizing: border-box; margin: 0; }
html { color-scheme: light dark; }
body {
  font: 400 16px/1.5 "Switzer", system-ui, sans-serif; background: var(--bg); color: var(--text);
  min-height: 100dvh; padding-bottom: calc(88px + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
}
button, a { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; text-decoration: none; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* En-tête : logo hibou + wordmark */
header.top {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px; background: var(--head);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.brand img { border-radius: 10px; display: block; }
.wordmark { font: 800 24px/1 "Baloo 2", sans-serif; color: var(--brand); letter-spacing: -.01em; }
/* Boutons d'en-tête (Retour, Mon compte) : même pastille ronde surface + icône */
.top button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; color: var(--text); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.top button:active { background: var(--bg-soft); }
/* Pastille de notification : compteur (barre haute, lignes du compte) */
.dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; border: 2px solid var(--bg); box-sizing: content-box; }
.cnt { flex: none; min-width: 24px; height: 24px; padding: 0 8px; border-radius: 12px; background: var(--danger); color: #fff; font-size: 13px; font-weight: 700; line-height: 24px; text-align: center; }
.sup { display: grid; gap: 12px; }
.sup textarea { width: 100%; min-height: 140px; padding: 14px 16px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; resize: vertical; }
.sup textarea:focus { outline: 3px solid var(--green); outline-offset: 0; border-color: transparent; }
.sup.duo, .duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sup.duo select, .sup .duo select, .sup.duo input, .sup .duo input { padding: 0 8px; font-size: 14px; text-overflow: ellipsis; }
.sup .btn:disabled { opacity: .6; }
.sup input, .sup select { width: 100%; min-height: 52px; padding: 0 16px; font: inherit; font-size: 17px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.sup input:focus, .sup select:focus { outline: 3px solid var(--green); outline-offset: 0; border-color: transparent; }
.alert + .alert { margin-top: 8px; }
#offline { background: var(--warn-bg); color: var(--warning); font-size: 13px; font-weight: 600; text-align: center; padding: 8px 16px; }

main { padding: 8px 16px 16px; max-width: 720px; margin: 0 auto; animation: rise .28s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 14px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft); margin: 24px 4px 10px; }

/* Carte héros : total / solde */
.hero {
  position: relative; overflow: hidden; color: #fff; border-radius: 24px; padding: 22px 20px;
  background: linear-gradient(135deg, var(--brand-2) 0%, #0A5C36 60%, #084A2B 100%);
  box-shadow: 0 12px 28px rgba(10,92,54,.28);
}
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle, rgba(36,211,102,.35), transparent 70%); }
.hero small { display: block; font-size: 14px; font-weight: 500; opacity: .85; }
.hero .big { font-size: 38px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; margin: 4px 0 14px; position: relative; z-index: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
.chip { font-size: 13px; font-weight: 600; padding: 4px 12px; border-radius: 99px; background: rgba(255,255,255,.16); color: #fff; }

/* Sélecteur de période (Rapports : Semaine / Mois) */
.seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; }
.seg button { flex: 1; min-height: 44px; border-radius: 99px; font-weight: 600; color: var(--text-soft); }
.seg button[aria-pressed=true] { background: var(--ok-bg); color: var(--ok); }

.hero + .list { margin-top: 12px; }

/* Listes */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px; border: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 12px 0; text-align: left; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
button.row:active { opacity: .6; }
.row .mid { flex: 1; min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--text-soft); }
.row .chev { color: var(--text-soft); width: 18px; height: 18px; }
.avatar { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 700; font-size: 15px; background: var(--ok-bg); color: var(--ok); }
.avatar.due { background: var(--warn-bg); color: var(--warning); }
.avatar.pay { background: var(--ok-bg); color: var(--ok); }
.avatar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.amt { font-weight: 700; white-space: nowrap; text-align: right; }
.amt.due { color: var(--warning); } .amt.ok { color: var(--ok); }
.amt small { display: block; font-size: 12px; font-weight: 500; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--danger-bg); color: var(--danger); margin-top: 2px; }

/* Recherche */
.search { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 4; padding: 4px 0 10px; background: var(--bg); }
.search svg { position: absolute; left: 14px; top: 18px; color: var(--text-soft); }
.search input { width: 100%; min-height: 50px; padding: 0 16px 0 44px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.search input:focus { outline: 3px solid var(--green); outline-offset: 0; border-color: transparent; }

/* États : vide, squelette */
.empty { text-align: center; color: var(--text-soft); padding: 40px 16px; }
.empty img { width: 72px; height: 72px; border-radius: 20px; margin-bottom: 12px; opacity: .9; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.skeleton { height: 76px; border-radius: 20px; background: linear-gradient(90deg, var(--bg-soft), var(--surface), var(--bg-soft)); background-size: 200% 100%; margin-bottom: 10px; animation: shimmer 1.4s linear infinite; }
.skeleton.tall { height: 150px; border-radius: 24px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 24px; border-radius: 14px; font-weight: 700; background: var(--green); color: var(--on-green); }
.btn:active { background: var(--green-dark); }
/* Action secondaire : contour seul, pour ne pas concurrencer l'action principale de l'écran */
.btn.ghost { background: transparent; color: var(--ok); box-shadow: inset 0 0 0 2px currentColor; }
.btn.ghost:active { background: rgba(0, 0, 0, .05); }

/* Connexion */
.guest header.top { display: none; }
.login { text-align: center; padding: 9vh 8px 0; max-width: 420px; margin: 0 auto; }
.login img { width: 104px; height: 104px; border-radius: 28px; box-shadow: 0 14px 32px rgba(36,211,102,.35); }
.login .wordmark { display: block; font-size: 46px; margin: 18px 0 4px; }
.login .tagline { color: var(--text-soft); margin-bottom: 28px; }
.login .steps { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 16px; }
.login .step { display: flex; gap: 12px; align-items: center; padding: 12px 0; }
.login .step + .step { border-top: 1px solid var(--border); }
.login .step span { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--green); color: var(--on-green); font-weight: 700; font-size: 14px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.kpi { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
.btn.more { width: 100%; margin-top: 8px; }
.kpi small { font-size: 13px; font-weight: 500; color: var(--text-soft); }
.kpi b { font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.kpi b.due { color: var(--warning); } .kpi b.ok { color: var(--ok); }
.kpi span { font-size: 12px; color: var(--text-soft); }
.alert { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; margin-top: 12px; padding: 0 16px; font-weight: 600; text-align: left; color: var(--danger); background: var(--danger-bg); border-radius: 16px; }
.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.quick a { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px 12px; font-size: 15px; font-weight: 700; line-height: 1.2; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.quick a:active { background: var(--bg-soft); }
.login form { display: grid; gap: 12px; text-align: left; margin-bottom: 8px; }
.login label { font-size: 14px; font-weight: 600; color: var(--text-soft); display: grid; gap: 6px; }
.login input { width: 100%; min-height: 52px; padding: 0 16px; font: inherit; font-size: 18px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.login input[inputmode=numeric] { letter-spacing: .4em; text-align: center; }
.login input:focus { outline: 3px solid var(--green); outline-offset: 0; border-color: transparent; }
.login .btn { min-height: 52px; border-radius: 16px; background: var(--green); color: var(--on-green); font-weight: 700; }
.login .btn:active { background: var(--green-dark); }
.login .btn:disabled { opacity: .6; }
.login .link { margin-top: 12px; min-height: 44px; padding: 0 12px; color: var(--ok); font-weight: 600; }
.login .msg { margin: 0 0 20px; font-weight: 600; }
.msg.err { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 0; font-weight: 600; color: var(--danger); }
.msg.err svg.i { margin-top: 1px; }
.login .msg.err { margin: 0 0 20px; }
.login .spin { width: 28px; height: 28px; margin: 20px auto 0; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Barre basse */
nav.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--nav); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
nav.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; font-size: 12px; font-weight: 500; color: var(--text-soft); }
nav.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav.tabs .pill { display: grid; place-items: center; width: 56px; height: 32px; border-radius: 16px; transition: background .2s; }
nav.tabs button[aria-current=page] { color: var(--ok); font-weight: 700; }
nav.tabs button[aria-current=page] .pill { background: var(--ok-bg); }

@media (min-width: 768px) {
  header.top { padding-inline: max(8px, calc((100% - 720px) / 2)); }
  nav.tabs { padding-inline: max(8px, calc((100% - 720px) / 2)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Descriptif court sous le titre d'un écran */
.lead { margin: -8px 0 16px; font-size: 15px; line-height: 1.4; color: var(--text-soft); }

/* Fenêtre de confirmation (feuille basse, mobile d'abord) */
.sheet-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(0, 0, 0, .5); animation: fade .15s ease-out; }
.sheet { display: grid; gap: 12px; width: 100%; max-width: 720px; padding: 24px 16px calc(16px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 24px 24px 0 0; animation: rise .22s ease-out; }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 700; text-transform: none; letter-spacing: -.01em; color: var(--text); }
.sheet p { margin: 0; color: var(--text-soft); line-height: 1.45; overflow-wrap: anywhere; }
.sheet .btn { width: 100%; min-height: 52px; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:active { opacity: .85; }
@keyframes fade { from { opacity: 0; } }
.sup label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.sup label small { font-weight: 400; color: var(--text-soft); }

/* Mobile-first : onglets de sections, en-têtes de jour, filtres repliés (voir app.js paged/sections/txAdd) */
.seg.stick { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 4; margin: 16px 0 12px; }
.seg.stick button { font-size: 14px; padding: 0 6px; white-space: nowrap; }
.sect > .seg.stick { margin-top: 16px; }
.list .day { position: sticky; top: calc(116px + env(safe-area-inset-top)); z-index: 3; margin: 0 -16px; padding: 6px 16px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-soft); background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.list .day:first-child { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.filt { margin-bottom: 12px; }
.filt summary { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; font-weight: 600; list-style: none; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.filt summary::-webkit-details-marker { display: none; }
.filt summary span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; font-size: 14px; color: var(--text-soft); }
.filt summary::after { content: "▾"; margin-left: auto; color: var(--text-soft); transition: transform .2s; }
.filt[open] summary::after { transform: rotate(180deg); }
.filt form { margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .filt summary::after { transition: none; } }
.list .row { min-height: 60px; padding: 10px 0; }
