* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --navy: #1C2B5A;
    --navy-dk: #131f42;
    --gold: #D4A017;
    --ivory: #FAF7F0;
    --ivory-dk: #F0E8D4;
    --muted: #5A5040;
    --white: #FFFEF9;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #f59e0b;
    --shadow: 0 2px 10px rgba(28, 43, 90, 0.08);
}

html, body { height: 100%; max-width: 100%; overflow-x: hidden; }
body {
    font-family: 'Lora', serif;
    background: var(--ivory);
    color: var(--muted);
    line-height: 1.6;
}

h1, h2, h3, h4 { font-family: 'Playfair Display', serif; color: var(--navy); font-weight: 600; }
a { color: var(--navy); }

/* ── LOGIN ── */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--ivory-dk); padding: 24px;
}
.login-card {
    background: var(--white); border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35); text-align: center;
}
.login-card img { width: clamp(120px, 32vw, 160px); height: clamp(120px, 32vw, 160px); margin-bottom: 20px; }
.login-card h1 { font-size: clamp(1.3rem, 4vw, 1.6rem); margin-bottom: 4px; }
.login-card .sub { font-family: 'Cinzel', serif; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); margin-bottom: 28px; }
.login-card form { text-align: left; }
@media (max-width: 480px) {
    .login-card { padding: 32px 22px; }
}

/* ── LAYOUT APP ── */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: var(--ivory-dk); color: var(--navy); flex-shrink: 0;
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
    overflow-y: auto; z-index: 20; transition: transform 0.2s;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(28,43,90,0.12); }
.sidebar .brand img { width: 64px; height: 64px; flex-shrink: 0; }
.sidebar .brand span { font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.08em; line-height: 1.4; color: var(--navy); text-transform: uppercase; flex: 1; }
.sidebar-close { display: none; background: none; border: none; color: var(--navy); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.sidebar-backdrop { display: none; }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: rgba(28,43,90,0.65);
    text-decoration: none; font-size: 0.88rem; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(212,160,23,0.12); color: var(--navy); }
.sidebar nav a.active { background: rgba(212,160,23,0.22); border-left-color: var(--gold); color: var(--navy); font-weight: 600; }
.sidebar .rodape { padding: 16px 20px; border-top: 1px solid rgba(28,43,90,0.12); font-size: 0.78rem; }
.sidebar .rodape .nome { color: var(--navy); font-weight: 600; }
.sidebar .rodape .perfil { color: rgba(28,43,90,0.55); font-family: 'Cinzel', serif; font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }
.sidebar .rodape button { margin-top: 10px; width: 100%; }

