/* Styles communs caisse + back-office */
:root {
  --bg: #f3f4f8; --surface: #ffffff; --surface2: #f8f9fc; --line: #e3e6ee; --txt: #161a2b; --muted: #6b7290;
  --primary: #3b3bd6; --primary-h: #2f2fb8; --primary-soft: #ececfd;
  --ok: #138a4e; --ok-soft: #e3f6ec; --warn: #b26a00; --warn-soft: #fff4dd; --bad: #c62839; --bad-soft: #fde8ea;
  --gold: #c99400; --radius: 14px; --shadow: 0 1px 2px rgba(20,24,60,.06), 0 6px 20px rgba(20,24,60,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; background: var(--bg); color: var(--txt); font-size: 15px; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 10px 16px; border-radius: 10px; cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-h); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { padding: 16px 22px; font-size: 18px; border-radius: 12px; }

input, select, textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.f > input, label.f > select, label.f > textarea { margin-top: 5px; color: var(--txt); font-weight: 400; font-size: 15px; }
label.chk { display: flex; gap: 8px; align-items: center; font-weight: 600; cursor: pointer; }
label.chk input { width: 18px; height: 18px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 15px; margin-bottom: 12px; }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; }
table.t tbody tr:hover { background: var(--surface2); }

.tag { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--surface2); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.info { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.ball { --bc: #e63946; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; font-size: 14px; font-weight: 800; position: relative; flex-shrink: 0;
  background: radial-gradient(circle at 30% 24%, rgba(255,255,255,.7) 0, rgba(255,255,255,0) 28%), radial-gradient(circle at 50% 45%, var(--bc) 50%, color-mix(in srgb, var(--bc) 55%, #000) 100%); color: #111; }
.ball::after { content: ""; position: absolute; inset: 20%; border-radius: 50%; background: rgba(255,255,255,.9); }
.ball b { position: relative; z-index: 1; }
.ball.dim { opacity: .3; filter: grayscale(.6); }
.ball.lg { width: 46px; height: 46px; font-size: 19px; }
.balls { display: inline-flex; gap: 5px; flex-wrap: wrap; }

.overlay { position: fixed; inset: 0; background: rgba(14,16,40,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: 100%; max-width: 460px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 92vh; overflow: auto; }
.modal h2 { font-size: 20px; margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

#toasts { position: fixed; bottom: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1d2140; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 600; max-width: 380px; animation: tin .25s ease; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); } .toast.warn { background: var(--warn); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(ellipse at top, #22205a, #0d0d24); }
.login { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.login h1 { font-size: 26px; font-weight: 900; letter-spacing: 1px; }
.login .sub { color: var(--muted); margin: 4px 0 20px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 14px; }
.keypad button { padding: 16px 0; font-size: 22px; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); cursor: pointer; }
.keypad button:active { background: var(--primary-soft); }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin: 6px 0 4px; min-height: 18px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); }

.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: #14163a; color: #fff; }
.topbar .logo { font-weight: 900; font-size: 20px; letter-spacing: 1px; background: linear-gradient(90deg, #22e6ff, #ff3df2); -webkit-background-clip: text; background-clip: text; color: transparent; }
.topbar .btn.warnbtn { background: #ffb020; color: #1b1300; border-color: #ffb020; font-weight: 800; }
.sgcats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0 14px; }
.sgcat { display: block; cursor: pointer; }
.sgcat input { position: absolute; opacity: 0; pointer-events: none; }
.sgcat span { display: block; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; font-size: 16px; background: var(--surface2); }
.sgcat input:checked + span { border-color: var(--primary); background: var(--primary-soft, #e9e8ff); }
.sgcat input:focus-visible + span { outline: 3px solid var(--primary); }
.sgrow { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--txt); }
.topbar .btn.icon { font-size: 18px; padding: 6px 10px; line-height: 1; }
.topbar .salchip { font-size: 13px; font-weight: 700; padding: 4px 10px; border-radius: 20px; background: rgba(255,255,255,.12); white-space: nowrap; }
.topbar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; }
.topbar .btn:hover { background: rgba(255,255,255,.16); }
.topbar .btn.active { background: #fff; color: #14163a; }
.drawchip { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.08); padding: 6px 14px; border-radius: 30px; font-weight: 700; }
.drawchip .dot { width: 10px; height: 10px; border-radius: 50%; background: #2bff88; box-shadow: 0 0 10px #2bff88; }
.drawchip.closed .dot { background: #ff3b5c; box-shadow: 0 0 10px #ff3b5c; }
.drawchip.paused .dot { background: #999; box-shadow: none; }
.drawchip .cd { font-variant-numeric: tabular-nums; font-size: 18px; }

.banner { border-radius: 14px; padding: 18px 20px; font-size: 22px; font-weight: 900; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner.ok { background: var(--ok); color: #fff; }
.banner.bad { background: var(--bad); color: #fff; }
.banner.warn { background: #ffb020; color: #2a1a00; }
.banner.info { background: var(--primary); color: #fff; }
.banner.grey { background: #59607e; color: #fff; }
.banner small { display: block; font-size: 14px; font-weight: 600; opacity: .9; }

.ball.hit { box-shadow: 0 0 0 3px var(--ok); }

/* Caisse sur petit écran (1366 et 1280 pixels) : la barre du haut tient sur une ligne. */
@media (max-width: 1520px) {
  .topbar { gap: 8px; }
  .topbar .btn small { display: none; }
  .topbar .btn { padding-left: 11px; padding-right: 11px; }
  .topbar .salchip { font-size: 12px; padding: 3px 8px; }
}
@media (max-width: 1300px) {
  .topbar .btn.warnbtn .lbl { display: none; }
  .topbar .right span small { display: none; }
}
@media (max-width: 1150px) {
  .topbar { flex-wrap: wrap; height: auto; padding-top: 6px; padding-bottom: 6px; }
}

/* Suites de numéros (caisse) */
.suites { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 2px; padding: 8px 10px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--line); }
.suites .slab { font-size: 12px; font-weight: 800; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.suites .srange { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; margin: 0 4px; }
.suites .srange input { width: 46px; padding: 6px; text-align: center; font-weight: 800; }
.suites .decs { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.suites .btn.sm { padding: 6px 9px; }
/* Réglages de l'imprimante (Ma caisse) */
.prgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 6px; }
.plab { display: block; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; margin-bottom: 5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 9px 14px; font-weight: 700; cursor: pointer; border-right: 1px solid var(--line); font-size: 14px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; }
