/* Retencao e Microbiologia - estilo base */

* { box-sizing: border-box; }

/* ============ PALETA PADRAO (Frooty) ============ */
:root {
    --topbar-bg: #ffffff;
    --topbar-text: #1e3a8a;
    --topbar-border: #e5e7eb;

    --sidebar-bg: #ffffff;
    --sidebar-text: #1f2937;
    --sidebar-hover-bg: #f3f4f6;
    --sidebar-active-bg: #eff6ff;
    --sidebar-active-text: #1e3a8a;
    --sidebar-active-border: #1e3a8a;

    --content-bg: #f4f6f8;
}

/* ============ PALETAS ALTERNATIVAS ============ */
body.tema-esmeralda {
    --topbar-bg: #065f46;
    --topbar-text: #ecfdf5;
    --topbar-border: #064e3b;

    --sidebar-hover-bg: #ecfdf5;
    --sidebar-active-bg: #d1fae5;
    --sidebar-active-text: #065f46;
    --sidebar-active-border: #065f46;

    --content-bg: #f0fdf4;
}

body.tema-vinho {
    --topbar-bg: #7f1d1d;
    --topbar-text: #fef2f2;
    --topbar-border: #991b1b;

    --sidebar-hover-bg: #fef2f2;
    --sidebar-active-bg: #fee2e2;
    --sidebar-active-text: #7f1d1d;
    --sidebar-active-border: #7f1d1d;

    --content-bg: #fdf6f6;
}

body.tema-roxo {
    --topbar-bg: #5b21b6;
    --topbar-text: #ede9fe;
    --topbar-border: #4c1d95;

    --sidebar-hover-bg: #f5f3ff;
    --sidebar-active-bg: #ede9fe;
    --sidebar-active-text: #5b21b6;
    --sidebar-active-border: #5b21b6;

    --content-bg: #faf5ff;
}

body.tema-cinza {
    --topbar-bg: #1f2937;
    --topbar-text: #f9fafb;
    --topbar-border: #111827;

    --sidebar-hover-bg: #f3f4f6;
    --sidebar-active-bg: #e5e7eb;
    --sidebar-active-text: #111827;
    --sidebar-active-border: #6b7280;

    --content-bg: #f9fafb;
}

/* ============ BASE ============ */
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--content-bg);
    color: #1f2937;
}

a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ AUTH ============ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 30% 20%, #6d28d9 0%, #4c1d95 55%, #3b0d6e 100%);
}
.auth-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 410px;
}
.auth-logo-top {
    width: 58%;
    max-width: 210px;
    height: auto;
    margin-bottom: 26px;
    filter: drop-shadow(0 6px 14px rgba(0,0,0,0.30));
}
.auth-card {
    background: #fff;
    padding: 36px 32px;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.30);
    width: 100%;
    text-align: center;
}
.auth-card h1 {
    margin: 0 0 4px;
    color: #5b21b6;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1.2;
}
.auth-sub {
    color: #6b7280;
    font-size: 14px;
    margin: 0 0 26px;
}
.auth-card p {
    color: #6b7280;
    margin-bottom: 24px;
    font-size: 14px;
}
.auth-logo {
    display: block;
    margin: 0 auto 16px;
    max-width: 180px;
    height: auto;
}
/* Botão "Entrar com Microsoft" */
.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 13px 16px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #1f2937 !important;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none !important;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn-microsoft:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: 0 3px 10px rgba(0,0,0,0.10);
}
.btn-microsoft svg { width: 19px; height: 19px; display: block; }
.auth-rodape {
    margin-top: 22px;
    color: rgba(255,255,255,0.75);
    font-size: 12px;
}

/* ============ BOTOES ============ */
/* Tamanho padrao para todos os botoes do sistema */
.btn-primary,
.btn-secondary,
.btn-danger {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    text-align: center;
    vertical-align: middle;
    transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
    background: #1e3a8a;
    color: #fff !important;
    font-weight: 600;
}
.btn-primary:hover { background: #1e40af; text-decoration: none; }

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937 !important;
}
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }

.btn-danger {
    background: #dc2626;
    color: #fff !important;
    font-weight: 600;
}
.btn-danger:hover { background: #b91c1c; text-decoration: none; }

/* Variante maior para CTAs principais (ex.: tela de login) */
.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

/* Botoes que mostram apenas icone (acoes em tabelas) */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    width: 34px;
    height: 34px;
    line-height: 1;
}
.btn-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* Botoes com icone + texto (ex.: "Nova retenção" com +) */
.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-with-icon svg { width: 16px; height: 16px; display: block; }

/* Espacamento entre acoes inline em tabelas */
td .btn-icon + .btn-icon,
td .btn-icon + form,
td form + .btn-icon,
td form + form,
td a + a,
td a + form,
td form + a { margin-left: 4px; }

td form { display: inline-block; vertical-align: middle; margin: 0; }
td .btn-icon { vertical-align: middle; }

/* Forca a ultima coluna (acoes) a manter botoes em uma linha so */
table tr > td:last-child {
    white-space: nowrap;
}

.btn-link {
    color: var(--topbar-text) !important;
    margin-left: 12px;
}

/* ============ LAYOUT ============ */
.topbar {
    background: var(--topbar-bg);
    color: var(--topbar-text);
    border-bottom: 1px solid var(--topbar-border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.topbar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--topbar-text) !important;
    font-size: 18px;
    text-decoration: none;
}
.topbar .brand:hover { text-decoration: none; opacity: 0.85; }
.topbar .brand img { height: 32px; width: auto; display: block; }
.topbar .user {
    color: var(--topbar-text);
    font-size: 14px;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.user-avatar-fallback {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.layout {
    display: flex;
    min-height: calc(100vh - 57px);
}

.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    border-right: 1px solid #e5e7eb;
    padding: 16px 0;
}
.sidebar a.menu-item {
    display: block;
    padding: 10px 20px;
    color: var(--sidebar-text) !important;
    border-left: 3px solid transparent;
}
.sidebar a.menu-item:hover { background: var(--sidebar-hover-bg); text-decoration: none; }
.sidebar a.menu-item.active {
    background: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active-border);
    color: var(--sidebar-active-text) !important;
    font-weight: 600;
}

