/* ============================================================
   IPC France Literie — Neumorphic Dark CSS
   Optimise iPad (portrait + paysage) — tous modeles
   ============================================================ */

/* ---- Tokens ---- */
:root {
  --bg:           #1e1510;
  --bg-card:      #231a13;
  --bg-raised:    #2a1f17;
  --bg-input:     #1a1109;
  --shadow-dark:  #120c07;
  --shadow-light: #312418;
  --accent:       #C8D400;
  --accent-dark:  #9ea900;
  --accent-hover: #d9e600;
  --text-main:    #F0E8D8;
  --text-muted:   #a08060;
  --text-dim:     #6a5040;
  --border:       rgba(255,255,255,0.06);
  --danger:       #e05050;
  --success:      #5db85d;
  --radius:       16px;
  --radius-sm:    10px;
  --radius-lg:    24px;
  --transition:   0.2s ease;

  /* Taille tactile minimale Apple : 44pt = ~44-48px */
  --tap:          48px;
  --tap-sm:       44px;

  /* Neumorphic shadows */
  --nm-inset:  inset 3px 3px 8px var(--shadow-dark), inset -3px -3px 8px var(--shadow-light);
  --nm-raised: 5px 5px 12px var(--shadow-dark), -5px -5px 12px var(--shadow-light);
  --nm-card:   8px 8px 20px var(--shadow-dark), -8px -8px 20px var(--shadow-light);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/*  ============================================================
    Ecrans Affichage / Centrage
    ============================================================ */

.screen {
  display: none !important;
}

.screen.active {
  display: block !important;
}

#loginScreen.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
}

#appScreen.active {
  display: flex !important;
  flex-direction: column;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

/* ============================================================
   LOGIN
   ============================================================ */
#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 20px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--nm-card);
  padding: 44px 36px 36px;
  border: 1px solid var(--border);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}
.login-logo svg { width: 160px; height: auto; }

.login-title {
  text-align: center;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  margin-bottom: 36px;
}

.login-footer {
  text-align: center;
  margin-top: 28px;
}
.login-footer a {
  color: var(--text-dim);
  font-size: 0.72rem;
  text-decoration: none;
}
.login-footer a:hover { color: var(--text-muted); }

/* ============================================================
   APP LAYOUT
   ============================================================ */
#appScreen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}
#appScreen.hidden { display: none !important; }

/* ---- Header ---- */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px var(--shadow-dark);
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-brand svg { width: 80px; height: auto; }
.header-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.18em;
}

.header-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  color: var(--text-muted);
}
/* Affichage du role/fonction dans le bandeau supérieur */
.header-role {
  background: var(--bg-raised);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--accent);
  border: 1px solid var(--accent-dark);
}

.header-role.role-commercial {
  color: var(--accent);
  border-color: var(--accent-dark);
  background: var(--bg-raised);
}

.header-role.role-responsable {
  color: #ffb347;
  border-color: rgba(255, 179, 71, 0.45);
  background: rgba(255, 179, 71, 0.12);
}

.header-role.role-admin {
  color: #f08080;
  border-color: rgba(224,80,80,0.4);
  background: rgba(224,80,80,0.12);
}
/* Affichage du magasin dans le bandeau supérieur */
.header-magasin {
  background: var(--bg-raised);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: var(--accent);
  border: 1px solid var(--accent-dark);
}

/* Bouton déconnexion — zone tactile généreuse */
#logoutBtn {
  width: var(--tap);
  height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---- Tab bar ---- */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 12px;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 9px;
  min-height: var(--tap-sm);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-dim);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.tab-btn svg { width: 20px; height: 20px; }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-btn:hover:not(.active) { color: var(--text-muted); }

/* ---- Tab content ---- */
.tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  -webkit-overflow-scrolling: touch;
}
.tab-content.hidden { display: none !important; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--nm-card);
  border: 1px solid var(--border);
  padding: 22px 18px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 20px;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-header-row .card-title { margin-bottom: 0; }

