:root {
  --bg: #0e1013;
  --surface: #171a1f;
  --surface-2: #20242b;
  --line: #2c3139;
  --text: #f1f3f5;
  --muted: #9aa3ad;
  --accent: #ff7a45;
  --accent-ink: #1a0d06;
  --ok: #4cc38a;
  --danger: #ff5c5c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  padding: 10px 16px; border-radius: 999px; cursor: pointer; text-decoration: none;
  font-weight: 600; font-size: 15px; white-space: nowrap; transition: background .15s, transform .05s;
}
.btn:hover { background: #2a2f37; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #ff8e60; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(255, 92, 92, .4); background: transparent; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn svg { width: 18px; height: 18px; flex: none; }

/* formulários */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; color: var(--muted); font-weight: 600; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); outline: none;
}
.input:focus { border-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }

/* ---------- página inicial ---------- */
.home { max-width: 560px; margin: 0 auto; padding: 56px 18px 80px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; margin-bottom: 40px; }
.brand-dot { width: 26px; height: 26px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); }
.brand-dot svg { width: 16px; height: 16px; }
.home h1 { font-size: clamp(30px, 6vw, 42px); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 14px; }
.home .lead { color: var(--muted); font-size: 18px; margin: 0 0 30px; }
.points { display: grid; gap: 10px; margin: 0 0 30px; padding: 0; list-style: none; }
.points li { display: flex; gap: 10px; color: #cfd5db; }
.points li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 9px; border-radius: 50%; background: var(--accent); }
.result h2 { margin: 0 0 6px; font-size: 22px; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; margin: 6px 0 16px; }
.linkbox code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.warn { background: rgba(255, 122, 69, .1); border: 1px solid rgba(255, 122, 69, .35); color: #ffc4a8; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 16px; }
.qr-mini { width: 180px; background: #fff; border-radius: 10px; padding: 6px; display: block; margin: 8px 0 18px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.my-events { margin-top: 40px; }
.my-events h3 { font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.my-events a { display: flex; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; text-decoration: none; background: var(--surface); }

/* ---------- página do evento ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(14, 16, 19, .88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.ev-title { flex: 1; min-width: 0; }
.ev-title h1 { font-size: 20px; margin: 0; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-title .stats { font-size: 13px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }
@media (max-width: 640px) { .top-actions .label { display: none; } .top-actions .btn { padding: 10px; } }

.adminbar { background: #1d1a17; border-bottom: 1px solid #3a2c22; }
.adminbar .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
.adminbar .tag { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-right: 6px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 600; padding: 6px 10px; }
.switch input { width: 38px; height: 22px; appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 19px; }

.banner { margin: 16px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 14px; }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 16px 0 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip.on b { color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; padding-bottom: 140px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 2px; } .grid-wrap { padding: 0 2px; } }
.tile { position: relative; aspect-ratio: 1; background: var(--surface); overflow: hidden; cursor: pointer; border-radius: 4px; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s, opacity .2s; }
.tile:hover img { transform: scale(1.03); }
.tile .badge { position: absolute; bottom: 6px; left: 6px; background: rgba(0, 0, 0, .6); border-radius: 6px; padding: 2px 6px; font-size: 11px; font-weight: 700; }
.tile .check { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, .25); display: none; }
.selecting .tile .check { display: block; }
.tile.sel .check { background: var(--accent); border-color: var(--accent); }
.tile.sel .check::after { content: ""; position: absolute; left: 7px; top: 3px; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.tile.sel img { opacity: .7; transform: scale(.92); }

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 0 0 8px; }

/* barra inferior */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; }
.dock > * { pointer-events: auto; }
.fab { box-shadow: var(--shadow); padding: 15px 26px; font-size: 17px; }
.selbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 10px 12px; box-shadow: var(--shadow); max-width: 100%; }
.selbar .count { font-weight: 700; padding: 0 6px; }

/* painel de envios */
.uploads { position: fixed; z-index: 40; right: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); width: min(380px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.uploads header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.uploads header strong { flex: 1; font-size: 15px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.uploads .total { padding: 10px 14px; }
.uploads ul { list-style: none; margin: 0; padding: 0 0 6px; max-height: 260px; overflow: auto; }
.uploads li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 14px; font-size: 13px; }
.uploads li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads li .st { color: var(--muted); }
.uploads li .st.ok { color: var(--ok); }
.uploads li .st.err { color: var(--danger); }
.uploads li .progress { grid-column: 1 / -1; height: 3px; }

/* janelas */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .65); display: grid; place-items: center; padding: 16px; }
.modal .card { width: min(440px, 100%); box-shadow: var(--shadow); }
.modal h2 { margin: 0 0 6px; font-size: 22px; }
.modal p { margin: 0 0 18px; color: var(--muted); }
.modal .qr-big { width: 100%; max-width: 320px; display: block; margin: 0 auto 14px; background: #fff; border-radius: 12px; padding: 8px; }

/* visualizador */
.lightbox { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.lb-top, .lb-bottom { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(0, 0, 0, .6); }
.lb-top { padding-top: calc(10px + env(safe-area-inset-top)); }
.lb-bottom { padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; justify-content: center; }
.lb-info { flex: 1; min-width: 0; font-size: 14px; }
.lb-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-info span { color: var(--muted); font-size: 13px; }
.lb-stage { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; touch-action: pan-y; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0, 0, 0, .45); border: 0; width: 46px; height: 46px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.lb-nav svg { width: 22px; height: 22px; }
.lb-prev { left: 12px; } .lb-next { right: 12px; }
@media (hover: none) { .lb-nav { display: none; } }
.icon-btn { background: transparent; border: 0; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); }
.icon-btn svg { width: 22px; height: 22px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- PIN ---------- */
.lock { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 24px 16px 80px; }
.lock-card { width: min(380px, 100%); text-align: center; }
.lock-icon { width: 64px; height: 64px; border-radius: 20px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 18px; color: var(--accent); }
.lock-icon svg { width: 30px; height: 30px; }
.lock h1 { font-size: 26px; margin: 0 0 4px; line-height: 1.2; }
.lock p { margin: 0 0 18px; }
.pin-input { text-align: center; font-size: 30px; letter-spacing: .4em; padding: 14px; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.lock-err { color: var(--danger); font-weight: 600; margin: 12px 0 0 !important; }
.pinbox { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.pinbox code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 16px; letter-spacing: .15em; font-weight: 700; }
.qr-pin { font-size: 15px; color: var(--text) !important; }
.qr-pin b { font-size: 22px; letter-spacing: .2em; }

/* ---------- app instalável ---------- */
.installbar { background: #1c1712; border-bottom: 1px solid #3a2c22; }
.installbar .wrap { display: flex; align-items: center; gap: 10px; padding-top: 8px; padding-bottom: 8px; font-size: 14px; }
.installbar img { width: 34px; height: 34px; border-radius: 9px; }
.installbar span { flex: 1; }
.install-steps { text-align: left; padding-left: 22px; margin: 0 0 20px; display: grid; gap: 10px; }

/* ---------- ecrã inicial da app ---------- */
.apphome { max-width: 640px; padding-top: 18px; padding-bottom: 60px; }
.installcard { display: flex; align-items: center; gap: 12px; background: #1c1712; border: 1px solid #3a2c22; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.installcard img { width: 44px; height: 44px; border-radius: 11px; }
.installcard > div { flex: 1; }
.evlist { display: grid; gap: 10px; margin-bottom: 22px; }
.evcard { display: flex; align-items: center; gap: 14px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; position: relative; }
.evcover { width: 72px; height: 72px; flex: none; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.evcover img { width: 100%; height: 100%; object-fit: cover; }
.evcover svg { width: 28px; height: 28px; }
.evbody { flex: 1; min-width: 0; display: grid; gap: 2px; }
.evbody strong { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evbody .muted { font-size: 14px; }
.evtag { justify-self: start; font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--accent); }
.evrm { color: var(--muted); flex: none; }
.joincard h3 { margin: 0 0 12px; font-size: 17px; }
.joinrow { display: flex; gap: 8px; }
.joinrow .input { flex: 1; min-width: 0; }
.scanvideo { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 1; object-fit: cover; }
.bigpin { font-size: 40px; font-weight: 800; letter-spacing: .25em; font-variant-numeric: tabular-nums; color: var(--accent); }
