/* ============================================================
   FAB-OS — Design system
   Charte : crème · aubergine · vert · accent terracotta
   Typo écosystème : Playfair Display (titres) · IBM Plex Mono (corps) · DM Sans
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Fonds */
  --creme:        #f4efe2;
  --creme-2:      #efe7d6;
  --card:         #ffffff;
  --card-soft:    #fbf7ee;

  /* Couleurs de marque */
  --aubergine:      #3d1a4f;   /* titres, texte fort */
  --aubergine-2:    #5a2b73;   /* liens, accents violets */
  --vert:           #4f9e3f;   /* accent vif, CTA, "chaud" */
  --vert-fonce:     #1f3a2b;   /* barre de navigation */
  --vert-fonce-2:   #2a4d38;
  --terracotta:     #d2602f;   /* bouton Importer, pill commercial */
  --terracotta-2:   #b84e22;

  /* Scores / statuts */
  --froid:   #e0574a;
  --tiede:   #efb53f;
  --chaud:   #4f9e3f;
  --warn-bg: #fdf3d6;
  --warn-fg: #9a7611;

  /* Texte */
  --ink:        #2e2535;
  --ink-soft:   #6b6275;
  --on-dark:    #f4efe2;

  /* Bordures / ombres */
  --border:   #e6ddcb;
  --shadow:   0 2px 8px rgba(61, 26, 79, 0.06);
  --shadow-lg:0 8px 28px rgba(61, 26, 79, 0.12);
  --radius:   16px;
  --radius-sm:10px;

  /* Typo écosystème SUPERWASTE Connect : Space Grotesk (titres) + DM Sans (corps) */
  --serif: "Space Grotesk", system-ui, sans-serif;   /* titres + hero */
  --title: "Space Grotesk", system-ui, sans-serif;   /* titres app */
  --sans:  "DM Sans", system-ui, sans-serif;         /* texte secondaire */
  --mono:  "DM Sans", system-ui, sans-serif;         /* corps, labels, données */
}

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