/* ============================================================
   FORMS
   ============================================================ */
.form-section-title {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 24px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(200,212,0,0.25);
  opacity: 0.9;
}
.form-section-title:first-child { margin-top: 0; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Inputs — hauteur tactile généreuse */
input[type="text"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--nm-inset);
  color: var(--text-main);
  font-size: 1rem;
  font-family: inherit;
  padding: 11px 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-dark);
  box-shadow: var(--nm-inset), 0 0 0 2px rgba(200,212,0,0.18);
}

/* Saisie libre en majuscules */
input[type="text"],
input[type="tel"],
textarea {
  text-transform: uppercase;
}

/* Exceptions : champs ou les majuscules ne sont pas souhaitees */
input[type="password"],
input[type="email"],
#fCpClient {
  text-transform: none;
}

/* Autofill — neutraliser le fond blanc navigateur */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 999px var(--bg-input) inset !important;
  -webkit-text-fill-color: var(--text-main) !important;
  caret-color: var(--text-main);
  transition: background-color 99999s ease;
}

select option { background: var(--bg-card); color: var(--text-main); }
textarea { resize: vertical; min-height: 88px; font-size: 1rem; }

/* Champ date — largeur limitee */
.field-row-date {
  max-width: 280px;
}

/* Date de relance — meme style que date visite */
#fDateRelanceDevis {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}
#fDateRelanceDevis:not([value=""]) {
  color: var(--text-main);
}

/* Icone calendrier visible sur fond sombre */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.8) sepia(0.3) saturate(3) hue-rotate(30deg) brightness(1.1);
  opacity: 0.85;
  cursor: pointer;
  padding: 2px;
  width: 22px;
  height: 22px;
}

/* intl-tel-input — integration complete neumorphic */
.iti {
  width: 100%;
  display: block;
}

.iti__selected-country {
  background: var(--bg-input) !important;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  min-height: var(--tap);
  padding: 0 10px 0 12px;
  border-right: 1px solid var(--border);
}
.iti__selected-country:hover,
.iti__selected-country:focus {
  background: var(--bg-raised) !important;
}

.iti__selected-dial-code {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 600;
  margin-left: 4px;
}

/* Dropdown */
.iti__dropdown-content {
  background: var(--bg-card) !important;
  border: 1px solid var(--accent-dark) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--nm-card), 0 8px 32px rgba(0,0,0,0.5) !important;
  overflow: hidden;
  margin-top: 4px;
}

/* Champ recherche dans le dropdown */
.iti__search-input {
  background: var(--bg-input) !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  color: var(--text-main) !important;
  font-size: 0.95rem !important;
  padding: 10px 14px !important;
  width: 100% !important;
  outline: none !important;
  text-transform: none !important;
}
.iti__search-input::placeholder {
  color: var(--text-dim);
}
.iti__search-input:focus {
  border-bottom-color: var(--accent-dark) !important;
}

/* Liste des pays */
.iti__country-list {
  background: var(--bg-card) !important;
  border: none !important;
  max-height: 240px;
}

.iti__country {
  padding: 10px 14px !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-height: var(--tap-sm) !important;
  border-bottom: 1px solid var(--border) !important;
  transition: background var(--transition) !important;
}
.iti__country:last-child {
  border-bottom: none !important;
}

.iti__country.iti__highlight,
.iti__country:hover {
  background: rgba(200,212,0,0.1) !important;
}

.iti__country-name {
  color: var(--text-muted) !important;
  font-size: 0.9rem !important;
}

.iti__dial-code {
  color: var(--accent) !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
}

.iti__divider {
  border-color: var(--border) !important;
  margin: 0 !important;
}

/* Pays preferes separes du reste */
.iti__country.iti__preferred {
  background: rgba(200,212,0,0.05) !important;
}

