:root {
  --bg: #100d20; --bg2: #171127; --panel: #1b162d; --panel2: #21193a; --line: #3a2d52;
  --white: #fff; --muted: #b8afc5; --muted2: #8d84a0;
  --purple: #742b92; --purple2: #a55ac1; --purple3: #d4a6e6;
  --red: #e7253d; --green: #57d78a; --amber: #f1c453;
  --glass: rgba(255,255,255,.055); --glass2: rgba(255,255,255,.09); --stroke: rgba(255,255,255,.11);
  --shadow: 0 28px 80px rgba(0,0,0,.32);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.45 Inter, ui-sans-serif, -apple-system, "system-ui", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--white);
  background: var(--bg);
  background-image:
    radial-gradient(900px 420px at -8% 72%, rgba(116,43,146,.48), transparent 70%),
    radial-gradient(760px 360px at 98% 45%, rgba(80,38,125,.35), transparent 72%),
    linear-gradient(160deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: #ff8a97; font-size: 14px; margin: 0; }
.kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; color: var(--purple3);
}

/* Boutons */
.btn {
  font: inherit; font-weight: 600; border: 1px solid transparent; border-radius: 14px; padding: 12px 20px; cursor: pointer;
  background: var(--glass); color: var(--white); border-color: var(--stroke);
}
.btn.primary { background: var(--purple); border-color: rgba(255,255,255,.12); }
.btn.danger { background: rgba(231,37,61,.18); border-color: rgba(231,37,61,.45); color: #ffb3bc; }
.btn.pill { border-radius: 999px; padding: 8px 14px; font-size: 13px; }
.btn.link { background: transparent; border-color: transparent; color: var(--purple3); padding: 6px 10px; }
.btn.huge { font-size: 26px; padding: 26px 56px; border-radius: 22px; box-shadow: 0 18px 50px rgba(116,43,146,.45); }
.btn:active { opacity: .82; }
.btn[disabled] { opacity: .5; }

/* Cartes */
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.1); border-radius: 28px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.panel::after {
  content: ""; position: absolute; right: -80px; bottom: -120px; width: 320px; height: 320px; border-radius: 50%;
  background: radial-gradient(circle, rgba(116,43,146,.35), transparent 70%); pointer-events: none;
}

/* Login */
.view { min-height: 100%; }
#view-login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login {
  width: 100%; max-width: 420px; padding: 36px 32px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login > * + * { margin-top: 14px; }
.logo {
  width: 48px; height: 48px; border-radius: 14px; background: var(--purple); display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; margin-bottom: 4px;
}
.login h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.login p { margin: 0; }
.login label { width: 100%; display: flex; flex-direction: column; font-size: 13px; color: var(--muted); text-align: left; }
.login label > input { margin-top: 6px; }
.login input {
  font: inherit; font-size: 18px; padding: 13px 14px; border-radius: 14px; color: var(--white);
  background: rgba(0,0,0,.35); border: 1px solid var(--stroke);
}
.login input:focus { outline: none; border-color: var(--purple2); }
.login .btn.primary { width: 100%; margin-top: 6px; font-size: 17px; }

/* App */
#view-app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 22px; }
.brand { display: flex; align-items: center; }
.brand > * + * { margin-left: 12px; }
.brand .logo { width: 36px; height: 36px; font-size: 17px; border-radius: 11px; margin: 0; }
.brand .title { font-weight: 800; font-size: 20px; letter-spacing: -.02em; line-height: 1.1; }
.brand .sub { font-size: 12px; color: var(--muted); }
.user { display: flex; align-items: center; font-size: 14px; color: var(--muted); }
.user > * + * { margin-left: 10px; }
.user .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; margin-right: 6px; }

.layout { display: flex; flex: 1; min-height: 0; padding: 0 22px 22px; }
.layout > * + * { margin-left: 18px; }
.sidebar { width: 300px; flex: 0 0 300px; padding: 18px 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; border-radius: 24px; }
.sidebar .kicker { margin: 4px 10px 12px; display: block; }
.session-list { list-style: none; margin: 0; padding: 0; position: relative; z-index: 1; }
.session-list li { padding: 12px 14px; border-radius: 16px; cursor: pointer; margin-bottom: 6px; border: 1px solid transparent; }
.session-list li:active, .session-list li.active { background: var(--glass2); border-color: var(--stroke); }
.session-list .when { font-weight: 600; font-size: 15px; }
.session-list .who { color: var(--muted); font-size: 13px; }
.session-list .counts { font-size: 13px; margin-top: 4px; }
.session-list .counts .ok { color: var(--green); }
.session-list .counts .ko { color: #ff8a97; margin-left: 10px; }
.session-list .live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 8px; box-shadow: 0 0 0 4px rgba(87,215,138,.18); }
.session-list .empty { color: var(--muted2); padding: 12px 14px; font-size: 14px; }

.main { flex: 1; min-width: 0; display: flex; }
.main .panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.panel-inner { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 640px; width: 100%; position: relative; z-index: 1; }
.panel-inner > * + * { margin-top: 22px; }
.panel-inner h2 { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -.02em; }
.panel-inner .lead { margin: 12px 0 0; color: var(--muted); font-size: 16px; }
.printer-line { color: var(--muted2); font-size: 13px; }

/* Scan */
.pulse {
  width: 76px; height: 76px; border-radius: 50%; background: var(--purple);
  box-shadow: 0 0 0 0 rgba(165,90,193,.5); animation: pulse 1.6s infinite; margin-bottom: -6px;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(165,90,193,.5); }
  70% { box-shadow: 0 0 0 30px rgba(165,90,193,0); }
  100% { box-shadow: 0 0 0 0 rgba(165,90,193,0); }
}
.scan-input {
  font: inherit; font-size: 24px; font-weight: 600; text-align: center; letter-spacing: 3px;
  width: 280px; padding: 12px; border-radius: 16px; color: var(--purple3);
  background: rgba(0,0,0,.35); border: 2px dashed rgba(165,90,193,.55);
}
.scan-input:focus { outline: none; border-style: solid; border-color: var(--purple2); }

