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

:root {
  --bg:      #141414;
  --bg2:     #1e1e1e;
  --bg3:     #282828;
  --text:    #e0e0e0;
  --hint:    #616161;
  --accent:  #5b8dee;
  --border:  #2c2c2c;
  --radius:  6px;
  --danger:  #e05555;
  --warning: #d4863a;
  --success: #46b87d;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100dvh;
  padding-bottom: 64px;
}

/* ── Navigation bas ── */
.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  z-index: 100;
  height: 56px;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color .12s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .2px;
}

.nav-btn.active { color: var(--accent); }
.nav-btn svg { width: 18px; height: 18px; }

/* ── Sections ── */
.section { display: none; padding: 16px; }
.section.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

/* ── Titres ── */
h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: -.2px;
}

h3 {
  font-size: 10px;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

/* ── Formulaires ── */
.form-group { margin-bottom: 10px; }

label {
  display: block;
  font-size: 12px;
  color: var(--hint);
  margin-bottom: 5px;
  font-weight: 500;
  letter-spacing: .2px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg3);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .12s;
  -webkit-appearance: none;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) opacity(.3);
}
select option { background: var(--bg2); }

/* ── Boutons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .12s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: .1px;
}
.btn:active { opacity: .7; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
  border-color: var(--accent);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Stat card principale ── */
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  margin-bottom: 10px;
}
.stat-card .stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -1px;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--hint);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .8px;
}

/* ── Mini stat cards (historique) ── */
.mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.mini-stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  text-align: center;
}
.mini-stat .val {
  font-size: 17px;
  font-weight: 700;
  color: var(--accent);
}
.mini-stat .lbl {
  font-size: 9px;
  color: var(--hint);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 2px;
}

/* ── Liste produits dashboard ── */
.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.product-row:last-child { border-bottom: none; }
.product-row .name { font-weight: 600; font-size: 14px; }
.product-row .price { font-size: 12px; color: var(--hint); margin-top: 2px; }

.stock-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  background: rgba(70,184,125,.1);
  color: var(--success);
  border: 1px solid rgba(70,184,125,.25);
}
.stock-badge.warn {
  background: rgba(212,134,58,.1);
  color: var(--warning);
  border-color: rgba(212,134,58,.25);
}
.stock-badge.danger {
  background: rgba(224,85,85,.1);
  color: var(--danger);
  border-color: rgba(224,85,85,.25);
}

/* ── Tableaux ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--hint);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
td { padding: 9px 8px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }

/* ── Jour header (historique) ── */
.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.day-header .day-label {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  text-transform: capitalize;
}
.day-header .day-total {
  font-weight: 700;
  color: var(--accent);
  font-size: 13px;
}

/* ── Catalogue & accès ── */
.catalog-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.catalog-item:last-child { border-bottom: none; }
.catalog-item .info { flex: 1; }
.catalog-item .info .item-name { font-weight: 600; font-size: 14px; }
.catalog-item .info .item-meta { font-size: 12px; color: var(--hint); margin-top: 2px; }
.catalog-item .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  align-items: flex-end;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px 16px;
  width: 100%;
  max-height: 85dvh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  width: 28px; height: 28px;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  color: var(--hint);
  display: flex; align-items: center; justify-content: center;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 66px; left: 16px; right: 16px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  z-index: 300;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .18s, transform .18s;
  pointer-events: none;
  letter-spacing: .1px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--success); color: #fff; }
#toast.error   { background: var(--danger);  color: #fff; }

/* ── Loader ── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.seller-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(91,141,238,.1);
  color: var(--accent);
  border: 1px solid rgba(91,141,238,.2);
  white-space: nowrap;
}

/* ── Écran verrouillé ── */
#locked-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 24px;
  text-align: center;
  gap: 10px;
}
#locked-screen .lock-icon { font-size: 48px; margin-bottom: 8px; }
#locked-screen h2 { font-size: 20px; font-weight: 700; }
#locked-screen p { color: var(--hint); font-size: 14px; max-width: 280px; }
#locked-screen .lock-hint { font-size: 12px; }

.empty {
  text-align: center;
  color: var(--hint);
  padding: 32px 0;
  font-size: 13px;
}

/* ── Écran PIN ── */
#pin-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0 24px;
  background: var(--bg);
  box-sizing: border-box;
}

.pin-wrapper {
  width: 100%;
  max-width: 300px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: clamp(8px, 2dvh, 24px) 0;
  box-sizing: border-box;
}

.pin-icon {
  font-size: clamp(28px, 5dvh, 44px);
  line-height: 1;
}

.pin-title {
  font-size: clamp(16px, 3.2dvh, 22px);
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.pin-subtitle {
  font-size: clamp(11px, 1.8dvh, 13px);
  color: var(--hint);
  text-align: center;
  min-height: 1em;
}

.pin-dots {
  display: flex;
  gap: clamp(12px, 4vw, 20px);
}

.pin-dot {
  width: clamp(12px, 3.5vw, 18px);
  height: clamp(12px, 3.5vw, 18px);
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background .1s, border-color .1s;
}

.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.pin-error {
  font-size: clamp(11px, 1.8dvh, 13px);
  color: var(--danger);
  text-align: center;
  min-height: 1em;
  font-weight: 600;
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-10px); }
  30%       { transform: translateX(10px); }
  45%       { transform: translateX(-7px); }
  60%       { transform: translateX(7px); }
  75%       { transform: translateX(-4px); }
  90%       { transform: translateX(4px); }
}
.pin-dots.shake { animation: pin-shake .45s ease; }

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(6px, 1.8dvh, 12px);
  width: 100%;
}

.numpad-btn {
  width:  min(72px, 25vw, 10.5dvh);
  height: min(72px, 25vw, 10.5dvh);
  justify-self: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-size: min(22px, 6.5vw, 3.2dvh);
  font-weight: 500;
  cursor: pointer;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.numpad-btn:active { background: var(--bg3); }
.numpad-del { color: var(--hint); }
.numpad-empty { /* vide */ }

/* ── Barre de progression objectif ── */
.target-wrap {
  padding: 2px 0 4px;
}
.target-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}
.target-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .4s ease;
}
.target-label {
  font-size: 11px;
  color: var(--hint);
}

/* ── Vente annulée ── */
tr.cancelled td {
  color: var(--hint);
  text-decoration: line-through;
  opacity: .55;
}
tr.cancelled td:last-child,
tr.cancelled td:nth-last-child(2) { text-decoration: none; }

.badge-cancelled {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(224,85,85,.1);
  color: var(--danger);
  border: 1px solid rgba(224,85,85,.25);
  white-space: nowrap;
  text-decoration: none;
}

.btn-cancel, .btn-uncancel {
  background: transparent;
  border: none;
  font-size: 15px;
  cursor: pointer;
  padding: 2px 4px;
  opacity: .4;
  transition: opacity .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn-cancel:hover, .btn-uncancel:hover { opacity: 1; }

/* ── Badge PIN (liste des accès) ── */
.pin-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 4px;
}
.pin-badge.no-pin {
  background: rgba(212,134,58,.1);
  color: var(--warning);
  border: 1px solid rgba(212,134,58,.25);
}
.pin-badge.has-pin {
  background: rgba(70,184,125,.08);
  color: var(--success);
  border: 1px solid rgba(70,184,125,.2);
}
