/* 
 * Sistema M-CHAT-R - Identidade Visual Saúde Digital
 * Baseado no Protocolo TEA PMS - V.25.11.2025
 * Versão: 1.0
 */

:root {
    /* Paleta Oficial Saúde Digital */
    --azul-principal: #337ab7;
    --azul-botao: #478fcd;
    --cinza-fundo: #f2f2f2;
    --cinza-texto: #555;
    --preto-texto: #222;
    --branco: #ffffff;
    --erro: #cc0000;
    --sucesso: #28a745;
    --aviso: #ffc107;
    
    /* Aliases para compatibilidade */
    --primary: var(--azul-principal);
    --primary-hover: #2868a0;
    --secondary: var(--cinza-texto);
    --success: var(--sucesso);
    --error: var(--erro);
    --bg: var(--cinza-fundo);
    --card-bg: var(--branco);
    --border: #ddd;
    --text: var(--preto-texto);
    --text-light: var(--cinza-texto);
}

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

html, body {
    font-family: 'Open Sans', 'Segoe UI', sans-serif;
    background: var(--cinza-fundo);
    min-height: 100vh;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
}

/* Remover qualquer background ou pseudo-elemento que possa estar causando o logo gigante */
html::before,
html::after,
body::before,
body::after {
    display: none !important;
    content: none !important;
    background: none !important;
    background-image: none !important;
}

/* Garantir que imagens não ultrapassem seus containers */
img {
    max-width: 100%;
    height: auto;
}

/* Remover qualquer background-image que possa estar sendo aplicado */
* {
    background-image: none !important;
}

body > *:not(.top-bar):not(.container):not(.modal):not(#login-gate):not(#main-app):not(.modal-impresso-overlay):not(#modal-impressao-mchat) {
    position: relative;
    z-index: 1;
}

/* ============================================
   BARRA SUPERIOR (HEADER)
   ============================================ */
.top-bar {
    background: var(--azul-principal) !important;
    background-image: none !important;
    color: var(--branco);
    padding: 10px 40px;
    margin: 0;
    margin-bottom: 0;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    height: 80px;
    min-height: 80px;
    max-height: 80px;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

/* ============================================
   PWA INSTALL BANNER
   ============================================ */
.pwa-install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 12000;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(6px);
}

.pwa-install-banner.hidden {
    display: none !important;
}

.pwa-install-banner__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.95rem;
    color: var(--text, #111);
    line-height: 1.25;
}

.pwa-install-banner__sub {
    font-weight: 600;
    color: rgba(0, 0, 0, 0.62);
    font-size: 0.85rem;
}

.pwa-install-banner__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-sm {
    padding: 8px 10px !important;
    font-size: 0.88rem !important;
    border-radius: 10px !important;
}

/* ============================================
   MOBILE UX TUNING
   ============================================ */
@media (max-width: 768px) {
    .top-bar {
        padding: 10px 14px !important;
        height: 72px !important;
        min-height: 72px !important;
        max-height: 72px !important;
    }
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    .home-toolbar {
        gap: 10px;
    }
    .home-search-wrap {
        flex: 1 1 100%;
    }
    .btn-novo-q,
    .btn-home-limpar {
        width: 100%;
    }
    .home-table-scroll {
        border-radius: 10px;
    }
    .result-actions {
        flex-wrap: wrap;
        justify-content: stretch;
    }
    .result-actions .btn {
        flex: 1 1 100%;
    }
    .pergunta-item {
        padding: 16px;
    }
    .progress-bar {
        height: 18px;
        border-radius: 10px;
    }
    .opcao-resposta {
        padding: 14px;
    }
}

.top-bar::before,
.top-bar::after {
    display: none !important;
    content: none !important;
    background: none !important;
    background-image: none !important;
}

.logo-header {
    height: 50px !important;
    width: auto !important;
    max-height: 50px !important;
    max-width: 200px !important;
    min-width: auto !important;
    object-fit: contain;
    display: block !important;
    flex-shrink: 0;
    margin: 0 !important;
    padding: 0 !important;
}

