:root {
    color-scheme: dark;
    --bg: #0b0d14;
    --bg-glow: rgba(139, 115, 214, .14);
    --surface: #141722;
    --surface-2: #1a1e2b;
    --border: #262b3b;
    --text: #e8eaf1;
    --muted: #8b92a8;
    --accent: #7c66cc;          /* roxo do logo ClickStories, clareado p/ contraste no fundo escuro */
    --accent-hover: #9683dc;
    --accent-soft: rgba(124, 102, 204, .18);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .10);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1000px 420px at 50% -120px, var(--bg-glow), transparent 70%),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}

svg { width: 20px; height: 20px; flex-shrink: 0; }

.shell { max-width: 920px; margin: 0 auto; padding: 56px 16px 64px; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Cabeçalho ---------------------------------------------------------------- */
.hero { display: flex; align-items: center; gap: 24px; margin-bottom: 32px; }
/* Logo em PNG transparente com texto roxo escuro: fica sobre uma base clara para não sumir no fundo. */
.brand img { display: block; width: auto; height: 60px; }
.hero-text { padding-left: 24px; border-left: 1px solid var(--border); }
h1 { margin: 0; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.subtitle { margin: 2px 0 0; color: var(--muted); }
.tag-scope { margin-top: 8px; color: var(--accent-hover); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }

/* Página inicial e 404 ------------------------------------------------------- */
.shell-narrow { max-width: 460px; }
.hero-center { justify-content: center; }
.entry { display: flex; flex-direction: column; gap: 14px; padding: 24px; }
.entry h1 { font-size: 1.3rem; }
.entry .alert { margin-bottom: 0; }
.empty a { margin-top: 10px; color: var(--accent-hover); font-weight: 600; text-decoration: none; }
.empty a:hover { text-decoration: underline; }


/* Cartões ------------------------------------------------------------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Busca -------------------------------------------------------------------- */
.search { display: flex; gap: 10px; padding: 10px; margin-bottom: 20px; }
.field { position: relative; flex: 1; display: flex; align-items: center; }
.field svg { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.field input {
    width: 100%; height: 48px; padding: 0 16px 0 44px;
    font: inherit; font-size: 1rem; color: var(--text);
    background: var(--surface-2); border: 1px solid transparent; border-radius: 10px;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--muted); }
.field input:focus {
    outline: none; background: var(--surface);
    border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Botões ------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 48px; padding: 0 22px;
    font: inherit; font-weight: 600; color: #fff;
    background: var(--accent); border: 0; border-radius: 10px; cursor: pointer;
    transition: background .15s, transform .05s, opacity .15s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }

/* Botão de download "apagado" enquanto nada estiver selecionado. */
.results:not(:has(tbody input:checked)) .btn-download { opacity: .45; pointer-events: none; }

/* Estado "gerando ZIP" (controlado pelo app.js). */
.spinner {
    display: none; width: 18px; height: 18px; flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-download.is-loading,
.results:not(:has(tbody input:checked)) .btn-download.is-loading { opacity: .85; cursor: progress; }
.btn-download.is-loading .spinner { display: inline-block; }
.btn-download.is-loading .btn-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Alertas / vazio ---------------------------------------------------------- */
.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; margin-bottom: 20px;
    color: var(--danger); background: var(--danger-soft);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 12px;
}
.alert span { color: var(--text); }
.empty { display: flex; flex-direction: column; gap: 4px; padding: 28px; text-align: center; }
.empty span { color: var(--muted); }

/* Resultados --------------------------------------------------------------- */
.results { overflow: clip; }
.results-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 18px 20px 12px;
}
.results-head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.hint { color: var(--muted); font-size: .85rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    padding: 10px 14px; text-align: left;
    font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); background: var(--surface-2);
    border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:has(input:checked) { background: var(--accent-soft); }
tbody tr.is-disabled { opacity: .5; }
tbody tr.is-disabled:hover { background: transparent; }

.col-check { width: 44px; padding-right: 0; }
.col-num { text-align: right; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
input[type=checkbox]:disabled { cursor: not-allowed; }

.person { display: flex; flex-direction: column; cursor: pointer; }
.is-disabled .person { cursor: default; }
.person-name { font-weight: 550; }
.person-id { font-size: .8rem; color: var(--muted); }

.tag {
    display: inline-block; padding: 3px 10px; font-size: .8rem; font-weight: 500;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 999px; white-space: nowrap;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; color: var(--muted); }

.count {
    display: inline-grid; place-items: center; min-width: 32px; height: 28px; padding: 0 10px;
    font-size: .9rem; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-radius: 999px;
    box-shadow: 0 2px 10px var(--accent-soft);
}
.count-zero {
    color: var(--muted); font-weight: 600;
    background: var(--surface-2); border: 1px solid var(--border); box-shadow: none;
}

/* Barra de download fixa no rodapé da tela enquanto a lista rola. */
.actions {
    position: sticky; bottom: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 20px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: 0; }

/* Celular ------------------------------------------------------------------ */
@media (max-width: 640px) {
    .shell { padding-top: 32px; }
    .hero { flex-direction: column; gap: 16px; text-align: center; }
    .hero-text { padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--border); }
    .brand img { height: 52px; }
    .search { flex-direction: column; }
    .btn { width: 100%; }
    .actions { flex-direction: column-reverse; align-items: stretch; text-align: center; }
    .col-cpf { display: none; }
}
