/* ============================================================
   KASS MANAGER — Design System
   Graphite profond + vert signature, précision d'atelier Apple
   ============================================================ */

:root {
  --ink: #1c1725;          /* anthracite HK (sidebar, titres) */
  --ink-soft: #2a2333;
  --surface: #f4f5f7;      /* fond général */
  --card: #ffffff;
  --line: #e4e7ec;
  --text: #1c2128;
  --text-soft: #6b7280;
  --accent: #c1121f;       /* rouge carmin HK */
  --accent-strong: #a10e19;
  --accent-soft: #fbe9eb;
  --amber: #b45309;
  --amber-soft: #fef3e2;
  --red: #b91c1c;
  --red-soft: #fdeaea;
  --blue: #1d4ed8;
  --blue-soft: #e8eefc;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(23, 27, 33, 0.06), 0 8px 24px rgba(23, 27, 33, 0.05);
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  font-size: 15px;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

/* ============ ÉCRAN DE CONNEXION ============ */

#screen-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(14, 140, 109, 0.25), transparent 60%),
    var(--ink);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 20px;
  padding: 40px 36px 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.5px;
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2.5px solid var(--card);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
  color: var(--ink);
  line-height: 1.1;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--text-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.login-card .subtitle {
  color: var(--text-soft);
  font-size: 13.5px;
  margin-bottom: 26px;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #fbfbfc;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 140, 109, 0.15);
  background: #fff;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s;
  margin-top: 6px;
}

.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }

.login-error {
  display: none;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.login-footer {
  margin-top: 22px;
  display: flex;
  justify-content: center;
}

/* ============ SÉLECTEUR DE LANGUE ============ */

.lang-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  border: none;
  background: transparent;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  transition: all 0.15s;
}

.lang-btn.active {
  background: var(--ink);
  color: #fff;
}

/* ============ APPLICATION (après connexion) ============ */

#screen-app { display: none; min-height: 100vh; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* --- Sidebar --- */

