:root {
  --bg: #15171c; --panel: #1f232b; --panel2: #2a2f3a; --line: #373d4a;
  --text: #f2f3f5; --muted: #9aa3b2; --accent: #1abc9c; --green: #27ae60;
  --red: #e74c3c; --blue: #3498db; --radius: 14px;
  --alert-bg: color-mix(in srgb, var(--red) 20%, var(--bg));
  --row-hover: color-mix(in srgb, var(--accent) 10%, var(--panel));
}
@supports not (background: color-mix(in srgb, red 10%, blue)) { :root { --alert-bg: #3a2a2a; --row-hover: #243038; } }
/* Thèmes : choisis avec le bouton « Apparence » (voir theme.js) */
:root[data-theme="noir"]    { --bg: #000000; --panel: #0d0d0f; --panel2: #1b1c20; --line: #2a2b31; }
:root[data-theme="bleu"]    { --bg: #0f1724; --panel: #172033; --panel2: #223049; --line: #2f3f5c; }
:root[data-theme="vert"]    { --bg: #101a14; --panel: #17251c; --panel2: #213428; --line: #2e4a38; }
:root[data-theme="violet"]  { --bg: #18121f; --panel: #241c2e; --panel2: #332842; --line: #46365a; }
:root[data-theme="marron"]  { --bg: #1b140f; --panel: #271d16; --panel2: #352821; --line: #4a382e; }
:root[data-theme="clair"]   { --bg: #f3f4f6; --panel: #ffffff; --panel2: #e5e7eb; --line: #d1d5db; --text: #111827; --muted: #6b7280; }
:root[data-theme="gris"]    { --bg: #e2e5ea; --panel: #f3f4f6; --panel2: #d6d9df; --line: #c3c7cf; --text: #1b1f27; --muted: #5b626f; }
:root[data-theme="sepia"]   { --bg: #f1e7d3; --panel: #faf3e4; --panel2: #e6d9bd; --line: #d8c7a0; --text: #3a2f1f; --muted: #7a6a50; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
button {
  font: inherit; color: inherit; border: 0; cursor: pointer; border-radius: var(--radius);
  background: var(--panel2); padding: 12px 16px; min-height: 48px; touch-action: manipulation; transition: transform .05s, filter .1s;
}
button:active { transform: scale(.96); filter: brightness(1.2); }
button:disabled { opacity: .4; pointer-events: none; }
.btn-accent { background: var(--accent); color: #111; font-weight: 700; }
.btn-green { background: var(--green); font-weight: 700; color: #fff; }
.btn-red { background: var(--red); font-weight: 700; color: #fff; }
.btn-blue { background: var(--blue); font-weight: 700; color: #fff; }
.btn-ghost { background: transparent; border: 1px solid var(--line); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
input[readonly] { opacity: .65; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.hidden { display: none !important; }
label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: 14px; }
.aide { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Fenêtres modales */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 20px; padding: 22px; width: min(480px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal h2 { margin: 0 0 6px; font-size: 22px; }
.modal .erreur { background: var(--alert-bg); border-left: 5px solid var(--red); padding: 10px 12px; border-radius: 10px; margin-top: 12px; }

/* Notifications */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(520px, 92vw); }
.toast { background: var(--panel2); border-left: 6px solid var(--blue); padding: 14px 16px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: pop .2s; }
.toast.error { border-color: var(--red); } .toast.ok { border-color: var(--green); } .toast.warn { border-color: var(--accent); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

/* Pavé numérique (code vendeur) */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.keypad button { font-size: 26px; font-weight: 600; min-height: 68px; }
.display { background: var(--bg); border-radius: 12px; padding: 14px; font-size: 32px; text-align: center; min-height: 64px; letter-spacing: 8px; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
th.tri { cursor: pointer; user-select: none; } th.tri:hover { color: var(--text); }
/* Ligne de titres figée : elle reste visible en haut quand on fait défiler une longue liste (zone de défilement = la page, ou la fenêtre qui contient le tableau) */
thead th { position: sticky; top: 0; z-index: 5; background: var(--panel); box-shadow: 0 1px 0 var(--line), 0 6px 8px -6px rgba(0, 0, 0, .55); }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; width: 1%; }
td.actions button { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; background: var(--panel2); }
.badge.red { background: var(--red); color: #fff; } .badge.green { background: var(--green); color: #fff; } .badge.orange { background: var(--accent); color: #111; }

/* Entête commune à toutes les pages (static/entete.js) */
#entete { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 8px 14px; background: var(--panel); position: sticky; top: 0; z-index: 30; border-bottom: 1px solid var(--line); }
#entete .logo { font-size: 20px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
#entete .pages { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
#entete .pages a { padding: 8px 14px; border-radius: 12px; color: var(--text); text-decoration: none; white-space: nowrap; }
#entete .pages a:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
#entete .pages a.actif { background: var(--accent); color: #111; font-weight: 700; }

/* Les pages sont des grilles à une colonne : sans cela, un menu trop long élargit toute la page au lieu de défiler dans l'entête. */
body { grid-template-columns: minmax(0, 1fr); }

nav [hidden] { display: none !important; }

#entete .bientot { padding: 8px 14px; border-radius: 12px; color: var(--muted); white-space: nowrap; opacity: .6; cursor: default; }
#entete .sous { flex-basis: 100%; display: flex; gap: 6px; overflow-x: auto; padding-top: 6px; border-top: 1px solid var(--line); }
#entete .sous a { padding: 5px 12px; border-radius: 10px; color: var(--text); text-decoration: none; white-space: nowrap; font-size: 14px; }
#entete .sous a:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
#entete .sous a.actif { background: color-mix(in srgb, var(--accent) 35%, transparent); font-weight: 700; }
#entete .sous .bientot { padding: 5px 12px; font-size: 14px; }
#entete .sous2 { padding-left: 28px; padding-top: 4px; border-top: 1px dashed var(--line); }
#entete .sous2 a { font-size: 13px; padding: 3px 10px; }

/* Téléphone : entête compacte (logo, session et boutons sur une ligne ; menus qui défilent à l'horizontale) */
@media (max-width: 760px) {
  #entete { gap: 6px 8px; padding: 6px 10px; }
  #entete .logo { font-size: 17px; }
  #entete .pages { order: 10; flex: 1 1 100%; }
  #entete .pages a { padding: 7px 11px; }
  #entete #qui { flex: 1; font-size: 12px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #entete #ver { display: none; }
  #entete button { min-height: 38px; padding: 4px 10px; }
  #entete nav.sous { flex: 1 1 100%; order: 11; overflow-x: auto; }
  .modal { padding: 16px; }
}