.counters { display: flex; }
.counters > * + * { margin-left: 16px; }
.counter {
  font: inherit; color: inherit; cursor: default; min-width: 160px; padding: 18px 22px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--stroke);
  display: flex; flex-direction: column; align-items: center;
}
.counter span { font-size: 42px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.counter small { color: var(--muted); margin-top: 8px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.counter.ok span { color: var(--green); }
.counter.ko { cursor: pointer; }
.counter.ko span { color: #ff6b7d; }
.counter.ko:active { background: rgba(231,37,61,.15); }
.actions { display: flex; }
.actions > * + * { margin-left: 12px; }

/* Toasts */
.toasts { position: fixed; top: 18px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; pointer-events: none; z-index: 70; }
.toast + .toast { margin-top: 8px; }
.toast {
  padding: 14px 24px; border-radius: 16px; color: var(--white); font-size: 20px; font-weight: 700;
  box-shadow: 0 16px 40px rgba(0,0,0,.45); max-width: 90%; text-align: center; border: 1px solid rgba(255,255,255,.14);
  animation: toast-in .2s ease-out;
}
.toast.ok { background: #1f9a55; }
.toast.ko { background: var(--red); }
.toast.warn { background: #b7791f; }
.toast.info { background: var(--panel2); }
.toast .sub { display: block; font-size: 15px; font-weight: 500; opacity: .95; margin-top: 2px; }
@keyframes toast-in { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Modal */
.modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(6,4,14,.7); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.modal-box {
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 24px; box-shadow: var(--shadow);
  width: 100%; max-width: 640px; max-height: 85%; display: flex; flex-direction: column;
}
.modal-box header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--stroke); }
.modal-box h3 { margin: 0; font-size: 18px; }
.modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 20px 20px; }
.modal-body h4 { margin: 16px 0 6px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--purple3); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.rows li > * + * { margin-left: 12px; }
.rows .id { font-weight: 700; font-variant-numeric: tabular-nums; }
.rows .reason { color: #ff8a97; flex: 1; }
.rows .at { color: var(--muted2); font-size: 13px; white-space: nowrap; }
.rows.ok .reason { color: var(--green); }
.modal-body .empty, .modal-body .muted { color: var(--muted); }
.modal-body .empty { padding: 12px 0; }

@media (max-width: 760px) {
  .layout { flex-direction: column; padding: 0 14px 14px; }
  .layout > * + * { margin-left: 0; margin-top: 14px; }
  .sidebar { width: auto; flex: 0 0 auto; max-height: 32%; }
  .main .panel { padding: 28px 18px; }
  .btn.huge { font-size: 22px; padding: 20px 36px; }
  .panel-inner h2 { font-size: 26px; }
}

.scan-status { display: flex; flex-direction: column; align-items: center; }
.scan-status > * + * { margin-top: 8px; }
.scan-status h2 { margin-top: 2px; }

/* La carte de login ne doit pas défiler quand un champ prend le focus (iOS). */
.panel.login { overflow: visible; }
.panel.login::after { display: none; }
.sidebar { scrollbar-width: none; }
.sidebar::-webkit-scrollbar { display: none; }

/* Lot */
a.btn { text-decoration: none; display: inline-block; }
.rows .reason.warn { color: var(--amber); }
.session-list .counts .warn { color: var(--amber); margin-left: 10px; }
.panel-inner .lead strong { color: var(--white); }

/* Avertissement taille de lot */
.warning {
  margin: -6px 0 0; padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 600;
  color: var(--amber); background: rgba(241,196,83,.12); border: 1px solid rgba(241,196,83,.4);
}
.counter.ok.warn { border-color: rgba(241,196,83,.6); }
.counter.ok.warn span { color: var(--amber); }

/* Clavier à l'écran */
.osk {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; padding: 8px 10px 14px;
  background: rgba(16,13,32,.96); border-top: 1px solid var(--stroke); box-shadow: 0 -20px 60px rgba(0,0,0,.5);
  -webkit-user-select: none; user-select: none;
}
.osk-head { display: flex; justify-content: space-between; align-items: center; max-width: 900px; margin: 0 auto 6px; }
.osk-keys { display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; }
.osk-row + .osk-row { margin-top: 6px; }
.osk-row { display: flex; justify-content: center; }
.osk-row > * + * { margin-left: 6px; }
.osk-key {
  flex: 1; max-width: 84px; height: 48px; font: inherit; font-size: 20px; font-weight: 600; color: var(--white);
  background: var(--glass2); border: 1px solid var(--stroke); border-radius: 10px; cursor: pointer;
}
.osk-key:active { background: var(--purple); }
.osk-key.wide { max-width: 130px; font-size: 15px; }
.osk-key.enter { max-width: 150px; background: var(--purple); font-size: 15px; }
.osk-key.on { background: var(--purple2); }
.osk.numeric .osk-key { max-width: 110px; height: 56px; font-size: 24px; }
body.osk-open .main .panel, body.osk-open .login { padding-bottom: 10px; }
body.osk-open #view-app .layout { padding-bottom: 300px; }
body.osk-open #view-login { align-items: flex-start; padding-top: 24px; padding-bottom: 340px; }
body.osk-open { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.scan-input[disabled] { opacity: .45; border-style: solid; }

a.link { color: var(--purple3); }