body {
  font-family: var(--mono);
  background: var(--creme);
  color: var(--ink);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Titres de l'app en sans-serif arrondi (CRM) ; .serif réservé à la vitrine */
h1, h2, h3 { font-family: var(--title); color: var(--aubergine); font-weight: 700; letter-spacing: -0.01em; }
.serif { font-family: var(--serif); color: var(--aubergine); font-weight: 700; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.5rem; }
.em-vert { color: var(--vert); font-style: italic; }
a { color: var(--aubergine-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.eyebrow {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--vert);
}

/* ============ Layout ============ */
.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }
.page { min-height: 100vh; min-height: 100dvh; }
.muted { color: var(--ink-soft); }
.row { display: flex; gap: 1rem; }
.wrap { flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }

/* ============ Navigation (barre verte, une ligne) ============ */
.nav {
  background: var(--vert-fonce);
  color: var(--on-dark);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
/* Marque (logo + nom) + toggle dessous */
.nav__brand { display: flex; flex-direction: column; gap: 0.4rem; flex-shrink: 0; }
.nav__brandtop { display: flex; align-items: center; gap: 0.55rem; }
.nav__logo { width: 38px; height: 38px; }
.nav__name { display: flex; flex-direction: column; line-height: 1.05; }
.nav__name b { font-family: var(--title); font-weight: 800; font-size: 1.25rem; letter-spacing: 0.01em; }
.nav__name span { font-size: 0.56rem; letter-spacing: 0.16em; opacity: 0.7; text-transform: uppercase; }
.nav__toggle { display: inline-flex; gap: 0.25rem; background: rgba(0,0,0,0.2); padding: 0.2rem; border-radius: 999px; align-self: flex-start; }
.nav__toggle button {
  border: 0; background: transparent; color: var(--on-dark); font-family: var(--mono);
  padding: 0.25rem 0.6rem; border-radius: 999px; cursor: pointer; font-size: 0.7rem; opacity: 0.65;
}
.nav__toggle button.is-on { background: var(--terracotta); opacity: 1; }
.nav__toggle button.machine.is-on { background: var(--vert); }

/* Centre : groupes + Importer */
.nav__center { flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }
.nav__group { display: inline-flex; gap: 0.2rem; align-items: center; }
.nav__link { color: var(--on-dark); padding: 0.45rem 0.8rem; border-radius: 999px; font-size: 0.85rem; opacity: 0.85; white-space: nowrap; }
.nav__link:hover { opacity: 1; text-decoration: none; background: rgba(255,255,255,0.08); }
.nav__link.is-active { background: var(--terracotta); opacity: 1; color: #fff; font-weight: 600; }
.nav__import {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--terracotta); color: #fff; font-weight: 700; padding: 0.5rem 1.1rem; border-radius: 999px;
  white-space: nowrap; box-shadow: 0 2px 8px rgba(210,96,47,.4); line-height: 1;
}
.nav__import svg { flex: none; }
.nav__import:hover { background: var(--terracotta-2); text-decoration: none; }

/* Droite : compte + menu déroulant */
.nav__account { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.nav__menu { position: relative; }
.nav__menubtn { border: 1.5px solid rgba(255,255,255,.3); background: transparent; color: var(--on-dark); font-family: var(--mono); padding: 0.4rem 0.8rem; border-radius: 999px; cursor: pointer; font-size: 0.82rem; }
.nav__menubtn:hover { background: rgba(255,255,255,0.08); }
.nav__dropdown { position: absolute; right: 0; top: calc(100% + 0.4rem); background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); min-width: 210px; padding: 0.4rem; z-index: 50; }
.nav__dropdown a, .nav__dropdown button { display: block; width: 100%; text-align: left; padding: 0.55rem 0.7rem; border-radius: 8px; font-family: var(--mono); font-size: 0.85rem; color: var(--ink); background: none; border: 0; cursor: pointer; }
.nav__dropdown a:hover, .nav__dropdown button:hover { background: var(--card-soft); text-decoration: none; }
.nav__sep { height: 1px; background: var(--border); margin: 0.35rem 0; }
.nav__logout { color: var(--froid) !important; }
.nav__user { font-size: 0.78rem; opacity: 0.75; white-space: nowrap; }
.nav__notif { position: relative; }
.nav__bell { position: relative; color: var(--on-dark); font-size: 1.15rem; text-decoration: none; padding: 0.2rem 0.3rem; flex-shrink: 0; background: none; border: 0; cursor: pointer; line-height: 1; }
.nav__bell:hover { text-decoration: none; opacity: 0.85; }
.nav__bell-badge { position: absolute; top: -3px; right: -4px; background: var(--terracotta); color: #fff;
  font-size: 0.62rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 3px; }
/* Centre de notifications */
.nav__notifdd { width: 320px; max-width: 88vw; max-height: 70vh; overflow-y: auto; padding: 0.3rem; }
.nav__notifhd { display: flex; align-items: center; justify-content: space-between; padding: 0.45rem 0.6rem 0.5rem; }
.nav__notifhd b { font-family: var(--mono); font-size: 0.85rem; }
.nav__notifhd button { width: auto; font-size: 0.72rem; color: var(--aubergine-2); background: none; border: 0; cursor: pointer; padding: 0.2rem 0.3rem; }
.nav__notifhd button:hover { text-decoration: underline; background: none; }
.nav__notifempty { padding: 1rem 0.7rem; color: var(--muted, #888); font-size: 0.85rem; text-align: center; }
.nav__notifitem { display: flex !important; gap: 0.55rem; align-items: flex-start; padding: 0.55rem 0.6rem !important; border-radius: 10px; }
.nav__notifitem.is-unread { background: var(--card-soft); }
.nav__notifico { font-size: 1.05rem; line-height: 1.3; flex-shrink: 0; }
.nav__notiftxt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nav__notiftxt b { font-family: var(--mono); font-size: 0.8rem; color: var(--ink); white-space: normal; }
.nav__notiftxt span { font-size: 0.76rem; color: var(--muted, #777); white-space: normal; }
.nav__notiftxt em { font-size: 0.68rem; color: var(--muted, #999); font-style: normal; margin-top: 1px; }
@media (max-width: 1100px) { .nav { flex-wrap: wrap; } .nav__center { order: 3; width: 100%; } }

/* ============ Boutons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono); font-size: 0.85rem; cursor: pointer;
  padding: 0.6rem 1.1rem; border-radius: 999px; border: 1.5px solid var(--aubergine);
  background: transparent; color: var(--aubergine); transition: all 0.15s;
}
.btn:hover { background: var(--aubergine); color: #fff; text-decoration: none; }
.btn--primary { background: var(--vert-fonce); border-color: var(--vert-fonce); color: #fff; }
.btn--primary:hover { background: var(--vert-fonce-2); }
.btn--vert { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn--orange { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
.btn--orange:hover { background: var(--terracotta-2); }
.btn--ghost { border-color: var(--border); color: var(--ink-soft); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* ============ Cartes ============ */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; border: 1px solid var(--border);
}
.card--soft { background: var(--card-soft); }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 1rem 1.25rem;
  border: 1px solid var(--border); border-top: 4px solid var(--aubergine-2); box-shadow: var(--shadow);
}
.stat-card .num { font-family: var(--title); font-weight: 700; font-size: 2rem; color: var(--aubergine); }
.stat-card .lbl { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.66rem; color: var(--ink-soft); }

/* ============ Badges / pills ============ */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.22rem 0.6rem; border-radius: 999px; font-size: 0.72rem; white-space: nowrap;
  background: #efe7f5; color: var(--aubergine);
}
.badge--offer { background: #e8f1e4; color: var(--vert-fonce); }
.badge--warn  { background: var(--warn-bg); color: var(--warn-fg); }
.badge--stage-lead         { background: #efe7f5; color: var(--aubergine-2); }
.badge--stage-prospection  { background: #ece6f7; color: #5a3b9e; }
.badge--stage-qualification{ background: #e3f1df; color: var(--vert-fonce); }
.badge--stage-gagne        { background: #d8f0d2; color: #1f6e2c; }
.badge--stage-perdu        { background: #f7dcd8; color: #a3382c; }

/* Pastille de score */
.score { display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.1rem; padding: 0.15rem 0.45rem; border-radius: 999px; color: #fff; font-weight: 700; font-size: 0.78rem; }
.score--froid { background: var(--froid); }
.score--tiede { background: var(--tiede); color: #5a4500; }
.score--chaud { background: var(--chaud); }

/* Priorité */
.prio-hot { color: var(--terracotta); }
.prio-int { color: var(--tiede); }

/* ============ Formulaires ============ */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 0.35rem; }
input, select, textarea {
  width: 100%; font-family: var(--mono); font-size: 0.9rem; color: var(--ink);
  padding: 0.7rem 0.85rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card-soft);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--aubergine-2); background: #fff; }

/* ============ Tables ============ */
.table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); }
.table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--card-soft); }

/* ============ Utilitaires ============ */
.flex { display: flex; } .between { justify-content: space-between; } .center { align-items: center; }
.mt-1{margin-top:.5rem}.mt-2{margin-top:1rem}.mt-3{margin-top:1.5rem}
.mb-1{margin-bottom:.5rem}.mb-2{margin-bottom:1rem}.mb-3{margin-bottom:1.5rem}
.gap-sm{gap:.4rem}
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--aubergine); color: #fff; padding: 0.75rem 1.25rem; border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 999; }

/* ============================================================
   Responsive / mobile + web app installée
   ============================================================ */
/* Bouton hamburger (injecté par nav.js) — caché sur desktop */
.nav__burger {
  display: none; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.28); background: transparent;
  color: var(--on-dark); font-size: 1.3rem; cursor: pointer; margin-left: auto;
}
/* Bouton Importer dédié mobile (toujours visible, hors hamburger) — caché en desktop */
.nav__import--m { display: none; }

@media (max-width: 900px) {
  .container { padding: 1rem; }
  /* Barre du haut : [logo FAB-OS] ........ [Importer] [☰] */
  .nav { padding: 0.6rem 1rem; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
  .nav__brand { flex-direction: row; align-items: center; gap: 0.5rem; flex-shrink: 1; min-width: 0; }
  .nav__name span { display: none; }                 /* sous-titre masqué */
  .nav__name b { font-size: 1.15rem; }
  .nav__toggle { display: none; }                     /* toggle Alex SIA / H-Machine : secondaire → caché mobile */
  .nav__import--m { display: inline-flex; margin-left: auto; padding: 0.5rem 0.95rem; font-size: 0.85rem; }
  .nav__burger { display: inline-flex; margin-left: 0.4rem; }
  /* Menu replié par défaut */
  .nav__center, .nav__account { display: none; }
  /* Menu déplié : liste verticale propre sous la barre */
  .nav.nav--open .nav__center {
    display: flex; flex-direction: column; align-items: stretch;
    order: 3; width: 100%; gap: 0.15rem; margin-top: 0.5rem;
  }
  .nav.nav--open .nav__group { display: contents; }   /* aplatit le groupe → 1 lien par ligne */
  .nav.nav--open .nav__center .nav__import { display: none; }  /* pas de doublon Importer (déjà en haut) */
  .nav.nav--open .nav__link { width: 100%; text-align: left; padding: 0.7rem 0.9rem; border-radius: 10px; }
  .nav.nav--open .nav__account {
    display: flex; order: 4; width: 100%; align-items: center; justify-content: space-between;
    margin-top: 0.5rem; padding-top: 0.7rem; border-top: 1px solid rgba(255,255,255,0.15);
  }
  .nav__dropdown { right: 0; left: auto; }
  /* Grilles génériques → 1 colonne */
  .two, .grid2 { grid-template-columns: 1fr !important; }
}

@media (max-width: 760px) {
  /* Anti-débordement horizontal global (sécurité) */
  html, body { overflow-x: hidden; }
  /* Les en-têtes "titre + bouton" passent à la ligne au lieu de déborder */
  .flex.between { flex-wrap: wrap; gap: 0.6rem; }
}

/* Tables : défilement horizontal plutôt que débordement */
@media (max-width: 760px) {
  .table, table.ca { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stat-card .num { font-size: 1.5rem; }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.25rem; }
  .card { padding: 1rem; }
  /* cibles tactiles plus généreuses */
  .btn { padding: 0.65rem 1rem; }
}

/* Encoche / barre d'état en mode app installée (standalone) */
@supports (padding: max(0px)) {
  .nav {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-top: max(0.6rem, env(safe-area-inset-top));
  }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
