:root {
  --navy: #1F3B57;
  --orange: #E07A2E;
  --grey: #F2F2F2;
  --text: #222;
  --border: #D9D9D9;
  --orange-texte: #A8541A; /* orange de marque assombri : 5,3:1 sur blanc, pour le texte */
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--grey);
  color: var(--text);
}
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .brand { font-weight: 700; letter-spacing: 0.5px; }
.topbar .brand span { color: var(--orange); }
.topbar button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  text-align: center;
}
.login-card h1 { color: var(--navy); font-size: 22px; margin-bottom: 2px; }
.login-card p.tagline { color: var(--orange-texte); font-size: 13px; margin-top: 0; margin-bottom: 24px; }
.field { text-align: left; margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 4px; color: #555; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.btn-primary {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 6px;
}
.btn-primary:hover { background: #16293d; }
.error-msg {
  background: #FDECEC;
  color: #B02A2A;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.auth-tabs {
  display: flex; gap: 6px; background: #F2F2F2; border-radius: 8px; padding: 4px; margin-bottom: 18px;
}
.auth-tab {
  flex: 1; border: none; background: transparent; padding: 9px 8px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: #666; cursor: pointer;
}
.auth-tab.active { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.field-hint { font-size: 12px; color: #666; margin-top: 5px; line-height: 1.4; }
.layout { display: flex; min-height: calc(100vh - 52px); }
.sidebar {
  width: 230px;
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 16px 0;
}
.sidebar a {
  display: block;
  padding: 10px 20px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar a:hover { background: var(--grey); border-left-color: var(--orange); }
.content { flex: 1; padding: 28px; }
.role-badge {
  display: inline-block;
  background: var(--orange);
  color: #152739; /* texte sombre : le blanc sur orange plafonne a 3:1 */
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: 8px;
}
.panel { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
table { width: 100%; border-collapse: collapse; margin-top: 10px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: var(--navy); color: #fff; }
tr:nth-child(even) { background: #FAFAFA; }
.tag-actif { color: #1a7a1a; font-weight: 600; }
.tag-inactif { color: #B02A2A; font-weight: 600; }

.section-btn-active { background: var(--navy) !important; color: #fff !important; border-color: var(--navy) !important; }

/* Groupes repliables par client (modules Entrepôts) */
.client-group { border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; overflow: hidden; }
.client-group-header {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: #F7F9FB; cursor: pointer; font-size: 14px; user-select: none;
}
.client-group-header:hover { background: #EEF3F7; }
.client-group-header .toggle-icon { color: var(--orange-texte); font-size: 12px; width: 12px; display: inline-block; }
.client-group-body { padding: 0 14px 10px; }
.client-group-body table { margin-top: 6px; }
/* La fiche client porte overflow:hidden pour arrondir ses coins ; sans la regle
   ci-dessous ce hidden rognait la table de l entrepot (15 colonnes) et rendait
   les colonnes Photos, Ajouter photo et Action inatteignables, sans barre de
   defilement. Le corps de la fiche defile donc horizontalement pour son compte. */
.client-group-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.client-group-body table { min-width: max-content; }

/* Modale d'édition (modules Entrepôts) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-box {
  background: #fff; border-radius: 10px; padding: 24px; width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn-secondary {
  background: #fff; color: var(--navy); border: 1px solid var(--border);
  padding: 9px 16px; border-radius: 6px; cursor: pointer; font-size: 14px;
}

@media print {
  .topbar, .sidebar, .no-print, form, button { display: none !important; }
  .content { padding: 0; }
  .panel { box-shadow: none; padding: 0; }
  .client-group-body { display: block !important; }
  .client-group { border: none; margin-top: 14px; break-inside: avoid; }
  .client-group-header { background: none; padding: 4px 0; font-weight: 700; }
  .client-group-header .toggle-icon { display: none; }
  .entrepot-section, .board-section { display: block !important; break-before: page; }
  .entrepot-section:first-of-type, .board-section:first-of-type { break-before: auto; }
}

.mp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 14px; }
.mp-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.mp-photo { position: relative; height: 150px; background: var(--grey); cursor: pointer; overflow: hidden; }
.mp-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-photo-empty { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #999; font-size: 12px; text-align: center; padding: 0 10px; }
.mp-badge { position: absolute; top: 8px; left: 8px; background: var(--navy); color: #fff; font-size: 12px; padding: 3px 8px; border-radius: 4px; }
.mp-badge.occasion { background: #6b6b6b; }
.mp-badge.vendu { background: #B02A2A; }
.mp-photo-count { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.55); color: #fff; font-size: 12px; padding: 2px 7px; border-radius: 4px; }
.mp-info { padding: 10px 12px; }
.mp-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.mp-price-row { display: flex; align-items: center; gap: 6px; }
.mp-price-input { flex: 1; min-width: 0; padding: 5px 7px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--navy); }
.mp-price-demande { flex: 1; font-size: 13px; color: #666; cursor: pointer; }
.mp-devise { font-size: 12px; color: #666; }
.mp-meta { font-size: 12px; color: #666; margin-top: 6px; }
.mp-actions { display: flex; gap: 8px; padding: 0 12px 12px; }
.mp-actions button { flex: 1; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.mp-actions button.mp-danger { color: #B02A2A; border-color: #E8B4B4; }
.mp-details { padding: 0 12px; }
.mp-details-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; font-size: 12px; margin-top: 8px; }
.mp-details-grid label { display: block; margin-bottom: 3px; color: #666; }
.mp-details-grid input, .mp-details-grid select { width: 100%; padding: 5px 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.mp-details textarea { width: 100%; padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.mp-add-tile { border: 1px dashed var(--border); background: transparent; cursor: pointer; min-height: 150px; }
.mp-add-inner { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #666; font-size: 13px; padding: 20px; }
.mp-add-plus { font-size: 22px; color: var(--orange); }
.mp-add-form { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.mp-add-form input, .mp-add-form select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

.mp-lightbox-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 999; padding: 20px; }
.mp-lb-box { background: #fff; border-radius: 10px; padding: 16px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; position: relative; }
.mp-lb-close { position: absolute; top: 12px; right: 12px; border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.mp-lb-main { height: 320px; background: var(--grey); border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-top: 30px; }
.mp-lb-main img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; transition: transform 0.15s ease-out; }
.mp-lb-main.zoomed img { transform: scale(2.2); cursor: zoom-out; }
.mp-lb-thumbs { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.mp-lb-thumb { position: relative; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--grey); }
.mp-lb-thumb.is-cover { border-color: var(--orange); }
.mp-lb-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mp-lb-thumb-actions { position: absolute; bottom: 0; left: 0; right: 0; display: flex; opacity: 0; transition: opacity 0.15s; }
.mp-lb-thumb:hover .mp-lb-thumb-actions { opacity: 1; }
.mp-lb-thumb-actions span { flex: 1; background: rgba(0,0,0,0.65); color: #fff; font-size: 12px; text-align: center; padding: 2px 0; }
.mp-lb-thumb-empty { display: flex; align-items: center; justify-content: center; font-size: 22px; color: var(--orange); border: 1px dashed var(--border); }
.mp-lb-hint { font-size: 12px; color: #666; margin-top: 10px; }

/* Liens sous le formulaire de connexion (suivi public + vitrine) */
.login-links { margin-top: 22px; padding-top: 18px; border-top: 1px solid #e1e6eb; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-link { text-decoration: none; font-size: 13.5px; color: #5a6b7a; font-weight: 600; }
.login-link:hover { color: var(--orange-texte); }
.login-link-suivi { display: block; width: 100%; text-align: center; padding: 12px 16px; border: 1.5px solid #1F3B57; border-radius: 9px; color: #1F3B57; font-size: 14.5px; font-weight: 700; transition: background .18s ease, color .18s ease; }
.login-link-suivi:hover { background: #1F3B57; color: #fff; }
@media (hover: none) { .login-link-suivi:hover { background: none; color: #1F3B57; } .login-link-suivi:active { background: #1F3B57; color: #fff; } }

/* --- Menu lateral : sections repliables (27/08/2026) --- */
.sidebar .menu-titre {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; box-sizing: border-box; margin: 16px 0 2px; padding: 5px 20px;
  background: none; border: 0; font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: #667085;
  cursor: pointer; text-align: left;
}
.sidebar .menu-titre:hover { color: var(--orange-texte); }
.sidebar .menu-signe { font-size: 16px; font-weight: 400; line-height: 1; color: #b3bac6; }
.sidebar .menu-groupe { display: block; }
.sidebar .menu-groupe a { padding-left: 26px; font-size: 14.5px; font-weight: 500; }

/* --- Menu lateral jamais ecrase (31/08/2026) ---
   .layout est un conteneur flex. .sidebar valait flex: 0 1 auto et .content
   min-width: auto : sur un ecran au contenu large (Caisse, 1413 px de cartes),
   le contenu refusait de retrecir et ecrasait le menu a 0,67 px de large.
   Le menu existait dans le DOM mais restait invisible et incliquable. */
.layout > .sidebar { flex: 0 0 230px; }
.layout > .content { min-width: 0; }
/* Un tableau large fait defiler la page horizontalement : le menu reste colle
   a gauche au lieu de sortir de l ecran. */
.layout > .sidebar { position: sticky; left: 0; z-index: 2; }
/* min-width:0 laisse le contenu retrecir : sans defilement propre, un tableau
   large etait coupe sans aucun moyen de le faire defiler. La zone de contenu
   defile donc horizontalement, le menu restant fixe a gauche. */
.layout > .content { overflow-x: auto; }

/* --- Telephone : le menu lateral devient un tiroir -----------------------
   .sidebar a 230 px fixes prenait plus de la moitie d un ecran de 390 px :
   le contenu se retrouvait dans une colonne ou chaque titre se cassait mot
   par mot. Sous 900 px il sort de la mise en page et glisse par-dessus. */
#cc-menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  margin-right: 12px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  cursor: pointer;
  flex: 0 0 auto;
}
#cc-menu:hover { background: rgba(255, 255, 255, .22); }

@media (max-width: 899px) {
  #cc-menu { display: inline-flex; }
  .layout { display: block; }
  .layout > .sidebar, .layout > #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    max-width: 84vw;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 1200;
    overflow-y: auto;
    box-shadow: 0 0 44px rgba(11, 20, 34, .22);
  }
  .layout > #sidebar.ouvert, .layout > .sidebar.ouvert { transform: none !important; }
  #cc-voile {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    background: rgba(11, 20, 34, .45);
    z-index: 1150;
  }
  /* En-tete : sur un telephone le nom du compte chevauchait la marque.
     On laisse la barre passer a la ligne plutot que de tout entasser. */
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
    column-gap: 10px;
    padding: 10px 14px;
  }
  .topbar > * { min-width: 0; }
  .topbar .brand { font-size: 15px; }
  .topbar #userInfo { font-size: 13px; }
  .topbar button { font-size: 13px; padding: 6px 10px; }
  /* La cloche se glissait sur une quatrieme ligne a elle toute seule :
     elle va dans le coin, dans la place laissee libre par la marque. */
  .topbar { position: relative; padding-right: 62px; }
  .topbar #cc-al-cloche {
    position: absolute;
    top: 8px;
    right: 12px;
    margin: 0;
  }

  .content { padding-left: 14px; padding-right: 14px; }
  .content input, .content select, .content textarea {
    max-width: 100%;
    box-sizing: border-box;
  }
  /* Un tableau large defile sur lui-meme au lieu de pousser toute la page. */
  .content table { display: block; width: 100%; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
