/* ═══════════════════════════════════════════════════════════
   Immeuble famille KABA — Design system V2 (Epic 0 / S-003)
   Refonte complète : un seul style pour tous les écrans,
   mobile-first tactile + desktop confortable (non calqué).
   ═══════════════════════════════════════════════════════════ */
:root {
  --accent: #0e7490;          /* teal — actions, liens */
  --accent-dark: #155e75;
  --accent-soft: #ecfeff;     /* fonds teal très clairs */
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 18px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
  --space: 24px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }

/* ── Layout ── */
.container { max-width: 1120px; margin: var(--space) auto; padding: 0 22px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.row h1, .row h2 { font-size: 1.4rem; margin: 0; font-weight: 750; letter-spacing: -.01em; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: var(--space); }
.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 30px 0 44px; }

/* ── Topbar / navigation ── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 26px; height: 58px; background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { font-weight: 800; font-size: 1.02rem; color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav a {
  padding: 7px 12px; border-radius: 9px; color: var(--muted);
  font-weight: 600; font-size: .9rem; white-space: nowrap;
}
.nav a:hover { background: var(--bg); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-dark); }
.nav-sep { width: 1px; background: var(--line); margin: 6px 10px; align-self: stretch; }
.nav-sec-link { color: var(--muted); font-weight: 550; font-size: .86rem; }
/* Bouton flottant « Encaisser » (P1 review) — mobile uniquement, caché sur l'écran Caisse */
.btn-fab {
  display: none; position: fixed; right: 18px; bottom: 18px; z-index: 25;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 1.5rem;
  align-items: center; justify-content: center; text-decoration: none;
  box-shadow: 0 8px 20px rgba(14, 116, 144, .38);
}
.btn-fab:hover { background: var(--accent-dark); text-decoration: none; }
.userchip { display: flex; align-items: center; gap: 10px; font-size: .88rem; color: var(--muted); white-space: nowrap; }
.burger {
  display: none; margin-left: auto;
  background: none; border: none; cursor: pointer;
  font-size: 1.55rem; line-height: 1; color: var(--ink); padding: 4px 6px;
}
.nav-logout { display: none; }
.chip-role { padding: 3px 10px; border-radius: 99px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.chip-admin { background: var(--warn-soft); color: var(--warn); }
.chip-gestionnaire { background: var(--ok-soft); color: var(--ok); }
.chip-lecture { background: #e2e8f0; color: #475569; }

/* ── Boutons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: .9rem; cursor: pointer; font-family: inherit;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { text-decoration: none; background: #f8fafc; border-color: #cbd5e1; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--bad); border-color: #fecaca; background: #fff; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); min-height: 36px; padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: .82rem; }
form.inline { display: inline; }
.actions-cell { white-space: nowrap; }
.actions-cell form { display: inline; }

/* ── Formulaires (un seul pattern partout) ── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-card { max-width: 780px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
label { font-size: .85rem; font-weight: 600; color: var(--ink); display: flex; flex-direction: column; gap: 6px; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 13px;
  border: 1px solid #cbd5e1; border-radius: var(--radius-sm);
  font: inherit; background: #fff; color: var(--ink);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 116, 144, .14); }
textarea { min-height: 90px; resize: vertical; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-field label { font-size: .85rem; font-weight: 600; }
.form-field input, .form-field select, .form-field textarea { min-height: 46px; }
input.montant { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .01em; }
.date-pair { display: flex; gap: 10px; }
.date-pair select { flex: 1; min-width: 0; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filters form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters label { min-width: 150px; }
.file-hint { font-size: .78rem; color: var(--muted); }
.hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* ── Cartes ── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px;
}
.card h2 { margin: 0 0 12px; font-size: .98rem; font-weight: 750; }
.card .label { color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.card .value { font-size: 1.55rem; font-weight: 800; margin-top: 4px; letter-spacing: -.01em; }
.card .sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.value.ok { color: var(--ok); } .value.warn { color: var(--warn); } .value.bad { color: var(--bad); }

/* ── Tableaux (style unique) ── */
table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid var(--line);
}
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: .9rem; }
th { background: #f8fafc; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: #fafcfd; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.matrix-wrap { overflow-x: auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.matrix { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 900px; box-shadow: none; border: none; }
.matrix th, .matrix td { border: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: right; white-space: nowrap; }
.matrix th.mois-col, .matrix td.mois-col { position: sticky; left: 0; background: #f8fafc; text-align: left; z-index: 1; font-weight: 650; min-width: 130px; }
.matrix thead th { position: sticky; top: 0; background: #f8fafc; z-index: 2; text-align: center; }
.matrix thead th.mois-col { z-index: 3; }
.matrix td.cell { text-align: right; }
.cell-paye { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.cell-partiel { background: var(--warn-soft); color: var(--warn); }
.cell-impaye { background: var(--bad-soft); color: var(--bad); }
.cell-avenir { background: rgba(127, 127, 127, 0.08); color: var(--muted); font-style: italic; }
.cell-nondue { background: #f9fafb; color: #9ca3af; }
.matrix .cell-total { font-weight: 750; background: #f0fdfa; }
.matrix .row-total { font-weight: 650; background: #f8fafc; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; margin: 10px 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.attendu-line { font-size: .72rem; opacity: .8; }

/* ── Badges ── */
.badge { padding: 3px 11px; border-radius: 99px; font-size: .74rem; font-weight: 650; white-space: nowrap; }
.badge-paye, .badge-encaissement { background: var(--ok-soft); color: var(--ok); }
.badge-partiel { background: var(--warn-soft); color: var(--warn); }
.badge-impaye, .badge-depense { background: var(--bad-soft); color: var(--bad); }
.badge-nondue { background: #e2e8f0; color: #475569; }
.badge-role { background: #ede9fe; color: #6d28d9; }

/* ── Flash ── */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: .92rem; font-weight: 550; }
.flash-ok { background: var(--ok-soft); color: #14532d; border: 1px solid #86efac; }
.flash-err { background: var(--bad-soft); color: #7f1d1d; border: 1px solid #fca5a5; }

/* ── Connexion ── */
.login-card {
  max-width: 410px; margin: 10vh auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 36px;
}
.login-logo { font-size: 2.3rem; text-align: center; }
.login-card h1 { text-align: center; margin: 8px 0 2px; font-size: 1.3rem; }
.login-card p.center { text-align: center; }
.login-card form { margin-top: 20px; }

/* ── Dashboard : bandeau trésorerie + cartes stats ── */
.treso-bandeau {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, #ecfeff, #f0fdfa);
  border: 1px solid #a5f3fc; border-radius: var(--radius);
  padding: 16px 22px; margin-bottom: 18px;
}
.treso-label { font-size: .95rem; font-weight: 750; }
.treso-valeur { font-size: 1.7rem; font-weight: 800; margin-top: 2px; letter-spacing: -.01em; }
.treso-valeur.ok { color: var(--ok); }
.treso-valeur.bad { color: var(--bad); }
.treso-detail { text-align: right; font-size: .8rem; }

/* ── Caisse (mobile-first : tablette centrée) ── */
.caisse { max-width: 500px; margin: 0 auto; padding: 14px 14px 96px; }
.caisse h1 { font-size: 1.3rem; }
.panel { display: none; }
.panel.active { display: block; }
.caisse .card { background: var(--card); border-radius: var(--radius); padding: 16px 17px; box-shadow: var(--shadow-sm); margin-bottom: 12px; }
.caisse .card h2 { font-size: 1rem; margin: 0 0 10px; }
.bilan { display: flex; gap: 8px; margin-bottom: 12px; }
.bilan .cell { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; box-shadow: var(--shadow-sm); }
.bilan .lbl { font-size: .66rem; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bilan .val { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.bilan .val.plus { color: var(--ok); }
.bilan .val.moins { color: var(--bad); }
.table-compact { width: 100%; border-collapse: collapse; font-size: .85rem; box-shadow: none; border: none; }
.table-compact th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 6px; border-bottom: 1px solid var(--line); background: transparent; }
.table-compact td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
.table-compact tr:last-child td { border-bottom: none; }
.tx { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: none; }
.tx .ico { font-size: 1.15rem; }
.tx .info { flex: 1; min-width: 0; }
.tx .info .nom { font-weight: 650; font-size: .9rem; }
.tx .info .sous { font-size: .74rem; color: var(--muted); }
.tx .mt { font-weight: 750; font-size: .9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx .mt.plus { color: var(--ok); }
.tx .mt.moins { color: var(--bad); }
.justifie { display: inline-block; font-size: .68rem; font-weight: 700; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.justifie a { color: var(--ok); text-decoration: underline; }
form.rattache { margin: 0; }
.btn-rattache { display: inline-block; font-size: .8rem; font-weight: 700; color: var(--accent); background: var(--ok-soft); border-radius: 999px; padding: 5px 11px; cursor: pointer; }
.caisse-barre {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 500px;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 20;
  box-shadow: 0 -4px 14px rgba(15, 23, 42, .05);
}
.caisse-barre button {
  flex: 1; background: none; border: none; padding: 10px 0 9px; cursor: pointer;
  font-size: .66rem; font-weight: 700; color: var(--muted); font-family: inherit;
}
.caisse-barre button .ico { display: block; font-size: 1.3rem; margin-bottom: 2px; }
.caisse-barre button.active { color: var(--accent); }
.tab-count { font-size: .6rem; font-weight: 800; background: var(--ok-soft); color: var(--ok); border-radius: 99px; padding: 1px 6px; margin-left: 2px; vertical-align: super; }

/* Desktop (≥ 761 px) : la Caisse s'élargit un peu et les onglets passent EN HAUT */
@media (min-width: 761px) {
  .caisse { max-width: 660px; display: flex; flex-direction: column; }
  .caisse-barre {
    position: static; transform: none; width: auto; max-width: none;
    order: -1; margin-bottom: 14px; border-radius: var(--radius);
    box-shadow: var(--shadow-sm); border: 1px solid var(--line);
  }
  .caisse-barre button { padding: 12px 0; font-size: .72rem; }
}

/* ── Divers ── */
.empty { text-align: center; padding: 60px 20px; }
.empty h1 { margin: 0 0 8px; }
.apercu-box { padding: 10px 12px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: var(--radius-sm); font-size: .95rem; }
.apercu-box .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.audit-changes { font-size: .75rem; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.situation-card { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 16px; margin: 12px 0 18px; }
.sit-item { display: flex; align-items: center; gap: 8px; }
.sit-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sit-val { font-size: 1.05rem; font-weight: 750; }
.sit-val.pos { color: var(--ok); }
.sit-val.neg { color: var(--bad); }
.contact-links { display: block; font-size: .75rem; color: var(--muted); margin-top: 2px; }
.contact-links a { text-decoration: underline; }
.justif-link { font-size: .82rem; }
.commentaire { background: #fffbeb; border-left: 3px solid var(--warn); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .85rem; }

/* ── Mobile (≤ 760 px) : hamburger, onglets bas, boutons tactiles ── */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 6px 14px; padding: 10px 16px; height: auto; min-height: 54px; }
  .burger { display: block; }
  .nav {
    display: none; flex-basis: 100%; flex-direction: column; gap: 2px;
    border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 10px; font-size: 1rem; }
  .nav-sep { width: auto; height: 1px; margin: 6px 0; flex-basis: 100%; }
  .btn-fab { display: flex; }
  .btn { min-height: 48px; padding: 12px 16px; font-size: .95rem; }
  .btn-sm { min-height: 40px; padding: 8px 12px; }
  .btn-ghost { min-height: 44px; }
  .userchip { display: none; }
  .nav-logout { display: block; color: var(--bad); font-weight: 700; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
  .container { padding: 0 14px; margin: 16px auto; }
  .container table { display: block; overflow-x: auto; white-space: nowrap; }
  .row { flex-wrap: wrap; }
  .treso-detail { text-align: left; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .card { padding: 14px 15px; }
  .card .value { font-size: 1.3rem; }
  .login-card { margin: 6vh 16px; padding: 28px 22px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters form { flex-direction: column; align-items: stretch; }
  .filters label { min-width: 0; }
}