/* Forçar que apenas o logo dentro da top-bar tenha esse tamanho */
.top-bar img.logo-header {
    height: 50px !important;
    max-height: 50px !important;
    max-width: 200px !important;
    width: auto !important;
}

/* Garantir que nenhuma outra imagem apareça como logo gigante */
body > img:not(.logo-header),
body > img:not(.top-bar img) {
    display: none !important;
}

.right-group {
    text-align: right;
    flex-shrink: 0;
}

.right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* ============================================
   TOP BAR — MARCA M-CHAT-R + SESSÃO
   ============================================ */
.top-bar-end {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(12px, 2.5vw, 28px);
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.top-bar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    line-height: 1.2;
    flex-shrink: 0;
}

.top-bar-brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--branco);
    letter-spacing: 0.04em;
}

.top-bar-brand-desc {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.88);
    margin-top: 4px;
}

.top-bar-brand--session .top-bar-brand-title--user {
    font-size: clamp(0.95rem, 2.2vw, 1.2rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.2;
    max-width: min(56vw, 420px);
    text-align: right;
    word-break: break-word;
    hyphens: auto;
}

.top-bar-brand--session .top-bar-brand-desc {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.35;
    opacity: 0.92;
    margin-top: 5px;
    max-width: min(58vw, 440px);
    text-align: right;
}

.header-state {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.header-state-auth {
    flex-wrap: nowrap;
}

.btn-logout-header {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.12);
    color: var(--branco);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    font-family: inherit;
}

.btn-logout-header:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.65);
}

.btn-logout-header:active {
    transform: translateY(1px);
}

.btn-logout-header:focus-visible {
    outline: 2px solid var(--branco);
    outline-offset: 3px;
}

@media (max-width: 640px) {
    .top-bar-brand--session .top-bar-brand-title--user {
        max-width: min(46vw, 220px);
        font-size: 0.82rem;
    }

    .btn-logout-header span:last-child {
        display: none;
    }

    .btn-logout-header {
        padding: 8px 12px;
    }
}

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

/* ============================================
   TELA DE LOGIN — CAIXA INFORMATIVA + FORM MÍNIMO
   ============================================ */
.login-shell {
    margin-top: 80px;
    min-height: calc(100vh - 80px);
    position: relative;
    overflow-x: hidden;
    background: linear-gradient(180deg, #e9eef5 0%, var(--cinza-fundo) 45%);
}

.login-shell-inner {
    position: relative;
    z-index: 1;
    max-width: 520px;
    margin: 0 auto;
    padding: clamp(20px, 4vw, 36px) clamp(14px, 4vw, 24px) 40px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: login-shell-in 0.45s ease-out;
}

.login-shell-inner--stack {
    max-width: 560px;
}

@keyframes login-shell-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .login-shell-inner {
        animation: none;
    }
}

/* Caixa amarela — texto institucional */
.login-alert-box {
    background: #fffbeb;
    border: 1px solid #f5e0a8;
    border-left: 5px solid var(--aviso);
    border-radius: 10px;
    padding: 18px 18px 16px;
    box-shadow: 0 2px 12px rgba(180, 140, 40, 0.12);
}

.login-alert-lead {
    margin: 0 0 14px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--preto-texto);
}

.login-alert-subheading {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #8a6914;
}

.login-alert-bullets {
    margin: 0 0 14px;
    padding-left: 1.15rem;
    font-size: 14px;
    line-height: 1.55;
    color: var(--preto-texto);
}

.login-alert-bullets li {
    margin-bottom: 4px;
}

.card-login-panel {
    margin: 0;
    padding: 16px 18px 14px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    background: var(--branco);
}

.login-panel--compact {
    padding-top: 14px;
    padding-bottom: 12px;
}

.login-form--minimal .login-field--tight {
    margin-bottom: 10px;
}

.login-label-min {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--cinza-texto);
    margin-bottom: 4px;
}

