/* =============================================================
   NUMOA-COMPTA · Charte Méridien — feuille de style
   Mobile-first. Tokens alignés sur config/charte.php.
   ============================================================= */

:root {
  /* Couleurs */
  --marine: #0F2942;
  --marine-profond: #081A2E;
  --cuivre: #C8924A;
  --cuivre-profond: #A07235;
  --cuivre-clair: #E5C290;
  --parchemin: #F5F0E8;
  --creme: #FAF7F1;
  --encre: #1A1A1A;
  --sepia: #6B6358;
  --recette: #3BAF78;
  --depense: #A07235;
  --ligne: #E0D8CC;

  /* Typographies (chargées via Google Fonts dans index.html) */
  --f-titre: 'Fraunces', Georgia, 'Times New Roman', serif;
  --f-texte: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Espacements */
  --e-xs: 4px; --e-sm: 8px; --e-md: 16px; --e-lg: 24px; --e-xl: 40px; --e-xxl: 64px;

  --radius: 4px;
  --ombre: 0 1px 3px rgba(8, 26, 46, .08), 0 4px 16px rgba(8, 26, 46, .06);
  --transition: .18s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--f-texte);
  background: var(--parchemin);
  color: var(--encre);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--f-titre); color: var(--marine); font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--cuivre-profond); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--f-mono); }
.label-tech {
  font-family: var(--f-mono);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sepia);
}

/* ---- Layout : sidebar + contenu ---- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--marine);
  color: var(--creme);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--e-md) var(--e-lg);
  position: sticky; top: 0; z-index: 20;
}
.topbar .marque { display: flex; align-items: center; gap: var(--e-sm); }
.topbar .marqueur {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--cuivre);
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar .marqueur::after {
  content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--cuivre-clair);
}
.topbar .nom { font-family: var(--f-titre); font-size: 1.15rem; font-weight: 600; letter-spacing: .02em; }
.topbar .sous { font-family: var(--f-mono); font-size: .62rem; letter-spacing: .1em; color: var(--cuivre-clair); text-transform: uppercase; }
.topbar .user { font-family: var(--f-mono); font-size: .72rem; color: var(--cuivre-clair); text-align: right; }
.topbar .user .role { display: block; color: var(--creme); }

/* barre tricolore signature */
.bande { height: 3px; display: flex; }
.bande i { display: block; height: 100%; }
.bande .b1 { background: var(--marine); flex: 5; }
.bande .b2 { background: var(--cuivre); flex: 2; }
.bande .b3 { background: var(--recette); flex: 1; }

.corps { display: flex; flex: 1; }

/* Navigation : en bas sur mobile, latérale sur desktop */
.nav {
  background: var(--marine-profond);
  display: flex;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  border-top: 1px solid rgba(200, 146, 74, .25);
}
.nav button {
  flex: 1;
  background: none; border: none; cursor: pointer;
  color: var(--cuivre-clair);
  padding: var(--e-sm) var(--e-xs);
  font-family: var(--f-mono); font-size: .6rem; letter-spacing: .04em;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-transform: uppercase;
  transition: var(--transition);
}
.nav button .ico { font-size: 1.1rem; line-height: 1; }
.nav button.actif { color: var(--creme); background: rgba(200, 146, 74, .12); box-shadow: inset 0 2px 0 var(--cuivre); }
.nav button:hover { color: var(--creme); }

.contenu { flex: 1; padding: var(--e-lg); padding-bottom: 90px; max-width: 1100px; margin: 0 auto; width: 100%; }

/* ---- En-tête de page ---- */
.page-tete { margin-bottom: var(--e-lg); }
.page-tete .fil { display: flex; align-items: center; gap: var(--e-sm); margin-bottom: var(--e-xs); }
.page-tete .fil::before { content: ''; width: 24px; height: 2px; background: var(--cuivre); }

/* ---- Cartes ---- */
.cartes { display: grid; grid-template-columns: 1fr; gap: var(--e-md); }
.carte {
  background: var(--creme);
  border: 1px solid var(--ligne);
  border-radius: var(--radius);
  padding: var(--e-lg);
  box-shadow: var(--ombre);
}
.carte.kpi { position: relative; overflow: hidden; }
.carte.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cuivre); }
.kpi .val { font-family: var(--f-titre); font-size: 1.8rem; color: var(--marine); margin-top: var(--e-xs); }
.kpi .val.pos { color: var(--recette); }
.kpi .val.neg { color: var(--cuivre-profond); }

