/* ============================================
   SISTEMA DE CERTIFICADOS - CSS COMPLETO
   ============================================ */

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --border: #334155;
    --border-hover: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: #60a5fa;
    --success: #10b981;
    --success-bg: #064e3b;
    --danger: #ef4444;
    --danger-bg: #7f1d1d;
    --warning: #f59e0b;
    --warning-bg: #78350f;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.4);
    --sidebar-width: 260px;
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    text-align: center;
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--accent-light);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 14px;
}

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 18px;
    color: var(--accent-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header .logo-icon {
    font-size: 24px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 4px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent);
    color: white;
}

.nav-item .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
}

.user-details .user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-details .user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.stat-icon.green { background: rgba(16,185,129,0.15); color: #34d399; }
.stat-icon.purple { background: rgba(139,92,246,0.15); color: #a78bfa; }

.stat-info .stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-info .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

.form-control::placeholder {
    color: var(--text-muted);
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.file-input-wrapper {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.file-input-wrapper:hover {
    border-color: var(--accent);
    background: rgba(59,130,246,0.05);
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-input-wrapper .file-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.file-input-wrapper .file-text {
    font-size: 13px;
    color: var(--text-secondary);
}

.file-preview {
    margin-top: 12px;
}

.file-preview img {
    max-width: 200px;
    max-height: 100px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== TABLE ===== */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.2);
}

table tr:hover td {
    background: rgba(59,130,246,0.05);
}

table td .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-green { background: rgba(16,185,129,0.15); color: #34d399; }

/* ===== MODELS GRID ===== */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.model-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
}

.model-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.model-card-preview {
    height: 140px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d1b69 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.model-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.model-card-preview .preview-text {
    font-size: 48px;
    opacity: 0.3;
}

.model-card-body {
    padding: 20px;
}

.model-card-body h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

.model-card-body p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.model-card-actions {
    display: flex;
    gap: 8px;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    min-width: 300px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    font-size: 14px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== CERTIFICATE PREVIEW ===== */
.cert-preview-container {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
}

.cert-page {
    width: 960px;
    height: 540px;
    background: white;
    color: #1a1a1a;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    font-family: 'Georgia', 'Times New Roman', serif;
}

.cert-page.scaled {
    transform: scale(0.55);
    transform-origin: top left;
    margin-bottom: -243px;
    margin-right: -432px;
}

.cert-page-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cert-page-content {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 60px;
    text-align: center;
}

.cert-logo {
    max-height: 60px;
    max-width: 200px;
    margin-bottom: 12px;
}

.cert-institution {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #1a365d;
}

.cert-cnpj {
    font-size: 10px;
    color: #666;
    margin-bottom: 16px;
}

.cert-title {
    font-size: 32px;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 16px;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.cert-body {
    font-size: 14px;
    line-height: 1.8;
    color: #333;
    max-width: 800px;
    margin-bottom: 20px;
}

.cert-signatures {
    display: flex;
    justify-content: space-around;
    width: 100%;
    max-width: 700px;
    margin-top: auto;
    padding-top: 16px;
}

.cert-signature {
    text-align: center;
}

.cert-signature-line {
    width: 180px;
    border-top: 1px solid #333;
    margin-bottom: 4px;
}

.cert-signature-name {
    font-size: 12px;
    font-weight: 600;
}

.cert-signature-role {
    font-size: 10px;
    color: #666;
}

.cert-code {
    position: absolute;
    bottom: 10px;
    right: 20px;
    font-size: 9px;
    color: #999;
    font-family: monospace;
}

.cert-back-content {
    text-align: left;
    font-size: 12px;
    line-height: 1.6;
    width: 100%;
    max-width: 800px;
}

.cert-back-title {
    font-size: 20px;
    font-weight: 700;
    color: #1a365d;
    margin-bottom: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ===== TAGS ===== */
.key-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.key-tag {
    background: rgba(59,130,246,0.15);
    color: var(--accent-light);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: monospace;
}

.key-tag:hover {
    background: rgba(59,130,246,0.3);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 24px;
}

/* ===== LOADING ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== MOBILE TOGGLE ===== */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    font-size: 20px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 20px;
        padding-top: 70px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .cert-page.scaled {
        transform: scale(0.35);
        margin-bottom: -351px;
        margin-right: -624px;
    }

    .models-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .mobile-toggle, .btn, .page-header, .no-print {
        display: none !important;
    }

    .main-content {
        margin: 0;
        padding: 0;
    }

    .cert-page {
        box-shadow: none;
        page-break-after: always;
    }

    .cert-page.scaled {
        transform: none;
        margin: 0;
    }
}

/* ===== TABS ===== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    border: none;
    background: none;
    position: relative;
    transition: var(--transition);
    font-family: inherit;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-light);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== CONFIRM DIALOG ===== */
.confirm-text {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

/* ===== CHIP LIST ===== */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip {
    background: var(--bg-tertiary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip .remove-chip {
    cursor: pointer;
    color: var(--danger);
    font-weight: 700;
}
/* ===== AJUSTE PROFISSIONAL DAS ASSINATURAS DO CERTIFICADO =====
   Corrige linhas da assinatura no preview e na impressão/exportação. */
.cert-front .cert-page-content {
    padding: 38px 58px 118px;
}

.cert-front .cert-body {
    max-width: 805px;
    margin-bottom: 0;
    font-size: 13.5px;
    line-height: 1.68;
}

.cert-front .cert-signatures {
    position: absolute;
    left: 86px;
    right: 86px;
    bottom: 42px;
    width: auto;
    max-width: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 34px;
    margin: 0;
    padding: 0;
    align-items: start;
}

.cert-front .cert-signature {
    min-width: 0;
    width: 100%;
    text-align: center;
    padding: 0 2px;
}

.cert-front .cert-signature-line {
    width: 88%;
    max-width: 172px;
    height: 0;
    border: 0;
    border-top: 1px solid rgba(20, 20, 20, 0.92);
    margin: 0 auto 7px;
}

.cert-front .cert-signature-name {
    min-height: 26px;
    color: #111;
    font-size: 10.2px;
    font-weight: 700;
    line-height: 1.12;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.cert-front .cert-signature.sig-sm .cert-signature-name {
    font-size: 9.3px;
    line-height: 1.08;
}

.cert-front .cert-signature.sig-xs .cert-signature-name {
    font-size: 8.4px;
    line-height: 1.04;
}

.cert-front .cert-signature-role {
    margin-top: 3px;
    font-size: 8px;
    line-height: 1.1;
    color: #5c5c5c;
    font-weight: 500;
}

.cert-front .cert-code {
    bottom: 14px;
    right: 22px;
    font-size: 7px;
    letter-spacing: 0.15px;
    opacity: 0.82;
}

.cert-page {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* ===== CORREÇÃO FINAL DO PREVIEW DO CERTIFICADO =====
   O certificado continua em 960x540 internamente, mas agora o preview usa
   um invólucro com altura correta. Isso elimina corte no modal. */
.modal.modal-view {
    max-width: 760px;
}

.modal.modal-view .modal-body {
    overflow-x: hidden;
}

.cert-preview-container {
    width: 100%;
    overflow: visible;
}

.cert-page-preview-wrap {
    --cert-preview-scale: 0.62;
    width: calc(960px * var(--cert-preview-scale));
    height: calc(540px * var(--cert-preview-scale));
    position: relative;
    overflow: visible;
    margin: 0 auto;
    flex: 0 0 auto;
}

.cert-page-preview-wrap > .cert-page {
    width: 960px !important;
    height: 540px !important;
    transform: scale(var(--cert-preview-scale)) !important;
    transform-origin: top left !important;
    margin: 0 !important;
}

.cert-page.scaled {
    transform: none !important;
    margin: 0 !important;
}

@media (max-width: 720px) {
    .modal.modal-view {
        max-width: calc(100vw - 18px);
    }
    .modal.modal-view .modal-body {
        padding: 14px;
    }
    .cert-page-preview-wrap {
        --cert-preview-scale: 0.34;
    }
}

/* ===== PDF POWERPOINT + PREVIEW IMPECÁVEL v3 =====
   Mantém o preview inteiro dentro do modal e prepara o PDF no formato PowerPoint 16:9. */
.modal.modal-view {
    width: min(1120px, calc(100vw - 32px));
    max-width: min(1120px, calc(100vw - 32px));
}

.modal.modal-view .modal-body {
    max-height: calc(90vh - 138px);
    overflow-y: auto;
    overflow-x: hidden;
}

.modal.modal-view .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 2;
}

.cert-preview-container {
    width: 100%;
    display: flex;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start;
    gap: 0;
    overflow: visible;
    padding-bottom: 8px;
}

.cert-page-preview-wrap {
    --cert-preview-scale: 0.72;
    width: calc(960px * var(--cert-preview-scale));
    height: calc(540px * var(--cert-preview-scale));
    max-width: 100%;
    position: relative;
    overflow: visible;
    margin: 0 auto;
    flex: 0 0 auto;
}

.cert-page-preview-wrap > .cert-page {
    width: 960px !important;
    height: 540px !important;
    transform: scale(var(--cert-preview-scale)) !important;
    transform-origin: top left !important;
    margin: 0 !important;
    box-shadow: var(--shadow-lg);
}

.cert-page.scaled {
    transform: none !important;
    margin: 0 !important;
}

.cert-front .cert-page-content {
    justify-content: flex-start;
    padding: 34px 58px 118px;
}

.cert-front .cert-logo {
    max-height: 54px;
    margin-bottom: 8px;
}

.cert-front .cert-institution {
    font-size: 15px;
    line-height: 1.15;
}

.cert-front .cert-cnpj {
    font-size: 9px;
    margin-bottom: 10px;
}

.cert-front .cert-title {
    font-size: 30px;
    line-height: 1;
    margin-bottom: 14px;
}

.cert-front .cert-body {
    width: 100%;
    max-width: 805px;
    margin: 0 auto;
    font-size: 13px;
    line-height: 1.58;
    color: #222;
}

.cert-front .cert-signatures {
    position: absolute;
    left: 82px;
    right: 82px;
    bottom: 42px;
    width: auto;
    max-width: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 36px;
    margin: 0;
    padding: 0;
    align-items: start;
}

.cert-front .cert-signature-line {
    width: 88%;
    max-width: 172px;
    height: 0;
    border: 0;
    border-top: 1px solid rgba(20, 20, 20, 0.92);
    margin: 0 auto 8px;
}

.cert-front .cert-signature-name {
    min-height: 26px;
    color: #111;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.10;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.cert-front .cert-signature.sig-sm .cert-signature-name {
    font-size: 9.1px;
    line-height: 1.06;
}

.cert-front .cert-signature.sig-xs .cert-signature-name {
    font-size: 8.2px;
    line-height: 1.03;
}

.cert-front .cert-signature-role {
    margin-top: 3px;
    font-size: 8px;
    line-height: 1.1;
    color: #5c5c5c;
    font-weight: 500;
}

.cert-front .cert-code {
    bottom: 14px;
    right: 22px;
    font-size: 7px;
    letter-spacing: 0.15px;
    opacity: 0.82;
}

.cert-back .cert-page-content {
    justify-content: flex-start;
    padding: 38px 66px;
}

.cert-back .cert-logo {
    max-height: 56px;
    margin-bottom: 8px;
}

.cert-back .cert-institution {
    font-size: 15px;
    margin-bottom: 12px;
}

.cert-back .cert-back-title {
    font-size: 20px;
    margin-bottom: 18px;
}

.cert-back .cert-back-content {
    width: 100%;
    max-width: 805px;
    font-size: 12px;
    line-height: 1.45;
    color: #222;
    overflow-wrap: anywhere;
}

@media (max-width: 720px) {
    .modal.modal-view {
        width: calc(100vw - 14px);
        max-width: calc(100vw - 14px);
    }
    .modal.modal-view .modal-body {
        padding: 12px;
    }
    .modal.modal-view .modal-footer {
        flex-wrap: wrap;
    }
    .modal.modal-view .modal-footer .btn {
        flex: 1 1 auto;
    }
}


/* ===== CERTIFICADO PDF 16:9 - CORTE ELIMINADO v4 =====
   O preview de tela continua proporcional e o verso agora reduz automaticamente
   o conteúdo programático para caber inteiro, sem cortar no fim. */
.modal.modal-view {
    width: min(1180px, calc(100vw - 24px)) !important;
    max-width: min(1180px, calc(100vw - 24px)) !important;
}
.modal.modal-view .modal-body {
    max-height: calc(96vh - 126px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 18px !important;
}
.cert-preview-container {
    width: 100% !important;
    overflow: visible !important;
}
.cert-page-preview-wrap {
    --cert-preview-scale: 0.72;
    width: calc(960px * var(--cert-preview-scale)) !important;
    height: calc(540px * var(--cert-preview-scale)) !important;
    max-width: 100% !important;
    position: relative !important;
    overflow: visible !important;
    margin: 0 auto !important;
    flex: 0 0 auto !important;
}
.cert-page-preview-wrap > .cert-page {
    width: 960px !important;
    height: 540px !important;
    transform: scale(var(--cert-preview-scale)) !important;
    transform-origin: top left !important;
    margin: 0 !important;
    overflow: hidden !important;
}
.cert-back .cert-page-content {
    justify-content: flex-start !important;
    padding: 26px 66px 22px !important;
}
.cert-back .cert-logo {
    max-height: 36px !important;
    margin-bottom: 4px !important;
}
.cert-back .cert-institution {
    font-size: 12px !important;
    margin-bottom: 6px !important;
    line-height: 1.1 !important;
}
.cert-back .cert-back-title {
    font-size: 17px !important;
    line-height: 1.05 !important;
    margin-bottom: 10px !important;
}
.cert-back .cert-back-content {
    width: 100% !important;
    max-width: 820px !important;
    font-size: 9.4px !important;
    line-height: 1.19 !important;
    color: #222 !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
}
.cert-back .cert-back-content.back-fit-sm {
    font-size: 8.7px !important;
    line-height: 1.16 !important;
}
.cert-back .cert-back-content.back-fit-xs {
    font-size: 8px !important;
    line-height: 1.12 !important;
}
.cert-back .cert-back-content.back-fit-xxs {
    font-size: 7.4px !important;
    line-height: 1.08 !important;
}
@media (max-width: 720px) {
    .modal.modal-view { width: calc(100vw - 10px) !important; max-width: calc(100vw - 10px) !important; }
    .modal.modal-view .modal-body { padding: 10px !important; }
}

/* ===== CERTIFICADO PDF A4 PAISAGEM - PONTA A PONTA v5 =====
   Preview em modo paisagem real (A4), sem cortar e com proporção igual ao PDF. */
.modal.modal-view {
    width: min(1220px, calc(100vw - 24px)) !important;
    max-width: min(1220px, calc(100vw - 24px)) !important;
}
.modal.modal-view .modal-body {
    max-height: calc(96vh - 126px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px !important;
}
.cert-preview-container {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    overflow: visible !important;
    padding-bottom: 8px !important;
}
.cert-page-preview-wrap {
    --cert-preview-scale: 0.58;
    width: calc(1123px * var(--cert-preview-scale)) !important;
    height: calc(794px * var(--cert-preview-scale)) !important;
    max-width: 100% !important;
    position: relative !important;
    overflow: visible !important;
    margin: 0 auto !important;
    flex: 0 0 auto !important;
}
.cert-page-preview-wrap > .cert-page {
    width: 1123px !important;
    height: 794px !important;
    transform: scale(var(--cert-preview-scale)) !important;
    transform-origin: top left !important;
    margin: 0 !important;
    overflow: hidden !important;
    box-shadow: var(--shadow-lg) !important;
}
.cert-page {
    width: 1123px !important;
    height: 794px !important;
}
.cert-page-bg {
    width: 100% !important;
    height: 100% !important;
    object-fit: fill !important;
}
.cert-front .cert-page-content {
    justify-content: flex-start !important;
    padding: 38px 68px 144px !important;
}
.cert-front .cert-logo {
    max-height: 57px !important;
    margin-bottom: 7px !important;
}
.cert-front .cert-institution {
    font-size: 17px !important;
    line-height: 1.12 !important;
}
.cert-front .cert-cnpj {
    font-size: 11px !important;
    margin-bottom: 10px !important;
}
.cert-front .cert-title {
    font-size: 42px !important;
    line-height: 1 !important;
    margin-bottom: 15px !important;
    letter-spacing: 4px !important;
}
.cert-front .cert-body {
    width: 100% !important;
    max-width: 955px !important;
    margin: 0 auto !important;
    font-size: 17px !important;
    line-height: 1.46 !important;
    color: #222 !important;
}
.cert-front .cert-signatures {
    position: absolute !important;
    left: 91px !important;
    right: 91px !important;
    bottom: 57px !important;
    width: auto !important;
    max-width: none !important;
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 53px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: start !important;
}
.cert-front .cert-signature-line {
    width: 90% !important;
    max-width: 197px !important;
    height: 0 !important;
    border: 0 !important;
    border-top: 1.5px solid rgba(20, 20, 20, 0.92) !important;
    margin: 0 auto 8px !important;
}
.cert-front .cert-signature-name {
    min-height: 31px !important;
    color: #111 !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    line-height: 1.08 !important;
    text-align: center !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
}
.cert-front .cert-signature.sig-sm .cert-signature-name {
    font-size: 10.5px !important;
    line-height: 1.05 !important;
}
.cert-front .cert-signature.sig-xs .cert-signature-name {
    font-size: 9.5px !important;
    line-height: 1.02 !important;
}
.cert-front .cert-signature-role {
    margin-top: 4px !important;
    font-size: 9.5px !important;
    line-height: 1.08 !important;
    color: #5c5c5c !important;
    font-weight: 500 !important;
}
.cert-front .cert-code {
    bottom: 15px !important;
    right: 27px !important;
    font-size: 8.5px !important;
    letter-spacing: 0.1px !important;
    opacity: 0.82 !important;
}
.cert-back .cert-page-content {
    justify-content: flex-start !important;
    padding: 26px 76px 26px !important;
}
.cert-back .cert-logo {
    max-height: 45px !important;
    margin-bottom: 4px !important;
}
.cert-back .cert-institution {
    font-size: 14px !important;
    margin-bottom: 8px !important;
    line-height: 1.08 !important;
}
.cert-back .cert-back-title {
    font-size: 22px !important;
    line-height: 1.03 !important;
    margin-bottom: 12px !important;
}
.cert-back .cert-back-content {
    width: 100% !important;
    max-width: 964px !important;
    font-size: 11.4px !important;
    line-height: 1.13 !important;
    color: #222 !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
}
.cert-back .cert-back-content.back-fit-sm {
    font-size: 10.5px !important;
    line-height: 1.10 !important;
}
.cert-back .cert-back-content.back-fit-xs {
    font-size: 9.7px !important;
    line-height: 1.07 !important;
}
.cert-back .cert-back-content.back-fit-xxs {
    font-size: 9.1px !important;
    line-height: 1.04 !important;
}
@media (max-width: 760px) {
    .modal.modal-view { width: calc(100vw - 10px) !important; max-width: calc(100vw - 10px) !important; }
    .modal.modal-view .modal-body { padding: 10px !important; }
    .cert-page-preview-wrap { --cert-preview-scale: 0.32; }
}

/* ===== CERTIFICADO E LISTA DE PRESENÇA - AJUSTES FINAIS v6 ===== */
.cert-page-content {
    align-items: stretch !important;
    justify-content: flex-start !important;
    text-align: left !important;
}
.cert-header {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 14px;
    margin-bottom: 8px;
}
.cert-header-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    text-align: left;
    padding-top: 2px;
}
.cert-header .cert-logo {
    max-height: 68px !important;
    max-width: 220px !important;
    margin: 0 !important;
    object-fit: contain;
}
.cert-header .cert-institution {
    margin-bottom: 3px !important;
    font-size: 18px !important;
    line-height: 1.08 !important;
}
.cert-header .cert-cnpj {
    margin-bottom: 0 !important;
    font-size: 11px !important;
}
.cert-title,
.cert-back-title {
    width: 100%;
    text-align: center !important;
}
.cert-front .cert-page-content {
    padding: 40px 68px 144px !important;
}
.cert-front .cert-title {
    margin-top: 8px !important;
    margin-bottom: 18px !important;
}
.cert-front .cert-body {
    width: 100% !important;
    max-width: 960px !important;
    margin: 0 auto !important;
    font-size: 18.5px !important;
    line-height: 1.56 !important;
    color: #222 !important;
    text-align: justify !important;
    text-align-last: auto !important;
}
.cert-back .cert-page-content {
    padding: 30px 76px 28px !important;
}
.cert-back .cert-back-title {
    margin-top: 6px !important;
    margin-bottom: 14px !important;
}
.cert-back .cert-back-content {
    width: 100% !important;
    max-width: 972px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    color: #222 !important;
    text-align: justify !important;
    text-align-last: auto !important;
    overflow: hidden !important;
    overflow-wrap: anywhere !important;
}
.cert-back .cert-back-content.back-fit-sm {
    font-size: 11.1px !important;
    line-height: 1.17 !important;
}
.cert-back .cert-back-content.back-fit-xs {
    font-size: 10.2px !important;
    line-height: 1.13 !important;
}
.cert-back .cert-back-content.back-fit-xxs {
    font-size: 9.5px !important;
    line-height: 1.10 !important;
}

/* ===== CERTIFICADOS - TEXTO MAIOR + FILTROS v8 ===== */
.cert-front .cert-page-content {
    padding: 56px 68px 144px !important;
}
.cert-front .cert-title {
    margin-top: 28px !important;
    margin-bottom: 22px !important;
}
.cert-front .cert-body {
    max-width: 980px !important;
    font-size: 21px !important;
    line-height: 1.58 !important;
    text-align: justify !important;
    text-align-last: auto !important;
    white-space: pre-wrap !important;
}
.cert-filters-grid {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 1fr) minmax(150px, .75fr) minmax(150px, .75fr) auto;
    gap: 14px;
    align-items: end;
}
.cert-filter-actions {
    display: flex;
    align-items: end;
}
.cert-list-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 12px;
}
.cert-results-summary {
    color: var(--text-secondary);
    font-size: 14px;
}
.cert-card-list {
    display: grid;
    gap: 12px;
}
.cert-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow);
}
.cert-result-main {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    flex: 1;
}
.cert-result-avatar {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(59,130,246,0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.cert-result-info {
    min-width: 0;
}
.cert-result-info h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 8px;
    overflow-wrap: anywhere;
}
.cert-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    color: var(--text-secondary);
    font-size: 13px;
}
.cert-result-code {
    display: inline-block;
    margin-top: 9px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(59,130,246,0.12);
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .2px;
}
.cert-result-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.cert-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}
.cert-pagination .btn[disabled] {
    opacity: .45;
    cursor: not-allowed;
}
.pagination-dots {
    color: var(--text-secondary);
    padding: 0 2px;
}
@media (max-width: 980px) {
    .cert-filters-grid {
        grid-template-columns: 1fr 1fr;
    }
    .cert-filter-actions {
        align-items: stretch;
    }
    .cert-filter-actions .btn {
        width: 100%;
    }
}
@media (max-width: 720px) {
    .cert-filters-grid {
        grid-template-columns: 1fr;
    }
    .cert-result-card {
        align-items: stretch;
        flex-direction: column;
    }
    .cert-result-actions {
        justify-content: flex-start;
    }
}


/* ===== IDENTIDADE VISUAL CLEAN + ICONES SVG v9 ===== */
:root {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent: #1e3a5f;
    --accent-hover: #172c48;
    --accent-light: #2f5f8f;
    --success: #166534;
    --success-bg: #ecfdf3;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --warning: #a16207;
    --warning-bg: #fffbeb;
    --shadow: 0 10px 24px rgba(15,23,42,.06);
    --shadow-lg: 0 24px 60px rgba(15,23,42,.14);
}
body { background: var(--bg-primary); color: var(--text-primary); }
.login-container { background: linear-gradient(135deg, #f8fafc 0%, #eef4fb 100%); }
.sidebar { background: rgba(255,255,255,.96); border-right-color: var(--border); box-shadow: 6px 0 24px rgba(15,23,42,.04); }
.sidebar-header h2 { color: var(--text-primary); letter-spacing: -0.02em; }
.nav-item { color: var(--text-secondary); border: 1px solid transparent; }
.nav-item:hover { background: #f8fafc; color: var(--text-primary); border-color: var(--border); }
.nav-item.active { background: #eef5ff; color: var(--accent); border-color: #dbeafe; }
.user-avatar { background: #e2e8f0; color: var(--accent); }
.card, .stat-card, .model-card, .cert-result-card, .attendance-group-card { border-color: var(--border); box-shadow: var(--shadow); background: #fff; }
.card-header { border-bottom-color: var(--border); }
.btn { border-radius: 10px; box-shadow: none; gap: 8px; }
.btn-primary { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--text-primary); }
.btn-secondary:hover { background: #f8fafc; border-color: var(--border-hover); }
.btn-success { background: var(--success); border: 1px solid var(--success); color: #fff; }
.btn-danger { background: #fff; border: 1px solid #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-info { background: #fff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.form-control { background: #fff; color: var(--text-primary); border-color: var(--border); border-radius: 10px; }
.form-control:focus { border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(59,130,246,.10); }
table th { background: #f8fafc; color: var(--text-secondary); }
table tr:hover td { background: #fbfdff; }
.badge-blue { background: #eef5ff; color: #1e3a5f; }
.badge-green { background: #ecfdf3; color: #166534; }

.app-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
.app-icon svg { width: 100%; height: 100%; display: block; }
.nav-svg { width: 20px; height: 20px; }
.brand-svg { width: 26px; height: 26px; color: var(--accent); }
.btn-svg { width: 16px; height: 16px; }
.stat-svg { width: 28px; height: 28px; }
.preview-svg, .empty-svg { width: 40px; height: 40px; color: var(--accent-light); }
.file-svg { width: 28px; height: 28px; color: var(--accent); }
.avatar-svg { width: 22px; height: 22px; color: #fff; }
.toast-svg { width: 18px; height: 18px; }
.icon-only { width: 36px; padding-left: 0; padding-right: 0; justify-content: center; }
.inline-empty-icon { display: flex; justify-content: center; margin-bottom: 10px; }
.stat-icon { background: #eef5ff !important; color: var(--accent) !important; }
.stat-icon.green { background: #ecfdf3 !important; color: var(--success) !important; }

/* Certificado: verso/conteúdo programático um pouco maior */
.cert-back .cert-back-content {
    font-size: 13.5px !important;
    line-height: 1.25 !important;
    white-space: pre-wrap !important;
}
.cert-back .cert-back-content.back-fit-sm { font-size: 12.3px !important; line-height: 1.2 !important; }
.cert-back .cert-back-content.back-fit-xs { font-size: 11.3px !important; line-height: 1.16 !important; }
.cert-back .cert-back-content.back-fit-xxs { font-size: 10.4px !important; line-height: 1.12 !important; }

/* Provas: modais e blocos mais limpos */
.modal { background: #fff; color: var(--text-primary); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 1px solid var(--border); padding: 20px 24px; }
.modal-header h2 { color: var(--text-primary); font-size: 20px; letter-spacing: -0.02em; }
.modal-body { padding: 22px 24px; }
.modal-footer { border-top: 1px solid var(--border); padding: 16px 24px; background: #fafafa; }
.modal-exam { max-width: 860px; }
.exam-section-title { margin: 22px 0 12px; font-size: 15px; color: var(--text-primary); font-weight: 700; }
.question-card { background: #fbfdff; padding: 18px; margin: 14px 0; border-radius: 14px; border: 1px solid var(--border); position: relative; }
.question-card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.option-row { display: grid; grid-template-columns: 34px 22px 1fr; align-items: center; gap: 10px; margin: 8px 0; }
.option-row input[type="radio"] { width: 16px; height: 16px; cursor: pointer; }
.option-letter { width: 30px; height: 30px; border-radius: 999px; background: #eef5ff; color: var(--accent); display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px; }
.key-tags { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.key-tag { border-radius: 999px; }


/* ===== CERTIFICADO - INFORMAÇÃO LOCAL + FILTRO DE CÓDIGO v11 ===== */
.cert-front .cert-body {
    font-size: 22px !important;
    line-height: 1.58 !important;
    white-space: pre-wrap !important;
}
.cert-local-info {
    width: 100% !important;
    max-width: 980px !important;
    margin: 34px auto 0 !important;
    font-family: Georgia, 'Times New Roman', serif !important;
    font-size: 18.5px !important;
    line-height: 1.35 !important;
    color: #222 !important;
    text-align: center !important;
    white-space: pre-wrap !important;
}
.cert-filters-grid {
    grid-template-columns: minmax(220px, 1.4fr) minmax(170px, .9fr) minmax(180px, 1fr) minmax(145px, .7fr) minmax(145px, .7fr) auto !important;
}
@media (max-width: 1180px) {
    .cert-filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 760px) {
    .cert-filters-grid { grid-template-columns: 1fr !important; }
}


/* ===== CORREÇÃO v12: campo Informação Local visível na emissão ===== */
.modal-certificate {
    max-width: 760px !important;
    width: min(760px, calc(100vw - 28px)) !important;
}
.modal-certificate .modal-body {
    max-height: calc(92vh - 150px) !important;
    overflow-y: auto !important;
    padding-bottom: 18px !important;
}
.issue-local-field {
    background: #f8fafc !important;
    border: 1px solid #dbe5f0 !important;
    border-radius: 14px !important;
    padding: 14px !important;
    margin-top: 4px !important;
}
.issue-local-field label {
    color: #0f172a !important;
    font-weight: 700 !important;
}
.issue-local-field textarea {
    min-height: 88px !important;
    resize: vertical !important;
    white-space: pre-wrap !important;
}
.issue-local-field .form-hint {
    margin-top: 8px !important;
    color: #526175 !important;
}


/* ===== RELATÓRIOS DE AULA v13 ===== */
.report-builder-card .card-header h2,
.card-header h2 { letter-spacing: -0.02em; }
.report-toolbar {
    display: grid;
    grid-template-columns: minmax(170px, .7fr) minmax(260px, 1.1fr) auto;
    gap: 16px;
    align-items: end;
}
.report-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}
.report-students-box { min-height: 120px; }
.loading-inline {
    color: var(--text-secondary);
    padding: 26px;
    text-align: center;
}
.report-module-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    margin-bottom: 14px;
    overflow: hidden;
}
.report-module-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
}
.report-module-header h3 {
    margin: 0 0 3px;
    color: var(--text-primary);
    font-size: 16px;
}
.report-module-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}
.report-student-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
}
.report-student-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #eef2f7;
    cursor: pointer;
    transition: var(--transition);
}
.report-student-item:nth-child(odd) { border-right: 1px solid #eef2f7; }
.report-student-item:hover { background: #fbfdff; }
.report-student-item input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.report-student-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.report-student-info strong { color: var(--text-primary); font-size: 13.5px; overflow-wrap: anywhere; }
.report-student-info small { color: var(--text-secondary); font-size: 11.5px; overflow-wrap: anywhere; }
.report-observations {
    min-height: 150px;
    resize: vertical;
    line-height: 1.55;
}
.report-photo-upload { display: grid; gap: 8px; }
.report-photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.report-photo-thumb {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    aspect-ratio: 4 / 3;
}
.report-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.report-photo-thumb span {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: rgba(15, 23, 42, .78);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}
.report-final-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}
@media (max-width: 1000px) {
    .report-toolbar { grid-template-columns: 1fr; }
    .report-actions-row { justify-content: flex-start; }
    .report-student-list { grid-template-columns: 1fr; }
    .report-student-item:nth-child(odd) { border-right: 0; }
}


/* ===== RELATÓRIO FOTOGRÁFICO - PADRÃO MANUAL v14 ===== */
.report-manual-builder .card-header h2,
.saved-reports-card .card-header h2 { letter-spacing: -0.02em; }
.report-form-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.report-toolbar-compact {
    grid-template-columns: minmax(280px, 1fr) auto;
    margin-bottom: 16px;
}
.report-photo-caption-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    align-items: start;
}
.report-photo-caption-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    padding: 10px;
    display: grid;
    gap: 9px;
}
.report-photo-caption-card .report-photo-thumb {
    aspect-ratio: 4 / 3;
    margin: 0;
}
.report-photo-caption-card label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
}
.saved-report-list {
    display: grid;
    gap: 12px;
}
.saved-report-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: 14px 16px;
}
.saved-report-card h3 {
    margin: 0 0 4px;
    font-size: 16px;
    color: var(--text-primary);
}
.saved-report-card p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}
.saved-report-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
@media (max-width: 920px) {
    .report-form-grid { grid-template-columns: 1fr; }
    .report-toolbar-compact { grid-template-columns: 1fr; }
    .saved-report-card { align-items: flex-start; flex-direction: column; }
    .saved-report-actions { justify-content: flex-start; }
}


/* ===== ORGANIZAÇÃO DA ABA RELATÓRIOS + DARK THEME v15 ===== */
html[data-theme="light"] {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent: #1e3a5f;
    --accent-hover: #172c48;
    --accent-light: #2f5f8f;
    --success: #166534;
    --success-bg: #ecfdf3;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --warning: #a16207;
    --warning-bg: #fffbeb;
    --shadow: 0 10px 24px rgba(15,23,42,.06);
    --shadow-lg: 0 24px 60px rgba(15,23,42,.14);
}
html[data-theme="dark"] {
    --bg-primary: #0b1120;
    --bg-secondary: #111827;
    --bg-tertiary: #1f2937;
    --bg-card: #111827;
    --border: #263244;
    --border-hover: #3b4a60;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-light: #93c5fd;
    --success: #22c55e;
    --success-bg: rgba(34,197,94,.13);
    --danger: #f87171;
    --danger-bg: rgba(248,113,113,.12);
    --warning: #facc15;
    --warning-bg: rgba(250,204,21,.12);
    --shadow: 0 12px 28px rgba(0,0,0,.22);
    --shadow-lg: 0 24px 70px rgba(0,0,0,.44);
}
html[data-theme="dark"] body,
html[data-theme="dark"] .main-content { background: var(--bg-primary); color: var(--text-primary); }
html[data-theme="dark"] .login-container { background: linear-gradient(135deg, #0b1120 0%, #111827 100%); }
html[data-theme="dark"] .sidebar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .model-card,
html[data-theme="dark"] .cert-result-card,
html[data-theme="dark"] .attendance-group-card,
html[data-theme="dark"] .report-module-card,
html[data-theme="dark"] .saved-report-card,
html[data-theme="dark"] .report-photo-caption-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .login-card {
    background: var(--bg-card) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .report-module-header,
html[data-theme="dark"] table th,
html[data-theme="dark"] .key-tags,
html[data-theme="dark"] .question-card,
html[data-theme="dark"] .issue-local-field,
html[data-theme="dark"] .report-photo-thumb {
    background: var(--bg-tertiary) !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] .form-control,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select {
    background: #0f172a !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}
html[data-theme="dark"] .form-control::placeholder { color: #718096 !important; }
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn-info {
    background: #0f172a !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}
html[data-theme="dark"] .nav-item:hover { background: rgba(148,163,184,.08) !important; }
html[data-theme="dark"] .nav-item.active { background: rgba(96,165,250,.12) !important; border-color: rgba(96,165,250,.22) !important; color: var(--accent-light) !important; }
html[data-theme="dark"] .badge-blue { background: rgba(96,165,250,.12) !important; color: #bfdbfe !important; }
html[data-theme="dark"] .badge-green { background: rgba(34,197,94,.12) !important; color: #bbf7d0 !important; }
html[data-theme="dark"] table tr:hover td { background: rgba(148,163,184,.06) !important; }
html[data-theme="dark"] .report-student-item { border-color: var(--border) !important; }
html[data-theme="dark"] .report-student-item:hover { background: rgba(148,163,184,.06) !important; }
html[data-theme="dark"] .saved-report-card p,
html[data-theme="dark"] .form-hint { color: var(--text-secondary) !important; }

.theme-toggle { margin-top: 8px; }
.report-workspace { display: grid; gap: 18px; }
.report-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg-primary);
    padding: 4px 0 8px;
}
.report-tab {
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: 14px;
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.report-tab span { display: block; color: var(--text-primary); font-weight: 800; font-size: 14px; }
.report-tab small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.report-tab:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.report-tab.active { border-color: rgba(30,58,95,.32); background: linear-gradient(180deg, rgba(30,58,95,.08), var(--bg-card)); }
html[data-theme="dark"] .report-tab.active { border-color: rgba(147,197,253,.36); background: linear-gradient(180deg, rgba(96,165,250,.16), var(--bg-card)); }
.report-panel { display: none; animation: reportFade .16s ease-out; }
.report-panel.active { display: grid; gap: 16px; }
@keyframes reportFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.report-step-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.report-page-header { margin-bottom: 18px; }
.report-saved-filter { display: grid; grid-template-columns: minmax(180px, 260px) auto; gap: 12px; align-items: end; margin-bottom: 16px; }
.report-panel .card { margin-bottom: 0; }
.report-panel .card-header p { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; font-weight: 400; }
@media (max-width: 900px) {
    .report-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); position: static; }
    .report-form-grid { grid-template-columns: 1fr !important; }
    .report-toolbar-compact { grid-template-columns: 1fr !important; }
    .report-saved-filter { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .report-tabs { grid-template-columns: 1fr; }
    .report-step-actions .btn { width: 100%; }
}


/* ===== LAYOUT FIXO GLOBAL + RELATÓRIOS v16 ===== */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden !important;
}
#app {
    height: 100vh;
    overflow: hidden;
}
.app-layout {
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden;
}
.sidebar {
    height: 100vh;
    overflow: hidden;
}
.sidebar-nav {
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-footer {
    flex-shrink: 0;
}
.main-content {
    height: 100vh !important;
    min-height: 0 !important;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}
.mobile-toggle {
    position: fixed !important;
}
.report-main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.report-fixed-card {
    max-width: 1120px;
}
.saved-report-clickable {
    cursor: pointer;
}
.saved-report-clickable:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.report-workspace-compact {
    max-width: 1180px;
}
.modal-report-preview {
    max-width: 980px;
}
.report-preview-modal {
    display: grid;
    gap: 18px;
}
.report-preview-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-primary);
}
.report-preview-summary div {
    color: var(--text-secondary);
    font-size: 14px;
}
.report-preview-summary strong {
    color: var(--text-primary);
}
.report-preview-observations h3 {
    margin-bottom: 8px;
    font-size: 15px;
}
.report-preview-observations pre {
    white-space: pre-wrap;
    font-family: inherit;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    max-height: 180px;
    overflow: auto;
}
.report-preview-photos {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.report-preview-thumb {
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-primary);
}
.report-preview-thumb img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
}
.report-preview-thumb span {
    display: block;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
}
.muted-text {
    color: var(--text-secondary);
}
@media (max-width: 760px) {
    body { overflow: auto !important; }
    #app, .app-layout { height: auto !important; min-height: 100vh !important; }
    .main-content { height: auto !important; overflow: visible; }
    .report-preview-summary,
    .report-preview-photos { grid-template-columns: 1fr; }
}


/* ===== MÚLTIPLAS DATAS ===== */
.multi-date-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.multi-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.multi-date-row .form-control {
    flex: 1;
}
.multi-date-add {
    align-self: flex-start;
    margin-top: 2px;
}


/* ===== MULTIDATAS VISÍVEL v19 ===== */
.multi-date-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    padding: 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: 14px !important;
    background: var(--bg-secondary) !important;
}
.multi-date-row {
    display: flex !important;
    gap: 10px !important;
    align-items: center !important;
}
.multi-date-row input[type="date"] {
    min-height: 42px !important;
}
.multi-date-add {
    width: fit-content !important;
    margin-top: 2px !important;
}


/* ===== HOTFIX ALUNOS E EDIÇÃO DE CERTIFICADOS v20 ===== */
.student-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 14px;
}
.student-result-card .cert-result-meta {
    gap: 14px;
}
#issue-students-datalist option,
#edit-students-datalist option {
    font-size: 14px;
}


/* ===== ROTA PERSISTENTE + FIXED REAL v22 ===== */
html,
body {
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    overflow: hidden !important;
}
#app {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
}
.app-layout {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
}
.sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: var(--sidebar-width) !important;
    height: 100vh !important;
    height: 100dvh !important;
    overflow: hidden !important;
}
.sidebar-nav {
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}
.main-content {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: var(--sidebar-width) !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin-left: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
}
@media (max-width: 768px) {
    body { overflow: hidden !important; }
    #app,
    .app-layout {
        height: 100vh !important;
        height: 100dvh !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }
    .sidebar {
        width: min(86vw, var(--sidebar-width)) !important;
    }
    .main-content {
        left: 0 !important;
        height: auto !important;
        overflow-y: auto !important;
        padding: 20px !important;
        padding-top: 70px !important;
    }
}
