:root {
  --brown-dark: #4e2a10;
  --brown-mid: #6d3d19;
  --orange-brand: #e8631a;
  --orange-warm: #d18a36;
  --cream-bg: #fbf6f0;
  --surface: #ffffff;
  --border: #e5d5c5;
  --text-main: #2d1a0c;
  --text-muted: #735c49;
  --danger: #c93b3b;
  --success: #24825c;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--cream-bg);
  color: var(--text-main);
  font-size: 16px;
}

.hidden { display: none !important; }
.mt-1 { margin-top: 1rem; }
.muted { color: var(--text-muted); font-size: 0.92rem; }

/* Logos sans déformation */
.brand-logo-large {
  max-width: 280px;
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.5rem;
}
.brand-logo-nav {
  height: 46px;
  width: auto;
  object-fit: contain;
  display: block;
}

/* Écran de connexion */
.login-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(145deg, #f7ede2 0%, #efe0cf 100%);
}

.login-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 2rem 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 12px 30px rgba(78, 42, 16, 0.12);
  text-align: center;
}

.subtitle { color: var(--brown-mid); font-weight: 600; margin-bottom: 1.25rem; }

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.emp-choice-btn {
  min-height: 56px;
  border-radius: 12px;
  border: 2px solid transparent;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  padding: 0.5rem;
}
.emp-choice-btn.selected {
  outline: 3px solid var(--brown-dark);
  transform: scale(1.03);
}

.pin-box input {
  width: 100%;
  font-size: 1.4rem;
  text-align: center;
  letter-spacing: 0.35rem;
  padding: 0.75rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.pin-keypad button {
  min-height: 54px;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fdf9f4;
  color: var(--brown-dark);
  cursor: pointer;
}

.error-msg { color: var(--danger); font-weight: 600; min-height: 1.25rem; }

/* Navigation */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0.6rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand { cursor: pointer; }
.main-nav { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.nav-btn {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--brown-dark);
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
}
.nav-btn.active {
  background: var(--brown-dark);
  color: #fff;
}

.active-user-box { display: flex; align-items: center; gap: 0.5rem; }
.user-badge {
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
}

/* Conteneur & Cartes */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 3px 10px rgba(78, 42, 16, 0.04);
}

.hero-search-card {
  background: linear-gradient(135deg, var(--brown-dark) 0%, var(--brown-mid) 100%);
  color: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.hero-search-card h1 { margin-top: 0; font-size: 1.5rem; }

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

input[type="text"], input[type="search"], input[type="tel"], input[type="password"] {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  width: 100%;
}
.input-xl { flex: 1; min-width: 240px; font-size: 1.15rem !important; min-height: 54px; }
.input-lg { font-size: 1.08rem !important; min-height: 50px; }

/* Boutons tactiles */
button, .file-label {
  min-height: 46px;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-primary { background: var(--orange-brand); color: #fff; }
.btn-secondary { background: var(--brown-mid); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border: 2px solid var(--border); color: var(--brown-dark); }
.btn-xl { min-height: 54px; font-size: 1.08rem; padding: 0.75rem 1.4rem; }
.btn-lg { min-height: 50px; }
.btn-sm { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.88rem; }

.btn-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn-stack { display: flex; flex-direction: column; gap: 0.6rem; }

/* Statistiques */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}
.stat-value { display: block; font-size: 1.85rem; font-weight: 800; color: var(--orange-brand); }
.stat-label { font-size: 0.9rem; color: var(--text-muted); font-weight: 600; }

/* Listes & Lignes clients */
.list-stack { display: flex; flex-direction: column; gap: 0.55rem; }

.client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffcf9;
  cursor: pointer;
  min-height: 58px;
}
.client-row:hover { border-color: var(--orange-brand); background: #fff6ed; }
.hero-search-card .client-row { color: var(--text-main); margin-top: 0.5rem; }

.badge-stamps {
  background: var(--brown-dark);
  color: #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
}
.badge-stamps.complete { background: var(--success); }

/* Grille carte 11 cases */
.section-header, .client-header-card, .card-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.counter-pill {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--brown-dark);
  background: #f5e8da;
  padding: 0.5rem 1.1rem;
  border-radius: 12px;
}

.loyalty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.85rem;
  margin: 1.25rem 0;
}

.stamp-slot {
  min-height: 105px;
  border-radius: 14px;
  border: 2px dashed #cbb39c;
  background: #fdf9f4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease;
}
.stamp-slot:active { transform: scale(0.97); }
.stamp-slot.filled {
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.15);
  color: #fff;
}
.stamp-slot.slot-reward {
  border-color: var(--orange-brand);
}
.slot-num { font-size: 1.5rem; font-weight: 800; }
.slot-meta { font-size: 0.78rem; margin-top: 0.25rem; line-height: 1.2; }

.reward-ready-banner {
  background: #e7f6ef;
  border: 2px solid var(--success);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

/* Historique & Admin */
.log-row {
  padding: 0.7rem 0.9rem;
  border-left: 5px solid var(--brown-mid);
  background: #faf5ef;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.92rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 56px 130px auto;
  gap: 0.5rem;
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1rem;
}

/* Modale */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(34, 18, 7, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}
.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
}

/* Justificatif imprimable */
.receipt-box {
  border: 2px dashed var(--brown-dark);
  padding: 1.25rem;
  border-radius: 10px;
  background: #fff;
  text-align: center;
}
.receipt-mention {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brown-dark);
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  padding: 0.65rem 0;
  margin: 0.85rem 0;
}

.print-only { display: none; }

@media print {
  body * { visibility: hidden; }
  #print-receipt-area, #print-receipt-area * { visibility: visible; }
  #print-receipt-area {
    display: block !important;
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    padding: 1rem;
  }
}