:root {
  --vert: #1d7a4f;
  --vert-fonce: #145c3a;
  --fond: #f4f6f5;
  --carte: #ffffff;
  --texte: #1c2b24;
  --muted: #6b7f75;
  --rouge: #c0392b;
  --orange: #d68910;
  --bord: #dde5e1;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--fond); color: var(--texte); font-size: 16px;
  display: flex; flex-direction: column;
}

/* ---------- login ---------- */
.login-page { justify-content: center; align-items: center; padding: 16px; }
.login-card {
  background: var(--carte); border-radius: 16px; padding: 28px 22px;
  width: 100%; max-width: 380px; box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.login-card h1 { color: var(--vert); text-align: center; margin-bottom: 4px; }
.login-card .muted { text-align: center; margin-bottom: 18px; }
.login-card input { margin-bottom: 10px; }

/* ---------- structure app ---------- */
#topbar {
  background: var(--vert); color: #fff; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; position: sticky; top: 0; z-index: 5;
}
#topbar .muted { color: #cfe8db; font-weight: 400; font-size: 13px; }
main#view { flex: 1; overflow-y: auto; padding: 12px 12px 80px; }
#tabs {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--carte);
  border-top: 1px solid var(--bord); display: flex; z-index: 5;
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; border: 0; background: none; padding: 8px 0 6px; font-size: 20px;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#tabs button span { font-size: 11px; }
#tabs button.active { color: var(--vert); font-weight: 600; }

/* ---------- composants ---------- */
input, select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--bord); border-radius: 10px;
  font-size: 16px; background: #fff; color: var(--texte);
}
.btn {
  display: inline-block; border: 0; border-radius: 10px; padding: 12px 16px;
  font-size: 16px; font-weight: 600; cursor: pointer; background: #e8eeeb; color: var(--texte);
}
.btn.primary { background: var(--vert); color: #fff; }
.btn.danger { background: var(--rouge); color: #fff; }
.btn.block { display: block; width: 100%; }
.btn.small { padding: 7px 10px; font-size: 14px; border-radius: 8px; }
.btn:disabled { opacity: .5; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.error { color: var(--rouge); font-size: 14px; margin-top: 8px; text-align: center; }
.card { background: var(--carte); border-radius: 12px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
h2 { font-size: 18px; margin: 6px 2px 10px; }
h3 { font-size: 15px; margin: 4px 2px 8px; color: var(--muted); }

/* ---------- caisse ---------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 10px; }
.cat-scroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.cat-scroll button {
  flex: 0 0 auto; border: 1px solid var(--bord); background: var(--carte); color: var(--texte);
  border-radius: 20px; padding: 7px 14px; font-size: 14px; white-space: nowrap;
}
.cat-scroll button.active { background: var(--vert); color: #fff; border-color: var(--vert); }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; }
.prod-tile {
  background: var(--carte); border: 1px solid var(--bord); border-radius: 12px;
  padding: 10px 8px; text-align: center; cursor: pointer; min-height: 84px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.prod-tile .nom { font-size: 13px; font-weight: 600; line-height: 1.25; overflow: hidden; }
.prod-tile .prix { color: var(--vert); font-weight: 700; font-size: 13px; }
.prod-tile .st { font-size: 11px; color: var(--muted); }
.prod-tile.rupture { opacity: .45; }
#cart-bar {
  position: fixed; bottom: 62px; left: 10px; right: 10px; background: var(--vert-fonce);
  color: #fff; border-radius: 12px; padding: 12px 16px; display: flex;
  justify-content: space-between; align-items: center; z-index: 6; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* ---------- listes ---------- */
.list-item {
  background: var(--carte); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.list-item .l { flex: 1; min-width: 0; }
.list-item .nom { font-weight: 600; font-size: 15px; }
.list-item .sub { font-size: 12.5px; color: var(--muted); }
.badge { border-radius: 8px; padding: 3px 8px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: #e3f2e9; color: var(--vert); }
.badge.warn { background: #fdf0dc; color: var(--orange); }
.badge.ko { background: #fde4e0; color: var(--rouge); }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.stat { background: var(--carte); border-radius: 12px; padding: 12px; }
.stat .val { font-size: 20px; font-weight: 800; color: var(--vert); }
.stat .lab { font-size: 12.5px; color: var(--muted); }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--carte); border-radius: 16px 16px 0 0; padding: 18px 16px 26px;
  width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 12px; }
.modal .field { margin-bottom: 10px; }
.modal label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 4px; }

/* ---------- ticket ---------- */
.ticket-preview {
  font-family: 'Courier New', monospace; font-size: 13px; white-space: pre;
  background: #fff; border: 1px dashed var(--bord); border-radius: 8px;
  padding: 12px; overflow-x: auto; margin-bottom: 12px;
}
