:root {
  --bg: #f4f6fb; --panel: #fff; --ink: #172033; --muted: #66708a; --line: #dfe4ef;
  --brand: #3557d6; --brand-ink: #fff; --ok: #138a4b; --ok-bg: #e5f6ec; --warn: #a66300; --warn-bg: #fff3df;
  --bad: #c0302b; --bad-bg: #fdeceb; --chip: #eef1f8; --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151f; --panel: #1a2030; --ink: #e8ecf6; --muted: #98a2bb; --line: #2c3448;
    --brand: #6f8cff; --ok: #4cc983; --ok-bg: #173325; --warn: #f0b252; --warn-bg: #3a2c12;
    --bad: #ff7a73; --bad-bg: #3b1a1a; --chip: #252c3f; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, "Segoe UI", Arial, sans-serif; background: var(--bg); color: var(--ink); }
header.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top h1 { font-size: 18px; margin: 0; }
header.top .spacer { flex: 1; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
section.card, .card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.strong { color: var(--ink); font-weight: 700; }
input, select { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
input[type=checkbox] { width: auto; }
input[dir=ltr] { text-align: left; }
input[readonly] { background: var(--chip); cursor: default; }
button { font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; background: var(--brand); color: var(--brand-ink); white-space: nowrap; }
button.secondary { background: var(--chip); color: var(--ink); border-color: var(--line); }
button.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
button.link { background: none; color: var(--brand); padding: 0; border: 0; text-decoration: underline; }
button.big { font-size: 17px; padding: 14px 22px; }
button:disabled { opacity: .5; cursor: default; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: start; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: var(--chip); position: sticky; top: 0; }
.scroll { overflow-x: auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.tabs button.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.stat { background: var(--chip); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 24px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--chip); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.dots { display: inline-flex; gap: 2px; font-family: ui-monospace, monospace; font-size: 12px; }
.dots span { width: 16px; text-align: center; border-radius: 3px; background: var(--chip); color: var(--muted); }
.dots span.on { background: var(--ok-bg); color: var(--ok); }
.hidden { display: none !important; }
.center-box { max-width: 420px; margin: 60px auto; }
.err { color: var(--bad); min-height: 1.4em; }
.okmsg { color: var(--ok); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); color: #fff; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; padding: 20px; width: min(560px, 100%); max-height: 90vh; overflow: auto; }
.modal h2 { display: flex; justify-content: space-between; align-items: center; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 22px; text-align: center; cursor: pointer; color: var(--muted); }
.drop.active { border-color: var(--brand); color: var(--brand); }
.qr-preview { max-width: 200px; max-height: 200px; display: block; margin: 10px auto; }

/* user work screen */
.timer { font: 700 26px ui-monospace, monospace; padding: 4px 14px; border-radius: 8px; background: var(--chip); }
.timer.low { background: var(--bad-bg); color: var(--bad); }
.svc-table input { width: 100%; min-width: 200px; padding: 6px 8px; }
.svc-table td.name { font-weight: 700; white-space: nowrap; }
.pw { display: flex; gap: 4px; }
.pw input { flex: 1; }
.pw button { padding: 4px 8px; }
.totp-code { font: 700 18px ui-monospace, monospace; letter-spacing: 2px; cursor: pointer; background: var(--chip); border: 0; color: var(--ink); padding: 4px 10px; }
.totp-left { font-size: 11px; color: var(--muted); display: block; }
.cookie-ok { color: var(--ok); font-size: 13px; }
.cookie-ok b { font-size: 16px; }
.saved-flash { animation: flash 1s; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--ok); } to { box-shadow: none; } }
.lock-overlay { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 30; text-align: center; padding: 16px; }
.lang-select { width: auto; padding: 5px 8px; font-size: 13px; }

/* FaceMaker user number with − / + buttons */
.stepper { display: flex; gap: 6px; align-items: stretch; }
.stepper input { flex: 1; min-width: 0; text-align: center; font-variant-numeric: tabular-nums; }
.stepper button { min-width: 2.5em; font-size: 1.15em; padding-inline: 0; }

/* Admin: use the full window width; entities table sorting / selection */
body.wide main { max-width: none; }
.nowrap { white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
.ent-table tr.selected td { background: var(--chip); }
a.btn { display: inline-flex; align-items: center; text-decoration: none; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; white-space: nowrap; }
a.btn.secondary { background: var(--chip); color: var(--ink); border-color: var(--line); }
a.btn.disabled { pointer-events: none; opacity: .5; }

/* operator guide popup; printing it ("Download PDF") shows only the guide */
.modal.guide { width: min(900px, 100%); }
.guide-actions { justify-content: flex-end; margin-bottom: 8px; }
.guide-actions select { width: auto; }
.guide-body h1 { font-size: 24px; margin: 0; }
.guide-body h2 { font-size: 19px; margin: 26px 0 8px; padding-bottom: 4px; border-bottom: 2px solid var(--brand); }
.guide-body h3 { font-size: 16px; margin: 18px 0 6px; }
.guide-subtitle { margin-top: 2px; font-size: 16px; }
.guide-step { margin: 6px 0; }
.guide-note { background: var(--chip); border-inline-start: 4px solid var(--brand); padding: 8px 12px; border-radius: 6px; }
.guide-body pre { background: var(--chip); padding: 8px 12px; border-radius: 6px; white-space: pre-wrap; font: 14px ui-monospace, monospace; }
.guide-body figure { margin: 12px 0; text-align: center; }
.guide-body figure img { max-width: 100%; max-height: 420px; border: 1px solid var(--line); border-radius: 6px; }
.guide-body figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }
.guide-body td, .guide-body th { font-size: 14px; }
@media print {
  body.print-guide { background: #fff; color: #000; }
  body.print-guide > *:not(.modal-bg) { display: none !important; }
  body.print-guide .modal-bg { position: static; background: none; padding: 0; display: block; }
  body.print-guide .modal { width: auto; max-height: none; overflow: visible; padding: 0; border-radius: 0; }
  body.print-guide .modal > h2, body.print-guide .guide-actions { display: none; }
  body.print-guide .guide-body h2 { break-after: avoid; }
  body.print-guide .guide-body figure, body.print-guide .guide-note, body.print-guide tr { break-inside: avoid; }
  body.print-guide .scroll { overflow: visible; }
}

/* Tour of the user page: a red frame around the place to act (clicks go through it) and the instruction box. */
.tour-ring { position: fixed; z-index: 20; pointer-events: none; border: 3px solid #e02424; border-radius: 12px;
  box-shadow: 0 0 0 4px rgba(224,36,36,.25), 0 0 0 9999px rgba(0,0,0,.28); animation: tour-pulse 1.4s ease-in-out infinite;
  transition: left .2s, top .2s, width .2s, height .2s; }
@keyframes tour-pulse { 50% { box-shadow: 0 0 0 10px rgba(224,36,36,.12), 0 0 0 9999px rgba(0,0,0,.28); } }
.tour-box { position: fixed; z-index: 21; width: min(360px, calc(100vw - 16px)); background: var(--panel); color: var(--ink);
  border: 2px solid #e02424; border-radius: 12px; padding: 12px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.25); }
.tour-box button.ok { background: var(--ok); color: #fff; }
@media print { .tour-ring, .tour-box { display: none; } }