/* ---- Profil buttons ---- */
.profil-btns {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.profil-btn {
  flex: 1;
  min-height: var(--tap);
  padding: 10px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--nm-raised);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.profil-btn.active {
  background: var(--accent);
  color: #1e1510;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(200,212,0,0.35);
}

/* Onglets Contact 1 / Contact 2 */
.contact-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  padding: 5px;
  border: 1px solid var(--border);
}

.contact-tab {
  flex: 1;
  min-height: var(--tap-sm);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.contact-tab.active {
  background: var(--bg-input);
  box-shadow: var(--nm-inset);
  color: var(--accent);
}
.contact-tab:hover:not(.active) { color: var(--text-muted); }

/* Picker Civilite */
.civilite-display {
  width: 100%;
  min-height: var(--tap);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--nm-inset);
  color: var(--text-dim);
  font-size: 1rem;
  padding: 11px 14px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color var(--transition);
  display: flex;
  align-items: center;
}
.civilite-display:hover,
.civilite-display:focus {
  border-color: var(--accent-dark);
  outline: none;
}
.civilite-display-filled {
  color: var(--text-main);
}

.civilite-picker,
.origine-picker {
  margin-top: 4px;
  background: var(--bg-input);
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius-sm);
  box-shadow: var(--nm-card);
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 500;
}

/* Bouton Decideur */
.decideur-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.decideur-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--tap-sm);
  padding: 6px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--nm-raised);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.decideur-btn::before {
  content: '';
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  flex-shrink: 0;
  transition: all var(--transition);
}
.decideur-btn.active {
  background: rgba(200,212,0,0.12);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--nm-raised), 0 0 10px rgba(200,212,0,0.2);
}
.decideur-btn.active::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px rgba(200,212,0,0.5);
}

/* Boutons Solo/Duo — version secondaire harmonisee */
.profil-btns-sm {
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 6px;
}