.sidebar {
  background: var(--ink);
  color: #cfd4dc;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { margin-bottom: 30px; padding: 0 8px; }
.sidebar .brand-name { color: #fff; font-size: 16px; }
.sidebar .brand-sub { color: #8b93a1; }
.sidebar .brand-mark { background: rgba(255,255,255,0.08); }
.sidebar .brand-mark::after { border-color: var(--ink); }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #b9c0cb;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }

.nav-item.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

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

.sidebar-user {
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  padding-top: 16px;
  margin-top: 16px;
}

.user-line {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 12px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.user-name { font-size: 13.5px; font-weight: 600; color: #fff; }
.user-role { font-size: 11.5px; color: #8b93a1; }

.btn-logout {
  width: 100%;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: #cfd4dc;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.btn-logout:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* --- Contenu principal --- */

.main { padding: 30px 36px; max-width: 1560px; margin: 0 auto; width: 100%; }

.main-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.main-header h2 {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.main-header .date-line {
  color: var(--text-soft);
  font-size: 13.5px;
  margin-top: 4px;
}

/* --- Cartes de statistiques --- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--ink);
  line-height: 1;
}

.stat-value small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0;
}

.stat-card.tone-green .stat-value { color: var(--accent-strong); }
.stat-card.tone-amber .stat-value { color: var(--amber); }

.stat-chip {
  display: inline-block;
  margin-top: 10px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.chip-green { background: var(--accent-soft); color: var(--accent-strong); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-grey { background: var(--surface); color: var(--text-soft); }

/* --- Panneau "module à venir" --- */

.placeholder {
  background: var(--card);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
  color: var(--text-soft);
}

.placeholder h3 {
  font-family: var(--font-display);
  color: var(--ink);
  font-size: 19px;
  margin-bottom: 8px;
}

/* --- Toast d'erreur globale --- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: none;
  max-width: 90vw;
  z-index: 100;
}

/* ============ RESPONSIVE (smartphone) ============ */

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    z-index: 50;
    gap: 4px;
  }

  .sidebar .brand, .sidebar-user { display: none; }

  .nav {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
  }

  .nav-item {
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    padding: 8px 6px;
    text-align: center;
    align-items: center;
  }

  .nav-item span.label { font-size: 10px; }

  .main { padding: 20px 16px 110px; }
  .main-header h2 { font-size: 21px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ============================================================
   MODULE CLIENTS & RÉPARATIONS
   ============================================================ */

/* --- Barre d'outils (recherche + bouton) --- */

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: var(--card);
}

.toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 140, 109, 0.12);
}

.btn-action {
  padding: 10px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.btn-action:hover { background: var(--accent-strong); }

.btn-secondary {
  padding: 10px 16px;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.btn-secondary:hover { border-color: var(--ink); }

/* --- Filtres par statut --- */

.chips {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chip-filter {
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 999px;
  transition: all 0.15s;
}

.chip-filter.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* --- Tableaux --- */

.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data tr:last-child td { border-bottom: none; }

table.data tbody tr { cursor: pointer; transition: background 0.1s; }
table.data tbody tr:hover { background: #f7faf9; }

.cell-strong { font-weight: 600; color: var(--ink); }
.cell-soft { color: var(--text-soft); font-size: 13px; }

.mono {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.empty-state {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
}

/* --- Badges de statut --- */

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-recu          { background: #eef1f5; color: #4b5563; }
.badge-diagnostic    { background: var(--blue-soft); color: var(--blue); }
.badge-devis_envoye  { background: #f3e8ff; color: #7e22ce; }
.badge-en_attente    { background: var(--amber-soft); color: var(--amber); }
.badge-en_reparation { background: #e0f2fe; color: #0369a1; }
.badge-pret          { background: var(--accent-soft); color: var(--accent-strong); }
.badge-livre         { background: #e5e7eb; color: #374151; }
.badge-annule        { background: var(--red-soft); color: var(--red); }

/* --- Modales --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 27, 33, 0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  z-index: 200;
  overflow-y: auto;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  margin: auto 0;
}

.modal h3 {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.3px;
  margin-bottom: 20px;
  color: var(--ink);
}

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

.form-grid .full { grid-column: 1 / -1; }

.form-grid label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--ink-soft);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfbfc;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14, 140, 109, 0.12);
  background: #fff;
}

.form-grid textarea { resize: vertical; min-height: 64px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.form-error {
  display: none;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  padding: 9px 13px;
  border-radius: 9px;
  margin-top: 14px;
}

.form-section-title {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}

/* --- Détail réparation --- */

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

.detail-sub {
  color: var(--text-soft);
  font-size: 13px;
  margin-bottom: 18px;
}

.tracking-box {
  background: var(--ink);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.tracking-box .code {
  font-family: "SF Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #7fe0c3;
}

.tracking-box .lbl { font-size: 11.5px; color: #9aa3b0; text-transform: uppercase; letter-spacing: 0.06em; }

.next-status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 14px 0 6px;
}

.btn-status {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 700;
}

.btn-status:hover { border-color: var(--accent); color: var(--accent-strong); }

.btn-whatsapp {
  width: 100%;
  padding: 12px;
  background: #22a35b;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 16px;
}

.btn-whatsapp:hover { background: #1b8a4c; }

.timeline { margin-top: 16px; border-left: 2px solid var(--line); padding-left: 16px; }

.timeline-item { position: relative; padding-bottom: 12px; font-size: 13px; }

.timeline-item::before {
  content: "";
  position: absolute;
  left: -21.5px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-item .tl-date { color: var(--text-soft); font-size: 12px; }

/* --- Tableaux responsives (mobile : cartes) --- */

@media (max-width: 820px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { border-bottom: 1px solid var(--line); padding: 10px 14px; }
  table.data td { border: none; padding: 3px 0; }
  .modal { padding: 22px 18px; }
  .form-grid { grid-template-columns: 1fr; }
}


/* ============================================================
   THÈME HK — Anthracite, Rouge carmin & Or (couleurs du logo)
   ============================================================ */

:root {
  --ink: #1c1725;            /* anthracite profond du logo */
  --ink-soft: #2a2333;
  --accent: #c1121f;         /* rouge carmin du logo */
  --accent-strong: #a10e19;
  --accent-soft: #fbe9eb;
  --gold: #f4b942;           /* or du logo (le comptoir) */
  --green: #0e8c6d;          /* vert conservé pour les statuts positifs */
  --green-strong: #0b7159;
  --green-soft: #e3f4ee;
}

/* Connexion : halo rouge et pointe d'or sur fond anthracite */
#screen-login {
  background:
    radial-gradient(1100px 560px at 82% -12%, rgba(255,77,90,0.28), transparent 60%),
    radial-gradient(700px 380px at -6% 108%, rgba(244,185,66,0.16), transparent 60%),
    var(--ink);
}

/* Texte blanc sur les boutons rouges (lisibilité) */
.btn-primary, .btn-action { color: #ffffff; font-weight: 700; }
.nav-item.active { color: #ffffff; }
.user-avatar { color: #ffffff; }

/* Focus des champs en rouge */
.field input:focus,
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus,
.toolbar input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(193,18,31,0.20);
}

/* Logo dans la pastille de marque */
.brand-mark { background: #fff; overflow: hidden; }
.brand-mark img { width: 86%; height: auto; display: block; }
.brand-mark::after { display: none; }

/* Statuts positifs : le vert reste vert (lisibilité universelle) */
.badge-pret { background: var(--green-soft); color: var(--green-strong); }
.stat-card.tone-green .stat-value { color: var(--green-strong); }

/* Code de suivi en or dans l'encadré anthracite */
.tracking-box .code { color: var(--gold); }


/* ============================================================
   MODULE STATISTIQUES
   ============================================================ */

.stats-panneaux {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.stats-panneau {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stats-panneau.large { grid-column: 1 / -1; }

.stats-panneau h4 {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: -0.2px;
  color: var(--ink);
  margin-bottom: 4px;
}

.stats-sous {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 14px;
}

/* Barres verticales (CA mensuel) */
.vbar-chart {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 170px;
}

.vbar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.vbar-valeur {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-soft);
  height: 14px;
  white-space: nowrap;
}

.vbar-piste {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.vbar-barre {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  border-radius: 5px 5px 0 0;
  min-height: 0;
}

.vbar-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-soft);
  margin-top: 5px;
  text-transform: capitalize;
}

/* Barres horizontales */
.hbar-ligne { margin-bottom: 11px; }

.hbar-tete {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 4px;
}

.hbar-label { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-valeur { color: var(--text-soft); white-space: nowrap; font-weight: 600; }

.hbar-piste {
  height: 9px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}

.hbar-barre {
  height: 100%;
  background: linear-gradient(90deg, var(--ink), #2e4270);
  border-radius: 999px;
}


/* ============================================================
   NAVIGATION MOBILE & TABLETTE — Barre en haut + menu déroulant
   ============================================================ */

.topbar { display: none; }
.nav-backdrop { display: none; }

@media (max-width: 1024px) {

  /* --- Barre du haut --- */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 58px;
    background: var(--ink);
    padding: 0 14px;
    z-index: 60;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  }

  .topbar .brand-mark { width: 36px; height: 36px; }
  .topbar .brand-name { color: #fff; font-size: 15px; }

  #btn-menu {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    border-radius: 10px;
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
  }

  #btn-menu:active { background: var(--accent); color: var(--ink); }

  /* --- Le menu devient un panneau déroulant sous la barre --- */
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 58px;
    bottom: auto;
    left: 0; right: 0;
    height: auto;
    max-height: calc(100vh - 58px);
    overflow-y: auto;
    flex-direction: column;
    padding: 14px;
    z-index: 55;
    transform: translateY(-110%);
    transition: transform 0.22s ease;
    box-shadow: 0 16px 40px rgba(0,0,0,0.35);
    border-radius: 0 0 18px 18px;
  }

  .sidebar.open { transform: translateY(0); }

  .sidebar .brand { display: none; }

  /* Noms complets, bien lisibles, les uns sous les autres */
  .nav {
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;
    flex: none;
  }

  .nav-item {
    flex-direction: row;
    align-items: center;
    gap: 13px;
    font-size: 15px;
    padding: 13px 14px;
    text-align: left;
  }

  .nav-item .icon { width: 21px; height: 21px; }
  .nav-item span.label { font-size: 15px; }

  /* Utilisateur + langue + déconnexion visibles dans le menu */
  .sidebar-user { display: block; }

  /* Fond assombri derrière le menu ouvert */
  .nav-backdrop.open {
    display: block;
    position: fixed;
    inset: 58px 0 0 0;
    background: rgba(20, 33, 61, 0.45);
    z-index: 50;
  }

  /* Le contenu commence sous la barre du haut */
  .main { padding: 76px 16px 30px; }
}


/* Barre du haut : bouton menu à gauche, marque centrée */
@media (max-width: 1024px) {
  .topbar-spacer { width: 42px; flex-shrink: 0; }
}


/* ============================================================
   ACCUEIL EN 3 ZONES : tâches / réparations récentes / client
   ============================================================ */

.dash-grid {
  display: grid;
  grid-template-columns: 300px 1fr 360px;
  gap: 16px;
  align-items: start;
}

.dash-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.dash-titre { font-size: 14.5px; margin-bottom: 12px; }

/* En-tête de panneau structuré */
.dash-titre {
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 14px;
}

/* Tâches rapides : tuiles encadrées sur 2 colonnes */
.dash-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.dash-tuile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 8px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.dash-tuile:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(20, 33, 61, 0.10);
}
.dash-tuile .tuile-icone { font-size: 26px; line-height: 1; }

/* Réparations récentes : chaque ligne dans son propre cadre */
.dash-rep-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  margin-bottom: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-rep-item:last-child { margin-bottom: 0; }
.dash-rep-item:hover {
  border-color: var(--accent);
  box-shadow: 0 3px 10px rgba(20, 33, 61, 0.08);
}
.dash-rep-infos { min-width: 0; }
.dash-rep-client { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-rep-appareil { font-size: 12px; color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   AJUSTEMENTS PLEIN ÉCRAN SMARTPHONE
   (hauteur réelle de l'écran, encoches, barres système)
   ============================================================ */

html, body { overflow-x: hidden; }

/* Hauteur dynamique : suit la vraie hauteur visible du navigateur
   mobile (barre d'adresse qui apparaît/disparaît) */
body { min-height: 100dvh; }
#screen-app { min-height: 100dvh; }
.layout { min-height: 100dvh; }

@media (min-width: 821px) {
  .sidebar { height: 100dvh; }
}

@media (max-width: 820px) {
  /* Zones sécurisées : encoche en haut, barre de gestes en bas */
  .sidebar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    padding-left: calc(10px + env(safe-area-inset-left));
    padding-right: calc(10px + env(safe-area-inset-right));
  }

  .main {
    padding: 18px 14px calc(104px + env(safe-area-inset-bottom));
    padding-left: calc(14px + env(safe-area-inset-left));
    padding-right: calc(14px + env(safe-area-inset-right));
  }

  /* Empêche le zoom automatique de l'iPhone à la saisie */
  input, select, textarea { font-size: 16px; }

  /* Les tableaux s'affichent en cartes empilées : les textes
     longs reviennent à la ligne au lieu de déborder du cadre */
  table.data td {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  /* Les modales tiennent dans l'écran, quel que soit le modèle */
  .modal {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    margin: calc(8px + env(safe-area-inset-top)) 10px calc(8px + env(safe-area-inset-bottom));
  }
}

/* Bandeau hors connexion : sous l'encoche des téléphones récents */
#bandeau-offline { padding-top: calc(8px + env(safe-area-inset-top)); }


/* ============================================================
   BOUTON D'ACTION FLOTTANT (smartphone)
   "Nouvelle inscription" devient un rond en bas à droite,
   au-dessus du menu de navigation, toujours visible.
   ============================================================ */

@media (max-width: 820px) {
  /* Tous les boutons d'ajout deviennent des boutons flottants :
     nouveau client, ticket, produit, vente, inscription,
     dépense, membre d'équipe */
  #btn-new-client,
  #btn-new-ticket,
  #btn-new-product,
  #btn-new-sale,
  #btn-new-inscription,
  #btn-new-depense,
  #btn-new-membre {
    position: fixed;
    right: 16px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 54; /* sous le menu déroulant, pour qu'il le recouvre */
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;              /* masque le libellé texte */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(20, 33, 61, 0.35);
  }

  #btn-new-client::before,
  #btn-new-ticket::before,
  #btn-new-product::before,
  #btn-new-sale::before,
  #btn-new-inscription::before,
  #btn-new-depense::before,
  #btn-new-membre::before {
    content: "＋";
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
  }

  #btn-new-client:active,
  #btn-new-ticket:active,
  #btn-new-product:active,
  #btn-new-sale:active,
  #btn-new-inscription:active,
  #btn-new-depense:active,
  #btn-new-membre:active {
    transform: scale(0.94);
  }
}

/* Le logo ramène à l'accueil : curseur main partout */
.topbar .brand, .sidebar .brand { cursor: pointer; }


/* Cartes du tableau de bord cliquables */
.stat-clic { cursor: pointer; transition: transform 0.1s, box-shadow 0.15s; }
.stat-clic:hover { transform: translateY(-2px); box-shadow: 0 5px 14px rgba(20, 33, 61, 0.12); }

/* Numéro dans les listes numérotées */
.ls-numero {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  border-radius: 50%;
  font-size: 13px; font-weight: 700;
}


/* Compteur affiché dans les puces de filtrage */
.chip-count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  margin-left: 4px;
  background: rgba(20, 33, 61, 0.12);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.chip-filter.active .chip-count { background: rgba(255, 255, 255, 0.25); }

/* Réparations en retard : surlignées en rouge pâle */
tr.ligne-retard { background: #fdecea !important; }
tr.ligne-retard:hover { background: #fbdcd8 !important; }


/* Tendance affichée sous les compteurs du tableau de bord */
.stat-tendance { margin-top: 6px; font-size: 12px; }


/* Statuts des commandes fournisseurs */
.badge-cmd-commandee { background: #e8eefb; color: #2b4a9b; }
.badge-cmd-en_transit { background: #fff3d6; color: #a06b00; }
.badge-cmd-recue { background: #e6f4ea; color: #1d8348; }

/* ============================================================
   BADGE D'ABONNEMENT (en haut à droite, toujours visible)
   ============================================================ */

.badge-abonnement {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 61;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .badge-abonnement { top: 13px; right: 12px; padding: 6px 12px; font-size: 12px; }
}

@media (max-width: 560px) {
  .badge-abonnement .lib { display: none; }
}
