/* ─── Ocultar dados sensíveis (CPF/CNS/Nome/Mãe/Pai/Contato/Endereço) ───
   Nasce invisível quando o servidor já sabe (sessão) que deve ocultar —
   evita o "flash" do dado real na tela antes do JS (ocultar_dados_sensiveis.js
   ou equivalente) mascarar, ex.: ao dar F5. O JS remove o atributo depois de
   já ter trocado o texto pelo valor certo (mascarado ou completo). */
[data-ocultar-sensivel][data-ocultar-inicial] { visibility: hidden; }

/* ─── Rolagem vertical nas tabelas de listagem (Brasil 360 / Vacinas) ───
   Mostra no máximo ~15 linhas de uma vez, mesmo com "Linhas" em 20/50/100
   — sem isso a página ficava do tamanho da quantidade escolhida (ex.: 100
   linhas = página gigante), o que não fazia sentido. O resto das linhas
   fica disponível rolando dentro do próprio bloco, sem empurrar o resto da
   página. Cabeçalho fixo (sticky) durante a rolagem, pra nunca perder a
   referência de qual coluna é qual.

   O `:where(th)` zera a especificidade da parte do seletor que escolhe o
   `th`, de propósito: assim, quando a tabela já define uma cor de fundo
   própria pro cabeçalho (ex.: `.b360-table th { background:#f1f5f9; }`),
   essa regra mais específica continua vencendo e o visual de cada tabela
   não muda; o `#fff` aqui é só um fallback de segurança pras tabelas que
   não tinham nenhum fundo definido — sem opacidade no cabeçalho, o texto
   das linhas de baixo apareceria "vazando" por trás dele durante o scroll. */
