/* CRM Original Marrakech — Stylesheet v1.0 */
:root {
  --primary:       #C4602A;
  --primary-dark:  #a04e22;
  --primary-light: #f5e8de;
  --accent:        #c8a94b;
  --bg:            #f7f3ee;
  --surface:       #ffffff;
  --text:          #1a0e05;
  --text-muted:    #7a6355;
  --border:        #e0d4c5;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 2px 16px rgba(50,20,0,.09);
  --shadow-md:     0 4px 24px rgba(50,20,0,.13);
  --sidebar-w:     240px;
  --header-h:      60px;

  /* Type */
  --atelier:    #7a4000;
  --atelier-bg: #fde8d0;
  --b2c:        #1a6bb5;
  --b2c-bg:     #ddeeff;
  --b2b:        #6a1b9a;
  --b2b-bg:     #ede0ff;

  /* Statut */
  --actif:      #1a6b3a;
  --actif-bg:   #dcf0e6;
  --inactif:    #888;
  --inactif-bg: #eee;
  --prospect:   #a06000;
  --prospect-bg:#fff0cc;
  --vip:        #8B0000;
  --vip-bg:     #ffe0e0;
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
textarea { resize: vertical; }
input, select, textarea, button { font: inherit; }

/* ─── Layout ───────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
  padding-bottom: 5rem; /* space for mobile bottom nav */
}

