:root {
  color-scheme: light;
  --ink: #102a43;
  --muted: #627d98;
  --line: #d9e2ec;
  --paper: #ffffff;
  --wash: #f0f4f8;
  --brand: #176b87;
  --brand-dark: #0b4f6c;
  --ok: #13795b;
  --ok-bg: #d9fbe8;
  --warn: #9a6700;
  --warn-bg: #fff1c2;
  --bad: #c62828;
  --bad-bg: #ffe2e0;
  --shadow: 0 12px 35px rgba(16, 42, 67, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--wash); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--brand-dark); }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.shell { width: min(1100px, 100%); margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.topbar h1 { margin: 0; font-size: clamp(1.25rem, 5vw, 1.8rem); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 4px 15px rgba(16,42,67,.05); }
.card h2 { margin: 0 0 14px; font-size: 1.1rem; }
.button, button { border: 0; border-radius: 11px; padding: 12px 16px; background: var(--brand); color: white; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button:hover, button:hover { background: var(--brand-dark); }
.button.secondary, button.secondary { color: var(--ink); background: #e6eef4; }
.button.danger, button.danger { background: var(--bad); }
.button.danger-outline, button.danger-outline { color: var(--bad); background: white; box-shadow: inset 0 0 0 1px #ef9a9a; }
.button.small, button.small { padding: 8px 11px; font-size: .88rem; }
.icon-button { width: 42px; height: 42px; padding: 0; }
label { display: grid; gap: 6px; color: var(--ink); font-weight: 650; }
input, select { width: 100%; min-height: 46px; border: 1px solid #bcccdc; border-radius: 10px; padding: 10px 12px; background: white; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgba(23, 107, 135, .18); border-color: var(--brand); }
.form-stack { display: grid; gap: 14px; }
.error { color: var(--bad); font-weight: 650; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #d7f0f2, var(--wash) 55%); }
.login-card { width: min(420px, 100%); padding: 30px; background: white; border-radius: 22px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; }
.login-card button { width: 100%; margin-top: 4px; }
.staff-body { background: linear-gradient(180deg, #081a27 0, #102f42 190px, var(--wash) 190px); }
.staff-shell { width: min(1180px, 100%); }
.staff-grid { display: grid; gap: 16px; }
.staff-topbar { color: white; }
.staff-topbar .muted { color: #b9d3df; }
.staff-brand { min-width: 0; }
.staff-brand h1 { max-width: 780px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { display: block; margin-bottom: 3px; color: #8fd1e5; font-size: .72rem; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.session-name { display: inline-block; margin-top: 3px; font-size: .78rem; }
.scanner-card { padding: 10px; overflow: hidden; border-color: rgba(255,255,255,.25); box-shadow: 0 14px 35px rgba(4,20,30,.22); }
.scanner-heading { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 4px 5px 9px; }
.scanner-heading h2 { margin: 0; font-size: 1.2rem; }
.scanner-hint { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--brand-dark); background: #dff4fa; font-weight: 900; }
.camera-state { display: flex; align-items: center; gap: 6px; margin: 3px 0 0; color: var(--muted); font-size: .78rem; font-weight: 700; }
.camera-dot { width: 8px; height: 8px; border-radius: 50%; background: #9fb3c8; }
.camera-dot.active { background: #16b47f; box-shadow: 0 0 0 4px rgba(22,180,127,.16); }
.scanner-stage { position: relative; width: 100%; height: min(calc(100svh - 260px), calc(100vw - 52px)); min-height: 280px; max-height: 520px; overflow: hidden; border-radius: 16px; background: #071620; isolation: isolate; }
#reader { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; background: #071620; transition: opacity .15s ease; }
.scanner-stage:not(.active) #reader { opacity: 0; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover !important; }
#reader > div { border: 0 !important; }
#reader__scan_region { min-height: 100% !important; }
#reader__dashboard, #reader__dashboard_section { display: none !important; }
.camera-idle { position: absolute; z-index: 3; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; padding: 24px; color: white; text-align: center; background: radial-gradient(circle at 50% 35%, #17475f, #071620 72%); }
.camera-idle span { max-width: 270px; color: #b9d3df; font-size: .88rem; }
.camera-icon { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 4px; border: 2px solid #72c2dc; border-radius: 50%; color: #8fd1e5; font-size: 1.8rem; }
.camera-start { min-width: 190px; min-height: 50px; margin-top: 12px; font-size: 1.02rem; }
.scanner-stop { position: absolute; z-index: 6; top: 10px; right: 10px; min-height: 40px; padding: 8px 13px; color: white; background: rgba(7,22,32,.78); border: 1px solid rgba(255,255,255,.55); backdrop-filter: blur(8px); }
.scan-frame { display: none; position: absolute; z-index: 5; left: 50%; top: 50%; width: min(66%, 270px); aspect-ratio: 1; transform: translate(-50%,-50%); pointer-events: none; }
.scanner-stage.active .scan-frame { display: block; }
.scan-frame span { position: absolute; width: 32px; height: 32px; border-color: white; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }
.scan-frame span:nth-child(1) { top: 0; left: 0; border-top: 4px solid white; border-left: 4px solid white; border-radius: 8px 0 0; }
.scan-frame span:nth-child(2) { top: 0; right: 0; border-top: 4px solid white; border-right: 4px solid white; border-radius: 0 8px 0 0; }
.scan-frame span:nth-child(3) { bottom: 0; left: 0; border-bottom: 4px solid white; border-left: 4px solid white; border-radius: 0 0 0 8px; }
.scan-frame span:nth-child(4) { right: 0; bottom: 0; border-right: 4px solid white; border-bottom: 4px solid white; border-radius: 0 0 8px; }
.scanner-help { min-height: 19px; text-align: center; margin: 9px 4px 7px; color: var(--muted); font-size: .82rem; }
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
.quick-actions button { min-width: 0; min-height: 44px; padding: 8px 5px; font-size: .82rem; }
.result-banner { position: fixed; z-index: 50; inset: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom)); display: grid; place-content: center; text-align: center; border-radius: 24px; box-shadow: var(--shadow); padding: 28px; animation: pop .15s ease-out; }
.result-banner.ok { background: var(--ok-bg); color: #07583e; border: 4px solid var(--ok); }
.result-banner.warn { background: var(--warn-bg); color: #734d00; border: 4px solid #d9a400; }
.result-banner.bad { background: var(--bad-bg); color: #8f1d1d; border: 4px solid var(--bad); }
.result-icon { font-size: 4.2rem; line-height: 1; }
.result-banner h2 { font-size: clamp(2rem, 10vw, 4rem); margin: 10px 0; }
.result-name { font-size: clamp(1.4rem, 7vw, 2.5rem); font-weight: 800; }
.result-time { margin-top: 8px; font-size: 1.05rem; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.people-list { display: grid; gap: 8px; margin-top: 12px; }
.person { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 11px; }
.person-name { font-weight: 800; }
.person-meta { color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.professional-meta { margin-top: 3px; color: var(--brand-dark); font-size: .82rem; font-weight: 700; overflow-wrap: anywhere; }
.person-time { color: var(--ok); font-weight: 700; font-size: .84rem; }
.two-col { display: grid; gap: 16px; }
.recent-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.recent-head h2 { margin: 0; }
.live-label { flex: 0 0 auto; color: var(--muted); font-size: .78rem; }
.section-note { margin: 8px 0 0; font-size: .88rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 5px; }
dialog { border: 0; border-radius: 18px; padding: 0; width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 26, 39, .62); }
.dialog-inner { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.dialog-head h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.check-label { display: flex; grid-template-columns: auto 1fr; align-items: center; }
.check-label input { width: 20px; min-height: 20px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
.stat-value { display: block; font-size: 1.7rem; font-weight: 850; }
.stat-label { color: var(--muted); font-size: .85rem; }
.admin-grid { display: grid; gap: 16px; }
.admin-grid > * { min-width: 0; }
.sync-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-pill { padding: 4px 9px; border-radius: 99px; font-size: .8rem; font-weight: 800; background: #e6eef4; }
.status-pill.ok { color: var(--ok); background: var(--ok-bg); }
.status-pill.bad { color: var(--bad); background: var(--bad-bg); }
.toolbar { display: grid; gap: 8px; margin: 12px 0; }
.toolbar .export-button { white-space: nowrap; }
.badge-note { margin: -4px 0 12px; color: var(--muted); font-size: .78rem; }
.badge-background-help { margin: 4px 0 0; }
.settings-dialog { width: min(920px, calc(100% - 24px)); }
.settings-dialog h3 { margin: 0 0 5px; }
.badge-designer-grid { display: grid; gap: 18px; align-items: center; }
.badge-upload-controls { display: grid; gap: 9px; align-content: start; }
.badge-upload-controls > label { font-weight: 800; }
.badge-upload-controls input[type="file"] { min-height: 52px; padding: 9px; }
.badge-upload-controls input[type="file"]::file-selector-button { margin-right: 10px; border: 0; border-radius: 8px; padding: 8px 10px; color: var(--ink); background: #e6eef4; font-weight: 750; }
.badge-upload-controls .badge-note { margin: -2px 0 0; }
.badge-designer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-designer-actions button { min-height: 46px; }
.badge-preview-frame { display: grid; place-items: center; width: 100%; aspect-ratio: 1011 / 638; overflow: hidden; border: 1px dashed #9fb3c8; border-radius: 13px; background: #f5f8fa; }
.badge-preview-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
#badge-background-status { min-height: 1.3em; margin: 0; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 750px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 8px; vertical-align: top; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table-actions { display: flex; align-items: flex-start; gap: 6px; flex-wrap: nowrap; }
th:last-child, td:last-child { width: 100px; min-width: 100px; }
.icon-action { width: 38px; height: 38px; padding: 8px; border-radius: 10px; }
.icon-action svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.edit-action { color: var(--brand-dark); background: #e6eef4; }
.remove-action { color: white; background: var(--bad); }
.attendance-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inactive-row { background: #fff7f7; }
.pass-body { min-height: 100vh; display: grid; place-items: center; padding: 18px; background: radial-gradient(circle at top, #d7f0f2, #edf2f7 60%); }
.pass-card { width: min(520px, 100%); background: white; border-radius: 26px; padding: 30px 22px; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--line); }
.pass-card h1 { margin: 14px 0 6px; font-size: clamp(1.8rem, 8vw, 2.6rem); }
.pass-card h2 { margin: 0 0 16px; color: var(--brand-dark); font-size: clamp(1.4rem, 6vw, 2rem); }
.pass-badge { display: inline-block; color: var(--ok); background: var(--ok-bg); border-radius: 99px; padding: 7px 12px; font-weight: 850; font-size: .8rem; letter-spacing: .04em; }
.pass-qr { display: block; width: min(360px, 100%); margin: 0 auto; border-radius: 12px; }
.pass-instruction { font-weight: 750; font-size: 1.08rem; }
.toast { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%; width: max-content; max-width: calc(100% - 24px); transform: translateX(-50%); z-index: 100; padding: 12px 18px; border-radius: 10px; color: white; background: #243b53; box-shadow: var(--shadow); text-align: center; }
@media (max-width: 520px) {
  input, select { font-size: 16px; }
  .staff-shell { padding: max(8px, env(safe-area-inset-top)) 8px max(12px, env(safe-area-inset-bottom)); }
  .staff-topbar { min-height: 54px; margin-bottom: 7px; padding: 0 3px; }
  .staff-brand h1 { max-width: calc(100vw - 145px); font-size: .98rem; }
  .session-name { display: none; }
  .top-actions { gap: 5px; }
  .top-actions .small { min-height: 42px; padding: 8px 10px; }
  .settings-button { width: 42px; padding-inline: 0 !important; font-size: 1.05rem; }
  .settings-label { display: none; }
  .scanner-card { padding: 7px; border-radius: 16px; }
  .scanner-heading { min-height: 46px; padding: 2px 4px 7px; }
  .scanner-heading h2 { font-size: 1.08rem; }
  .scanner-hint { width: 34px; height: 34px; font-size: .85rem; }
  .scanner-stage { height: min(calc(100svh - 248px), calc(100vw - 30px)); min-height: 278px; border-radius: 13px; }
  .scanner-help { margin: 7px 3px 5px; font-size: .76rem; }
  .staff-tools { scroll-margin-top: 8px; }
  #search-panel, #recent-panel { scroll-margin-top: 8px; }
  .search-row { grid-template-columns: 1fr; }
  .person { grid-template-columns: 1fr; }
  .person > button { width: 100%; min-height: 42px; }
  .dialog-inner { padding: 18px 16px max(18px, env(safe-area-inset-bottom)); }
  .dialog-actions { display: grid; grid-template-columns: 1fr; }
  .dialog-actions button { width: 100%; min-height: 46px; }
  .result-icon { font-size: 3.5rem; }
  .result-banner h2 { font-size: clamp(1.8rem, 10vw, 3rem); }
}
@media (max-width: 759px) {
  .admin-grid .wide { padding: 13px; }
  .badge-designer-actions { display: grid; grid-template-columns: 1fr; }
  .badge-designer-actions button { width: 100%; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar input, .toolbar select { grid-column: 1 / -1; }
  .toolbar button, .toolbar .export-button { width: 100%; min-height: 46px; padding-inline: 8px; }
  .toolbar .badge-download { grid-column: 1 / -1; width: 100%; min-height: 46px; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  table { min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tbody { display: grid; gap: 11px; }
  tbody tr { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: white; }
  tbody tr.inactive-row { background: #fff7f7; }
  tbody td { display: grid; grid-template-columns: minmax(95px, 34%) 1fr; gap: 9px; padding: 10px 11px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
  tbody td:last-child { border-bottom: 0; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: .7rem; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
  tbody td[data-label="Ações"] { grid-template-columns: 1fr; }
  tbody td[data-label="Ações"]::before { margin-bottom: -2px; }
  .table-actions { display: flex; justify-content: flex-end; }
  .table-actions button { min-height: 42px; }
}
@media (min-width: 760px) {
  .staff-grid { grid-template-columns: minmax(380px, 1.15fr) minmax(320px, .85fr); align-items: start; }
  .scanner-card { position: sticky; top: 16px; }
  .two-col { grid-template-columns: 1fr 1fr; }
  .staff-tools { grid-template-columns: 1fr; }
  .scanner-stage { height: min(520px, calc(100vh - 220px)); min-height: 360px; }
  .stats { grid-template-columns: repeat(5, 1fr); }
  .admin-grid { grid-template-columns: 1fr 1fr; }
  .admin-grid .wide { grid-column: 1 / -1; }
  .badge-designer-grid { grid-template-columns: minmax(260px, .72fr) minmax(420px, 1.28fr); }
  .toolbar { grid-template-columns: minmax(230px, 1fr) minmax(160px, 200px) auto auto auto; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .staff-shell { padding-top: 6px; }
  .staff-topbar { min-height: 42px; margin-bottom: 5px; }
  .eyebrow, .session-name { display: none; }
  .scanner-heading { min-height: 38px; }
  .scanner-stage { height: calc(100svh - 178px); min-height: 220px; }
  .scanner-help { margin: 4px 2px; }
}