.tabela-scroll-vertical { max-height: 560px; overflow-y: auto; }
.tabela-scroll-vertical thead :where(th) { position: sticky; top: 0; z-index: 2; background-color: #fff; }

/* ─── Sistema Geral ─── */
:root {
    --primary: #0d6efd;
    --sidebar-bg: #ffffff;
    --sidebar-text: #64748b;
    --sidebar-active: #6366f1;
    --sidebar-active-bg: #eef2ff;
    --sidebar-border: #eef0f4;
    --sidebar-hover: #f8fafc;
    --sidebar-heading: #1e293b;
    --sidebar-width: 250px;
}

/* Tema escuro só do menu lateral (botão de lua/sol na sidebar) */
body.sidebar-dark {
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #818cf8;
    --sidebar-active-bg: rgba(99, 102, 241, .18);
    --sidebar-border: #1e293b;
    --sidebar-hover: #1e293b;
    --sidebar-heading: #f1f5f9;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    transition: background-color 0.3s, color 0.3s;
}

/* ════════════════════════════════════════════
   TEMA ESCURO
   Ativado pela classe  body.dark-theme
   ════════════════════════════════════════════ */
body.dark-theme {
    /* ── Sobrescreve variáveis CSS do Bootstrap 5 ── */
    --bs-body-color:          #c9d1d9;
    --bs-body-bg:             #0d1117;
    --bs-emphasis-color:      #e6edf3;
    --bs-secondary-color:     #8b949e;
    --bs-tertiary-color:      #6e7681;
    --bs-border-color:        #30363d;
    --bs-border-color-translucent: rgba(48,54,61,.6);
    --bs-secondary-bg:        #161b22;
    --bs-tertiary-bg:         #1c2128;
    --bs-heading-color:       #e6edf3;
    --bs-link-color:          #79c0ff;
    --bs-link-hover-color:    #a5d6ff;
    --bs-code-color:          #f0883e;
    --bs-table-color:         #c9d1d9;
    --bs-table-bg:            #161b22;
    --bs-table-border-color:  #30363d;
    --bs-table-striped-bg:    #1c2128;
    --bs-table-hover-bg:      #21262d;
    --bs-card-bg:             #161b22;
    --bs-card-border-color:   #30363d;
    --bs-card-cap-bg:         #1c2128;
    --bs-modal-bg:            #161b22;
    --bs-modal-border-color:  #30363d;
    --bs-input-bg:            #0d1117;
    --bs-input-border-color:  #30363d;
    --bs-input-color:         #c9d1d9;

    background-color: #0d1117;
    color: #c9d1d9;
}
body.dark-theme .main-content {
    background-color: #0d1117;
}

/* Força todo texto sem cor explícita a herdar a cor clara */
body.dark-theme .main-content td,
body.dark-theme .main-content th,
body.dark-theme .main-content p,
body.dark-theme .main-content span:not(.badge),
body.dark-theme .main-content small,
body.dark-theme .main-content div:not(.toast):not([class*="alert"]) {
    color: inherit;
}

/* Textos escuros hardcoded → claro */
body.dark-theme .text-dark,
body.dark-theme .text-black,
body.dark-theme .text-body {
    color: #c9d1d9 !important;
}
body.dark-theme .text-secondary {
    color: #8b949e !important;
}

/* Cabeçalho de página */
body.dark-theme .page-header {
    border-color: #30363d;
}
body.dark-theme .page-header h2,
body.dark-theme .page-header h3,
body.dark-theme .page-header h4,
body.dark-theme h1, body.dark-theme h2,
body.dark-theme h3, body.dark-theme h4,
body.dark-theme h5, body.dark-theme h6 {
    color: #e6edf3;
}

/* Cards */
body.dark-theme .card {
    background-color: #161b22;
    border: 1px solid #30363d;
    color: #c9d1d9;
}
body.dark-theme .card-header {
    background-color: #1c2128;
    border-color: #30363d;
    color: #e6edf3;
}
body.dark-theme .card-footer {
    background-color: #161b22;
    border-color: #30363d;
}

/* Tabelas */
body.dark-theme .table {
    --bs-table-bg: #161b22;
    --bs-table-striped-bg: #1c2128;
    --bs-table-hover-bg: #21262d;
    --bs-table-border-color: #30363d;
    color: #c9d1d9;
}
body.dark-theme .table thead th,
body.dark-theme .table > thead {
    background-color: #1c2128;
    color: #8b949e;
    border-color: #30363d;
}
body.dark-theme .table td,
body.dark-theme .table th {
    border-color: #30363d;
}

/* Formulários */
body.dark-theme .form-control,
body.dark-theme .form-select,
body.dark-theme textarea.form-control {
    background-color: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}
body.dark-theme .form-control:focus,
body.dark-theme .form-select:focus {
    background-color: #161b22;
    border-color: #388bfd;
    color: #e6edf3;
    box-shadow: 0 0 0 0.2rem rgba(56,139,253,.25);
}
body.dark-theme .form-control::placeholder {
    color: #6e7681;
}
body.dark-theme .form-control:disabled,
body.dark-theme .form-select:disabled {
    background-color: #1c2128;
    color: #6e7681;
}
body.dark-theme .input-group-text {
    background-color: #1c2128;
    border-color: #30363d;
    color: #8b949e;
}
body.dark-theme .form-label,
body.dark-theme label {
    color: #c9d1d9;
}

/* Modais */
body.dark-theme .modal-content {
    background-color: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
}
body.dark-theme .modal-header,
body.dark-theme .modal-footer {
    border-color: #30363d;
}
body.dark-theme .modal-title {
    color: #e6edf3;
}
body.dark-theme .btn-close {
    filter: invert(1) grayscale(1);
}

/* Alertas e badges */
body.dark-theme .alert-info    { background-color: #12263a; border-color: #1a4a6b; color: #79c0ff; }
body.dark-theme .alert-success { background-color: #0d2616; border-color: #196c2e; color: #56d364; }
body.dark-theme .alert-warning { background-color: #2d1f00; border-color: #6e3c00; color: #e3b341; }
body.dark-theme .alert-danger  { background-color: #2d0f0f; border-color: #6e1313; color: #ff7b72; }

/* Botões outline */
body.dark-theme .btn-outline-secondary {
    color: #8b949e;
    border-color: #30363d;
}
body.dark-theme .btn-outline-secondary:hover {
    background-color: #21262d;
    color: #c9d1d9;
}

/* Dropdowns */
body.dark-theme .dropdown-menu {
    background-color: #1c2128;
    border-color: #30363d;
}
body.dark-theme .dropdown-item {
    color: #c9d1d9;
}
body.dark-theme .dropdown-item:hover {
    background-color: #21262d;
    color: #e6edf3;
}
body.dark-theme .dropdown-divider {
    border-color: #30363d;
}

/* Lista e misc */
body.dark-theme .list-group-item {
    background-color: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
}
body.dark-theme hr {
    border-color: #30363d;
    opacity: 1;
}
body.dark-theme .text-muted {
    color: #6e7681 !important;
}
body.dark-theme .text-dark {
    color: #c9d1d9 !important;
}
body.dark-theme .bg-white,
body.dark-theme .bg-light {
    background-color: #161b22 !important;
}
body.dark-theme .border,
body.dark-theme .border-bottom,
body.dark-theme .border-top {
    border-color: #30363d !important;
}

/* Paginação */
body.dark-theme .page-link {
    background-color: #161b22;
    border-color: #30363d;
    color: #8b949e;
}
body.dark-theme .page-item.active .page-link {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* ─── Login ─── */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a5f 0%, #0d6efd 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h2 {
    text-align: center;
    color: #1e293b;
    margin-bottom: 30px;
    font-weight: 700;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    min-width: 190px;
    max-width: 420px;
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding-top: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 1px 0 12px rgba(15, 23, 42, .03);
}

/* Alça de redimensionar (arrastar na borda direita da sidebar) */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 1001;
    background: transparent;
}
.sidebar-resize-handle:hover,
body.sidebar-resizing .sidebar-resize-handle {
    background: var(--sidebar-active);
    opacity: .5;
}
body.sidebar-collapsed .sidebar-resize-handle {
    display: none;
}
/* Desativa transições enquanto o usuário arrasta (evita atraso visual) */
body.sidebar-resizing .sidebar,
body.sidebar-resizing .main-content,
body.sidebar-resizing #sidebarToggleBtn,
body.sidebar-resizing #bg-logo-watermark {
    transition: none !important;
}
body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}

/* Campo de pesquisa de módulos no topo da sidebar */
.sidebar-search {
    padding: 0 20px 12px;
    flex: 0 0 auto;
}
.sidebar-search-wrap {
    position: relative;
}
.sidebar-search-wrap .bi-search {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 13px;
    pointer-events: none;
}
.sidebar-search-input {
    background: var(--sidebar-hover);
    border: 1px solid var(--sidebar-border);
    color: var(--sidebar-heading);
    font-size: 13px;
    padding: 8px 10px 8px 30px;
    border-radius: 10px;
    width: 100%;
}
.sidebar-search-input:focus {
    background: var(--sidebar-bg);
    border-color: var(--sidebar-active);
    color: var(--sidebar-heading);
    box-shadow: 0 0 0 .2rem rgba(99,102,241,.15);
}
.sidebar-search-input::placeholder {
    color: #64748b;
}
.sidebar-search-clear {
    display: none;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 2px;
    line-height: 1;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
}
.sidebar-search-clear:hover {
    color: var(--sidebar-heading);
}
.sidebar-search-wrap.tem-texto .sidebar-search-clear {
    display: block;
}
.sidebar-search-wrap.tem-texto .sidebar-search-input {
    padding-right: 28px;
}
.sidebar-search-empty {
    display: none;
    padding: 10px 20px;
    color: #64748b;
    font-size: 12.5px;
    font-style: italic;
}

/* Classes usadas pelo filtro de pesquisa do menu — !important garante que
   vençam qualquer outra regra (inclusive as classes do Bootstrap Collapse). */
.sidebar .nav-link.sidebar-search-hide {
    display: none !important;
}
.sidebar .collapse.sidebar-search-hide {
    display: none !important;
}
.sidebar .collapse.sidebar-search-show {
    display: block !important;
    height: auto !important;
}
.sidebar hr.sidebar-search-hide {
    display: none !important;
}

/* Scrollbar personalizado para a sidebar (WebKit + Firefox) */
.sidebar::-webkit-scrollbar {
    width: 12px;
}
.sidebar::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}
.sidebar::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 8px;
    border: 3px solid var(--sidebar-bg);
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Firefox */
.sidebar {
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 var(--sidebar-bg);
}

.sidebar .logo {
    position: relative;
    text-align: center;
    padding: 10px 20px 20px;
    border-bottom: 1px solid var(--sidebar-border);
    margin-bottom: 10px;
}

.sidebar-menu-theme-toggle {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--sidebar-border);
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.sidebar-menu-theme-toggle:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    border-color: var(--sidebar-active);
}

