/* ==========================================================================
   STYLE.CSS - Design System Premium para Gestão de Serviços Técnicos & Seguros
   ========================================================================== */

:root {
    /* Cores do Tema Dark (Default) */
    --bg-main: #0b0f19;
    --bg-card: #131b2e;
    --bg-card-hover: #1c2742;
    --bg-surface: #1e293b;
    --bg-input: #0f172a;
    --border-color: #28354f;
    --border-focus: #3b82f6;

    /* Tipografia e Cores de Texto */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Acentos e Cores de Destaque */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37, 99, 235, 0.15);
    
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);

    --info: #06b6d4;
    --info-light: rgba(6, 182, 212, 0.15);

    --realvida: #e11d48;
    --realvida-light: rgba(225, 29, 72, 0.15);

    /* Dimensões e Sombras */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-surface: #e2e8f0;
    --bg-input: #ffffff;
    --border-color: #cbd5e1;
    --border-focus: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --shadow-card: 0 4px 15px -2px rgba(0, 0, 0, 0.06);
    --shadow-modal: 0 20px 40px -8px rgba(0, 0, 0, 0.15);
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

#appDashboardWrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Scrollbars Globais Modernas e Discretas */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.25);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.45);
}

/* Layout Principal */
.app-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    width: 100%;
}

.header-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0.45rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    box-sizing: border-box;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.brand-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
    flex-shrink: 0;
}

.brand-title {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1.2;
    white-space: nowrap;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: none;
    line-height: 1.2;
    white-space: nowrap;
}

/* Navegação por Abas Desktop */
.nav-tabs {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--bg-input);
    padding: 0.2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
    overflow-x: hidden;
}

.nav-tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.38rem 0.65rem;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.79rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    user-select: none;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.tab-btn i {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

.cloud-sync-badge {
    height: 32px;
    padding: 0.25rem 0.5rem;
}

.cloud-sync-badge span#cloudSyncStatusText {
    display: none;
}

.badge-seguranca-encriptacao {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: #10b981;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    height: 32px;
}

.badge-seguranca-encriptacao i {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.badge-seguranca-encriptacao span {
    display: none;
}

#btnHeaderAuxilioAdmin span,
#btnHeaderHistorico span {
    display: none !important;
}

#btnHeaderAuxilioAdmin,
#btnHeaderHistorico {
    width: 32px;
    height: 32px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
}

#btnHeaderAuxilioAdmin:hover,
#btnHeaderHistorico:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
    border-color: var(--border-focus);
}

.user-header-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-input);
    padding: 0.2rem 0.35rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    height: 32px;
}

.user-header-badge #headerUserName {
    display: none;
}

/* Telas Ultra-Largas (>= 1650px) exibem mais detalhes contextuais */
@media (min-width: 1650px) {
    .brand-sub {
        display: block;
    }
    .cloud-sync-badge span#cloudSyncStatusText {
        display: inline;
    }
    .badge-seguranca-encriptacao span {
        display: inline;
        margin-left: 0.3rem;
    }
    .user-header-badge #headerUserName {
        display: inline;
        font-size: 0.78rem;
        font-weight: 600;
        margin-right: 0.25rem;
    }
}

/* Telas Médias / Laptops Compactos (<= 1300px) */
@media (max-width: 1300px) {
    .tab-btn {
        padding: 0.34rem 0.5rem;
        font-size: 0.76rem;
        gap: 0.25rem;
    }
    .header-actions {
        gap: 0.2rem;
    }
}

/* Telas Compactas / Tablets Paisagem (<= 1080px) */
@media (max-width: 1080px) {
    .brand-title {
        display: none;
    }
    .badge-seguranca-encriptacao {
        display: none !important;
    }
    .tab-btn {
        padding: 0.3rem 0.38rem;
        font-size: 0.72rem;
        gap: 0.2rem;
    }
    .header-container {
        padding: 0.3rem 0.4rem;
    }
    .header-actions {
        gap: 0.15rem;
    }
}

