:root {
  --bg: #121012; --bg-elev: #1b1719; --bg-elev-2: #241f22;
  --border: #33292c; --red: #b0141f; --red-bright: #e21b28;
  --text: #f2e9ea; --text-dim: #b7a8ab; --text-faint: #7d6d70;
  --ok: #3fae60;
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font-body); min-height: 100vh; padding-bottom: 40px; }

header.top {
  background: linear-gradient(180deg, var(--bg-elev) 0%, var(--bg) 100%);
  border-bottom: 2px solid var(--red);
  padding: 20px 16px 12px; text-align: center; position: sticky; top: 0; z-index: 20;
}
header.top .logo {
  position: absolute;
  top: 12px;
  left: 16px;
  margin: 0;
  display: block;
  width: 10px;
  height: 10px;
  object-fit: contain;
  border-radius: 10px;
}
header.top h1 {
  font-family: var(--font-display); letter-spacing: 3px; text-transform: uppercase;
  font-size: clamp(20px, 5vw, 28px); margin: 0 0 2px; color: var(--red-bright);
  text-shadow: 0 0 18px rgba(226,27,40,0.35);
}
header.top p.sub { margin: 0 0 12px; color: var(--text-faint); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }

nav.tabs { display: flex; gap: 8px; max-width: 460px; margin: 0 auto 10px; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px; flex-wrap: wrap; }
nav.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--text-dim); padding: 8px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
nav.tabs a.active { background: var(--red); color: #fff; }

.session-bar { max-width: 460px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-faint); }
.session-bar .link-sair { color: var(--red-bright); text-decoration: none; font-weight: 600; }
.session-bar-deslogado { position: absolute; top: 12px; right: 16px; max-width: none; margin: 0; }
.link-sair { font-size: 12.5px; color: var(--text-faint); text-decoration: none; }
.link-sair:hover { color: var(--red-bright); }

main { max-width: 720px; margin: 0 auto; padding: 18px 16px 60px; }

.rodape-sistema {
  text-align: center;
  padding: 16px 16px 20px;
  font-size: 11px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.auth-card { max-width: 380px; margin: 30px auto; }

h2.section-title {
  font-family: var(--font-display); font-size: 18px; letter-spacing: 1px; margin: 0 0 14px;
  color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 8px;
}
.hint-block { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; }
.status-banner { background: var(--bg-elev-2); border: 1px solid var(--border); border-left: 3px solid var(--red); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--text-dim); margin-bottom: 16px; line-height: 1.5; }

/* Photo */
.photo-block { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 20px; }
.photo-frame { width: 148px; height: 148px; border-radius: 50%; border: 3px solid var(--red); background: var(--bg-elev-2); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }
.photo-frame .placeholder { font-size: 40px; color: var(--text-faint); }
.photo-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.photo-actions button, .photo-actions label { font-size: 12.5px; }

video#camera-video { width: 100%; max-width: 360px; border-radius: var(--radius); border: 1px solid var(--border); background: #000; }
.camera-modal { position: fixed; inset: 0; background: rgba(5,3,4,0.9); z-index: 100; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; padding: 20px; }
.camera-modal-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.camera-btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Form */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
.field .req { color: var(--red-bright); }
.field input, .field select {
  width: 100%; background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: 8px; font-size: 15px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--red); }
.field small.hint { display: block; margin-top: 5px; font-size: 11.5px; color: var(--text-faint); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .row2 { grid-template-columns: 1fr; } }

fieldset.emergency { border: 1px dashed var(--border); border-radius: 8px; padding: 14px 14px 2px; margin: 18px 0 14px; }
fieldset.emergency legend { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--red-bright); font-weight: 700; padding: 0 6px; }

.btn {
  display: inline-block; border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text);
  padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  text-decoration: none; text-align: center;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-bright); }
.btn.danger { background: transparent; color: var(--red-bright); border-color: var(--red); }
.btn.block { display: block; width: 100%; padding: 13px; font-size: 15px; margin-top: 6px; }

.msg { font-size: 13px; margin-top: 10px; padding: 10px 12px; border-radius: 8px; display: none; }
.msg.show { display: block; }
.msg.ok { background: rgba(63,174,96,0.12); color: var(--ok); border: 1px solid rgba(63,174,96,0.3); }
.msg.err { background: rgba(226,27,40,0.1); color: #ff8a8f; border: 1px solid rgba(226,27,40,0.35); }

/* List */
.list-toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.search-form { display: flex; gap: 8px; flex: 1; }
.search-form input { flex: 1; background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.count-pill { background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-dim); font-size: 12.5px; padding: 9px 12px; border-radius: 8px; white-space: nowrap; }

.members-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.member-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 10px; text-align: center; text-decoration: none; color: var(--text); display: block; }
.member-card:hover { border-color: var(--red); }
.member-card .thumb { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 10px; overflow: hidden; background: var(--bg-elev-2); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--text-faint); }
.member-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.member-card .name { font-weight: 700; font-size: 13.5px; line-height: 1.3; }
.member-card .apelido { color: var(--red-bright); font-size: 12px; margin-top: 2px; }
.member-card .subsede { color: var(--text-faint); font-size: 11px; margin-top: 4px; }

.empty-state { text-align: center; padding: 40px 10px; color: var(--text-faint); font-size: 14px; }

/* Dashboard / painel inicial */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dashboard-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px 14px; text-decoration: none; color: var(--text);
}
.dashboard-tile:hover { border-color: var(--red); }
.dashboard-icon { font-size: 30px; margin-bottom: 4px; }
.dashboard-label { font-weight: 700; font-size: 14.5px; }
.dashboard-desc { font-size: 12px; color: var(--text-faint); }

/* Página de entrada (login ou autocadastro) */
.landing-card { max-width: 460px; margin: 20px auto 0; }
.landing-choices { display: flex; flex-direction: column; gap: 12px; }
.landing-btn {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 16px; text-decoration: none; color: var(--text);
}
.landing-btn:hover { border-color: var(--red); }
.landing-icon { font-size: 32px; margin-bottom: 4px; }
.landing-label { font-weight: 700; font-size: 16px; }
.landing-desc { font-size: 12.5px; color: var(--text-faint); }

.link-voltar { display: inline-block; margin-top: 14px; font-size: 12.5px; color: var(--text-faint); text-decoration: none; }
.link-voltar:hover { color: var(--red-bright); }

/* Detail */
.detail-card { max-width: 480px; margin: 0 auto; }
.modal-photo { width: 100px; height: 100px; border-radius: 50%; margin: 0 auto 16px; border: 3px solid var(--red); overflow: hidden; background: var(--bg-elev-2); display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--text-faint); }
.modal-photo img { width: 100%; height: 100%; object-fit: cover; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.detail-row:last-of-type { border-bottom: none; }
.detail-row .k { color: var(--text-faint); }
.detail-row .v { color: var(--text); text-align: right; font-weight: 600; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions form { flex: 1; }

/* Users */
.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-row { display: flex; justify-content: space-between; align-items: center; background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; gap: 10px; }
.user-row-nome { font-weight: 700; font-size: 14px; }
.user-row-login { color: var(--text-faint); font-size: 12px; }
.tag { font-size: 10.5px; padding: 2px 7px; border-radius: 999px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.tag-admin { background: rgba(226,27,40,0.18); color: var(--red-bright); }
.tag-cadastro { background: rgba(63,174,96,0.15); color: var(--ok); }
.tag-leitura { background: rgba(183,168,171,0.15); color: var(--text-dim); }
.hint-inline { color: var(--text-faint); font-size: 12px; }