.sidebar .logo h4 {
    color: var(--sidebar-heading);
    font-weight: 700;
    margin: 0;
    font-size: 18px;
}
    .sidebar .logo .sidebar-logo {
        height: 64px;
        width: auto;
        display: block;
        margin: 0 auto 8px;
        border-radius: 14px;
    }

    .sidebar .logo .logo-title {
        display: block;
        margin-top: 6px;
        font-size: 16px;
    }

.sidebar .logo small {
    color: #94a3b8;
    font-size: 12px;
}

.sidebar .nav-link {
    color: var(--sidebar-text);
    padding: 10px 12px;
    margin: 2px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background .15s, color .15s;
    border-radius: 10px;
    font-size: 14px;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-heading);
}
.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

/* Destaque para itens pai (expanders) quando uma sub-rotas está ativa */
.sidebar .nav-link.active-parent {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

/* Submenu expandido — recuo levemente indentado, sem fundo destacado */
.sidebar .collapse,
.sidebar .collapsing {
    background: transparent;
}

/* Animação suave dos submenus do sidebar */
.sidebar .collapsing {
    transition: height .3s ease !important;
    overflow: hidden;
}

/* Chevron do sidebar: rotação animada ao expandir/colapsar */
.sidebar .nav-link .bi-chevron-down {
    display: inline-block;
    transition: transform .3s ease;
}
.sidebar .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar .collapse .nav-link,
.sidebar .collapsing .nav-link {
    padding-top: 8px;
    padding-bottom: 8px;
    margin-left: 20px;
    color: #94a3b8;
    font-size: 13px;
}

.sidebar .collapse .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-heading);
}
.sidebar .collapse .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
}