.profil-btn-detail {
  flex: 0 0 auto;
  min-width: 90px;
  min-height: var(--tap-sm);
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  box-shadow: var(--nm-raised);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.profil-btn-detail.active {
  background: var(--accent);
  color: #1e1510;
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(200,212,0,0.35);
}

/* ---- Toggle rows ---- */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-height: var(--tap);
}
.toggle-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}
.toggle-btns {
  display: flex;
  gap: 8px;
}
.toggle-btn {
  min-height: var(--tap-sm);
  min-width: 60px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.toggle-btn.active {
  background: var(--accent);
  color: #1e1510;
  border-color: var(--accent);
}

.sub-section {
  padding: 14px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  padding: 13px 24px;
  background: var(--accent);
  color: #1e1510;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(200,212,0,0.28);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); box-shadow: 0 2px 8px rgba(200,212,0,0.2); }
.btn-primary svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-full { width: 100%; margin-top: 24px; }

.btn-secondary {
  min-height: var(--tap-sm);
  padding: 10px 22px;
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:hover { color: var(--text-main); border-color: var(--text-dim); }

.btn-danger {
  min-height: var(--tap-sm);
  padding: 10px 22px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-danger:hover { background: #c03030; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-icon svg { width: 22px; height: 22px; }
.btn-icon:hover { color: var(--accent); }

.btn-sm {
  min-height: var(--tap-sm);
  padding: 8px 18px;
  background: var(--accent);
  color: #1e1510;
  border: none;
  border-radius: 24px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-sm:hover { background: var(--accent-hover); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-error {
  background: rgba(224,80,80,0.12);
  border: 1px solid rgba(224,80,80,0.4);
  color: #f08080;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-top: 12px;
  line-height: 1.5;
}
.alert-success {
  background: rgba(93,184,93,0.12);
  border: 1px solid rgba(93,184,93,0.4);
  color: #80d880;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-top: 12px;
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
   IPC LIST
   ============================================================ */
/* Bandeau commercial lecture seule */
.ipc-commercial-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.ipc-banner-tag {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-input);
  border-radius: 20px;
  padding: 4px 12px;
  letter-spacing: 0.04em;
}

.ipc-banner-tag-accent {
  color: var(--accent);
  border: 1px solid rgba(200,212,0,0.3);
}

.loading-msg, .empty-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.88rem;
  padding: 12px 0;
}

.filters-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.filter-select {
  flex: 1;
  min-width: 140px;
  min-height: var(--tap-sm);
  padding: 8px 12px;
  font-size: 0.88rem;
}

.ipc-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ipc-item {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  transition: background var(--transition);
}
.ipc-item:hover { background: #2e2318; }

.ipc-item-left { flex: 1; min-width: 0; }

.ipc-item-date {
  font-size: 0.74rem;
  color: var(--text-dim);
  margin-bottom: 3px;
}
.ipc-item-client {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ipc-item-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 5px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.ipc-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-promeneur { background: rgba(106,80,64,0.4); color: var(--text-dim); }
.badge-prospect  { background: rgba(200,212,0,0.15); color: var(--accent); border: 1px solid rgba(200,212,0,0.3); }
.badge-client    { background: rgba(200,212,0,0.25); color: var(--accent); border: 1px solid rgba(200,212,0,0.5); }
.badge-devis     { background: rgba(93,184,93,0.15); color: #80d880; }

.ipc-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}
.btn-edit, .btn-delete {
  width: var(--tap-sm);
  height: var(--tap-sm);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-edit   { background: rgba(200,212,0,0.1); color: var(--accent); }
.btn-edit:hover { background: rgba(200,212,0,0.25); }
.btn-delete { background: rgba(224,80,80,0.1); color: var(--danger); }
.btn-delete:hover { background: rgba(224,80,80,0.25); }
.btn-edit svg, .btn-delete svg { width: 17px; height: 17px; }

/* ============================================================
   KPI STATS GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 18px;
}

.kpi-card {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--nm-raised);
  padding: 16px 12px;
  text-align: center;
}
.kpi-card.accent {
  border-color: rgba(200,212,0,0.3);
  box-shadow: var(--nm-raised), 0 0 14px rgba(200,212,0,0.1);
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  margin-bottom: 6px;
}
.kpi-card.accent .kpi-value { color: var(--accent); }

.kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--border);
  box-shadow: var(--nm-card);
  width: 100%;
  max-width: 580px;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-box-sm { max-width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
  width: var(--tap-sm);
  height: var(--tap-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}
.modal-close:hover { color: var(--text-main); }

.modal-body {
  padding: 20px 24px;
}
.modal-body p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
}

/* ============================================================
   VILLE PICKER — liste de communes cliquables
   ============================================================ */
#ville-picker,
#cp-picker {
  margin-top: 4px;
  background: var(--bg-input);
  border: 1px solid var(--accent-dark);
  border-radius: var(--radius-sm);
  box-shadow: var(--nm-card);
  max-height: 220px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 500;
}

.ville-picker-item {
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition), color var(--transition);
  min-height: var(--tap-sm);
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}
.ville-picker-item:last-child { border-bottom: none; }
.ville-picker-item:hover,
.ville-picker-item:active {
  background: rgba(200,212,0,0.12);
  color: var(--accent);
}

/* Ville picker — layout nom + badge CP */
.ville-picker-item {
  justify-content: space-between;
}
.ville-picker-item strong {
  font-weight: 600;
  color: inherit;
}
.cp-badge {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(200,212,0,0.1);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(200,212,0,0.3);
  flex-shrink: 0;
  margin-left: 8px;
}

/* ============================================================
   TOAST SYSTEM — modal centre a l'ecran
   ============================================================ */
#ipc-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.88);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: min(460px, 90vw);
  padding: 18px 22px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--nm-card), 0 8px 32px rgba(0,0,0,0.5);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#ipc-toast.ipc-toast-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.ipc-toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.ipc-toast-msg {
  flex: 1;
}

/* Variantes */
#ipc-toast.ipc-toast-success {
  border-color: rgba(93,184,93,0.4);
  box-shadow: var(--nm-card), 0 0 24px rgba(93,184,93,0.2);
}
#ipc-toast.ipc-toast-success .ipc-toast-icon { color: #5db85d; }
#ipc-toast.ipc-toast-success .ipc-toast-msg  { color: #80d880; }

#ipc-toast.ipc-toast-error {
  border-color: rgba(224,80,80,0.4);
  box-shadow: var(--nm-card), 0 0 24px rgba(224,80,80,0.2);
}
#ipc-toast.ipc-toast-error .ipc-toast-icon { color: var(--danger); }
#ipc-toast.ipc-toast-error .ipc-toast-msg  { color: #f08080; }

#ipc-toast.ipc-toast-info {
  border-color: rgba(200,212,0,0.3);
  box-shadow: var(--nm-card), 0 0 24px rgba(200,212,0,0.15);
}
#ipc-toast.ipc-toast-info .ipc-toast-icon { color: var(--accent); }
#ipc-toast.ipc-toast-info .ipc-toast-msg  { color: var(--text-main); }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-raised); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   RESPONSIVE — iPad portrait (768px+)
   ============================================================ */
@media (min-width: 768px) {
  .tab-content { padding: 24px 24px; }
  .card { padding: 28px 24px; }
  .login-card { padding: 52px 48px 40px; }

  .kpi-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }

  .modal-overlay { align-items: center; padding: 24px; }
  .modal-box { border-radius: var(--radius-lg); }

  /* Formulaire saisie : centré avec max-width */
  #tabSaisie .card { max-width: 700px; margin-left: auto; margin-right: auto; }
}

/* ============================================================
   RESPONSIVE — iPad paysage / grand écran (1024px+)
   ============================================================ */
@media (min-width: 1024px) {
  .app-header { padding: 0 32px; height: 60px; }
  .tab-bar { padding: 0 24px; }
  .tab-content { padding: 28px 32px; }

  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }

  /* Layout deux colonnes en paysage : formulaire + liste côte à côte */
  #tabSaisie .card {
    max-width: 760px;
    margin-left: auto;
    margin-right: auto;
  }

  /* Inputs légèrement plus grands */
  input[type="text"],
  input[type="tel"],
  input[type="date"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  select {
    font-size: 1.02rem;
  }
}