/* ============ GRUPOS DE MENU ============ */
.sidebar .menu-group {
    margin: 0;
}
.sidebar .menu-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-weight: 600;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 3px solid transparent;
}
.sidebar .menu-group > summary::-webkit-details-marker { display: none; }
.sidebar .menu-group > summary::marker { display: none; content: ''; }
.sidebar .menu-group > summary:hover { background: var(--sidebar-hover-bg); }
.sidebar .menu-group > summary::after {
    content: '▸';
    font-size: 12px;
    color: #9ca3af;
    transition: transform 0.15s;
    margin-left: 8px;
}
.sidebar .menu-group[open] > summary::after {
    transform: rotate(90deg);
}
.sidebar .menu-sub a.menu-item {
    padding-left: 36px;
    font-size: 14px;
}

/* ============ TOGGLE DO MENU LATERAL ============ */
.btn-toggle-sidebar {
    background: transparent;
    border: none;
    color: var(--topbar-text);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    padding: 4px 10px;
    margin-right: 10px;
    border-radius: 6px;
    transition: opacity 0.15s;
}
.btn-toggle-sidebar:hover { opacity: 0.75; }
.topbar-left {
    display: flex;
    align-items: center;
}

.sidebar-collapsed .sidebar { display: none; }

/* Ajuda / Configurações / Sair vivem na topbar no desktop; o rodapé do menu
   é a versão para celular, onde a topbar não tem espaço. */
.menu-rodape { display: none; }
.sidebar-fundo { display: none; }

/* ============ AUTOCOMPLETE ============ */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 360px;
    max-width: 600px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    max-height: 280px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}
