:root {
    --bg: #f3f5f9;
    --panel: #fff;
    --ink: #1c2230;
    --muted: #697386;
    --line: #e2e6ee;
    --accent: #1f6fd0;
    --accent-ink: #fff;
    --warn: #b45309;
    --warn-bg: #fef4e2;
    --danger: #c0282d;
    --danger-bg: #fdeaea;
    --ok: #15803d;
    --top: #141b2b;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
h1 { margin: 0 0 18px; font-size: 22px; }
h2 { margin: 0; font-size: 17px; }
h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

button { font: inherit; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); padding: 9px 14px; }
button:hover:not(:disabled) { border-color: #b7c0d0; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 10px; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px; }

input, select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }

.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--top); color: #fff; }
.topbar button.ghost { color: #fff; border-color: #475066; }
.brand { font-weight: 700; }
.client { color: #aab4c6; }
.desk-badge { background: #2b364d; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.spacer { flex: 1; }
.who { color: #cdd5e2; }
.toplink { color: #cdd5e2; text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.toplink:hover { background: #2b364d; }
.sos { background: transparent; border-color: #e05a5a; color: #ff9d9d; font-weight: 700; }
.sos.active { background: var(--danger); color: #fff; }

.banner { padding: 10px 20px; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.flash { animation: flash 1s steps(2, start) infinite; }
@keyframes flash { to { background: #f9c9c9; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
.center-screen { display: flex; justify-content: center; padding: 40px 20px; }
.center-screen .card { width: 100%; max-width: 620px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.desk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.desk { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 8px; }
.desk strong { font-size: 22px; }
.desk span { font-size: 13px; color: var(--ok); }
.desk.busy span { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.service-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.service-call { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; font-size: 16px; text-align: left; }
.service-call strong { font-variant-numeric: tabular-nums; }
.service-list.choice { margin: 0 0 8px; }
.service-option { display: flex; align-items: center; gap: 4px; width: 100%; padding: 12px 14px; font-size: 16px; text-align: left; }
.service-option.selected .letter { background: rgba(255, 255, 255, .22); color: #fff; }

.workspace { display: grid; grid-template-columns: minmax(340px, 440px) minmax(0, 1fr); gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; align-items: start; }
.work { text-align: center; }
.work.idle { text-align: left; }
.work .chips { justify-content: center; }
.work.idle .chips { justify-content: flex-start; margin-top: 12px; }
.hint { margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.ticket-number { font-size: 68px; line-height: 1.1; font-weight: 800; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.ticket-service { color: var(--muted); margin-bottom: 14px; }
.timers { display: flex; justify-content: center; gap: 28px; margin-bottom: 16px; }
.timer span { display: block; font-size: 13px; color: var(--muted); }
.timer strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.recall { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.recall label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 14px; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }

.board { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; }
thead th { font-size: 13px; color: var(--muted); font-weight: 600; }
tbody th { font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.letter { display: inline-block; min-width: 26px; text-align: center; margin-right: 8px; padding: 1px 6px; border-radius: 6px; background: #e8eefb; color: var(--accent); font-weight: 700; }
tr.level1 td.num:first-of-type { color: var(--warn); font-weight: 700; }
tr.level2 td.num:first-of-type { color: var(--danger); font-weight: 700; }
tr.inactive { color: var(--muted); }
tfoot th, tfoot td { border-bottom: 0; font-weight: 700; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--top); color: #fff; padding: 12px 18px; border-radius: 8px; max-width: 90vw; }

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.login { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; text-align: center; }
.login-client { margin: 0; text-align: center; color: var(--muted); font-weight: 600; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.login-error { margin: 0; color: var(--danger); font-size: 14px; }

@media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; padding: 12px; }
    .topbar { flex-wrap: wrap; padding: 10px 12px; }
    .ticket-number { font-size: 54px; }
}

.login-ok { color: var(--ok); font-weight: 600; }
.login-back { display: block; text-align: center; margin-top: 12px; color: var(--accent); }

/* Sélecteur de système de l'administrateur client (barre du haut de toutes les pages) */
.system-switch { display: flex; align-items: center; gap: 6px; margin: 0; }
.system-switch select { padding: 5px 8px; border-radius: 8px; border: 1px solid #475066; background: #222b3d; color: #fff; max-width: 260px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* Barre du haut : retour à la ligne plutôt que des libellés coupés (administrateur client : nombreux liens). */
.topbar { flex-wrap: wrap; row-gap: 6px; }
.topbar > * { white-space: nowrap; }

/* Bouton « Son » du guichet : bloqué par le navigateur (pas encore de clic dans la page) */
button.sound.blocked { background: #fff3cd; border-color: #e0a800; color: #6b4e00; }