/* Conteúdo Principal */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.25s ease-out;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grelha de Estatísticas / Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

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

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }
.stat-icon.info { background: var(--info-light); color: var(--info); }
.stat-icon.realvida { background: var(--realvida-light); color: var(--realvida); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* Painel de Filtros e Controlos */
.panel-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filters-bar {
    padding: 0.85rem 1.25rem;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

/* Formulários & Inputs */
.form-input, .form-select, .form-textarea {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.55rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--transition);
    width: 100%;
}

.form-input-sm, .form-select-sm {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover {
    background: #059669;
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
}

.btn-warning {
    background: var(--warning);
    color: #1e293b;
}
.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
}
.btn-danger:hover {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35);
}

.btn-danger-outline {
    background: transparent;
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.btn-danger-outline:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: #ef4444;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-focus);
}

.btn-whatsapp {
    background: #25d366;
    color: white;
    font-weight: 700;
}
.btn-whatsapp:hover {
    background: #128c7e;
    box-shadow: 0 2px 12px rgba(37, 211, 102, 0.4);
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}
.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
    border-color: var(--border-focus);
}
.btn-icon-danger:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-light);
}

/* Tabelas */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.85rem;
}

.app-table th {
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.app-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
}

.app-table tbody tr {
    transition: var(--transition);
}

.app-table tbody tr:hover {
    background: var(--bg-card-hover);
}