.sidebar .user-info {
    width: 100%;
    padding: 14px 20px;
    background: var(--sidebar-hover);
    border-top: 1px solid var(--sidebar-border);
    font-size: 13px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar .user-info .user-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--sidebar-active);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
}

.sidebar .user-info .user-info-texto {
    flex: 1 1 auto;
    min-width: 0;
}

/* Conteúdo rolável dentro da sidebar (exclui o footer) */
.sidebar-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 6px; /* evita overlay da scrollbar */
}

.sidebar .user-info .nome {
    color: var(--sidebar-heading);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .user-info .tipo {
    color: #94a3b8;
    font-size: 11px;
    text-transform: uppercase;
}

/* ─── Content ─── */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

/* ─── Sidebar Collapse ─── */
body.sidebar-collapsed .sidebar {
    transform: translateX(calc(var(--sidebar-width) * -1));
}

body.sidebar-collapsed .main-content {
    margin-left: 0;
}

/* Desativa transições no carregamento inicial (evita flash) */
body.sidebar-no-transition .sidebar,
body.sidebar-no-transition .main-content,
body.sidebar-no-transition #sidebarToggleBtn {
    transition: none !important;
}

/* ─── Botão Toggle Sidebar ─── */
#sidebarToggleBtn {
    position: fixed;
    top: 16px;
    left: calc(var(--sidebar-width) - 2px);
    z-index: 1010;
    width: 20px;
    height: 46px;
    background: var(--sidebar-bg);
    color: #94a3b8;
    border: 1px solid var(--sidebar-border);
    border-left: none;
    border-radius: 0 10px 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: left 0.3s ease, color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
    padding: 0;
    font-size: 12px;
    box-shadow: 2px 0 8px rgba(15,23,42,0.06);
    line-height: 1;
}

#sidebarToggleBtn i {
    transition: transform 0.2s ease;
}

#sidebarToggleBtn:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-active);
    border-color: #dfe3ea;
    box-shadow: 3px 0 10px rgba(15,23,42,0.1);
}

#sidebarToggleBtn:hover i {
    transform: translateX(-2px);
}

body.sidebar-collapsed #sidebarToggleBtn:hover i {
    transform: translateX(2px);
}

#sidebarToggleBtn:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: 2px;
}

body.sidebar-collapsed #sidebarToggleBtn {
    left: 0;
}

.page-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e2e8f0;
}

.page-header h2 {
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

.stat-card {
    border-left: 4px solid var(--primary);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    color: #64748b;
    font-size: 13px;
    text-transform: uppercase;
}

/* ─── Search Box ─── */
.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid rgba(15,23,42,0.06);
    border-radius: 8px;
    max-height: 260px;
    overflow-y: auto;
    z-index: 2000;
    box-shadow: 0 8px 30px rgba(2,6,23,0.12);
    display: none;
    padding: 6px 6px;
}

.search-results .search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
    margin: 4px 2px;
    font-weight: 600;
    color: #0f172a;
}

.search-results .search-item:hover,
.search-results .search-item.active {
    background: var(--primary);
    color: #fff;
}