.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    line-height: 1.4;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: #eff6ff; }
.autocomplete-item .ac-codigo { color: #1e3a8a; font-weight: 600; margin-right: 8px; }
.autocomplete-item .ac-desc { color: #4b5563; }
.autocomplete-empty {
    padding: 10px 12px;
    color: #6b7280;
    font-size: 13px;
    text-align: center;
}

.content {
    flex: 1;
    padding: 24px;
}

/* ============ COMPONENTES ============ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.page-header h1 {
    margin: 0;
    font-size: 22px;
    color: #1f2937;
}

.card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

table {
    width: 100%;
    background: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
th, td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
}
th { background: #f9fafb; font-weight: 600; color: #4b5563; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

.row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.field { flex: 1; min-width: 180px; }
.row label,
.field label {
    display: block;
    font-size: 13px;
    color: #4b5563;
    margin-bottom: 4px;
    font-weight: 500;
}
.row input, .row select, .row textarea,
.field input, .field select, .field textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.row input:focus, .row select:focus, .row textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.row textarea, .field textarea { min-height: 80px; resize: vertical; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; }

/* Tabela com inputs/selects/textareas dentro das celulas (ex.: tolerancias por pais) */
.tabela-form td select,
.tabela-form td input,
.tabela-form td textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
.tabela-form td textarea {
    min-height: 60px;
    resize: vertical;
}
.tabela-form td select:focus,
.tabela-form td input:focus,
.tabela-form td textarea:focus {
    outline: none;
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.tabela-form td { vertical-align: top; }

/* Validação visual do campo Resultado (entre m e M) */
.input-conforme {
    background: #d1fae5 !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
    font-weight: 600;
}
.input-nao-conforme {
    background: #fee2e2 !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
    font-weight: 600;
}

/* Grid de 6 colunas iguais (para alinhar campos em multiplas linhas) */
.grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
    margin-bottom: 12px;
}
@media (max-width: 1024px) {
    .grid-6 { grid-template-columns: repeat(3, 1fr); }
    .grid-6 .field[style*="grid-column"] { grid-column: span 3 !important; }
}
@media (max-width: 600px) {
    .grid-6 { grid-template-columns: repeat(2, 1fr); }
    .grid-6 .field[style*="grid-column"] { grid-column: span 2 !important; }
}

/* ============ LOADING ============ */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
    animation: fadeIn 0.15s ease-out;
}
.loading-overlay .spinner {
    width: 56px;
    height: 56px;
    border: 5px solid #e5e7eb;
    border-top-color: #1e3a8a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}
.loading-overlay .msg {
    font-size: 15px;
    color: #1e3a8a;
    font-weight: 600;
}
.loading-overlay .submsg {
    font-size: 13px;
    color: #6b7280;
    margin-top: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef3c7; color: #92400e; }
.badge-info      { background: #dbeafe; color: #1e40af; }
.badge-primary   { background: #c7d2fe; color: #3730a3; }
.badge-purple    { background: #ede9fe; color: #5b21b6; }
.badge-pink      { background: #fce7f3; color: #9d174d; }
.badge-orange    { background: #ffedd5; color: #9a3412; }
.badge-secondary { background: #e5e7eb; color: #4b5563; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Grids genericos do dashboard quebram em telas pequenas */
@media (max-width: 900px) {
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.stat-card .label { color: #6b7280; font-size: 13px; margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #1e3a8a; }

.empty {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.filters-bar {
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

/* ============ SELETOR DE TEMA ============ */
.tema-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 8px;
}
.tema-card {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
}
.tema-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.tema-card.selected {
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30,58,138,0.1);
}
.tema-card .preview {
    display: flex;
    height: 90px;
}
.tema-card .preview .pv-topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 24px;
}
.tema-card .preview .pv-sidebar {
    width: 38%;
    margin-top: 24px;
    border-right: 1px solid #e5e7eb;
}
.tema-card .preview .pv-content {
    flex: 1;
    margin-top: 24px;
}
.tema-card .info {
    padding: 12px 14px;
    border-top: 1px solid #f3f4f6;
}
.tema-card .info .nome {
    font-weight: 600;
    color: #1f2937;
    font-size: 15px;
}
.tema-card .info .selecionado {
    display: none;
    font-size: 12px;
    color: #065f46;
    background: #d1fae5;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
}
.tema-card.selected .info .selecionado { display: inline-block; }
.tema-card input[type=radio] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* ============ LISTA DE FORMULARIOS (PREENCHER) ============ */
/* ===== Busca de formulários ===== */
.pf-busca {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.pf-busca input[type="search"] {
    flex: 1;
    max-width: 460px;
    padding: 11px 14px;
    font-size: 15px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    -webkit-appearance: none;
}
.pf-busca input[type="search"]:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}
.pf-contador { font-size: 13px; color: #6b7280; white-space: nowrap; }

/* ===== Agrupamento por área ===== */
.pf-grupo { margin-bottom: 26px; }
.pf-grupo[hidden] { display: none; }
.pf-grupo-tit {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.pf-grupo-tit small {
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    background: #ede9fe;
    color: #5b21b6;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* ===== Cartões ===== */
.preencher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 14px;
}
.preencher-card {
    display: flex;
    flex-direction: column;
    min-height: 148px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #7c3aed;
    border-radius: 10px;
    padding: 16px 16px 12px;
    text-decoration: none !important;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: transform .1s, box-shadow .15s, border-color .15s;
}
/* display:flex venceria o atributo hidden usado pela busca */
.preencher-card[hidden] { display: none !important; }

.preencher-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.1);
    border-left-color: #5b21b6;
}
.preencher-card:focus-visible {
    outline: 3px solid #a78bfa;
    outline-offset: 2px;
}

.preencher-card .pc-topo { display: block; margin-bottom: 10px; }
.preencher-card .pc-nome {
    display: block;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    /* Vários formulários têm nome em CAIXA ALTA: normaliza o peso visual. */
    text-transform: none;
}
.preencher-card .pc-desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;      /* 2 linhas: evita cartão gigante ao lado de um curto */
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 5px;
    font-size: 12.5px;
    line-height: 1.45;
    color: #6b7280;
}

.preencher-card .pc-rodape {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.preencher-card .pc-codigo {
    font-size: 11px;
    color: #9ca3af;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.preencher-card .pc-acao {
    margin-left: auto;
    font-weight: 600;
    font-size: 13.5px;
    color: #5b21b6;
    white-space: nowrap;
}

/* Toque: em tela sem mouse o cartão cresce e o hover não se aplica. */
@media (hover: none) {
    .preencher-card { min-height: 160px; padding: 18px 18px 14px; }
    .preencher-card:hover { transform: none; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
    .preencher-card .pc-nome { font-size: 16px; }
    .pf-busca input[type="search"] { max-width: none; padding: 13px 16px; font-size: 16px; }
}
@media (max-width: 600px) {
    .preencher-grid { grid-template-columns: 1fr; }
    .pf-busca { flex-direction: column; align-items: stretch; }
    .pf-contador { text-align: right; }
}

/* ============ PREENCHIMENTO (TABLET) ============ */
.preencher-body { background: var(--content-bg); }
.preencher-topo {
    position: sticky; top: 0; z-index: 10;
    background: var(--topbar-bg); color: var(--topbar-text);
    border-bottom: 1px solid var(--topbar-border);
    padding: 12px 18px; display: flex; align-items: center; gap: 16px;
}
.preencher-topo .pt-voltar { color: var(--topbar-text) !important; font-weight: 600; white-space: nowrap; }
.preencher-topo .pt-titulo { display: flex; flex-direction: column; line-height: 1.2; }
.preencher-topo .pt-titulo small { opacity: 0.8; font-size: 12px; }
.preencher-main { max-width: 820px; margin: 0 auto; padding: 18px; }

.secao {
    background: #fff; border-radius: 10px; padding: 16px 18px;
    margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: grid; grid-template-columns: repeat(12, 1fr);
    column-gap: 16px; row-gap: 0; align-items: start;
}
.secao-titulo {
    grid-column: 1 / -1;
    font-size: 16px; margin: 0 0 12px; padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb; color: #1f2937;
}

.campo { margin-bottom: 18px; grid-column: 1 / -1; }
.campo:last-child { margin-bottom: 0; }
/* Larguras (grade de 12 colunas) */
.campo-w-6 { grid-column: span 6; }
.campo-w-4 { grid-column: span 4; }
.campo-w-3 { grid-column: span 3; }

/* "Data e hora" mostra dd/mm/aaaa hh:mm mais o icone do calendario: nao cabe
   em 1/4 de linha e o navegador corta os minutos. Quando o campo for desse
   tipo, o quarto vira um terco -- e a largura minima em que o conteudo cabe
   inteiro. As demais larguras escolhidas no construtor sao respeitadas. */
.campo-w-3:has(input[type="datetime-local"]) { grid-column: span 4; }

/* Um pouco mais justo que os demais inputs, para sobrar folga ao conteudo. */
.preencher-form input[type="datetime-local"] { padding-left: 10px; padding-right: 8px; }
.campo-informativo { grid-column: 1 / -1; }
@media (max-width: 640px) {
    .campo-w-6, .campo-w-4, .campo-w-3 { grid-column: 1 / -1; }
}
.campo-label { display: block; font-weight: 600; font-size: 15px; margin-bottom: 6px; color: #1f2937; }
.campo-label .obrig, .obrig { color: #dc2626; }
.campo-ajuda { font-size: 13px; color: #6b7280; margin-bottom: 8px; }
.campo-fixo { padding: 10px 12px; background: #f3f4f6; border-radius: 8px; font-size: 15px; }
.campo-informativo {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    border-radius: 8px; padding: 12px 14px; font-size: 14px; margin-bottom: 18px;
}
.campo-informativo.info-centro { text-align: center; }
.campo-informativo.info-direita { text-align: right; }

/* Inputs grandes para toque */
.preencher-form input[type=text],
.preencher-form input[type=number],
.preencher-form input[type=date],
.preencher-form input[type=time],
/* datetime-local precisa vir aqui: sem a regra o campo fica com a largura
   intrinseca do navegador, estreito ao lado dos demais. */
.preencher-form input[type="datetime-local"],
.preencher-form input[type=file],
.preencher-form select,
.preencher-form textarea {
    width: 100%; padding: 12px 14px; font-size: 16px;
    border: 1px solid #d1d5db; border-radius: 8px; font-family: inherit; background: #fff;
}
.preencher-form input:focus, .preencher-form select:focus, .preencher-form textarea:focus {
    outline: none; border-color: #1e3a8a; box-shadow: 0 0 0 3px rgba(30,58,138,0.12);
}

/* Botões de opção (radio) grandes */
.opcao-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; margin: 0 8px 8px 0;
    border: 1px solid #d1d5db; border-radius: 8px; cursor: pointer;
    font-size: 15px; background: #fff; user-select: none;
}
.opcao-btn:has(input:checked) { border-color: #1e3a8a; background: #eff6ff; font-weight: 600; }
.opcao-check {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 4px; font-size: 15px; cursor: pointer;
}

/* Checklist */
.checklist-lista { display: flex; flex-direction: column; }
.checklist-lista .cl-linha { padding: 8px 0; border-bottom: 1px solid #f3f4f6; }
.checklist-lista .cl-linha:last-child { border-bottom: none; }
.checklist-lista .cl-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.checklist-lista .cl-item { font-weight: 500; }
/* Observação por item: largura total, escondida até o item ser marcado como negativo (NOK/Não/Não atende) */
.checklist-lista .cl-obs {
    display: none;
    box-sizing: border-box;
    width: 100%;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 14px;
    text-align: left;
    border: 1px solid #d1d5db;
    border-radius: 8px;
}
.cl-linha:has(.tg-nao input:checked) .cl-obs { display: block; }

/* Toggle liga/desliga (Atende/Não atende, Sim/Não) */
.toggle-group {
    display: inline-flex;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    background: #f3f4f6;
    padding: 2px;
    gap: 2px;
    max-width: 100%;
}
/* Com uma 3a opção (ex.: "Não Aplicável") o grupo pode quebrar de linha no
   tablet — a pílula redonda fica estranha quebrada, então arredonda menos. */
.toggle-group:has(> :nth-child(3)) {
    flex-wrap: wrap;
    border-radius: 14px;
}
.toggle-group:has(> :nth-child(3)) .toggle-opt span {
    border-radius: 10px;
    padding-left: 14px;
    padding-right: 14px;
}
.toggle-opt { position: relative; cursor: pointer; user-select: none; }
.toggle-opt input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-opt span {
    display: block;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    border-radius: 999px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.toggle-opt.tg-sim:has(input:checked) span { background: #10b981; color: #fff; }
.toggle-opt.tg-nao:has(input:checked) span { background: #ef4444; color: #fff; }
/* N/A é neutro de propósito: não é acerto nem desvio. */
.toggle-opt.tg-na:has(input:checked) span { background: #6b7280; color: #fff; }
.toggle-opt input:focus-visible + span { outline: 2px solid #1e3a8a; outline-offset: 1px; }

/* ===== Escala / nota (1 a N) ===== */
.escala {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
}
.esc-rotulo { font-size: 12.5px; color: #6b7280; }
.esc-opcoes {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px;
}
.esc-opt { position: relative; cursor: pointer; user-select: none; }
.esc-opt input { position: absolute; opacity: 0; pointer-events: none; }
.esc-opt span {
    display: flex;
    align-items: center;
    justify-content: center;
    /* Alvo de toque confortável no tablet, que é onde isto é preenchido. */
    min-width: 46px;
    height: 46px;
    padding: 0 6px;
    font-size: 16px;
    font-weight: 700;
    color: #4b5563;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    transition: background .15s, color .15s, border-color .15s;
}
.esc-opt:hover span { border-color: #a78bfa; }
.esc-opt:has(input:checked) span {
    background: #5b21b6;
    border-color: #5b21b6;
    color: #fff;
}
.esc-opt input:focus-visible + span { outline: 2px solid #1e3a8a; outline-offset: 2px; }

/* Tabela/grade repetível */
.tabela-campo { overflow-x: auto; }
.tabela-grade { width: 100%; box-shadow: none; border: 1px solid #e5e7eb; }
.tabela-grade th { background: #f9fafb; font-size: 13px; padding: 8px; }
.tabela-grade td { padding: 6px; border-bottom: 1px solid #f3f4f6; }
.tabela-grade .td-item { font-weight: 600; white-space: nowrap; }
.tabela-grade input, .tabela-grade select { padding: 8px 10px; font-size: 14px; }

/* Graficos do painel */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card h2 { margin: 0 0 12px; font-size: 15px; color: #1f2937; }
.chart-card h2 small { color: #9ca3af; font-weight: 400; font-size: 12px; margin-left: 6px; }
.chart-box { position: relative; height: 260px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

/* Indicador de formularios aguardando envio (offline) */
.offline-badge {
    position: fixed; bottom: 16px; right: 16px; z-index: 9998;
    background: #b45309; color: #fff; padding: 11px 16px;
    border-radius: 10px; font-size: 13px; font-weight: 600;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25); cursor: pointer; max-width: 90vw;
}
.offline-badge:hover { background: #92400e; }

/* Botoes de ordenacao (subir/descer campo) */
.ordem-btns { display: inline-flex; flex-direction: column; gap: 3px; width: 30px; }
.ordem-btns form { margin: 0; display: block; }
.btn-ordem {
    width: 30px; height: 20px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid #d1d5db; background: #fff; color: #4b5563;
    border-radius: 5px; cursor: pointer; font-size: 10px; line-height: 1;
    transition: background 0.12s;
}
.btn-ordem:hover:not(:disabled) { background: #eff6ff; border-color: #1e3a8a; color: #1e3a8a; }
.btn-ordem:disabled { opacity: 0.3; cursor: default; }

/* Lista multi-coluna */
.lista-multi-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.lista-col-campo { flex: 1; min-width: 160px; }
.lista-col-label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 4px; font-weight: 500; }
.lista-col-campo input[readonly] { background: #f3f4f6; }

/* Assinatura */
.assinatura-wrap { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.assinatura-box {
    position: relative; height: 200px; overflow: hidden;
    border: 2px dashed #cbd5e1; border-radius: 10px; background: #fafbfc;
    transition: border-color 0.15s, background 0.15s;
}
.assinatura-box:hover { border-color: #94a3b8; }
.assinatura-box.assinando { border-style: solid; border-color: #1e3a8a; background: #fff; }
.assinatura-canvas {
    position: relative; z-index: 2;
    display: block; width: 100%; height: 100%;
    touch-action: none; cursor: crosshair;
}
.assinatura-hint {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    color: #cbd5e1; font-size: 18px; font-weight: 500;
    pointer-events: none; user-select: none; z-index: 1;
}
.assinatura-box.assinando .assinatura-hint { display: none; }
.assinatura-linha {
    position: absolute; left: 28px; right: 28px; bottom: 44px;
    height: 1px; background: #e2e8f0; z-index: 1;
}
.assinatura-rodape { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.assinatura-rodape small { color: #9ca3af; font-size: 12px; }
.btn-icon-text { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; }
.btn-icon-text svg { width: 14px; height: 14px; display: block; }

.preencher-acoes { margin: 22px 0 40px; display: flex; flex-direction: column; gap: 10px; }
.btn-rascunho { width: 100%; padding: 14px; font-size: 16px; }
.btn-enviar { width: 100%; padding: 16px; font-size: 18px; }

/* Banner "Em andamento" (rascunhos) */
.andamento-banner {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 18px; padding: 14px 16px;
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    border-radius: 10px; font-size: 15px;
}
.andamento-banner:hover { background: #fef3c7; text-decoration: none; }
.andamento-banner .ab-acao { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* ============ VISUALIZACAO DE RESPOSTA ============ */
.resp-cabecalho { border-left: 4px solid #5b21b6; }
.rc-topo {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid #f3f4f6;
}
.rc-form { font-size: 18px; font-weight: 700; color: #1f2937; line-height: 1.25; }
.rc-codigo { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.rc-meta { display: flex; flex-wrap: wrap; gap: 10px 36px; }
.rc-meta > div { display: flex; flex-direction: column; }
.rc-meta span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: #9ca3af; margin-bottom: 2px; }
.rc-meta strong { font-size: 14px; color: #374151; font-weight: 600; }

.resp-secao-tit {
    margin: 0 0 8px; font-size: 16px; color: #1f2937; font-weight: 700;
    padding-bottom: 8px; border-bottom: 2px solid #ede9fe;
}
.resp-item { display: flex; gap: 16px; padding: 11px 6px; border-radius: 6px; }
.resp-item:nth-child(even) { background: #fafafa; }
.resp-rotulo { flex: 0 0 240px; font-weight: 600; color: #6b7280; font-size: 14px; }
.resp-valor { flex: 1; font-size: 15px; color: #1f2937; }
.resp-mini { width: auto; min-width: 280px; box-shadow: none; border: 1px solid #e5e7eb; }
.resp-mini th, .resp-mini td { padding: 6px 10px; font-size: 13px; }
.resp-foto { max-width: 280px; max-height: 280px; border-radius: 8px; border: 1px solid #e5e7eb; }
.resp-assinatura { max-width: 320px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
@media (max-width: 700px) {
    .resp-item { flex-direction: column; gap: 4px; }
    .resp-rotulo { flex-basis: auto; }
}

/* ===== Respostas agrupadas por formulário ===== */
.grupo-resp {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 14px;
    overflow: hidden;
}
.grupo-resp > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    font-weight: 600;
    color: #1f2937;
    border-left: 4px solid #5b21b6;
}
.grupo-resp > summary::-webkit-details-marker { display: none; }
.grupo-resp > summary::marker { content: ''; }
.grupo-resp > summary:hover { background: #faf5ff; }

/* Seta indicando aberto/fechado */
.grupo-resp > summary .gr-nome::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    color: #9ca3af;
    font-weight: 400;
    transition: transform .15s;
}
.grupo-resp[open] > summary .gr-nome::before { transform: rotate(90deg); }

.grupo-resp .gr-nome { min-width: 0; }
.grupo-resp .gr-nome small {
    display: block;
    margin-left: 20px;
    color: #6b7280;
    font-weight: 400;
    font-size: 12px;
}
.grupo-resp .gr-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    white-space: nowrap;
}
.grupo-resp .gr-meta small { color: #6b7280; font-weight: 400; font-size: 12px; }

.grupo-resp .gr-corpo { padding: 0 14px 14px; }
/* A tabela interna já está dentro do card do grupo: sem sombra própria. */
.grupo-resp .gr-corpo table { box-shadow: none; border: 1px solid #e5e7eb; }
.grupo-resp .gr-acoes { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; }

@media (max-width: 700px) {
    .grupo-resp > summary { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ===== Paginação ===== */
.paginacao {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 16px 0 4px;
    font-size: 14px;
}
.paginacao a,
.paginacao .pg-atual {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    text-decoration: none;
}
.paginacao a:hover { background: #faf5ff; border-color: #ddd6fe; text-decoration: none; }
.paginacao .pg-atual { background: #5b21b6; border-color: #5b21b6; color: #fff; font-weight: 600; }
.paginacao .pg-sep { color: #9ca3af; padding: 0 2px; }
.paginacao .pg-info { color: #6b7280; font-size: 13px; margin-left: auto; }

/* ===== Lista com seleção múltipla (busca + etiquetas) ===== */
.lista-mult .lm-busca {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.lista-mult .lm-input { flex: 1; min-width: 0; }
.lista-mult .lm-add { white-space: nowrap; flex-shrink: 0; }

.lista-mult .lm-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.lista-mult .lm-chips:empty { margin-top: 0; }

.lm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ede9fe;
    border: 1px solid #ddd6fe;
    color: #4c1d95;
    border-radius: 999px;
    padding: 6px 6px 6px 14px;
    font-size: 14px;
    font-weight: 600;
    max-width: 100%;
}
.lm-chip .lm-chip-txt {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lm-chip .lm-remove {
    /* Alvo de toque: 26px é o mínimo confortável para o dedo no tablet. */
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(76, 29, 149, .12);
    color: #4c1d95;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.lm-chip .lm-remove:hover { background: #dc2626; color: #fff; }

/* Exibição na resposta */
.resp-lista-mult { margin: 0; padding-left: 20px; }
.resp-lista-mult li { margin-bottom: 3px; }

/* ===== Hub de relatórios ===== */
.rel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 16px;
}
.rel-card { display: flex; flex-direction: column; margin-bottom: 0; }
.rel-card h2 { margin: 0 0 6px; font-size: 18px; }
.rel-card p { color: #6b7280; font-size: 13.5px; margin: 0 0 14px; }
.rel-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

/* ===== Acesso local na tela de login ===== */
.auth-alerta {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13.5px;
    margin-bottom: 18px;
    text-align: left;
}
.auth-externo { margin-top: 18px; text-align: left; }
.auth-externo > summary {
    list-style: none;
    cursor: pointer;
    text-align: center;
    font-size: 13.5px;
    color: #5b21b6;
    font-weight: 600;
    padding: 8px;
    user-select: none;
}
.auth-externo > summary::-webkit-details-marker { display: none; }
.auth-externo > summary::marker { content: ''; }
.auth-externo > summary:hover { text-decoration: underline; }
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; }
.auth-form label span { font-size: 13px; font-weight: 600; color: #4b5563; }
.auth-form input {
    padding: 11px 13px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}
.auth-form input:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .15);
}
.auth-nota { color: #6b7280; font-size: 12px; margin: 12px 0 0; line-height: 1.5; }


/* ===== Passos da carga por planilha ===== */
.imp-passos { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.imp-passo { display: flex; gap: 12px; align-items: flex-start; }
.imp-passo > div { flex: 1; min-width: 0; }
.imp-passo strong { font-size: 14.5px; color: #1f2937; }
.imp-passo p { margin: 3px 0 0; font-size: 13.5px; color: #6b7280; line-height: 1.5; }
.imp-num {
    flex-shrink: 0;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    background: #ede9fe; color: #5b21b6;
    border-radius: 50%; font-size: 13px; font-weight: 700;
}
.imp-exemplo {
    width: auto; min-width: 0; margin: 8px 0 0;
    box-shadow: none; border: 1px solid #e5e7eb; border-radius: 6px;
}
.imp-exemplo th, .imp-exemplo td { padding: 6px 12px; font-size: 12.5px; }
.imp-exemplo th { background: #f9fafb; color: #374151; text-transform: none; letter-spacing: 0; }
/* Marca a coluna que vira a chave de busca do item. */
.imp-exemplo th.imp-chave { background: #ede9fe; color: #5b21b6; }
.imp-nota { margin-top: 6px !important; font-size: 12.5px !important; }


/* ===== Página de ajuda ===== */
.ajuda-indice { background: #faf5ff; border: 1px solid #ddd6fe; max-width: 900px; }
.ajuda-indice strong { display: block; margin-bottom: 8px; color: #5b21b6; font-size: 14px; }
.ajuda-indice ol { margin: 0; padding-left: 20px; columns: 2; column-gap: 32px; }
.ajuda-indice li { margin-bottom: 4px; font-size: 14px; break-inside: avoid; }

.ajuda { max-width: 900px; line-height: 1.65; }
.ajuda h2 {
    font-size: 20px; margin: 34px 0 12px; padding-top: 20px;
    border-top: 2px solid #ede9fe; color: #4c1d95;
    /* Compensa a topbar fixa ao pular por âncora */
    scroll-margin-top: 80px;
}
.ajuda h2:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.ajuda h3 { font-size: 16px; margin: 22px 0 8px; color: #1f2937; }
.ajuda p { margin: 0 0 12px; font-size: 15px; color: #374151; }
.ajuda ul, .ajuda ol { margin: 0 0 14px; padding-left: 22px; font-size: 15px; color: #374151; }
.ajuda li { margin-bottom: 6px; }
.ajuda table { margin: 0 0 16px; table-layout: fixed; }
.ajuda td, .ajuda th {
    font-size: 14px;
    vertical-align: top;
    /* A regra global deixa a ultima celula sem quebra, por causa dos botoes de
       acao das listagens. Aqui a ultima coluna e texto corrido e precisa
       quebrar, senao a tabela estoura a largura do card. */
    white-space: normal;
    overflow-wrap: anywhere;
}
.ajuda em { color: #4b5563; }

.ajuda-nota {
    background: #f9fafb; border-left: 3px solid #d1d5db;
    padding: 10px 14px; font-size: 14px !important; color: #4b5563 !important;
}
.ajuda-aviso {
    background: #fffbeb; border: 1px solid #fde68a; color: #78350f;
    border-radius: 8px; padding: 14px 16px; font-size: 14px; margin: 0 0 16px;
}

.ajuda-fluxo { display: flex; gap: 14px; flex-wrap: wrap; margin: 0 0 18px; }
.ajuda-fluxo > div {
    flex: 1; min-width: 190px;
    border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px;
    background: #fff;
}
.ajuda-fluxo span {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: #ede9fe; color: #5b21b6; font-weight: 700; font-size: 13px;
    margin-bottom: 8px;
}
.ajuda-fluxo strong { display: block; font-size: 15px; color: #1f2937; }
.ajuda-fluxo p { margin: 4px 0 0 !important; font-size: 13.5px !important; }

.ajuda-faq dt { font-weight: 600; color: #1f2937; margin-top: 16px; font-size: 15px; }
.ajuda-faq dd { margin: 6px 0 0; padding-left: 0; color: #4b5563; font-size: 14.5px; }

@media print {
    .topbar, .sidebar, .page-header .btn-secondary, .ajuda-indice { display: none; }
    .content { padding: 0; }
    .card { box-shadow: none; border: none; padding: 0; }
    .ajuda { max-width: none; }
    .ajuda h2 { page-break-after: avoid; }
    .ajuda table, .ajuda-faq dd { page-break-inside: avoid; }
}

/* ===== Campo Foto: câmera na página + miniaturas ===== */
.fc-acoes { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.fc-acoes input[type=file] { flex: 1; min-width: 200px; }
.fc-ou { color: #9ca3af; font-size: 13px; }

.fc-camera {
    position: relative;
    background: #111827;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
}
.fc-video {
    display: block;
    width: 100%;
    max-height: 420px;
    /* "contain" evita cortar a cena: o que se vê é o que a foto vai registrar. */
    object-fit: contain;
    background: #000;
}
.fc-camera-acoes {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 10px;
    background: #1f2937;
}
.fc-camera-acoes .btn-primary { flex: 1; min-width: 140px; padding: 12px; font-size: 16px; }

.fc-miniaturas { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.fc-miniaturas:empty { margin-top: 0; }
.fc-mini { position: relative; display: inline-block; }
.fc-mini img {
    display: block;
    width: 104px; height: 104px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
}
.fc-mini .fc-remover {
    position: absolute; top: -7px; right: -7px;
    /* 26px é o mínimo confortável para o dedo no tablet. */
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff; border-radius: 50%;
    background: #dc2626; color: #fff;
    font-size: 15px; line-height: 1; cursor: pointer; padding: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.fc-mini .fc-remover:hover { background: #b91c1c; }

.fc-aviso {
    margin: 10px 0 0;
    padding: 10px 12px;
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    border-radius: 8px; font-size: 13.5px;
}

/* Várias fotos na visualização da resposta */
.resp-fotos { display: flex; flex-wrap: wrap; gap: 10px; }
.resp-fotos .resp-foto { max-width: 200px; max-height: 200px; }

/* ============================================================
   CELULAR E TABLET EM RETRATO  (até 860px)
   O painel foi desenhado para tela larga: barra lateral fixa de 220px e
   tabelas de várias colunas. Num celular a barra comeria mais da metade da
   largura, então aqui ela vira gaveta e o conteúdo ocupa a tela inteira.
   ============================================================ */
@media (max-width: 860px) {

    /* ---- Barra lateral vira gaveta ---- */
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        max-width: 82vw;
        z-index: 60;
        overflow-y: auto;
        padding-top: 12px;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 0 0 28px rgba(0,0,0,.28);
    }
    .sidebar-aberta .sidebar { transform: translateX(0); }

    /* No celular a gaveta começa fechada; o estado salvo do desktop não vale */
    .sidebar-collapsed .sidebar { display: block; }

    .sidebar-fundo {
        display: block;   /* anula o display:none que o esconde no desktop */
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(17,24,39,.5);
        z-index: 55;
    }
    .sidebar-fundo[hidden] { display: none; }

    /* Alvo de toque maior nos itens do menu */
    .menu-item { padding: 13px 20px; font-size: 15px; }
    .menu-group > summary { padding: 13px 20px; }
    .menu-sub a.menu-item { padding-left: 34px; }

    /* Ajuda / Configurações / Sair descem para cá (somem da topbar) */
    .menu-rodape {
        display: block;
        margin-top: 14px;
        padding-top: 10px;
        border-top: 1px solid #e5e7eb;
    }

    /* ---- Topbar enxuta ---- */
    .topbar { padding: 10px 14px; }
    .topbar .brand { font-size: 16px; }
    .topbar .brand img { height: 26px; }
    /* Sem espaço para o nome nem para os links: ficam a marca e o avatar */
    .topbar .user > span:not(.user-avatar) { display: none; }
    .topbar .user .btn-link { display: none; }

    /* ---- Conteúdo ---- */
    .content { padding: 16px 14px; }
    .layout { min-height: calc(100vh - 53px); }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .page-header h1 { font-size: 21px; }
    /* Botões do cabeçalho em linha própria, ocupando a largura */
    .page-header > div { display: flex; flex-wrap: wrap; gap: 8px; }
    .page-header > div > a,
    .page-header > div > button,
    .page-header > a.btn-primary,
    .page-header > a.btn-secondary { flex: 1; text-align: center; }

    .card { padding: 16px 14px; }

    /* ---- Tabelas rolam de lado em vez de espremer ---- */
    /* display:block transforma a tabela num container rolável sem precisar
       envolver cada uma numa div — são muitas telas. */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    th, td { padding: 10px 12px; }
    /* A 1ª coluna costuma ser o nome do registro: pode quebrar e ficar legível */
    td:first-child { white-space: normal; min-width: 160px; }

    /* ---- Formulários e filtros empilhados ---- */
    .row { gap: 12px; }
    .field { min-width: 100%; }
    /* Larguras fixas declaradas nas telas não valem no celular */
    .field[style*="max-width"] { max-width: none !important; }
    .filters-bar .field button,
    .filters-bar .field a { flex: 1; }

    /* Alvo de toque nos campos */
    input[type=text], input[type=email], input[type=password], input[type=number],
    input[type=date], input[type=time], input[type="datetime-local"],
    input[type=search], select, textarea {
        font-size: 16px;   /* abaixo disto o iOS dá zoom ao focar */
        padding: 11px 12px;
    }

    .btn-primary, .btn-secondary, .btn-danger { padding: 10px 16px; }
    .btn-icon { width: 40px; height: 40px; }

    /* ---- Grades ---- */
    .cards-grid { grid-template-columns: 1fr 1fr !important; }
    .rel-grid, .chart-grid { grid-template-columns: 1fr; }
    .ajuda-indice ol { columns: 1; }
}

/* Telas bem estreitas (até 420px) */
@media (max-width: 420px) {
    .cards-grid { grid-template-columns: 1fr !important; }
    .preencher-grid { grid-template-columns: 1fr; }
    .page-header > div > a,
    .page-header > div > button { flex: 1 1 100%; }
}

/* Tela de preenchimento no celular */
@media (max-width: 640px) {
    .preencher-topo { padding: 10px 12px; gap: 10px; }
    .preencher-topo .pt-titulo strong { font-size: 15px; }
    .preencher-main { padding: 12px; }
    .secao { padding: 14px 12px; }
    /* Botões de enviar ocupam a largura e ficam altos: é o toque final e não
       pode depender de mira. */
    .btn-rascunho, .btn-enviar { padding: 16px; font-size: 17px; }
    .fc-mini img { width: 88px; height: 88px; }
}

/* ===== Bloco repetível =====
   Cada repetição é um cartão. No computador os campos ficam lado a lado,
   parecido com a linha de uma tabela; no celular eles empilham, que é o
   motivo de o bloco existir — uma tabela de 8 colunas não cabe na tela. */
.bloco-campo { display: flex; flex-direction: column; gap: 10px; }

.bl-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
    overflow: hidden;
}

.bl-topo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.bl-titulo { font-weight: 600; font-size: 13px; color: #374151; }

.bl-remover {
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 20px;
    line-height: 1;
    /* Alvo de 32px: com 20px o dedo erra e a pessoa apaga o bloco errado. */
    width: 32px; height: 32px;
    border-radius: 6px;
    cursor: pointer;
}
.bl-remover:hover { background: #fee2e2; color: #b91c1c; }

/* Flex, e nao grid, para que "Automática" e uma largura fixa convivam na
   mesma linha: o campo automatico estica no espaco que sobrou. */
.bl-campos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 12px;
}

.bl-campo {
    display: flex; flex-direction: column; gap: 4px;
    min-width: 0;
    flex: 1 1 160px;          /* automatica: divide a linha em partes iguais */
}

/* Larguras escolhidas no construtor. O desconto acompanha o gap de 12px para
   que a conta feche exatamente: 4 x (25% - 9px) + 3 x 12px = 100%. */
.bl-campo.bl-w-12 { flex: 0 0 100%; }
.bl-campo.bl-w-6  { flex: 0 0 calc(50% - 6px); }
.bl-campo.bl-w-4  { flex: 0 0 calc(33.333% - 8px); }
.bl-campo.bl-w-3  { flex: 0 0 calc(25% - 9px); }

/* "Data e hora" mostra dd/mm/aaaa hh:mm mais o icone: em 1/4 o navegador corta
   os minutos, entao o quarto vira um terco -- mesma regra do campo normal. */
.bl-campo.bl-w-3:has(input[type="datetime-local"]) { flex-basis: calc(33.333% - 8px); }
.bl-campo > label { font-size: 12px; font-weight: 500; color: #6b7280; }
.bl-campo input, .bl-campo select, .bl-campo textarea { width: 100%; }
.bl-campo textarea { resize: vertical; }

.bl-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }

.bl-acoes { display: flex; align-items: center; gap: 10px; }
.bl-acoes .bl-adicionar:disabled { opacity: .5; cursor: not-allowed; }
.bl-limite { font-size: 12px; color: #9ca3af; }

@media (max-width: 860px) {
    /* Uma coluna: no celular ler o rótulo acima do campo é mais rápido do que
       caçar a coluna certa, e 1/4 de tela não caberia nada. */
    .bl-campo,
    .bl-campo.bl-w-12, .bl-campo.bl-w-6, .bl-campo.bl-w-4, .bl-campo.bl-w-3 {
        flex: 0 0 100%;
    }
    .bl-acoes .bl-adicionar { width: 100%; text-align: center; }
}

@media print {
    .bl-acoes, .bl-remover { display: none; }
    .bl-item { break-inside: avoid; background: #fff; }
}

/* ===== Editor dos campos internos do bloco (construtor) =====
   Uma linha por campo: ordem, rótulo, tipo, opções, remover. O tipo é a
   mesma lista do campo normal, então ninguém precisa decorar o nome dele. */
.bloco-campos-editor { display: flex; flex-direction: column; gap: 8px; }
.bc-linhas { display: flex; flex-direction: column; gap: 8px; }

.bc-linha {
    display: grid;
    grid-template-columns: 34px minmax(110px, 1.3fr) minmax(140px, 1fr) 118px minmax(110px, 1fr) 32px;
    align-items: center;
    gap: 8px;
}
.bc-linha input, .bc-linha select { margin: 0; }
/* Sem opções a coluna some, mas o espaço fica: as linhas continuam alinhadas. */
.bc-linha .bc-opcoes[hidden] { display: block; visibility: hidden; }

.bc-ordem { display: flex; flex-direction: column; gap: 2px; }
.bc-ordem button {
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    border-radius: 4px;
    font-size: 9px;
    line-height: 1;
    padding: 3px 0;
    cursor: pointer;
}
.bc-ordem button:hover { background: #f3f4f6; color: #374151; }

.bc-remover {
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 20px;
    line-height: 1;
    width: 32px; height: 32px;
    border-radius: 6px;
    cursor: pointer;
}
.bc-remover:hover { background: #fee2e2; color: #b91c1c; }

@media (max-width: 860px) {
    /* Empilhado: cinco colunas nesta largura deixam o rótulo com duas letras. */
    .bc-linha {
        grid-template-columns: 1fr 34px 32px;
        gap: 6px;
        padding: 8px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
    }
    .bc-linha .bc-rotulo { grid-column: 1; }
    .bc-linha .bc-ordem  { grid-column: 2; grid-row: 1; }
    .bc-linha .bc-remover{ grid-column: 3; grid-row: 1; }
    .bc-linha .bc-tipo    { grid-column: 1 / -1; }
    .bc-linha .bc-largura { grid-column: 1 / -1; }
    .bc-linha .bc-opcoes  { grid-column: 1 / -1; }
    .bc-linha .bc-opcoes[hidden] { display: none; }
    .bc-adicionar { width: 100%; }
}