.main { flex: 1; min-width: 0; margin-left: 240px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    background: var(--white); border-bottom: 1px solid rgba(212,160,23,0.2); padding: 16px 28px;
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 1.3rem; flex: 1; min-width: 0; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; color: var(--navy); cursor: pointer; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-user { font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
.content { padding: 28px; flex: 1; min-width: 0; }

@media (max-width: 600px) {
    .topbar-user { display: none; }
}

@media (max-width: 860px) {
    .sidebar {
        transform: translateX(-100%); box-shadow: 0 0 30px rgba(0,0,0,0.3);
        z-index: 30; transition: transform 0.25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: block; }
    .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(19,31,66,0.5);
        z-index: 25; opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
    }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .content { padding: 16px; }
}

/* ── CARDS / GRID ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
    background: var(--white); border-radius: 12px; padding: 18px 20px; border-top: 3px solid var(--gold);
    box-shadow: var(--shadow);
}
.card .num { font-family: 'Playfair Display', serif; font-size: 2rem; color: var(--navy); line-height: 1; }
.card .lbl { font-family: 'Cinzel', serif; font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.card.alerta { border-top-color: var(--red); }
.card.alerta .num { color: var(--red); }

.panel { background: var(--white); border-radius: 12px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 24px; }
.panel h2 { font-size: 1.1rem; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--gold); }
.panel h2 small { font-family: 'Cinzel', serif; font-size: 0.65rem; color: var(--muted); font-weight: 400; text-transform: none; margin-left: 8px; }

/* ── FORMS ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 700px) { .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-family: 'Cinzel', serif; font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--navy); }
.field .hint { font-size: 0.75rem; color: var(--muted); opacity: 0.7; }
input, select, textarea {
    font-family: 'Lora', serif; font-size: 0.92rem; padding: 10px 12px; border: 1px solid rgba(212,160,23,0.35);
    border-radius: 8px; background: var(--white); color: var(--muted); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,160,23,0.15); }
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
fieldset { border: 1px dashed rgba(212,160,23,0.4); border-radius: 10px; padding: 16px; margin-bottom: 20px; }
legend { font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); padding: 0 8px; }

/* ── BUTTONS ── */
.btn {
    font-family: 'Cinzel', serif; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase;
    padding: 11px 20px; border-radius: 8px; border: none; cursor: pointer; display: inline-flex;
    align-items: center; gap: 8px; text-decoration: none; font-weight: 600;
}
.btn-primary { background: var(--navy); color: var(--gold); }
.btn-primary:hover { background: var(--navy-dk); }
.btn-gold { background: var(--gold); color: var(--navy); }
.btn-gold:hover { filter: brightness(1.08); }
.btn-outline { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.btn-outline:hover { background: rgba(28,43,90,0.06); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-sm { padding: 6px 12px; font-size: 0.62rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; background: var(--white); border-radius: 12px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 640px; }
th {
    background: var(--navy); color: var(--gold); font-family: 'Cinzel', serif; font-size: 0.62rem;
    letter-spacing: 0.06em; text-transform: uppercase; padding: 12px 14px; text-align: left; white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid rgba(212,160,23,0.12); vertical-align: middle; }
tr:hover td { background: rgba(212,160,23,0.04); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ivory-dk); display: inline-flex;
    align-items: center; justify-content: center; font-family: 'Cinzel', serif; font-weight: 600; color: var(--navy);
    font-size: 0.75rem; object-fit: cover; }

/* ── BADGES ── */
.badge { display: inline-block; font-family: 'Cinzel', serif; font-size: 0.6rem; letter-spacing: 0.06em;
    text-transform: uppercase; padding: 4px 10px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.badge.pendente { background: rgba(245,158,11,0.12); color: #b45309; border: 1px solid rgba(245,158,11,0.3); }
.badge.ativo { background: rgba(34,197,94,0.12); color: #16a34a; border: 1px solid rgba(34,197,94,0.3); }
.badge.suspenso { background: rgba(239,68,68,0.12); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.badge.inativo { background: rgba(90,80,64,0.12); color: var(--muted); border: 1px solid rgba(90,80,64,0.25); }
.badge.rascunho { background: rgba(90,80,64,0.12); color: var(--muted); border: 1px solid rgba(90,80,64,0.25); }
.badge.lista_gerada, .badge.convocada { background: rgba(212,160,23,0.14); color: var(--gold); border: 1px solid rgba(212,160,23,0.35); }
.badge.em_andamento { background: rgba(28,43,90,0.1); color: var(--navy); border: 1px solid rgba(28,43,90,0.3); }
.badge.encerrada, .badge.recebeu { background: rgba(34,197,94,0.12); color: #16a34a; border: 1px solid rgba(34,197,94,0.3); }
.badge.checkin_realizado, .badge.chamada { background: rgba(212,160,23,0.14); color: var(--gold); border: 1px solid rgba(212,160,23,0.35); }
.badge.ausente, .badge.fila_espera { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.28); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); }

/* ── ALERT ── */
.alert { background: rgba(212,160,23,0.08); border-left: 3px solid var(--gold); border-radius: 6px; padding: 12px 16px; margin-bottom: 16px; font-size: 0.88rem; }
.alert.danger { background: rgba(239,68,68,0.08); border-color: var(--red); color: #991b1b; }
.alert.success { background: rgba(34,197,94,0.08); border-color: var(--green); color: #166534; }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid rgba(212,160,23,0.2); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
    background: none; border: none; padding: 10px 16px; font-family: 'Cinzel', serif; font-size: 0.68rem;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.tab-btn.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── MODAL ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(28,43,90,0.55); display: none; align-items: center;
    justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--white); border-radius: 14px; padding: 26px; max-width: 520px; width: 100%; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }

/* ── MISC ── */
.muted { color: var(--muted); opacity: 0.75; font-size: 0.85rem; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .ico { font-size: 2.4rem; margin-bottom: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: flex-end; }
.filters .field { margin-bottom: 0; min-width: 160px; }
.pontuacao-badge {
    display: inline-flex; align-items: center; justify-content: center; font-family: 'Cinzel', serif;
    font-weight: 700; font-size: 0.82rem; padding: 4px 10px; border-radius: 20px;
}
.pontuacao-badge.alta { background: rgba(34,197,94,0.15); color: #16a34a; }
.pontuacao-badge.media { background: rgba(245,158,11,0.15); color: #b45309; }
.pontuacao-badge.baixa { background: rgba(239,68,68,0.12); color: var(--red); }
.spinner { border: 3px solid rgba(212,160,23,0.2); border-top-color: var(--gold); border-radius: 50%; width: 28px; height: 28px; animation: spin 0.8s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.scan-box {
    width: 100%; max-width: 420px; margin: 0 auto; aspect-ratio: 1; background: var(--navy); border-radius: 16px;
    display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
#qr-reader { width: 100%; }
.big-btn {
    width: 100%; max-width: 420px; margin: 20px auto; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 10px; background: var(--navy); color: var(--gold); border-radius: 16px;
    padding: 40px 20px; border: 2px solid var(--gold); cursor: pointer; font-family: 'Cinzel', serif;
    font-size: 0.9rem; letter-spacing: 0.08em; text-transform: uppercase;
}
.big-btn .ico { font-size: 2.6rem; }
.identificacao-card {
    max-width: 420px; margin: 0 auto; background: var(--white); border-radius: 16px; padding: 24px;
    box-shadow: var(--shadow); text-align: center;
}
.identificacao-card .foto { width: 80px; height: 80px; border-radius: 50%; margin: 0 auto 12px; background: var(--ivory-dk);
    display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--navy); object-fit: cover; }
.identificacao-card h3 { font-size: 1.15rem; margin-bottom: 4px; }
canvas.signature-pad { border: 2px dashed rgba(212,160,23,0.5); border-radius: 12px; width: 100%; height: 200px; touch-action: none; background: var(--white); }