/* ─── Sidebar ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .3rem;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  font-weight: 800;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -.5px;
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

.sidebar-brand {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 500;
  padding-left: 2px;
}

.nav-list {
  list-style: none;
  padding: .75rem .6rem;
  flex: 1;
}

.nav-list li { margin-bottom: 2px; }

.nav-list a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}

.nav-list a:hover { background: var(--primary-light); color: var(--primary); }
.nav-list a.active { background: var(--primary); color: #fff; }
.nav-list a.active .nav-icon { stroke: #fff; }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: .85rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.sidebar-user { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }

.logout-btn {
  color: var(--text-muted);
  display: flex;
  padding: .35rem;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.logout-btn:hover { background: var(--primary-light); color: var(--primary); text-decoration: none; }

/* ─── Page header ───────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: .75rem;
  flex-wrap: wrap;
}

.page-header-left { display: flex; align-items: center; gap: .75rem; }

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.back-btn {
  color: var(--text-muted);
  display: flex;
  padding: .4rem;
  border-radius: 8px;
  transition: background .15s;
}
.back-btn:hover { background: var(--border); text-decoration: none; }

.count-badge {
  background: var(--border);
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 600;
  padding: .15rem .55rem;
  border-radius: 99px;
}

/* ─── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-secondary { background: var(--primary-light); color: var(--primary); }
.btn-secondary:hover { background: #edd8c6; text-decoration: none; }

.btn-danger  { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #a93226; text-decoration: none; color: #fff; }

.btn-ghost   { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; }

.btn-block   { width: 100%; justify-content: center; }
.btn-lg      { padding: .7rem 1.5rem; font-size: .95rem; }

/* ─── Alerts ────────────────────────────────── */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-success { background: var(--actif-bg); color: var(--actif); border: 1px solid #a8d8bc; }
.alert-danger  { background: var(--vip-bg);   color: var(--vip);   border: 1px solid #f5b8b8; }

/* ─── Badges ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-lg { font-size: .78rem; padding: .2rem .7rem; }

.badge-atelier { background: var(--atelier-bg); color: var(--atelier); }
.badge-b2c     { background: var(--b2c-bg);     color: var(--b2c); }
.badge-b2b     { background: var(--b2b-bg);     color: var(--b2b); }
.badge-actif   { background: var(--actif-bg);   color: var(--actif); }
.badge-inactif { background: var(--inactif-bg); color: var(--inactif); }
.badge-prospect{ background: var(--prospect-bg);color: var(--prospect); }
.badge-vip     { background: var(--vip-bg);     color: var(--vip); }

/* ─── Search & Filters ──────────────────────── */
.quick-search-bar { margin-bottom: 1.5rem; }

.filter-bar {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: .9rem;
  color: var(--text-muted);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

.search-input {
  width: 100%;
  padding: .7rem .9rem .7rem 2.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196,96,42,.12);
}

.search-clear {
  position: absolute;
  right: .9rem;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  text-decoration: none;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

.chip {
  padding: .3rem .75rem;
  border-radius: 99px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover    { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.active   { background: var(--primary); border-color: var(--primary); color: #fff; }

.chip-atelier.active { background: var(--atelier); border-color: var(--atelier); }
.chip-b2c.active     { background: var(--b2c);     border-color: var(--b2c); }
.chip-b2b.active     { background: var(--b2b);     border-color: var(--b2b); }

.filter-sort {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.filter-sort select {
  padding: .3rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
}

/* ─── Client List ───────────────────────────── */
.client-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.client-row {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  cursor: pointer;
}

.client-row:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  text-decoration: none;
  transform: translateY(-1px);
}

.client-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.client-avatar.atelier { background: var(--atelier-bg); color: var(--atelier); }
.client-avatar.b2c     { background: var(--b2c-bg);     color: var(--b2c); }
.client-avatar.b2b     { background: var(--b2b-bg);     color: var(--b2b); }

.client-info { flex: 1; min-width: 0; }
.client-name { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-meta { font-size: .8rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 0 .5rem; margin-top: .1rem; }
.client-meta span::after { content: '·'; margin-left: .5rem; }
.client-meta span:last-child::after { content: ''; }

.client-badges { display: flex; gap: .35rem; flex-shrink: 0; align-items: center; flex-wrap: wrap; }

.row-chevron { color: var(--border); flex-shrink: 0; width: 16px; height: 16px; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ─── Pagination ────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.page-btn {
  padding: .5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: .85rem;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.page-info { font-size: .85rem; color: var(--text-muted); }

/* ─── Dashboard ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .75rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
  display: block;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); text-decoration: none; }

.stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; font-weight: 500; }

.stat-total   { border-left: 3px solid var(--primary); }
.stat-total .stat-value { color: var(--primary); }
.stat-atelier { border-left: 3px solid var(--atelier); }
.stat-atelier .stat-value { color: var(--atelier); }
.stat-b2c     { border-left: 3px solid var(--b2c); }
.stat-b2c .stat-value { color: var(--b2c); }
.stat-b2b     { border-left: 3px solid var(--b2b); }
.stat-b2b .stat-value { color: var(--b2b); }
.stat-prospect{ border-left: 3px solid var(--prospect); }
.stat-prospect .stat-value { color: var(--prospect); }
.stat-vip     { border-left: 3px solid var(--vip); }
.stat-vip .stat-value { color: var(--vip); }

.section { margin-top: 1.5rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.section-title  { font-size: 1.05rem; font-weight: 700; }
.section-link   { font-size: .85rem; color: var(--primary); text-decoration: none; }
.section-link:hover { text-decoration: underline; }

/* ─── Forms ─────────────────────────────────── */
.client-form { max-width: 780px; display: flex; flex-direction: column; gap: 1rem; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.form-section-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
  margin-bottom: .85rem;
}

.form-row:last-child { margin-bottom: 0; }

.form-group { display: flex; flex-direction: column; gap: .35rem; }

.form-group label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.required { color: var(--primary); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: .6rem .85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196,96,42,.1);
}

.form-group textarea { min-height: 100px; }

.checkbox-label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .9rem !important;
  color: var(--text) !important;
  font-weight: 500 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.input-eye { position: relative; }
.input-eye input { width: 100%; padding-right: 3rem; }
.eye-btn {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: .2rem;
}

.hidden { display: none !important; }

/* Type selector */
.type-selector { display: flex; gap: .5rem; flex-wrap: wrap; }
.type-option {
  padding: .5rem 1.1rem;
  border: 2px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  transition: all .15s;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.type-option input[type="radio"] { display: none; }
.type-option:hover { border-color: var(--primary); color: var(--primary); }
.type-option-atelier.selected { background: var(--atelier-bg); border-color: var(--atelier); color: var(--atelier); }
.type-option-b2c.selected     { background: var(--b2c-bg);     border-color: var(--b2c);     color: var(--b2c); }
.type-option-b2b.selected     { background: var(--b2b-bg);     border-color: var(--b2b);     color: var(--b2b); }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding-top: .5rem;
}

/* ─── Client view ───────────────────────────── */
.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.atelier-bg { background: var(--atelier-bg); color: var(--atelier); }
.b2c-bg     { background: var(--b2c-bg);     color: var(--b2c); }
.b2b-bg     { background: var(--b2b-bg);     color: var(--b2b); }

.profile-meta { flex: 1; min-width: 0; }
.profile-badges { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.profile-company { font-size: .9rem; color: var(--text-muted); margin-bottom: .75rem; }

.profile-quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .82rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.quick-action-btn:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); text-decoration: none; }
.quick-action-btn.whatsapp { color: #25d366; }
.quick-action-btn.whatsapp:hover { background: #e6fff2; border-color: #25d366; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem;
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
}

.detail-card-full { grid-column: 1 / -1; }

.detail-card-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .85rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--border);
}

.field-row { display: flex; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--bg); flex-wrap: wrap; }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; min-width: 120px; flex-shrink: 0; padding-top: .05rem; }
.field-value { font-size: .88rem; word-break: break-word; }

.notes-text { font-size: .9rem; line-height: 1.6; white-space: pre-wrap; }

/* ─── Modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: .75rem; }
.modal-body  { font-size: .9rem; color: var(--text-muted); margin-bottom: 1.5rem; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; }

/* ─── Login ─────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2c1810 0%, #C4602A 60%, #c8a94b 100%);
  padding: 1rem;
}

.login-container {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 2.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-header { text-align: center; margin-bottom: 1.75rem; }

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: #fff;
  border-radius: 16px;
  font-weight: 900;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  letter-spacing: -1px;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

.login-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

.login-form { display: flex; flex-direction: column; gap: 1rem; }

.login-footer {
  text-align: center;
  margin-top: 1.25rem;
  font-size: .75rem;
  color: rgba(255,255,255,.5);
}

/* ─── Mobile ────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 200;
    transition: left .25s ease;
    height: 100vh;
    width: var(--sidebar-w);
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { left: 0; }

  .mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 150;
  }
  .mobile-overlay.active { display: block; }

  .main-content {
    padding: 1rem;
    padding-bottom: 5rem;
  }

  /* Bottom navigation bar */
  .app-layout::after {
    content: '';
    display: block;
    height: 60px;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .form-row { grid-template-columns: 1fr; }

  .detail-grid { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }

  .client-badges { flex-direction: column; gap: .25rem; }
}

/* Mobile bottom nav */
@media (max-width: 768px) {
  .bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    height: 60px;
    box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  }

  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    font-size: .65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    padding: .35rem;
    transition: color .15s;
  }

  .bottom-nav a svg { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a:hover { color: var(--primary); text-decoration: none; }
}

@media (min-width: 769px) { .bottom-nav { display: none; } }

/* ─── Tablet ────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── Large screen ──────────────────────────── */
@media (min-width: 1280px) {
  .main-content { padding: 2rem; }
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ─── Import IA ─────────────────────────────── */
.import-layout { display: flex; flex-direction: column; gap: 1rem; max-width: 780px; }
.import-form   { display: flex; flex-direction: column; gap: 1rem; }

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  pointer-events: none;
}
.upload-placeholder p { font-weight: 600; color: var(--text-muted); }
.upload-placeholder small { font-size: .75rem; color: var(--text-muted); }

.import-tips {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.import-tips h4 { font-size: .82rem; font-weight: 700; margin-bottom: .6rem; color: var(--text); }
.import-tips ul { padding-left: 1.2rem; line-height: 1.8; }

/* Review step */
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.review-confidence { display: flex; align-items: center; gap: 1rem; }
.confidence-label  { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.confidence-desc   { font-size: .88rem; font-weight: 600; margin-top: .15rem; }
.review-actions-top { display: flex; gap: .5rem; }

.source-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.source-preview summary {
  padding: .75rem 1rem;
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.source-preview summary:hover { background: var(--bg); }
.source-text {
  padding: .75rem 1rem 1rem;
  font-size: .82rem;
  white-space: pre-wrap;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
}

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; transform-origin: center; }

/* ─── Settings ──────────────────────────────── */
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ─── Client Tabs ────────────────────────────── */
.client-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.client-tabs::-webkit-scrollbar { display: none; }
.client-tab {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .65rem 1.1rem;
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.client-tab:hover { color: var(--primary); }
.client-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
}
.client-tab:not(.active) .tab-count {
  background: var(--border);
  color: var(--text-muted);
}

/* ─── Documents ──────────────────────────────── */
.doc-section { margin-bottom: 2rem; }
.doc-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: .6rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
}
.doc-list { display: flex; flex-direction: column; gap: .5rem; }
.doc-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .7rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.doc-item:hover {
  border-color: var(--primary-light, #e8c9b5);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.doc-thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.doc-icon {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
}
.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.doc-name:hover { color: var(--primary); }
.doc-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .15rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.doc-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.doc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.doc-btn:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }
.doc-btn.delete-btn:hover { color: var(--danger, #e55); border-color: var(--danger, #e55); }

/* Doc type badges */
.badge-doc {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-doc-facture      { background: #e8f4fd; color: #1a73c6; }
.badge-doc-devis        { background: #fef3e2; color: #b45309; }
.badge-doc-bon_commande { background: #f3e8fd; color: #7c3aed; }
.badge-doc-etiquette    { background: #e8fdf4; color: #0f7e54; }
.badge-doc-photo        { background: #fde8f4; color: #9d174d; }
.badge-doc-autre        { background: var(--bg); color: var(--text-muted); }

/* Upload modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg, 12px);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  position: relative;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  color: var(--text);
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: .2rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.upload-zone.drag-over {
  border-color: var(--primary);
  background: #fef7f2;
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone-icon { font-size: 2rem; margin-bottom: .5rem; }
.upload-zone-text { font-size: .85rem; color: var(--text-muted); }
.upload-zone-text strong { color: var(--primary); }
.upload-filename {
  margin-top: .5rem;
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
  display: none;
}

/* ─── Orders ─────────────────────────────────── */
.order-summary {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.order-summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1.2rem;
  min-width: 100px;
  gap: .2rem;
}
.order-summary-val {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}
.order-summary-lbl {
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.order-list { display: flex; flex-direction: column; gap: .85rem; }
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.order-card:hover {
  border-color: var(--primary-light, #e8c9b5);
  box-shadow: 0 3px 12px rgba(0,0,0,.07);
}
.order-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1rem .6rem;
  gap: .75rem;
  flex-wrap: wrap;
}
.order-ref-group { display: flex; align-items: baseline; gap: .65rem; }
.order-ref {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', monospace;
}
.order-date { font-size: .78rem; color: var(--text-muted); }
.order-badges { display: flex; gap: .4rem; flex-wrap: wrap; }
.order-products {
  padding: 0 1rem .6rem;
  font-size: .84rem;
  color: var(--text-muted);
  white-space: pre-line;
}
.order-amount {
  padding: 0 1rem .7rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}
.order-notes {
  padding: .5rem 1rem .7rem;
  font-size: .82rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  line-height: 1.55;
}
.order-card-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* Payment badges */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .6rem; border-radius: 20px; font-size: .73rem; font-weight: 600; }
.badge-pay-paye    { background: #e6faf0; color: #0d7a47; }
.badge-pay-partiel { background: #fff4e5; color: #b45309; }
.badge-pay-attente { background: #f1f3f5; color: #6c757d; }

/* Production badges */
.badge-prod-en_cours { background: #e8f0fe; color: #1a6adc; }
.badge-prod-termine  { background: #e6faf0; color: #0d7a47; }
.badge-prod-expedie  { background: #f3e8fd; color: #7c3aed; }

/* ─── Tracking rows (suivi commercial) ───────── */
.tracking-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.tracking-row:last-child { border-bottom: none; }
.tracking-label {
  flex: 1;
  font-size: .88rem;
  color: var(--text);
}
.tracking-date-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.tracking-date-wrap input[type="date"] {
  padding: .25rem .5rem;
  font-size: .82rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

/* ─── Devis form ─────────────────────────────── */
.devis-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.devis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
.devis-table thead th {
  background: var(--bg);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .5rem .55rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.devis-table tbody tr { border-bottom: 1px solid var(--border); }
.devis-table tbody tr:last-child { border-bottom: none; }
.devis-table td {
  padding: .3rem .35rem;
  vertical-align: top;
}
.devis-table td input[type="text"],
.devis-table td input[type="number"],
.devis-table td textarea {
  width: 100%;
  padding: .35rem .45rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: .83rem;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  font-family: inherit;
}
.devis-table td input:focus,
.devis-table td textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(196,96,42,.12);
}
.devis-table td.total-cell {
  text-align: right;
  padding: .5rem .55rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  vertical-align: middle;
}
.remove-row-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .85rem;
  padding: .25rem .4rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
  vertical-align: middle;
}
.remove-row-btn:hover { color: var(--danger, #e55); background: #fff0f0; }

/* Totals box */
.devis-totals-box {
  min-width: 260px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-left: auto;
}
.devis-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3rem 0;
  font-size: .88rem;
  border-bottom: 1px dashed var(--border);
}
.devis-total-row:last-child { border-bottom: none; }
.devis-total-ttc {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-top: .35rem;
  padding-top: .45rem;
  border-top: 2px solid var(--primary) !important;
  border-bottom: none !important;
}


/* ═══════════════════════════════════════════════════════════════════════════
   P-374 — THÈME GLOBAL clair / sombre (déplacé de client_view.php / P-328)
   Le thème est posé sur <html data-theme="…"> par le script inline de head()
   (functions.php) AVANT le rendu de la page : pas de flash blanc. Défaut clair.
   La feuille n'exposait que --bg/--surface/--text/--text-muted/--border ; les
   blocs P-319/P-328 lisent en plus --bg-card/--text-primary… : les DEUX
   familles sont définies ici pour que toutes les pages suivent le thème.
   ═════════════════════════════════════════════════════════════════════════ */
html[data-theme="light"] {
  --bg-card:       #ffffff;
  --border-color:  #e0d4c5;
  --text-primary:  #1a0e05;
  --text-secondary:#7a6355;
  --bg-hover:      #faf7f2;
  --color-surface: #ffffff;
  --color-border:  #e8ded1;
  --color-primary: #c4602a;
  --p328-soft:     #faf7f2;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg:            #14120f;
  --surface:       #1e1b17;
  --text:          #f1ebe3;
  --text-muted:    #a2968a;
  --border:        #332e28;
  --primary-light: #3a2a1d;
  --shadow:        0 2px 16px rgba(0,0,0,.45);
  --shadow-md:     0 4px 24px rgba(0,0,0,.55);
  --bg-card:       #1e1b17;
  --border-color:  #332e28;
  --text-primary:  #f1ebe3;
  --text-secondary:#a2968a;
  --bg-hover:      #262119;
  --bg-secondary:  #242019;
  --color-surface: #1e1b17;
  --color-border:  #332e28;
  --color-primary: #d97b45;
  --p328-soft:     #242019;
  color-scheme: dark;
}

/* ── Rattrapage sombre des styles en dur : le CRM compte des centaines
      d'attributs style="" écrits en clair. On neutralise les fonds et les
      textes les plus courants plutôt que de réécrire chaque page. ─────────── */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#FFF"],
html[data-theme="dark"] [style*="background:#f9f9f9"],
html[data-theme="dark"] [style*="background: #f9f9f9"],
html[data-theme="dark"] [style*="background:#f9f8f7"],
html[data-theme="dark"] [style*="background:#faf9f7"],
html[data-theme="dark"] [style*="background:#faf7f2"],
html[data-theme="dark"] [style*="background:#f5f5f5"],
html[data-theme="dark"] [style*="background: #f5f5f5"],
html[data-theme="dark"] [style*="background:#fafafa"],
html[data-theme="dark"] [style*="background:#f0f0f0"],
html[data-theme="dark"] [style*="background:#f0f0f3"],
html[data-theme="dark"] [style*="background:#f7f7f7"],
html[data-theme="dark"] [style*="background:#f8f8f8"],
html[data-theme="dark"] [style*="background:#eee"],
html[data-theme="dark"] [style*="background:#e8e8e8"],
html[data-theme="dark"] [style*="background:#f0ece6"],
html[data-theme="dark"] [style*="background:#f9f7f5"],
html[data-theme="dark"] [style*="background:#fff8f5"],
html[data-theme="dark"] [style*="background:#f7f3ee"],
html[data-theme="dark"] [style*="background:#fdfdfd"],
html[data-theme="dark"] [style*="background:#f6f6f6"],
html[data-theme="dark"] [style*="background:#e8e0d5"],
html[data-theme="dark"] [style*="background:#e0e0e0"],
html[data-theme="dark"] [style*="background: #e0e0e0"],
html[data-theme="dark"] [style*="background:#e5e5e5"],
html[data-theme="dark"] [style*="background:#d0d0d0"],
html[data-theme="dark"] [style*="background:#ddd"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"],
html[data-theme="dark"] [style*="background:#f0ede8"] { background-color: var(--p328-soft) !important; }
html[data-theme="dark"] .form-card { background-color: var(--p328-soft) !important; }

html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color: #333"],
html[data-theme="dark"] [style*="color:#1c1a17"],
html[data-theme="dark"] [style*="color:#1a0e05"] { color: var(--text-primary) !important; }
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#666"],
html[data-theme="dark"] [style*="color: #666"],
html[data-theme="dark"] [style*="color:#777"],
html[data-theme="dark"] [style*="color:#888"],
html[data-theme="dark"] [style*="color:#999"],
html[data-theme="dark"] [style*="color:#bbb"],
html[data-theme="dark"] [style*="color:#ccc"],
html[data-theme="dark"] [style*="color:#6b6460"] { color: var(--text-muted) !important; }

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background-color: #26221c; color: var(--text-primary); border-color: #3a342c;
}
html[data-theme="dark"] code { background: #2a251e !important; }
html[data-theme="dark"] hr { border-color: var(--border); }
html[data-theme="dark"] table th { background-color: var(--p328-soft); }

/* ── Interrupteur global, dans l'en-tête du menu à côté de « CRM » ────────── */
.sidebar-header .sidebar-logo { display: flex; align-items: center; gap: .6rem; }
.om-theme-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  width: 30px; height: 30px;
  line-height: 1;
  font-size: .95rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.om-theme-btn:hover { border-color: var(--primary); }

/* [P-374-B] Les navigateurs imposent un fond blanc aux champs de recherche via
   leur feuille par defaut : le texte clair devenait invisible en mode sombre.
   Cible uniquement search/date : un appearance:none global casserait les cases
   a cocher, les boutons radio et la fleche des listes deroulantes. */
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  background-color: #26221c;
  color: var(--text-primary);
  border: 1px solid #3a342c;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #8a8078; }
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator { filter: invert(.75); }