.search-results .search-item:hover code,
.search-results .search-item.active code {
    color: inherit;
}

.search-results .search-item + .search-item {
    /* subtle separator handled by spacing */
}

.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    padding: 4px;
    line-height: 1;
    cursor: pointer;
}

.search-clear-btn:hover {
    color: #475569;
}

/* ─── Cidadão Selecionado ─── */
.info-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-field-label {
    font-weight: 600;
    color: #198754;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-field-value {
    font-size: 15px;
    color: #1e293b;
    font-weight: 500;
    min-height: 22px;
}

/* ─── Botões Fichas ─── */
.ficha-btn {
    /* tamanho fixo e alinhamento central para todos os cartões */
    width: 260px;
    height: 140px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid #e2e8f0;
    background: #fff;
    text-decoration: none;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.ficha-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(13,110,253,0.2);
    transform: translateY(-2px);
}

.ficha-btn i {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

.ficha-btn h5 {
    margin: 0;
    font-weight: 600;
    line-height: 1.1;
}

.ficha-btn small {
    color: #64748b;
}

/* ─── Tabela ─── */
.table th {
    font-size: 13px;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}

/* ═══════════════════════════════════════════════
   ESTILOS PARA FICHAS A4 (IMPRESSÃO)
   ═══════════════════════════════════════════════ */

.ficha-a4 {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    background: #fff;
    padding: 10mm 12mm;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt;
    color: #000;
    box-sizing: border-box;
    position: relative;
}

.ficha-a4 .header-ficha {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
}

.ficha-a4 .header-ficha .logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ficha-a4 .header-ficha .logo-area img {
    height: 50px;
}

.ficha-a4 .header-ficha .header-titulo {
    font-weight: bold;
    font-size: 11pt;
    color: #004085;
    text-transform: uppercase;
    line-height: 1.4;
}

.ficha-a4 .header-ficha .datas {
    text-align: right;
    font-size: 9pt;
    color: #333;
}

.ficha-a4 .header-ficha .datas p {
    margin: 2px 0;
}

.ficha-a4 .titulo-ficha {
    text-align: center;
    font-weight: bold;
    font-size: 13pt;
    background: #004085;
    color: #fff;
    border: 1px solid #000;
    padding: 5px 0;
    margin-bottom: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ficha-a4 .dados-table {
    width: 100%;
    border-collapse: collapse;
}

.ficha-a4 .dados-table td {
    border: 1px solid #000;
    padding: 5px 8px;
    font-size: 10pt;
    vertical-align: top;
    line-height: 1.5;
}

.ficha-a4 .dados-table .label {
    font-weight: bold;
    color: #004085;
    font-size: 8pt;
    text-transform: uppercase;
    display: block;
    margin-bottom: 1px;
}

.ficha-a4 .dados-table .valor {
    font-size: 10pt;
    font-weight: 500;
}

.ficha-a4 .secao-titulo {
    text-align: center;
    font-weight: bold;
    font-size: 11pt;
    border: 1px solid #000;
    border-top: none;
    padding: 4px 0;
    background: #e9ecef;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ficha-a4 .exames-list {
    border: 1px solid #000;
    border-top: none;
    padding: 8px 12px;
    min-height: 100px;
    columns: 2;
    column-gap: 15px;
}

.ficha-a4 .exames-list label {
    display: block;
    font-size: 9pt;
    margin-bottom: 3px;
    font-weight: bold;
    break-inside: avoid;
    line-height: 1.5;
}

.ficha-a4 .exames-list input[type="checkbox"] {
    margin-right: 5px;
    transform: scale(1.1);
}

.ficha-a4 .observacoes-box {
    border: 1px solid #000;
    border-top: none;
    min-height: 100px;
    padding: 10px;
}

.ficha-a4 .procedimento-box {
    border: 1px solid #000;
    border-top: none;
    padding: 10px 15px;
}

.ficha-a4 .procedimento-box .proc-titulo {
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-size: 11pt;
}

.ficha-a4 .procedimento-box .linha {
    border-bottom: 1px solid #999;
    height: 28px;
    margin-bottom: 2px;
}

.ficha-a4 .campo-extra {
    font-size: 10pt;
    margin-top: 10px;
    padding: 0 15px;
}

.ficha-a4 .assinatura-area {
    text-align: center;
    margin-top: 40px;
}

.ficha-a4 .assinatura-area .linha-ass {
    width: 320px;
    border-bottom: 1px solid #000;
    margin: 0 auto 5px;
}

.ficha-a4 .assinatura-area p {
    margin: 2px 0;
    font-size: 10pt;
}

.ficha-a4 .secretario-area {
    text-align: center;
    position: absolute;
    bottom: 15mm;
    left: 0;
    right: 0;
}

.ficha-a4 .secretario-area .linha-ass {
    width: 320px;
    border-bottom: 1px solid #000;
    margin: 0 auto 5px;
}

.ficha-a4 .secretario-area p {
    margin: 2px 0;
    font-size: 10pt;
}

.ficha-a4 .secretario-area .nome-sec {
    font-weight: bold;
}

/* ─── Print ─── */
@media print {
    @page {
        size: A4;
        margin: 0;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        width: 210mm;
        height: 297mm;
        overflow: hidden;
    }

    .no-print,
    .print-toolbar {
        display: none !important;
    }

    .ficha-wrapper {
        margin: 0 !important;
        padding: 0 !important;
    }

    .ficha-a4 {
        margin: 0 !important;
        padding: 10mm 15mm !important;
        box-shadow: none !important;
        border: none !important;
        min-height: 297mm;
        max-height: 297mm;
        width: 210mm;
        position: absolute;
        top: 0;
        left: 0;
        overflow: hidden;
        page-break-after: avoid;
        page-break-inside: avoid;
    }

    .ficha-a4-preview {
        box-shadow: none !important;
    }
}

/* ─── Tela de preview ─── */
.print-toolbar {
    background: #1e293b;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
}

.print-toolbar .btn {
    font-size: 14px;
}

.ficha-wrapper {
    margin-top: 60px;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.ficha-a4-preview {
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

/* ═══════════════════════════════════════════════
   ESTILOS PARA ESCALA MÉDICA (CALENDÁRIO)
   ═══════════════════════════════════════════════ */

.escala-table {
    table-layout: fixed;
    border-collapse: collapse;
}

/* ═══════════════════════════════════════════════
   ÍCONES SVG CUSTOMIZADOS (substituem bi-* quando
   o Bootstrap Icons não tem um glifo adequado)
   ═══════════════════════════════════════════════ */

.b360-icon-svg {
    height: 1.45em;
    width: auto;
    vertical-align: -0.32em;
    display: inline-block;
    flex-shrink: 0;
    fill: currentColor;
}

.escala-header th {
    background: #fff;
    color: #000;
    font-weight: bold;
    text-align: center;
    font-size: 11px;
    padding: 6px 2px;
    border: 1px solid #000;
    width: 14.28%;
}

.escala-header th.th-weekend {
    background: #c00;
    color: #fff;
}

.escala-cell {
    vertical-align: top;
    padding: 4px !important;
    min-height: 110px;
    height: 110px;
    position: relative;
    font-size: 11px;
    border: 1px solid #bbb;
}

.escala-cell-empty {
    background: #f9f9f9;
}

.escala-cell-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.escala-cell-content .escala-dia-num {
    flex-shrink: 0;
}

.escala-cell-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.escala-cell-single .escala-cell-body {
    justify-content: center;
}

.escala-dia-num {
    text-align: right;
    font-weight: bold;
    font-size: 12px;
    color: #555;
    margin-bottom: 3px;
}

.escala-evento {
    font-weight: bold;
    font-size: 9px;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 2px;
    position: relative;
}

.escala-evento .btn-del-sm {
    position: absolute;
    right: -2px;
    top: -2px;
}

.escala-entrada {
    text-align: center;
    margin-bottom: 3px;
    padding: 3px 2px;
    background: #f0f4ff;
    border-radius: 3px;
    position: relative;
    line-height: 1.3;
}

.escala-entrada.escala-em-aberto {
    background: #fff0f0;
}

.escala-prof-nome {
    font-weight: bold;
    font-size: 10px;
    text-transform: uppercase;
    color: #000;
}

.escala-turno {
    font-size: 9px;
    text-transform: uppercase;
    color: #e67300;
    font-weight: bold;
}

.escala-del-form {
    position: absolute;
    top: 0;
    right: 2px;
}

.btn-del-sm {
    background: none;
    border: none;
    color: #c00;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.5;
}

.btn-del-sm:hover {
    opacity: 1;
}

.escala-add-area {
    position: absolute;
    bottom: 2px;
    left: 2px;
    display: flex;
    gap: 2px;
}