/* ============================================================
   RESPONSIVE — iPad Pro 12.9" (1366px+)
   ============================================================ */
@media (min-width: 1300px) {
  .kpi-grid { grid-template-columns: repeat(6, 1fr); }

  #tabSaisie .card { max-width: 820px; }

  /* Tab bar plus large */
  .tab-btn { font-size: 0.82rem; }
  .tab-btn svg { width: 22px; height: 22px; }
}

/* ============================================================
   SAFE AREA — encoche / barre de navigation iPad
   ============================================================ */
.app-header {
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.tab-content {
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
#resetFormBtn {
  margin-top: 12px;
}

/* ============================================================
   MES IPC — version finale compacte
   ============================================================ */

#tabMesFiches {
  padding-top: 14px;
}

#tabMesFiches .card {
  margin-top: 0;
}

#tabMesFiches .card-title {
  margin-bottom: 0;
}

#tabMesFiches .card-header-row {
  margin-bottom: 12px;
}

.ipc-filters-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.ipc-filter-group {
  margin-bottom: 0;
}

.filter-input,
.filter-select {
  width: 100%;
}

#tabMesFiches .filter-input,
#tabMesFiches .filter-select {
  min-height: var(--tap-sm);
  padding: 8px 12px;
  font-size: 0.88rem;
}

.ipc-scope-info {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

#tabMesFiches .loading-msg,
#tabMesFiches .empty-msg {
  padding: 18px 0;
}

#tabMesFiches .ipc-list {
  gap: 10px;
}

#tabMesFiches .ipc-item {
  padding: 13px 14px;
}

#tabMesFiches .ipc-scope-info.hidden,
#tabMesFiches #blocFiltreMagasin.hidden,
#tabMesFiches #blocFiltreVendeur.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .ipc-filters-bar {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}
