:root {
  --accent: #C6178C;
  --accent-dark: #8F1066;
  --accent-light: #F4CBE4;
  --brand-green: #A7CD39;
  --brand-green-dark: #6F9420;
  --brand-green-light: #E9F3D0;
  --paper: #FAF4F8;
  --paper-dark: #F0E1EC;
  --card: #FFFFFF;
  --ink: #231F20;
  --ink-soft: #675F62;
  --line: #E3D3DD;
  --red-600: #B23A2E;
  --green-600: #6F9420;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(35, 31, 32, 0.08);
  --shadow-lg: 0 12px 32px rgba(35, 31, 32, 0.2);
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: Georgia, 'Times New Roman', serif; margin: 0 0 .3em; letter-spacing: .2px; }
.mono { font-family: 'Courier New', Courier, monospace; font-variant-numeric: tabular-nums; }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- Bandeau supérieur ---------- */
.topbar {
  background: linear-gradient(180deg, var(--accent-dark), var(--accent));
  color: #fff;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 40;
}
.topbar .brand { font-family: Georgia, serif; font-weight: 700; font-size: 1.25rem; text-decoration: none; color: #fff; display: inline-block; cursor: pointer; }
.topbar .brand small { display: block; font-family: -apple-system, sans-serif; font-weight: 400; font-size: .68rem; opacity: .75; letter-spacing: .5px; text-transform: uppercase; }
.topbar-spacer { flex: 1; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav a {
  text-decoration: none; color: #fff; padding: 8px 14px; border-radius: 999px;
  font-size: .92rem; opacity: .85; border: 1px solid rgba(255,255,255,.25);
}
.topbar nav a.active, .topbar nav a:hover { opacity: 1; background: rgba(255,255,255,.14); }
.poste-badge {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  padding: 6px 12px; border-radius: 999px; font-size: .85rem; display: flex; gap: 8px; align-items: center;
  cursor: pointer; color: #fff;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #999; display: inline-block; }
.dot.on { background: #6FCF97; box-shadow: 0 0 0 3px rgba(111,207,151,.25); }
.dot.off { background: #E06B5C; }

/* ---------- Layout caisse ---------- */
.caisse-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
  padding: 16px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 920px) {
  .caisse-layout { grid-template-columns: 1fr; }
}

.categories { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: var(--card); padding: 8px 16px; border-radius: 999px;
  font-size: .88rem; color: var(--ink-soft);
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.produits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.produit-tag {
  background: var(--tag-color, var(--card));
  border: 1px solid rgba(35, 36, 32, 0.12);
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  text-align: left;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: relative;
  transition: transform .08s ease;
}
.produit-tag:active { transform: scale(.97); }
.produit-tag .nom { font-weight: 600; font-size: .95rem; padding-right: 16px; line-height: 1.25; color: var(--ink); }
.produit-tag .prix { font-family: 'Courier New', monospace; font-size: 1.15rem; font-weight: 700; color: var(--accent-dark); margin-top: 8px; }
.produit-tag .stock-info { font-size: .72rem; color: var(--ink-soft); margin-top: 2px; }
.produit-tag.rupture {
  filter: grayscale(90%);
  opacity: .55;
  cursor: not-allowed;
}
.produit-tag.rupture .prix,
.produit-tag.rupture .nom { color: var(--ink-soft); }
.produit-tag .stock-info.low { color: var(--red-600); font-weight: 600; }
.produit-tag .alerte-seuil {
  position: absolute;
  bottom: 10px;
  right: 8px;
  font-size: 1.5rem;   /* plus grand que la valeur d'origine (.95rem) */
  line-height: 1;
}

/* ---------- Panier ---------- */
.panier-panel {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 96px);
}
.panier-lignes { flex: 1; overflow-y: auto; margin: 10px 0; min-height: 80px; }
.panier-ligne { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.panier-ligne .nom { flex: 1; font-size: .9rem; }
.panier-ligne .qty-ctrl { display: flex; align-items: center; gap: 6px; }
.panier-ligne .qty-ctrl button {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); font-weight: 700;
}
.panier-ligne .sous-total { width: 72px; text-align: right; font-family: 'Courier New', monospace; font-weight: 700; }
.panier-vide { color: var(--ink-soft); font-size: .9rem; text-align: center; padding: 24px 0; }

.total-row {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 2px solid var(--ink); padding-top: 10px; margin-top: 6px;
}
.total-row .label { font-family: Georgia, serif; font-size: 1rem; }
.total-row .value { font-family: 'Courier New', monospace; font-size: 1.8rem; font-weight: 700; }

.paiement-modes { display: flex; gap: 6px; margin: 12px 0 8px; }
.paiement-modes button {
  flex: 1; padding: 10px 4px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--paper);
  font-size: .82rem; font-weight: 600; color: var(--ink-soft);
}
.paiement-modes button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.recu-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.recu-row input { flex: 1; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); font-size: 1.1rem; font-family: 'Courier New', monospace; }
.quick-amounts { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.quick-amounts button { padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font-size: .8rem; }

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.numpad button {
  padding: 12px 0; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card);
  font-size: 1.05rem; font-weight: 600; font-family: 'Courier New', monospace; color: var(--ink);
}
.numpad button:active { background: var(--paper-dark); }
.numpad .numpad-zero { grid-column: span 2; }

.rendu-box {
  background: var(--paper-dark); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; font-family: 'Courier New', monospace;
}
.rendu-box .rendu-total { font-size: 1.4rem; font-weight: 700; color: var(--green-600); }
.rendu-box .rendu-total.negatif { color: var(--red-600); }
.rendu-detail { font-size: .78rem; color: var(--ink-soft); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 10px; }

.btn { border: none; border-radius: var(--radius-sm); padding: 12px 16px; font-weight: 700; font-size: .95rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { background: #B9B6A8; cursor: not-allowed; }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 16px; font-size: 1.05rem; }
.btn-sm { padding: 6px 10px; font-size: .78rem; border-radius: 6px; }

.actions-row { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- Pages admin / rapport ---------- */
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h2 { font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: none; padding: 10px 16px; font-weight: 600; color: var(--ink-soft); border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--accent-dark); border-color: var(--brand-green); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .78rem; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.field input, .field select, .field textarea {
  padding: 9px 10px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: #fff; font-size: .92rem;
}
.field textarea { resize: vertical; min-height: 60px; }

table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: var(--paper); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-low { background: #FBE3DE; color: var(--red-600); }
.badge-ok { background: var(--brand-green-light); color: var(--brand-green-dark); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat-box { background: var(--paper); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.stat-box .n { font-family: 'Courier New', monospace; font-size: 1.6rem; font-weight: 700; color: var(--accent-dark); }
.stat-box .l { font-size: .76rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }

#toast-box { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .88rem;
  opacity: 0; transform: translateY(10px); transition: all .25s ease; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--red-600); }
.toast-success { background: var(--green-600); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(35,31,32,.5); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 16px;
}
.modal { background: #fff; border-radius: var(--radius); padding: 20px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 10px; }
.modal .actions-row { justify-content: flex-end; }
.apercu-ticket {
  width: 180px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 12px 10px;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  color: #111;
  text-align: center;
  line-height: 1.35;
  min-height: 120px;
}
.apercu-ticket img { max-width: 70%; margin: 0 auto 6px; display: block; filter: grayscale(100%) contrast(1.2); }
.apercu-ticket .ap-nom { font-weight: 700; }
.apercu-ticket .ap-grand { font-size: 16px; }
.apercu-ticket .ap-tresgrand { font-size: 20px; }
.apercu-ticket .ap-hr { border-top: 1px dashed #999; margin: 6px 0; }
.apercu-ticket .ap-petit { font-size: 8px; color: #555; }

.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: .82rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

.print-only { display: none; }
@media print {
  body * { visibility: hidden; }
  .printable-area, .printable-area * { visibility: visible; }
  .printable-area { position: absolute; left: 0; top: 0; width: 100%; display: block !important; padding: 0; }
  .printable-area input, .printable-area select, .printable-area button, .printable-area form { display: none !important; }
  .printable-area .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; margin-bottom: 14px; }
  .print-only { display: block !important; margin-bottom: 16px; }
  .print-only h1 { font-size: 1.4rem; margin-bottom: 2px; }
  .print-only .small { color: #555; }
}

/* Écran de connexion caisse/rapport (protection par mot de passe) */
#caisse-auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper, #FFF7FC);
}
.caisse-auth-box {
  width: 320px; max-width: 90vw; text-align: center;
  background: #fff; border-radius: var(--radius, 14px);
  box-shadow: 0 8px 30px rgba(0,0,0,.12); padding: 32px 24px;
}
.caisse-auth-box h2 { margin: 0 0 6px; color: var(--accent, #C6178C); }
.caisse-auth-box input {
  width: 100%; margin: 16px 0 12px; padding: 10px 12px;
  border-radius: 8px; border: 1px solid var(--line, #E5D3E0); font-size: 1rem;
  box-sizing: border-box; text-align: center;
}
.caisse-auth-box .btn { width: 100%; }
.caisse-auth-error { display: none; color: var(--red-600, #B23A2E); margin-top: 10px; }