/* Badges e Tags */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary { background: var(--primary-light); color: #60a5fa; }
.badge-success { background: var(--success-light); color: #34d399; }
.badge-warning { background: var(--warning-light); color: #fbbf24; }
.badge-danger { background: var(--danger-light); color: #f87171; }
.badge-info { background: var(--info-light); color: #22d3ee; }
.badge-secondary { background: var(--bg-surface); color: var(--text-secondary); }
.badge-realvida { background: var(--realvida-light); color: #fb7185; border: 1px solid rgba(225, 29, 72, 0.3); }

.matricula-badge {
    display: inline-block;
    background: #0f172a;
    color: #fbbf24;
    font-family: 'Courier New', monospace;
    font-weight: 800;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid #334155;
    letter-spacing: 0.08em;
}

.visitas-pill {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
}

/* Modais */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.modal-backdrop.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 840px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: scaleUp 0.2s ease-out;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-content-lg {
    max-width: 1020px;
}

.modal-content-sm {
    max-width: 520px;
}

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}
.modal-body::-webkit-scrollbar-track {
    background: var(--bg-input);
}
.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: var(--bg-input);
    flex-shrink: 0;
}

/* Secções em Modais */
.section-box {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Visitas e Histórico */
.visita-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.visita-card.visita-realizada {
    border-left: 4px solid var(--success);
}

.visita-card.visita-reagendada {
    border-left: 4px solid var(--danger);
}

.visita-motivo {
    background: var(--danger-light);
    color: #fca5a5;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

/* Fecho de PDF / Seleção */
.fecho-item-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
    transition: var(--transition);
}

.fecho-item-card:hover {
    border-color: var(--border-focus);
}

.resumo-totais-box {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.resumo-linha {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.resumo-linha.destaque {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    border-top: 1px solid var(--border-color);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

/* Galeria de Talões Digitais */
.galeria-taloes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.talao-gallery-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
}

.talao-gallery-card:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.talao-img-wrapper {
    height: 140px;
    width: 100%;
    background: #000;
    overflow: hidden;
}

.talao-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.talao-gallery-card:hover .talao-img-wrapper img {
    transform: scale(1.08);
}

.talao-meta {
    padding: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.talao-valor {
    font-weight: 700;
    color: var(--danger);
}

.talao-desc {
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-talao-thumb {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.4rem;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-talao-thumb img {
    width: 20px;
    height: 20px;
    object-fit: cover;
    border-radius: 2px;
}

.btn-talao-thumb:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Gráficos e Analytics */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

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

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

/* Utilidades Rápidas */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.fw-bold { font-weight: 700 !important; }
.fw-medium { font-weight: 500 !important; }
.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-1 { flex: 1 1 0% !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.align-items-start { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.justify-content-start { justify-content: flex-start !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }
.text-nowrap { white-space: nowrap !important; }
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.w-100 { width: 100% !important; }
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   BARRA DE NAVEGAÇÃO MOBILE INFERIOR (SMARTPHONES)
   ========================================================================== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    padding: 0.45rem 0.25rem;
    padding-bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.35rem 0.2rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.mobile-nav-btn i {
    width: 20px;
    height: 20px;
    stroke-width: 2.2;
}

.mobile-nav-btn.active {
    color: var(--primary);
}

.mobile-nav-btn.active i {
    stroke-width: 2.6;
}

/* Responsividade Mobile & Tablet */
@media (max-width: 860px) {
    .mobile-bottom-nav {
        display: flex;
    }

    .app-header .nav-tabs {
        display: none; /* Em smartphones, usar a barra inferior nativa */
    }

    .app-header {
        position: sticky;
        top: 0;
        z-index: 90;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .header-container {
        padding: 0.5rem 0.65rem;
        width: 100%;
        max-width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 0.35rem;
        box-sizing: border-box;
    }

    .brand-wrapper {
        gap: 0.4rem;
        min-width: 0;
        flex-shrink: 1;
        overflow: hidden;
    }

    .brand-icon {
        width: 32px;
        height: 32px;
        border-radius: var(--radius-sm);
        flex-shrink: 0;
    }

    .brand-icon i {
        width: 18px;
        height: 18px;
    }

    .brand-title {
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 130px;
    }

    .brand-sub {
        display: none !important; /* Compactar cabeçalho no ecrã do telemóvel */
    }

    .header-actions {
        gap: 0.25rem;
        flex-shrink: 0;
    }

    /* Ocultar badge de texto militar no smartphone para não rebentar a largura */
    .badge-seguranca-encriptacao {
        display: none !important;
    }

    /* Compactar badge de utilizador */
    .user-header-badge {
        padding: 0.2rem;
        border: none;
        background: transparent;
    }

    .user-header-badge span {
        display: none !important;
    }

    /* Compactar botão histórico: ícone apenas */
    #btnHeaderHistorico span {
        display: none !important;
    }

    #btnHeaderHistorico {
        padding: 0.35rem 0.5rem;
    }

    .btn-icon {
        width: 30px;
        height: 30px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-icon i {
        width: 15px;
        height: 15px;
    }

    .main-content {
        padding: 0.75rem 0.65rem 5.5rem 0.65rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: hidden;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 0.75rem 0.65rem;
        width: 100%;
        box-sizing: border-box;
        border-radius: var(--radius-md);
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .stat-value {
        font-size: 1.15rem;
    }

    .stat-sub {
        font-size: 0.65rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .panel-card {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .panel-header .d-flex {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .panel-header .d-flex .btn {
        flex: 1;
        min-width: 120px;
    }

    .filters-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 0.65rem !important;
        gap: 0.5rem !important;
    }

    .filters-bar > div,
    .filters-bar > div[style] {
        width: 100% !important;
        min-width: 0 !important;
        flex: 1 1 100% !important;
    }

    .table-responsive,
    .table-container {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
    }

    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 94vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .brand-title {
        max-width: 100px;
    }
}

/* Bloqueio total do ecrã e scroll enquanto o utilizador não estiver autenticado */
body.login-active {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
    position: fixed !important;
    width: 100% !important;
    touch-action: none;
}

body.login-active .app-header,
body.login-active .main-content,
body.login-active .mobile-bottom-nav,
body.login-active .toast-container,
body.login-active .modal-backdrop {
    display: none !important;
}

/* Quando existe uma sessão ativa restaurada de imediato (0ms) */
html.has-active-session body.login-active {
    overflow: auto !important;
    height: auto !important;
    position: static !important;
    width: 100% !important;
    touch-action: auto !important;
}

html.has-active-session body.login-active .app-header,
html.has-active-session body.login-active .mobile-bottom-nav,
html.has-active-session body.login-active .toast-container {
    display: flex !important;
}

html.has-active-session body.login-active .main-content {
    display: block !important;
}

html.has-active-session #appDashboardWrapper {
    display: block !important;
}

html.has-active-session #loginOverlay {
    display: none !important;
}

/* ==========================================================================
   ECRÃ DE LOGIN & AUTENTICAÇÃO
   ========================================================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background: #0b0f19 radial-gradient(circle at top right, #1e293b, #0b0f19 80%);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 1.5rem 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-sizing: border-box;
}

.login-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
    width: 100%;
    max-width: 440px;
    margin: auto;
    padding: 2.25rem 2rem;
    animation: loginScaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), #4f46e5, #06b6d4);
}

@keyframes loginScaleUp {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.4);
}

.login-icon-wrap i {
    width: 32px;
    height: 32px;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.login-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-error-alert {
    background: var(--danger-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    margin-bottom: 1.25rem;
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-wrapper input {
    padding-right: 2.75rem;
}

.btn-toggle-pwd {
    position: absolute;
    right: 0.65rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-toggle-pwd:hover {
    color: var(--text-primary);
}

.btn-login-submit {
    width: 100%;
    padding: 0.75rem;
    font-size: 0.95rem;
    font-weight: 700;
    margin-top: 1rem;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-login-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.login-credentials-hint {
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.78rem;
    text-align: center;
    color: var(--text-secondary);
}

@media (max-width: 480px) {
    .login-overlay {
        padding: 1rem 0.75rem;
    }

    .login-card {
        padding: 1.75rem 1.25rem;
        border-radius: var(--radius-md);
    }

    .login-header {
        margin-bottom: 1.5rem;
    }

    .login-icon-wrap {
        width: 52px;
        height: 52px;
        border-radius: 14px;
        margin-bottom: 0.75rem;
    }

    .login-icon-wrap i {
        width: 26px;
        height: 26px;
    }

    .login-title {
        font-size: 1.25rem;
    }

    .login-sub {
        font-size: 0.8rem;
    }
}

.user-header-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-input);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-avatar-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
}

/* ==========================================================================
   CENTRO DE NOTIFICAÇÕES & ALERTAS
   ========================================================================== */
.position-relative {
    position: relative !important;
}

.notification-badge-pulse {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--bg-surface), 0 0 8px rgba(239, 68, 68, 0.7);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.notif-item {
    display: flex;
    gap: 0.85rem;
    padding: 0.85rem;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.notif-item.notif-nao-lida {
    border-left: 4px solid var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.notif-item:hover {
    border-color: var(--primary);
}

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-icon.urgente {
    background: var(--danger-light);
    color: #f87171;
}

.notif-icon.alta {
    background: var(--warning-light);
    color: #fbbf24;
}

.notif-icon.media, .notif-icon.info {
    background: var(--primary-light);
    color: #60a5fa;
}

.notif-icon i {
    width: 20px;
    height: 20px;
}

.notif-conteudo {
    flex: 1;
    min-width: 0;
}

.notif-titulo {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.notif-texto {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
    line-height: 1.4;
}

.notif-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   PORTAIS DE VISITANTE & TEMPORIZADOR DE EXPIRAÇÃO DE 4 HORAS
   ========================================================================== */
.badge-timer-expiracao {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.76rem;
    font-weight: 700;
}

.badge-timer-expiracao i {
    width: 14px;
    height: 14px;
}

.label-timer-expiracao {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    letter-spacing: 0.05em;
}

#ecraLinkExpirado {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10001;
}

/* ==========================================================================
   NAVEGAÇÃO GPS (GOOGLE MAPS & WAZE)
   ========================================================================== */
.btn-morada-gps {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 0.78rem;
    padding: 0.2rem 0.45rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    max-width: 100%;
}

.btn-morada-gps:hover {
    background: rgba(37, 99, 235, 0.12);
    border-color: rgba(37, 99, 235, 0.4);
    color: var(--primary-light);
}

.btn-morada-gps i {
    width: 13px;
    height: 13px;
    color: #ef4444;
    flex-shrink: 0;
}

.badge-gps-chip {
    font-size: 0.68rem;
    font-weight: 700;
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    margin-left: 0.2rem;
    flex-shrink: 0;
}

.btn-gps {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.btn-gps:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-gmaps:hover {
    border-color: #4285f4;
    background: rgba(66, 133, 244, 0.08);
}

.btn-waze:hover {
    border-color: #33ccff;
    background: rgba(51, 204, 255, 0.08);
}

.btn-apple:hover {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.08);
}

.gps-icon-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gps-icon-circle.gmaps {
    background: #4285f4;
    color: white;
}

.gps-icon-circle.waze {
    background: #33ccff;
    color: #0b0f19;
}

.gps-icon-circle.apple {
    background: #64748b;
    color: white;
}

/* ==========================================================================
   PORTAIS DE VISITANTE (VALIDAÇÃO DA EMPRESA & PORTAL DO CONTABILISTA)
   Design Responsivo Mobile-First & Desktop de Alta Qualidade
   ========================================================================== */

.portal-container {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
}

/* 1. Header do Portal */
.portal-header-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    padding: 1.15rem 1.25rem;
    margin-bottom: 1rem;
}

/* 2. Grid de Identificação (Prestador & Adquirente) */
.portal-ident-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .portal-ident-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.portal-info-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.65rem;
}

.portal-info-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.4rem !important;
    width: 100% !important;
}

.portal-info-row {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    padding: 0.45rem 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    font-size: 0.85rem !important;
    width: 100% !important;
}

.portal-info-row:last-child {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.portal-info-label {
    color: #94a3b8 !important;
    font-weight: 500 !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}

.portal-info-value {
    color: #f8fafc !important;
    text-align: right !important;
    font-weight: 600 !important;
    word-break: break-word !important;
    flex: 1 !important;
}

/* 3. Caixa de Apuramento Fiscal & Bases Tributáveis */
.portal-resumo-box {
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.08), rgba(15, 23, 42, 0.95)) !important;
    border: 1px solid rgba(16, 185, 129, 0.35) !important;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.25rem;
}

.portal-resumo-title {
    color: #10b981;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.portal-resumo-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.875rem;
}

.portal-resumo-row:last-child {
    border-bottom: none;
}

.portal-resumo-label {
    color: #cbd5e1;
    font-weight: 500;
    line-height: 1.4;
}

.portal-resumo-val {
    color: #f8fafc;
    font-weight: 700;
    white-space: nowrap !important;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.portal-resumo-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.85rem;
    border-top: 2px solid rgba(16, 185, 129, 0.4);
}

.portal-resumo-total-label {
    font-size: 1.05rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.portal-resumo-total-val {
    font-size: 1.4rem;
    font-weight: 900;
    color: #10b981;
    white-space: nowrap !important;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 14px rgba(16, 185, 129, 0.4);
}

/* 4. Tabelas Mobile Responsivas */
.portal-table-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.portal-table-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.portal-table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.portal-table-scroll table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
}

/* 5. Banner de Download de PDF */
.portal-pdf-card {
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.12), rgba(15, 23, 42, 0.95)) !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    margin-bottom: 1.25rem;
    width: 100%;
}

.portal-pdf-card .btn-pdf-download {
    width: 100%;
    max-width: 380px;
    padding: 0.85rem 1.25rem;
    font-size: 0.98rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    transition: all 0.2s ease;
}

.portal-pdf-card .btn-pdf-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

@media (max-width: 576px) {
    .portal-resumo-total-label {
        font-size: 0.95rem;
    }
    .portal-resumo-total-val {
        font-size: 1.25rem;
    }
    .portal-info-row {
        font-size: 0.82rem;
    }
    .portal-resumo-row {
        font-size: 0.82rem;
    }
}

/* ==========================================================================
   CLOUD SYNC STATUS BADGE & MULTI-DEVICE INDICATORS
   ========================================================================== */
.cloud-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    user-select: none;
}

.cloud-sync-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cloud-sync-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

/* Estado: Conectado / Sincronizado */
.cloud-sync-badge.status-connected {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
}
.cloud-sync-badge.status-connected .cloud-sync-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
    animation: pulseDot 2.5s infinite;
}

/* Estado: A Sincronizar */
.cloud-sync-badge.status-syncing,
.cloud-sync-badge.status-connecting {
    border-color: rgba(6, 182, 212, 0.4);
    background: rgba(6, 182, 212, 0.08);
    color: #06b6d4;
}
.cloud-sync-badge.status-syncing .cloud-sync-dot,
.cloud-sync-badge.status-connecting .cloud-sync-dot {
    background: #06b6d4;
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.8);
    animation: pulseDot 0.8s infinite;
}

/* Estado: Offline */
.cloud-sync-badge.status-offline {
    border-color: rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
}
.cloud-sync-badge.status-offline .cloud-sync-dot {
    background: #f59e0b;
}

/* Estado: Erro */
.cloud-sync-badge.status-error {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
}
.cloud-sync-badge.status-error .cloud-sync-dot {
    background: #ef4444;
}

/* Estado: Desconectado / Local */
.cloud-sync-badge.status-disconnected {
    border-color: var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
}
.cloud-sync-badge.status-disconnected .cloud-sync-dot {
    background: #94a3b8;
}

@keyframes pulseDot {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

/* ==========================================================================
   UTILITÁRIOS GLOBAIS DE LAYOUT, ESPAÇAMENTO & TIPOGRAFIA
   ========================================================================== */
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.d-none { display: none !important; }
.d-block { display: block !important; }

.flex-column { flex-direction: column !important; }
.flex-row { flex-direction: row !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }
.flex-1 { flex: 1 1 0% !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }

.justify-content-start { justify-content: flex-start !important; }
.justify-content-center { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-end { justify-content: flex-end !important; }

.align-items-start { align-items: flex-start !important; }
.align-items-center { align-items: center !important; }
.align-items-end { align-items: flex-end !important; }
.align-items-stretch { align-items: stretch !important; }

.gap-1 { gap: 0.35rem !important; }
.gap-2 { gap: 0.65rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.35rem !important; }
.mb-2 { margin-bottom: 0.65rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: 0.35rem !important; }
.mt-2 { margin-top: 0.65rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.me-1 { margin-right: 0.35rem !important; }
.me-2 { margin-right: 0.65rem !important; }
.ms-1 { margin-left: 0.35rem !important; }
.ms-2 { margin-left: 0.65rem !important; }

.p-0 { padding: 0 !important; }
.p-1 { padding: 0.35rem !important; }
.p-2 { padding: 0.65rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.pt-1 { padding-top: 0.35rem !important; }
.pt-2 { padding-top: 0.65rem !important; }
.pt-3 { padding-top: 1rem !important; }
.pb-1 { padding-bottom: 0.35rem !important; }
.pb-2 { padding-bottom: 0.65rem !important; }
.px-2 { padding-left: 0.65rem !important; padding-right: 0.65rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }
.py-1 { padding-top: 0.35rem !important; padding-bottom: 0.35rem !important; }
.py-2 { padding-top: 0.65rem !important; padding-bottom: 0.65rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

.text-primary { color: #60a5fa !important; }
.text-success { color: #34d399 !important; }
.text-warning { color: #fbbf24 !important; }
.text-danger { color: #f87171 !important; }
.text-info { color: #22d3ee !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-white { color: #ffffff !important; }
.text-center { text-align: center !important; }
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }

.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-normal { font-weight: 400 !important; }

.fs-5 { font-size: 1.15rem !important; }
.fs-6 { font-size: 0.95rem !important; }
.fs-7 { font-size: 0.85rem !important; }
.fs-8 { font-size: 0.75rem !important; }

.rounded { border-radius: var(--radius-md) !important; }
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded-pill { border-radius: var(--radius-full) !important; }
.border-top { border-top: 1px solid var(--border-color) !important; }
.border-bottom { border-bottom: 1px solid var(--border-color) !important; }

/* ==========================================================================
   CENTRAL DE COMUNICAÇÃO INTERNA & SUPORTE AO ADMINISTRADOR
   ========================================================================== */
.ticket-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.95rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
    overflow: hidden;
}
.ticket-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
}
.ticket-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    margin-bottom: 0.5rem;
}
.ticket-badges-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.ticket-status-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.ticket-badge {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.3;
}
.ticket-admin-panel {
    background: rgba(37, 99, 235, 0.07);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-top: 0.75rem;
}
.ticket-admin-btns {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.ticket-admin-response-box {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.5rem;
}

@media (max-width: 640px) {
    .ticket-card {
        padding: 0.75rem;
    }
    .ticket-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
    .ticket-status-group {
        width: 100%;
        justify-content: space-between;
    }
    .ticket-admin-response-box {
        flex-direction: column;
    }
    .ticket-admin-response-box .btn {
        width: 100%;
    }
    .w-100-mobile {
        width: 100% !important;
    }
}