.login-input--compact {
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 15px;
    border: 1px solid var(--border);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input--compact:hover {
    border-color: #bbb;
}

.login-input--compact:focus {
    outline: none;
    border-color: var(--azul-principal);
    box-shadow: 0 0 0 3px rgba(51, 122, 183, 0.2);
}

.login-error-box--compact {
    min-height: 1.2em;
    font-size: 13px;
    font-weight: 600;
    color: var(--erro);
    margin: 4px 0 8px;
}

.login-error-box--compact:empty {
    margin: 0;
    min-height: 0;
}

.btn-login-submit--compact {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
    padding: 11px 16px;
    font-size: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(51, 122, 183, 0.28);
}

.btn-login-submit--compact:hover {
    box-shadow: 0 4px 12px rgba(51, 122, 183, 0.35);
}

.btn-login-submit.btn-login-submit--busy {
    opacity: 0.92;
    pointer-events: none;
}

.login-inline-help {
    margin: 10px 0 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--cinza-texto);
    text-align: center;
}

.login-inline-help a {
    color: var(--azul-principal);
    font-weight: 600;
    text-decoration: none;
}

.login-inline-help a:hover {
    text-decoration: underline;
}

@media (max-width: 880px) {
    .top-bar-end {
        flex-direction: column;
        align-items: flex-end;
        gap: 10px;
    }

    .top-bar-brand {
        align-items: flex-end;
    }
}

@media (max-width: 520px) {
    .top-bar-brand-desc {
        font-size: 11px;
    }

    .top-bar-brand-title {
        font-size: 1rem;
    }

    .login-alert-box {
        padding: 14px 14px 12px;
    }

    .login-alert-lead {
        font-size: 13px;
    }
}

body.login-gate-open {
    overflow-x: hidden;
}

/* ============================================
   CONTAINER E LAYOUT
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    margin-top: 80px;
    padding-top: 20px;
}

/* ============================================
   CARDS E SECTIONS
   ============================================ */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 20px;
}