/* ---- Tableaux ---- */
.tableau-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--ligne); }
table { width: 100%; border-collapse: collapse; background: var(--creme); font-size: .85rem; }
thead th {
  background: var(--marine); color: var(--creme);
  font-family: var(--f-mono); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  padding: var(--e-sm) var(--e-md); text-align: left; white-space: nowrap;
}
tbody td { padding: var(--e-sm) var(--e-md); border-bottom: 1px solid var(--ligne); }
tbody tr:nth-child(even) { background: #fff; }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-family: var(--f-mono); white-space: nowrap; }
.t-recette { color: var(--recette); font-weight: 600; }
.t-depense { color: var(--depense); font-weight: 600; }
.ligne-total td { background: var(--parchemin); font-weight: 700; font-family: var(--f-titre); color: var(--marine); }

/* ---- Formulaires ---- */
.champ { margin-bottom: var(--e-md); }
.champ label { display: block; font-family: var(--f-mono); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--sepia); margin-bottom: var(--e-xs); }
.champ input, .champ select, .champ textarea {
  width: 100%; padding: 10px var(--e-md);
  border: 1px solid var(--ligne); border-radius: var(--radius);
  font-family: var(--f-texte); font-size: .95rem; background: #fff; color: var(--encre);
  transition: var(--transition);
}
.champ input:focus, .champ select:focus, .champ textarea:focus {
  outline: none; border-color: var(--cuivre); box-shadow: 0 0 0 3px rgba(200, 146, 74, .15);
}
.grille-champs { display: grid; grid-template-columns: 1fr; gap: 0 var(--e-md); }

/* ---- Boutons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-sm);
  padding: 11px var(--e-lg); border-radius: var(--radius); cursor: pointer;
  font-family: var(--f-mono); font-size: .75rem; letter-spacing: .05em; text-transform: uppercase;
  border: 1px solid transparent; transition: var(--transition); font-weight: 500;
}
.btn-primaire { background: var(--marine); color: var(--creme); }
.btn-primaire:hover { background: var(--marine-profond); }
.btn-cuivre { background: var(--cuivre); color: var(--marine-profond); }
.btn-cuivre:hover { background: var(--cuivre-profond); color: var(--creme); }
.btn-ligne { background: transparent; border-color: var(--cuivre); color: var(--cuivre-profond); }
.btn-ligne:hover { background: var(--cuivre); color: var(--marine-profond); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; flex-wrap: wrap; gap: var(--e-sm); }

/* ---- Badges & alertes ---- */
.badge { font-family: var(--f-mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 3px; }
.badge-ouvert { background: rgba(59, 175, 120, .15); color: #2a7d56; }
.badge-cloture { background: rgba(200, 146, 74, .18); color: var(--cuivre-profond); }
.badge-archive { background: rgba(15, 41, 66, .1); color: var(--marine); }

.alerte { padding: var(--e-md); border-radius: var(--radius); margin-bottom: var(--e-md); font-size: .88rem; border-left: 3px solid; }
.alerte-info { background: rgba(94, 176, 229, .1); border-color: #5EB0E5; }
.alerte-attention { background: rgba(200, 146, 74, .12); border-color: var(--cuivre); }
.alerte-erreur { background: rgba(160, 114, 53, .12); border-color: var(--depense); color: var(--depense); }

/* ---- Connexion ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--e-lg); background: var(--marine); }
.login-carte { background: var(--creme); border-radius: var(--radius); padding: var(--e-xl); max-width: 380px; width: 100%; box-shadow: 0 20px 60px rgba(8, 26, 46, .4); }
.login-carte .marque-c { text-align: center; margin-bottom: var(--e-xl); }
.login-carte .nom-c { font-family: var(--f-titre); font-size: 1.8rem; color: var(--marine); }
.login-carte .sous-c { font-family: var(--f-mono); font-size: .62rem; letter-spacing: .12em; text-transform: uppercase; color: var(--sepia); margin-top: 4px; }

.vide { text-align: center; padding: var(--e-xxl) var(--e-lg); color: var(--sepia); }
.vide .ico { font-size: 2.5rem; opacity: .4; }

.muet { color: var(--sepia); font-size: .85rem; }

/* =============================================================
   DESKTOP (≥ 768px) : navigation latérale
   ============================================================= */
@media (min-width: 768px) {
  .corps { flex-direction: row; }
  .nav {
    position: static; flex-direction: column;
    width: 210px; border-top: none; border-right: 1px solid rgba(200, 146, 74, .25);
    padding-top: var(--e-md);
  }
  .nav button {
    flex: none; flex-direction: row; justify-content: flex-start; gap: var(--e-md);
    padding: var(--e-md) var(--e-lg); font-size: .72rem;
  }
  .nav button.actif { box-shadow: inset 3px 0 0 var(--cuivre); }
  .nav button .ico { font-size: 1rem; }
  .contenu { padding: var(--e-xl); padding-bottom: var(--e-xl); }
  .cartes { grid-template-columns: repeat(3, 1fr); }
  .grille-champs { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 2rem; }
}

@media (min-width: 1024px) {
  .cartes.duo { grid-template-columns: repeat(2, 1fr); }
}
