:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --ink: #0f2240;
    --ink-soft: #5a6678;
    --brand: #1257b0;
    --brand-dark: #0e4690;
    --accent: #15a04a;
    --warn: #b45309;
    --erro: #c0392b;
    --line: #e3e8f0;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 34, 64, .06);
    --shadow-md: 0 6px 24px rgba(15, 34, 64, .08);
    --shadow-lg: 0 18px 48px rgba(15, 34, 64, .12);
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Faixa de marca no topo da viewport */
.topbar-accent {
    position: fixed; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--brand), var(--accent));
    z-index: 50;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    gap: 24px;
}
.page--wide { justify-content: flex-start; }

/* Cabeçalho das telas internas */
.brand {
    width: 100%;
    max-width: 1080px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand__logo-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand__logo-img { height: 56px; width: auto; display: block; }
.brand__logo { font-size: 22px; font-weight: 800; color: var(--brand); }
.brand__tag {
    font-size: 12px; font-weight: 700; color: var(--ink-soft);
    background: #eef2f7; border: 1px solid var(--line);
    padding: 3px 10px; border-radius: 6px; letter-spacing: .02em;
}

/* Indicador de etapas */
.steps { display: flex; align-items: center; gap: 8px; }
.step {
    font-size: 13px; font-weight: 600; color: var(--ink-soft);
    padding: 7px 14px; border-radius: 8px; background: #fff;
    border: 1px solid var(--line);
}
.step--active { color: var(--brand); border-color: var(--brand); background: #f1f6fd; }
.step--done { color: var(--accent); border-color: #cdeccf; background: #f1faf3; }

/* Cartão */
.card {
    width: 100%;
    max-width: 520px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-md);
}
.card--center { text-align: center; }
.card--narrow { max-width: 400px; }
.card__title { font-size: 27px; font-weight: 800; letter-spacing: -0.4px; }
.card__subtitle { color: var(--ink-soft); margin-top: 8px; font-size: 16px; }

.question {
    font-size: 21px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--ink);
    margin: 14px 0 26px;
}

/* Formulário */
.form { margin-top: 26px; display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-weight: 600; font-size: 14px; color: var(--ink); }
.field__opt { font-weight: 400; color: #9aa4b4; font-size: 13px; }
.field input {
    font-family: inherit;
    border: 1px solid #cdd5e1;
    border-radius: 10px;
    padding: 14px 15px;
    font-size: 16px;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: #9aa4b4; }
.field input:focus {
    outline: none;
    border-color: var(--brand);
    background: var(--brand);
    color: #fff;
    caret-color: #fff;
    box-shadow: 0 0 0 3px rgba(18, 87, 176, .25);
}
.field input:focus::placeholder { color: rgba(255, 255, 255, .7); }

/* Autocomplete (Município) */
.ac-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #cdd5e1;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    z-index: 60;
    max-height: 248px;
    overflow-y: auto;
    padding: 6px;
}
.ac-item {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: none;
    font-family: inherit;
    font-size: 16px;
    color: var(--ink);
    padding: 12px 12px;
    border-radius: 8px;
    cursor: pointer;
}
.ac-item:hover { background: #f1f6fd; color: var(--brand); }

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    padding: 15px 24px;
    border-radius: 10px;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); }
.btn--ghost { background: #fff; color: var(--ink); border-color: #cdd5e1; }
.btn--ghost:hover { background: #f4f6fa; }
.btn--sm { font-size: 14px; padding: 10px 16px; }
.btn--block { width: 100%; }

.actions { display: flex; gap: 12px; margin-top: 6px; }
.actions .btn { flex: 1; }

/* Opções da pergunta */
.options { display: flex; flex-direction: column; gap: 12px; }
.option { cursor: pointer; display: block; }
.option input { position: absolute; opacity: 0; pointer-events: none; }
.option__box {
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid #cdd5e1;
    border-radius: 12px;
    padding: 18px 18px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.option__letter {
    width: 40px; height: 40px;
    flex: 0 0 40px;
    display: flex; align-items: center; justify-content: center;
    background: #eef2f7; color: var(--brand);
    border-radius: 9px; font-weight: 800; font-size: 18px;
}
.option__text { font-size: 18px; font-weight: 600; }
.option input:checked + .option__box {
    border-color: var(--brand);
    background: #f4f8fd;
    box-shadow: 0 0 0 3px rgba(18, 87, 176, .12);
}
.option input:checked + .option__box .option__letter { background: var(--brand); color: #fff; }
.option input:focus-visible + .option__box { border-color: var(--brand); }

/* Alertas */
.alert { padding: 13px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px; }
.alert--error { background: #fcecec; color: var(--erro); border: 1px solid #f3c6c6; }
.alert ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }

/* Sucesso */
.success-icon {
    width: 76px; height: 76px;
    margin: 0 auto 20px;
    background: #eafaf0; color: var(--accent);
    border: 1px solid #cdeccf;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 40px; font-weight: 800;
}
.card--center .btn { margin-top: 24px; }
.redirect-note { margin-top: 16px; color: var(--ink-soft); font-size: 13px; }

.footer { color: var(--ink-soft); font-size: 13px; }

/* ===== Tela inicial (welcome) ===== */
.welcome-body { background: var(--bg); }
.welcome {
    height: 100vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2.2vh;
    padding: 2.5vh 24px 5vh;
    text-align: center;
    text-decoration: none;
    color: var(--ink);
    overflow: hidden;
}
.welcome__logo {
    margin-bottom: 10px;
    background: #fff;
    padding: 40px 56px;
    border-radius: 28px;
    box-shadow: var(--shadow-lg);
}
.welcome__brand-img { height: 260px; width: auto; max-width: 86vw; display: block; }
.welcome__brand { font-size: 44px; font-weight: 900; color: var(--brand); letter-spacing: -1px; }
.welcome__title {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    max-width: 640px;
}
.welcome__lead {
    font-size: 17px;
    color: var(--ink-soft);
    max-width: 520px;
    line-height: 1.55;
}
.welcome__cta {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--brand);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    padding: 17px 38px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    transition: background .15s, transform .06s;
}
.welcome:hover .welcome__cta { background: var(--brand-dark); }
.welcome:active .welcome__cta { transform: translateY(1px); }
.welcome__hint { margin-top: 2px; font-size: 13px; color: var(--ink-soft); }

/* Slideshow de banners (gerados a partir dos PDFs) */
/* Banner quadrado dimensionado pela ALTURA da tela, para caber no tótem 1024x768. */
.hero {
    position: relative;
    width: min(90vw, 58vh);
    aspect-ratio: 1 / 1;
    margin-bottom: 0;
    border-radius: 24px;
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow-lg);
}
.hero__track { position: absolute; inset: 0; }
.hero__slide {
    position: absolute; inset: 0;
    margin: 0;
    opacity: 0;
    transition: opacity .8s ease;
    pointer-events: none;
}
.hero__slide.is-active { opacity: 1; }
.hero__slide img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero__dots {
    position: absolute; left: 0; right: 0; bottom: 14px;
    display: flex; justify-content: center; gap: 8px; z-index: 2;
}
.hero__dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: rgba(255, 255, 255, .55);
    box-shadow: 0 0 0 1px rgba(15, 34, 64, .15);
    transition: background .3s, transform .3s;
}
.hero__dot.is-active { background: #fff; transform: scale(1.25); }

.welcome__footer {
    position: fixed; bottom: 22px; left: 0; right: 0;
    text-align: center; color: var(--ink-soft); font-size: 13px;
}
.welcome__exit {
    position: fixed;
    bottom: 16px;
    right: 20px;
    z-index: 60;
    background: #fff;
    color: var(--ink-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 18px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: background .15s, color .15s, border-color .15s;
}
.welcome__exit:hover { background: var(--erro); color: #fff; border-color: var(--erro); }
.welcome__exit:active { transform: translateY(1px); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 34, 64, .5);
}
.modal-overlay.is-open { display: flex; }
.modal {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 28px;
    text-align: center;
    animation: modalIn .16s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
.modal__title { font-size: 21px; font-weight: 800; color: var(--ink); }
.modal__text { margin-top: 8px; color: var(--ink-soft); font-size: 16px; }
.modal__actions { display: flex; gap: 12px; margin-top: 24px; }
.modal__actions .btn { flex: 1; }
.btn--danger { background: var(--erro); color: #fff; }
.btn--danger:hover { background: #a5301f; }

/* ===== Admin ===== */
.admin-body .page { padding-top: 28px; }
.admin { width: 100%; max-width: 1080px; }
.cards-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.stat {
    flex: 1; min-width: 180px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 4px;
}
.stat__num { font-size: 32px; font-weight: 800; color: var(--brand); }
.stat__label { color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.stat--a .stat__num { color: var(--accent); }
.stat--b .stat__num { color: var(--warn); }

.admin__toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.admin__toolbar h2 { font-size: 20px; }

.table-wrap {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; overflow: auto; box-shadow: var(--shadow-sm);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 13px 16px; text-align: left; white-space: nowrap; }
.table thead th {
    background: #f7f9fc; color: var(--ink-soft);
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--line);
}
.table tbody tr { border-top: 1px solid var(--line); }
.table tbody tr:hover { background: #f7f9fc; }
.table__empty { text-align: center; color: var(--ink-soft); padding: 30px; }

.badge { padding: 4px 11px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.badge--a { background: #eafaf0; color: #15803d; border: 1px solid #cdeccf; }
.badge--b { background: #fef4e6; color: var(--warn); border: 1px solid #f6dcb4; }

/* ===== Teclado virtual (tótem) ===== */
body.kb-open { padding-bottom: 46vh; }

.vk {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 100;
    background: transparent;
    border: none;
    transform: translateY(120%);
    transition: transform .22s ease;
    padding: 0 8px calc(12px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: center;
    align-items: flex-end;
    pointer-events: none;
}
.vk--open { transform: translateY(0); }

.vk__inner {
    pointer-events: auto;
    width: max-content;
    max-width: 100%;
    margin: 0 auto;
    background: #e9edf3;
    border: 1px solid #d3dae5;
    border-radius: 16px;
    box-shadow: 0 12px 36px rgba(15, 34, 64, .18);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.vk__row { display: flex; gap: 8px; justify-content: center; }

.vk__key {
    flex: 1 1 0;
    min-width: 0;
    width: 64px;
    max-width: 72px;
    height: 56px;
    border: 1px solid #c6cedb;
    background: #fff;
    color: var(--ink);
    border-radius: 9px;
    font-family: var(--font);
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 0 #c6cedb;
    transition: background .08s, transform .05s;
    user-select: none;
}
.vk__key:active { background: #eef2f7; transform: translateY(1px); }
.vk__key--char { max-width: 72px; }
.vk__key--accent { color: var(--brand); }
.vk__key--mod { background: #dfe5ee; font-size: 22px; max-width: 96px; }
.vk__key--space { background: #fff; font-size: 16px; font-weight: 600; max-width: none; }
.vk__key--ok { background: var(--brand); color: #fff; border-color: var(--brand); font-size: 17px; max-width: none; }
.vk__key--ok:active { background: var(--brand-dark); }
.vk--caps .vk__key--mod { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== Responsivo ===== */
@media (max-width: 600px) {
    .card { padding: 26px; }
    .card__title { font-size: 23px; }
    .question { font-size: 18px; }
    .brand__logo-img { height: 46px; }
    .steps { display: none; }
    .actions { flex-direction: column-reverse; }
    .welcome__logo { padding: 24px 28px; border-radius: 20px; }
    .welcome__brand-img { height: 150px; }
    .welcome__title { font-size: 23px; }
    .welcome__lead { font-size: 15px; }
    .welcome__cta { font-size: 16px; padding: 15px 30px; }
    .hero { width: min(92vw, 52vh); border-radius: 18px; }
    .vk__key { height: 48px; font-size: 18px; }
    .vk__row { gap: 6px; }
    .vk__inner { gap: 6px; }
    body.kb-open { padding-bottom: 52vh; }
}
