/* Nagrom Asso — conçu d'abord pour le téléphone */
:root {
  --bg: #F5F6F3;
  --surface: #FFFFFF;
  --text: #17201D;
  --muted: #56615C;
  --line: #E3E7E3;
  --field: #D9DED9;
  --accent: #0E6B5C;
  --accent-dark: #0A5246;
  --accent-soft: #E3F1EE;
  --warm: #A8461B;
  --warm-soft: #FBEDE4;
  --cta: #E07B39;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --surface: #1B2220;
    --text: #E9EEEB;
    --muted: #A3AEA8;
    --line: #2B3431;
    --field: #3A4541;
    --accent: #4FB8A4;
    --accent-dark: #7ACDBC;
    --accent-soft: #1E3530;
    --warm: #F0A27A;
    --warm-soft: #3A2A22;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1, h2, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.icon { flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.warn { color: var(--warm); font-weight: 600; }
.grow { flex: 1; min-width: 0; }

/* Coque : barre en bas sur téléphone, colonne à gauche sur grand écran */
.shell { min-height: 100vh; }
.main { max-width: 760px; margin: 0 auto; padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-brand { display: none; }
.nav-item { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); text-decoration: none; }
.nav-item.is-active { color: var(--accent); font-weight: 600; }
.nav-item.is-soon { opacity: 0.45; }
@media (min-width: 900px) {
  .shell { display: flex; }
  .nav { position: sticky; top: 0; height: 100vh; width: 220px; display: flex; flex-direction: column; gap: 4px; padding: 24px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .nav-brand { display: block; font-weight: 700; font-size: 18px; padding: 0 12px 16px; }
  .nav-item { min-height: 44px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; border-radius: 12px; font-size: 15px; }
  .nav-item.is-active { background: var(--accent-soft); }
  .main { flex: 1; padding: 32px 32px 48px; }
}

/* Blocs */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.eyebrow { font-size: 13px; color: var(--muted); }
.back { width: 44px; height: 44px; margin-left: -10px; display: flex; align-items: center; justify-content: center; color: var(--text); }
.chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 14px; background: var(--accent-soft); color: var(--accent-dark); font-size: 12px; font-weight: 600; white-space: nowrap; }
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.hero { background: var(--accent); color: #FFFFFF; border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 4px; }
@media (prefers-color-scheme: dark) { .hero { background: #0E6B5C; } }
.hero-label { font-size: 13px; opacity: 0.85; }
.hero-value { font-size: 30px; font-weight: 650; }
.hero-note { font-size: 13px; opacity: 0.9; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 650; }
.stat-note { font-size: 12px; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 0; color: var(--text); text-decoration: none; }
.row-top { align-items: flex-start; padding: 12px 0; }
.badge { width: 32px; height: 32px; border-radius: 10px; background: var(--warm-soft); color: var(--warm); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }

/* Formulaires */
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.form-inline { flex-direction: row; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  min-height: 48px; padding: 0 14px; border: 1px solid var(--field); border-radius: 12px;
  background: var(--surface); color: var(--text); font: 16px var(--font); width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.input-code { font-size: 26px !important; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--field);
  background: var(--surface); color: var(--text); font: 600 15px var(--font);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
@media (prefers-color-scheme: dark) { .btn-primary { background: #0E6B5C; border-color: #0E6B5C; } }
.btn-primary:hover { color: #FFFFFF; filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--warm); border-color: var(--warm); background: transparent; }
.btn-small { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.inline { display: inline; }
.pager { display: flex; justify-content: space-between; margin-top: 10px; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; right: 0; top: 46px; z-index: 5; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); width: max-content; }

.flash { padding: 12px 14px; border-radius: 14px; font-size: 14px; }
.flash-ok, .flash-info { background: var(--accent-soft); color: var(--accent-dark); }
.flash-erreur { background: var(--warm-soft); color: var(--warm); }

/* Pages publiques (connexion) */
.public-main { max-width: 440px; margin: 0 auto; padding: 48px 16px; display: flex; flex-direction: column; gap: 14px; }
.public-brand { font-weight: 700; color: var(--accent); }
.public .card { padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.steps { padding-left: 20px; margin: 4px 0; display: flex; flex-direction: column; gap: 10px; }
.qr { width: 220px; max-width: 100%; margin: 10px 0 4px; padding: 0; border-radius: 12px; overflow: hidden; background: #FFFFFF; }
.qr svg { display: block; width: 100%; height: auto; }
.secret { display: block; margin-top: 6px; padding: 10px 12px; border-radius: 10px; background: var(--bg); font-size: 17px; letter-spacing: 1px; word-break: break-all; }

/* Trésorerie */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.amount-in { color: var(--accent); }
.amount-out { color: var(--warm); }
.amount-neutral { color: var(--muted); }
.hero .amount-in, .hero .amount-out { color: inherit; }
.hero-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; margin-top: 10px; }
.hero-cell { background: rgba(255,255,255,0.14); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; color: #FFFFFF; text-decoration: none; font-size: 12px; }
.hero-cell:hover { color: #FFFFFF; background: rgba(255,255,255,0.22); }
.hero-cell strong { font-size: 15px; }
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--line); }
.tab { min-height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.tab.is-active { background: var(--surface); color: var(--text); font-weight: 600; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.pill { flex-shrink: 0; min-height: 36px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 18px; border: 1px solid var(--field); background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; }
.pill.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.pill-warn { border-color: var(--warm); color: var(--warm); }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 6px 4px -6px; }
.card-list { padding: 2px 14px; }
.op { min-height: 64px; }
.op-date { width: 26px; flex-shrink: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.op-label, .op-meta { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op-label { font-weight: 500; }
.op-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.op-amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { display: flex; flex-direction: column; gap: 6px; }
.chip-light { background: var(--bg); color: var(--muted); font-weight: 500; }
.period { margin: 0; }
.fab { position: fixed; right: 20px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 28px; background: var(--cta); color: #FFFFFF; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(0,0,0,0.2); z-index: 9; }
.fab:hover { color: #FFFFFF; filter: brightness(1.05); }
@media (min-width: 900px) { .fab { bottom: 32px; right: 32px; } }

.segmented { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; margin: 0; border: 0; border-radius: 14px; background: var(--line); }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--surface); }
.seg-depense input:checked + span { color: var(--warm); }
.seg-recette input:checked + span { color: var(--accent); }
.seg-transfert input:checked + span { color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.amount-field { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.amount-input { display: flex; align-items: baseline; gap: 6px; }
.amount-input input { width: 190px; border: 0; background: transparent; color: var(--text); text-align: right; font: 650 40px var(--font); font-variant-numeric: tabular-nums; }
.amount-input input:focus { outline: none; }
.amount-input span { font-size: 30px; font-weight: 600; color: var(--muted); }
.fields { display: flex; flex-direction: column; gap: 12px; }
.fields [hidden] { display: none; }
.upload { position: relative; min-height: 80px; margin-top: 8px; border: 2px dashed var(--field); border-radius: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; text-align: center; color: var(--text); font-weight: 500; cursor: pointer; }
.upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload:focus-within { outline: 2px solid var(--accent); }
.upload .icon, .upload svg { color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.compte-form { padding: 12px 0; border-top: 1px solid var(--line); }
h3 { margin: 12px 0 0; font-weight: 600; }

.table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 14px 0 6px; }
.table td { padding: 8px 0; border-top: 1px solid var(--line); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .total td { font-weight: 600; }
.table .grand td { font-size: 16px; border-top: 2px solid var(--text); padding-top: 12px; }

.hero-link { text-decoration: none; color: #FFFFFF; }
.hero-link:hover { color: #FFFFFF; }

/* Familles */
.pre-line { white-space: pre-line; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.legend { font-size: 15px; font-weight: 600; padding: 0; margin-bottom: 4px; cursor: default; }
details > summary.legend { cursor: pointer; min-height: 32px; }
fieldset.card { border: 0; margin: 0; min-width: 0; }
.child-sep { border-top: 1px solid var(--line); padding-top: 12px; }
.child { display: flex; flex-direction: column; gap: 10px; }
.check-top { align-items: flex-start; }
.check-top input { margin-top: 2px; flex-shrink: 0; }
.progress { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tag-ok { color: var(--accent); font-weight: 600; }
.tag-no { color: var(--warm); font-weight: 600; }
.tag-none { color: var(--muted); }

.stat-card { display: flex; flex-direction: column; gap: 8px; text-decoration: none; color: var(--text); }
.row-flat { display: flex; align-items: baseline; gap: 10px; }
.field textarea { padding: 10px 14px; border: 1px solid var(--field); border-radius: 12px; background: var(--surface); color: var(--text); font: 15px/1.4 var(--font); width: 100%; resize: vertical; }
.niveaux { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.niveaux legend { margin-bottom: 6px; }
.pill-check { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border: 1px solid var(--field); border-radius: 18px; font-size: 13px; }
.filters-form { margin-top: 0; }
.progress-0 { width: 0%; }
.progress-5 { width: 5%; }
.progress-10 { width: 10%; }
.progress-15 { width: 15%; }
.progress-20 { width: 20%; }
.progress-25 { width: 25%; }
.progress-30 { width: 30%; }
.progress-35 { width: 35%; }
.progress-40 { width: 40%; }
.progress-45 { width: 45%; }
.progress-50 { width: 50%; }
.progress-55 { width: 55%; }
.progress-60 { width: 60%; }
.progress-65 { width: 65%; }
.progress-70 { width: 70%; }
.progress-75 { width: 75%; }
.progress-80 { width: 80%; }
.progress-85 { width: 85%; }
.progress-90 { width: 90%; }
.progress-95 { width: 95%; }
.progress-100 { width: 100%; }