.card h1 {
    font-size: 28px;
    color: var(--azul-principal);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.card h2 {
    font-size: 20px;
    color: var(--azul-principal);
    margin: 30px 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section {
    background: var(--branco);
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.hidden {
    display: none !important;
}

/* ============================================
   BOTÕES
   ============================================ */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--azul-botao);
    color: white;
}

.btn-primary:hover {
    background: var(--azul-principal);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(51, 122, 183, 0.3);
}

.btn-secondary {
    background: var(--cinza-texto);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: var(--sucesso);
    color: white;
}

.btn-success:hover {
    background: #218838;
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 17px;
    margin-top: 30px;
}

/* ============================================
   FORMULÁRIOS E INPUTS
   ============================================ */
.form-group {
    margin: 25px 0;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    font-size: 15px;
}

.form-group label i {
    margin-right: 8px;
    color: var(--azul-principal);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.input-field {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: 'Open Sans', 'Segoe UI', sans-serif;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input[readonly] {
    background-color: #e9ecef;
    cursor: not-allowed;
}

select.input-field {
    cursor: pointer;
}

/* ============================================
   ALERTAS
   ============================================ */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.alert i {
    font-size: 20px;
}

.alert-success {
    background: #d4edda;
    border: 1px solid var(--sucesso);
    color: #155724;
}

.alert-success i {
    color: #28a745;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid var(--aviso);
    color: #856404;
}

.alert-warning i {
    color: #ffc107;
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    border: 1px solid var(--erro);
    color: #721c24;
}

.alert-error i,
.alert-danger i {
    color: #dc3545;
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-bar {
    width: 100%;
    height: 30px;
    background: var(--bg);
    border-radius: 15px;
    overflow: hidden;
    margin: 20px 0;
    border: 2px solid var(--border);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #06b6d4);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    width: 0%;
}

/* ============================================
   PERGUNTAS M-CHAT
   ============================================ */
.pergunta-item {
    margin-bottom: 30px;
    padding: 25px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    transition: all 0.3s;
}

.pergunta-item.active {
    background-color: #e7f3ff;
    border-left-color: var(--primary);
    box-shadow: 0 2px 8px rgba(51, 122, 183, 0.15);
}

.pergunta-numero {
    font-weight: 600;
    color: var(--azul-principal);
    margin-bottom: 10px;
    font-size: 0.9em;
}

.pergunta-texto {
    font-size: 1.1em;
    font-weight: 500;
    margin-bottom: 20px;
    color: var(--text);
    line-height: 1.6;
}

.opcoes-resposta {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.opcao-resposta {
    display: flex;
    align-items: center;
    padding: 15px;
    background-color: white;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.opcao-resposta:hover {
    border-color: var(--primary);
    background-color: #f0f7ff;
    transform: translateX(4px);
}

.opcao-resposta input[type="radio"] {
    margin-right: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--azul-principal);
}

.opcao-resposta label {
    margin: 0;
    cursor: pointer;
    flex: 1;
    font-weight: normal;
    font-size: 15px;
}

.opcao-pontos {
    font-weight: 700;
    color: rgba(0, 0, 0, 0.55);
    margin-left: 6px;
}

.opcao-resposta input[type="radio"]:checked + label {
    font-weight: 600;
    color: var(--azul-principal);
}

.opcao-resposta:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background-color: #e7f3ff;
    box-shadow: 0 2px 4px rgba(51, 122, 183, 0.2);
}

/* ============================================
   AÇÕES DO FORMULÁRIO
   ============================================ */
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Questionário: «Anterior» à esquerda; «Próxima» / «Finalizar» sempre à direita */
.form-actions--questionario .form-actions-nav-start {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.form-actions--questionario .form-actions-nav-end {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Lista de perguntas no resultado (tela) */
.mchat-perguntas-bloco {
    margin-top: 24px;
    padding: 20px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.mchat-perguntas-titulo {
    font-size: 1.1em;
    margin: 0 0 14px;
    color: var(--azul-principal);
    font-weight: 600;
}

.mchat-tabela-perguntas {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.mchat-tabela-perguntas th,
.mchat-tabela-perguntas td {
    border: 1px solid var(--border);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.mchat-tabela-perguntas th {
    background: #e8ecef;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mchat-tabela-perguntas .col-n {
    width: 44px;
    text-align: center;
}

.mchat-tabela-perguntas .col-r {
    width: 88px;
    text-align: center;
    font-weight: 600;
}

/* Modal impresso (preview tipo Sigus) */
.modal-impresso-overlay {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
}

.modal-impresso-overlay.hidden {
    display: none !important;
}

.modal-impresso-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 960px;
    max-height: calc(100vh - 32px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-impresso-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #f8f9fa;
}

.modal-impresso-toolbar h3 {
    flex: 1;
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.modal-impresso-toolbar .btn {
    white-space: nowrap;
}

.modal-impresso-frame-wrap {
    flex: 1;
    min-height: 0;
    background: #e9ecef;
}

#iframe-impresso {
    display: block;
    width: 100%;
    height: min(72vh, 720px);
    border: none;
    background: #fff;
}

@media (max-width: 768px) {
    #iframe-impresso {
        height: 60vh;
    }
}

/* ============================================
   RESULTADO
   ============================================ */
.resultado-box {
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.resultado-box.baixo-risco {
    background-color: #d4edda;
    border-left: 4px solid var(--sucesso);
}

.resultado-box.medio-risco {
    background-color: #fff3cd;
    border-left: 4px solid var(--aviso);
}

.resultado-box.alto-risco {
    background-color: #f8d7da;
    border-left: 4px solid var(--erro);
}

.resultado-titulo {
    font-size: 1.5em;
    font-weight: 600;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.resultado-pontuacao {
    font-size: 1.2em;
    margin-bottom: 15px;
    font-weight: 600;
}

.resultado-descricao {
    line-height: 1.8;
    margin-bottom: 15px;
}

.resultado-recomendacao {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
    border: 1px solid var(--border);
}

.resultado-recomendacao h3 {
    color: var(--azul-principal);
    margin-bottom: 15px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.resultado-info {
    background-color: #e7f3ff;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.resultado-info h3 {
    color: var(--azul-principal);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.resultado-info ul {
    list-style-position: inside;
    line-height: 2;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 30px;
    justify-content: center;
}

.sisweb-sync-status {
    flex: 1 1 100%;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(51, 122, 183, 0.08);
    border: 1px solid rgba(51, 122, 183, 0.18);
    color: #1f4f7a;
    font-weight: 600;
    text-align: center;
}

/* ============================================
   MODAL
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content h3 {
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--text);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-content p {
    color: var(--text-light);
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 25px;
}

.modal-buttons .btn {
    flex: 1;
}

/* Modal histórico do paciente (lista de questionários) */
.modal-content--historico {
    max-width: 640px;
    width: 92%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    padding: 28px 28px 24px;
}

.modal-historico-sub {
    margin: -6px 0 16px;
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.45;
}

.modal-historico-lista {
    flex: 1;
    min-height: 120px;
    max-height: min(56vh, 520px);
    overflow-y: auto;
    margin: 0 -4px;
    padding: 4px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
}

.modal-content--historico .modal-buttons {
    margin-top: 18px;
    flex-shrink: 0;
}

.modal-content--historico .modal-buttons .btn {
    flex: 0 0 auto;
    min-width: 120px;
}

.historico-paciente-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.historico-paciente-item:last-child {
    margin-bottom: 0;
}

.historico-paciente-item__data {
    font-size: 15px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #cbd5e1;
}

.historico-paciente-item__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 13px;
    color: var(--text);
    line-height: 1.45;
    margin-bottom: 12px;
}

.historico-paciente-item__meta strong {
    color: #334155;
    font-weight: 600;
}

.historico-paciente-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}

.historico-paciente-badge--baixo {
    background: #d1fae5;
    color: #065f46;
}

.historico-paciente-badge--moderado {
    background: #fef3c7;
    color: #92400e;
}

.historico-paciente-badge--alto {
    background: #fee2e2;
    color: #991b1b;
}

.historico-paciente-item__acoes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.historico-paciente-item__acoes .btn {
    flex: 0 0 auto;
    font-size: 13px;
    padding: 6px 14px;
}

.historico-paciente-sis {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
}

.historico-paciente-sis--ok {
    background: #dcfce7;
    color: #166534;
}

.historico-paciente-sis--pend {
    background: #fef9c3;
    color: #854d0e;
}

@media (max-width: 768px) {
    .modal-content--historico {
        max-width: none;
        width: 94%;
        padding: 20px 16px 16px;
    }

    .modal-historico-lista {
        max-height: 50vh;
    }

    .historico-paciente-item__acoes {
        flex-direction: column;
    }

    .historico-paciente-item__acoes .btn {
        width: 100%;
    }
}

/* ============================================
   ANIMAÇÕES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* ============================================
   RESPONSIVIDADE
   ============================================ */
@media (max-width: 768px) {
    .card {
        padding: 20px;
        margin: 10px;
    }
    
    .top-bar {
        padding: 10px 20px;
        height: auto;
        min-height: 70px;
        flex-direction: row;
        gap: 15px;
    }
    
    .logo-header {
        height: 40px;
        max-height: 40px;
    }
    
    .right-group {
        flex: 1;
    }
    
    .right div:first-child {
        font-size: 16px;
    }
    
    .right div:last-child {
        font-size: 12px;
    }
    
    .card h1 {
        font-size: 24px;
    }
    
    .card h2 {
        font-size: 18px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions--questionario .form-actions-nav-end {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
    }

    .form-actions--questionario .form-actions-nav-start {
        width: 100%;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .pergunta-item {
        padding: 20px;
    }
}

/* Busca SIS + lista de avaliações salvas */
.busca-sis-panel {
    background: rgba(51, 122, 183, 0.06);
    border: 1px solid rgba(51, 122, 183, 0.25);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 22px;
}

.busca-sis-heading {
    font-size: 1rem;
    margin: 0 0 8px 0;
    color: var(--text);
}

.busca-sis-help {
    font-size: 0.9rem;
    color: var(--text-muted, #555);
    margin: 0 0 12px 0;
    line-height: 1.45;
}

.busca-sis-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
}

.busca-sis-input {
    flex: 1 1 200px;
    min-width: 160px;
}

.busca-sis-msg {
    margin-top: 10px;
    font-size: 0.9rem;
    min-height: 1.2em;
}

.busca-sis-msg--erro {
    color: #c0392b;
    font-weight: 600;
}

.lista-avaliacoes-wrap {
    margin-bottom: 22px;
}

.lista-avaliacoes-heading {
    font-size: 1rem;
    margin: 0 0 10px 0;
}

.lista-avaliacoes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lista-avaliacao-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    background: #fafafa;
}

.lista-avaliacao-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 14px;
    font-size: 0.92rem;
}

.lista-avaliacao-badge {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(51, 122, 183, 0.15);
    color: #2c5f8d;
}

.lista-avaliacao-data {
    color: var(--text-muted, #666);
    font-size: 0.85rem;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary, #337ab7);
    color: var(--primary, #337ab7);
}

.btn-outline:hover {
    background: rgba(51, 122, 183, 0.08);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.88rem;
}

.identificacao-dados-paciente {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.identificacao-dados-lead {
    font-size: 0.95rem;
    color: #2e7d32;
    margin: 0 0 16px 0;
    font-weight: 600;
}

/* Home / listagem de concluídos */
.mchat-view-home {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.card-home h1 {
    margin-bottom: 6px;
}

.home-lead {
    color: var(--text-muted, #555);
    margin: 0 0 18px 0;
    font-size: 0.95rem;
}

.home-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.home-search-wrap {
    flex: 1 1 220px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 6px;
    padding: 6px 12px;
    background: #fff;
}

.home-search-wrap .fa-search {
    color: #777;
}

.home-live-search {
    flex: 1;
    border: none !important;
    box-shadow: none !important;
    padding: 8px 4px !important;
    margin: 0 !important;
}

.btn-novo-q {
    white-space: nowrap;
}

.btn-home-limpar {
    white-space: nowrap;
    color: #8a3a3a;
    border-color: rgba(180, 60, 60, 0.4);
    background: #fff;
    font-size: 0.88rem;
}

.btn-home-limpar:hover {
    background: #fff5f5;
    border-color: rgba(180, 60, 60, 0.6);
}

.home-table-scroll {
    overflow-x: auto;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.home-tabela {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.home-tabela thead {
    background: rgba(51, 122, 183, 0.12);
}

.home-tabela th,
.home-tabela td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.home-th-sis {
    text-align: center;
    width: 1%;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #555;
    white-space: nowrap;
}

.home-td-sis {
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
}

.home-td-sis--ok {
    color: #1a6b2a;
}

.home-td-sis--pend {
    color: #a35b00;
}

.home-td-sis--sem {
    color: #999;
    font-weight: 500;
}

.home-th-acoes {
    text-align: center;
    width: 1%;
    white-space: nowrap;
}

.home-td-acoes-wrap {
    text-align: center;
    vertical-align: middle;
    padding: 8px 10px !important;
}

.home-acoes-cluster {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.home-acoes-cluster .btn-home-acao {
    min-width: 38px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.home-acoes-cluster .btn-home-acao:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(51, 122, 183, 0.2);
}

.home-acoes-cluster .btn-home-acao--edit {
    background: linear-gradient(180deg, #e8f4fc 0%, #d6e9f8 100%);
    color: #286090;
}

.home-acoes-cluster .btn-home-acao--sync {
    background: linear-gradient(180deg, #eef8f0 0%, #d9eedf 100%);
    color: #256d3a;
}

.home-acoes-cluster .btn-home-acao--hist {
    background: linear-gradient(180deg, #f3f0ff 0%, #e5ddff 100%);
    color: #4b2ea6;
    position: relative;
}

.home-acoes-cluster .btn-home-acao--print {
    background: linear-gradient(180deg, #f7f7f9 0%, #ebecef 100%);
    color: #4a5568;
}

.home-acao-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #d93025;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.home-acoes-cluster .btn-home-sync:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.home-tabela tbody tr:hover {
    background: rgba(51, 122, 183, 0.04);
}

.btn-icon {
    padding: 8px 12px;
    min-width: 42px;
    border-radius: 6px;
}

.btn-voltar-home {
    margin-bottom: 12px;
    padding-left: 0 !important;
    font-weight: 600;
}

.home-empty {
    margin-top: 14px;
    color: var(--text-muted, #666);
    font-size: 0.92rem;
}

