/* ==========================================================================
   DESIGN SYSTEM & VARIABLES (Light Theme Default)
   ========================================================================== */
:root {
    /* Color Palette - Defensoria Pública do Estado do Maranhão (DPE-MA) */
    --primary-color: #071D41;      /* Deep Cove (Azul Escuro institucional) */
    --primary-light: #0d2d5d;      /* Hover Navy */
    --primary-ultra-light: #e8f5e9;/* Verde claro / background tint */
    --accent-color: #FBD75A;       /* Energy Yellow (Amarelo institucional) */
    --accent-hover: #e5c147;       /* Hover Yellow */
    --accent-light: #fffbea;       /* Energy Yellow light tint */

    /* Sidebar Verde Institucional DPE-MA */
    --sidebar-bg: linear-gradient(175deg, #004d16 0%, #006b1e 45%, #008C28 100%);
    --sidebar-bg-solid: #004d16;   /* fallback */
    
    /* Semantic Colors */
    --bg-app: #f4f7fc;             /* Light Gray App Background */
    --bg-card: #ffffff;            /* White Card Background */
    --border-color: #e2e8f0;       /* Slate border */
    
    --text-primary: #1e293b;       /* Dark Slate Text */
    --text-secondary: #475569;     /* Slate Medium Text */
    --text-muted: #94a3b8;         /* Light Slate Text */
    
    --success: #10b981;            /* Emerald */
    --success-light: #ecfdf5;
    --warning: #f59e0b;            /* Amber */
    --warning-light: #fef3c7;
    --danger: #ef4444;             /* Red */
    --danger-light: #fef2f2;
    --info: #008C28;               /* Verde Institucional DPE-MA */
    --info-light: #e8f5e9;         /* Verde claro tint */
    
    /* Layout & Styling */
    --sidebar-width: 280px;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 16px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --box-shadow-hover: 0 10px 15px -3px rgba(7, 29, 65, 0.1), 0 4px 6px -2px rgba(7, 29, 65, 0.05);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --primary-color: #0b1a30;      /* Darker Deep Cove */
    --primary-light: #008C28;      /* Verde institucional como hover light */
    --primary-ultra-light: #162438;
    --accent-color: #FBD75A;
    --accent-hover: #e5c147;
    --accent-light: #2d2b1f;

    --sidebar-bg: linear-gradient(175deg, #003510 0%, #004d18 45%, #006b22 100%);
    --sidebar-bg-solid: #003510;
    
    --bg-app: #0f172a;             /* Dark blue background */
    --bg-card: #1e293b;            /* Slate dark card */
    --border-color: #334155;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    
    --success-light: #064e3b;
    --warning-light: #78350f;
    --danger-light: #7f1d1d;
    --info: #00b330;               /* Verde mais claro para dark mode */
    --info-light: #052e0f;
    
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    --box-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   BASE & RESET STYLES
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: normal;
    line-height: 1.25;
}

.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.mt-3 { margin-top: 1rem; }

/* Controle de Visibilidade de Login */
body.auth-required #app-container-main {
    display: none;
}
body:not(.auth-required) #login-screen {
    display: none;
}

/* ==========================================================================
   TELA DE LOGIN
   ========================================================================== */
.login-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #ffffff 0%, #008C28 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 140, 40, 0.15);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    box-shadow: 0 20px 40px rgba(0, 77, 22, 0.2);
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: loginFadeIn 0.5s ease-out;
}

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

.login-card-header {
    text-align: center;
    color: #004d16;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.login-logo-container {
    background-color: var(--accent-color);
    color: var(--primary-color);
    width: 50px;
    height: 50px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.login-logo-icon {
    font-size: 28px;
    font-weight: 700;
}

.login-logo-img {
    height: 80px;
    margin-bottom: 0.75rem;
    object-fit: contain;
}

.login-card-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: normal;
}

.login-card-header p {
    font-size: 0.85rem;
    color: #008C28;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-form .form-group label {
    color: #004d16;
    font-weight: 600;
    font-size: 0.8rem;
    margin-bottom: 0.35rem;
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.password-input-wrapper .lock-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.4);
    font-size: 20px;
}

.password-input-wrapper input {
    width: 100%;
    padding: 0.85rem 1.25rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.password-input-wrapper input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-block {
    width: 100%;
}

.login-error-message {
    color: #fca5a5;
    background-color: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.65rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    text-align: center;
    display: none;
}

.login-card-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg, linear-gradient(175deg, #004d16 0%, #006b1e 45%, #008C28 100%));
    color: #ffffff;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    z-index: 10;
    transition: width 0.3s ease, background 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Efeito sutil de textura na sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    top: -60px;
    right: -60px;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
}

.sidebar::after {
    content: '';
    position: absolute;
    bottom: 80px;
    left: -40px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1.5rem;
}

.logo-container {
    background-color: var(--accent-color);
    color: var(--primary-color);
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.3);
}

.logo-icon {
    font-size: 24px;
    font-weight: bold;
}

.sidebar-logo-img {
    height: 72px;
    object-fit: contain;
    margin-right: 0.5rem;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25));
}

.logo-text h2 {
    font-size: 1rem;
    letter-spacing: normal;
    font-weight: 700;
    line-height: 1.2;
}

.logo-text p {
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex-grow: 1;
}

.menu-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
    padding: 0 1rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.menu-item {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    transition: var(--transition);
    letter-spacing: 0.3px;
    border-left: 3px solid transparent;
}

.menu-item:hover {
    background-color: rgba(255, 255, 255, 0.04);
    color: #ffffff;
}

.menu-item.active {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-weight: 600;
    border-left-color: var(--accent-color);
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.menu-icon {
    margin-right: 10px;
    opacity: 0.7;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-item:hover .menu-icon,
.menu-item.active .menu-icon {
    opacity: 1;
    color: var(--accent-color);
}

.sidebar.collapsed {
    width: 80px;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding-bottom: 1.5rem;
}

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

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

.sidebar.collapsed .menu-section-title {
    display: none;
}

.sidebar.collapsed .menu-item {
    justify-content: center;
    padding: 0.9rem 0;
}

.sidebar.collapsed .menu-item span {
    display: none;
}

.sidebar.collapsed .menu-icon {
    margin-right: 0;
    font-size: 1.2rem;
}

.sidebar.collapsed .btn-toggle-sidebar {
    margin-left: 0;
}

.sidebar.collapsed .btn-toggle-sidebar svg {
    transform: rotate(180deg);
}

.sidebar.collapsed .btn-back-portal {
    justify-content: center;
    padding: 0.8rem 0;
}

.sidebar.collapsed .btn-back-portal span {
    display: none;
}

.sidebar.collapsed .btn-back-portal svg {
    margin-right: 0 !important;
}

.sidebar.collapsed .theme-toggle {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-toggle-sidebar {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
}

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

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
}

.theme-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Switch Slider */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.app-version {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.content-header {
    background-color: var(--bg-card);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-title h1 {
    font-size: 1.75rem;
    color: var(--primary-color);
}

[data-theme="dark"] .header-title h1 {
    color: var(--accent-color);
}

.header-title p {
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.header-right-group {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Status de Conexão */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--primary-ultra-light);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.green {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: blink 2s infinite;
}

.status-dot.orange {
    background-color: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.status-text {
    color: var(--text-secondary);
}

/* Usuário e Logout */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border-right: 1px solid var(--border-color);
    padding-right: 1rem;
}

.user-avatar {
    color: var(--text-secondary);
    font-size: 24px;
}

.user-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
}

.btn-logout svg {
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.btn-logout:hover {
    background-color: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-logout:hover svg {
    color: var(--danger);
    transform: translateX(2px);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.content-body {
    padding: 2rem;
    flex-grow: 1;
    overflow-y: auto;
}

/* Tab Content Visibility */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--border-radius-md);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 44, 89, 0.15);
}

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

.btn-secondary:hover {
    background-color: var(--primary-ultra-light);
    color: var(--primary-color);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   TAB 1: DASHBOARD STYLING
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.stat-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1rem 1.2rem;
    box-shadow: var(--box-shadow);
    border-left: 4px solid var(--border-color);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-hover);
}

.stat-card.total { border-left-color: var(--info); }
.stat-card.pending-crc { border-left-color: var(--warning); }
.stat-card.pending-contact { border-left-color: var(--danger); }
.stat-card.completed { border-left-color: var(--success); }

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

.stat-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-icon-wrapper {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.total .stat-icon-wrapper { background-color: var(--info-light); color: var(--info); }
.pending-crc .stat-icon-wrapper { background-color: var(--warning-light); color: var(--warning); }
.pending-contact .stat-icon-wrapper { background-color: var(--danger-light); color: var(--danger); }
.completed .stat-icon-wrapper { background-color: var(--success-light); color: var(--success); }

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.stat-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.dashboard-details {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-details {
        grid-template-columns: 1fr;
    }
}

.dashboard-widget {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
    transition: background-color 0.3s ease;
}

.dashboard-widget h3 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

[data-theme="dark"] .dashboard-widget h3 {
    color: var(--accent-color);
}

.progress-widget {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin: 1.5rem 0 0.5rem 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--info), var(--success));
    border-radius: 10px;
    width: 0%;
    transition: width 1s ease-in-out;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.notary-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.notary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-color);
}

.notary-item:last-child {
    border-bottom: none;
}

.notary-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.notary-badge {
    background-color: var(--primary-ultra-light);
    color: var(--primary-color);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

/* ==========================================================================
   TAB 2: CONTROLES E FILTROS
   ========================================================================== */
.filters-panel {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: background-color 0.3s ease;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 0.85rem 1.25rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(15, 44, 89, 0.1);
    background-color: var(--bg-card);
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    flex: 1;
    min-width: 160px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flex-row-align {
    flex-direction: row;
    align-items: center;
    min-height: 38px;
    padding-top: 1.2rem;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 0.65rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-app);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.filter-group select:focus {
    border-color: var(--primary-color);
}

/* ==========================================================================
   TABELA DE DADOS
   ========================================================================== */
.table-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow);
    overflow: hidden;
    transition: background-color 0.3s ease;
}

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

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

.data-table th {
    background-color: var(--primary-ultra-light);
    color: var(--primary-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

[data-theme="dark"] .data-table th {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--accent-color);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--accent-color);
    background-color: rgba(15, 44, 89, 0.05);
}

.sort-icon {
    font-size: 14px;
    vertical-align: middle;
    margin-left: 4px;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.9rem;
    white-space: normal;
    word-break: break-word;
}

.data-table td strong {
    font-size: 0.85rem;
    color: var(--text-dark);
}

[data-theme="dark"] .data-table td strong {
    color: #e2e8f0;
}

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

.data-table tbody tr:hover {
    background-color: rgba(244, 247, 252, 0.5);
}

[data-theme="dark"] .data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Badges e Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-pending {
    background-color: var(--warning-light);
    color: var(--warning);
}

.badge-success {
    background-color: var(--success-light);
    color: var(--success);
}

.badge-danger {
    background-color: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background-color: var(--info-light);
    color: var(--info);
}

/* Ações na Tabela (Links textuais elegantes) */
.table-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-link {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

.btn-link.edit {
    color: var(--info);
}

.btn-link.edit:hover {
    background-color: var(--info-light);
    text-decoration: underline;
}

.btn-link.delete {
    color: var(--danger);
}

.btn-link.delete:hover {
    background-color: var(--danger-light);
    text-decoration: underline;
}

/* Botão textual de exclusão na listagem de assessores */
.btn-text-delete {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-text-delete:hover {
    background-color: var(--danger);
    color: white;
}

/* Tabela Rodapé & Paginação */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-page {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-page:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    gap: 0.25rem;
}

.page-num {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
}

.page-num:hover {
    background-color: var(--border-color);
}

.page-num.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

/* ==========================================================================
   TAB 3: ASSESSORES (NOVA)
   ========================================================================== */
.assessores-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .assessores-grid {
        grid-template-columns: 1fr;
    }
}

.assessor-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.assessor-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

[data-theme="dark"] .assessor-card-title {
    color: var(--accent-color);
}

.assessor-card h3 {
    font-size: 1.2rem;
}

.assessor-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ==========================================================================
   TAB 4: BACKUP E DADOS
   ========================================================================== */
.backup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.backup-card {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.backup-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--box-shadow-hover);
}

.backup-card-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary-ultra-light);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.backup-card-icon .material-symbols-outlined {
    font-size: 32px;
}

.backup-card h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.backup-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.backup-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
    width: 100%;
    justify-content: center;
}

.flex-column {
    flex-direction: column;
    align-items: center;
}

.danger-card {
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.danger-card .backup-card-icon {
    background-color: var(--danger-light);
    color: var(--danger);
}

.file-name-display {
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

/* ==========================================================================
   MODAIS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 44, 89, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-container {
    background-color: var(--bg-card);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.1);
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

.modal-sm .modal-container {
    max-width: 450px;
}

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

.modal-header.header-danger {
    background-color: var(--danger);
}

.modal-header h3 {
    font-size: 1.2rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

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

/* Formulários no Modal */
.form-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    font-size: 0.95rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
}

[data-theme="dark"] .form-section-title {
    color: var(--accent-color);
}

.form-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 768px) {
    .form-grid.cols-3, .form-grid.cols-2 {
        grid-template-columns: 1fr;
    }
}

.col-span-1 { grid-column: span 1; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.required-label::after {
    content: " *";
    color: var(--danger);
}

.form-group input, .form-group select {
    padding: 0.65rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(15, 44, 89, 0.1);
}

/* Grupo de Data associado a Checkbox */
.checkbox-date-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 38px;
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 28px;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 20px;
    width: 20px;
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    transition: var(--transition);
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary-color);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.sub-date-input {
    flex-grow: 1;
}

/* Section Finalização Design */
.finalizacao-section {
    background-color: var(--primary-ultra-light);
    border-radius: var(--border-radius-md);
    padding: 1.25rem !important;
    border: 1px dashed var(--primary-color) !important;
}

[data-theme="dark"] .finalizacao-section {
    background-color: rgba(30, 58, 138, 0.1);
    border-color: var(--accent-color) !important;
}

.finalizacao-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.finalizacao-text h4 {
    font-size: 0.95rem;
    color: var(--primary-color);
    margin-bottom: 0.25rem;
}

[data-theme="dark"] .finalizacao-text h4 {
    color: var(--accent-color);
}

.finalizacao-text p {
    font-size: 0.8rem;
}

.switch.large {
    width: 52px;
    height: 26px;
}

.switch.large .slider:before {
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
}

.switch.large input:checked + .slider:before {
    transform: translateX(26px);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1000;
}

.toast {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-radius: var(--border-radius-md);
    padding: 1rem 1.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 280px;
    max-width: 400px;
    border-left: 4px solid var(--border-color);
    animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

.toast-icon { font-size: 20px; }
.success .toast-icon { color: var(--success); }
.error .toast-icon { color: var(--danger); }
.warning .toast-icon { color: var(--warning); }
.info .toast-icon { color: var(--info); }

.toast-message {
    font-size: 0.85rem;
    font-weight: 500;
    flex-grow: 1;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

/* ==========================================================================
   RESPONSIVIDADE E ADAPTAÇÃO PARA DISPOSITIVOS MÓVEIS
   ========================================================================== */

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    padding: 6px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background-color: var(--primary-ultra-light);
}

.menu-bar {
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

[data-theme="dark"] .menu-bar {
    background-color: var(--text-primary);
}

/* Backdrop para o Menu Lateral no Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(7, 29, 65, 0.4);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Regras de CSS Responsivo */
@media (max-width: 992px) {
    /* 1. Header Bar Responsivo */
    .content-header {
        padding: 1rem 1.25rem;
        gap: 1rem;
    }
    
    .mobile-menu-toggle {
        display: flex; /* Exibe o botão no Mobile/Tablet */
    }

    .header-title h1 {
        font-size: 1.3rem;
    }
    
    .header-title p {
        font-size: 0.8rem;
        display: none; /* Oculta subtítulo para economizar espaço horizontal */
    }

    .header-right-group {
        gap: 0.75rem;
    }

    .connection-status {
        padding: 0.3rem 0.6rem;
    }
    
    .connection-status .status-text {
        display: none; /* Oculta o texto do status da D1, mantendo apenas a bolinha verde */
    }

    .user-profile {
        padding-right: 0.5rem;
        border-right: none;
    }
    
    .user-profile .user-label {
        display: none; /* Oculta o nome por escrito para economizar espaço */
    }

    /* 2. Menu Lateral (Sidebar) como Gaveta (Drawer) */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px; /* Esconde a sidebar no canto esquerdo */
        height: 100vh;
        width: 280px;
        z-index: 100;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease;
    }

    .sidebar.open {
        left: 0; /* Desliza a sidebar para a tela */
    }

    /* 3. Ajuste do Container Principal */
    .app-container {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }

    .main-content {
        width: 100%;
        height: 100vh;
    }
    
    .content-body {
        padding: 1rem 1.25rem;
    }
}

@media (max-width: 768px) {
    /* 4. Dashboard Grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 colunas no celular */
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-card {
        padding: 1.25rem 1rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }

    .dashboard-details {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* 5. Tabela Responsiva em formato de Cards (Visualização Premium) */
    .table-card {
        border: none;
        box-shadow: none;
        background: transparent;
    }
    
    .data-table {
        display: block; /* Transforma a tabela em fluxo bloco */
    }

    .data-table th {
        display: none; /* Oculta a linha de títulos no mobile */
    }

    .data-table tbody {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .data-table tr {
        display: block;
        background-color: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-lg);
        padding: 1rem;
        box-shadow: var(--box-shadow);
        transition: var(--transition);
        position: relative;
    }
    
    .data-table tr:hover {
        transform: translateY(-2px);
        box-shadow: var(--box-shadow-hover);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.03);
        text-align: right;
        font-size: 0.85rem;
        white-space: normal;
    }

    [data-theme="dark"] .data-table td {
        border-bottom: 1px solid rgba(255,255,255,0.03);
    }

    .data-table td:last-child {
        border-bottom: none;
        padding-top: 0.75rem;
    }

    /* Insere o rótulo da coluna dinamicamente pelo atributo data-label */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.5px;
        text-align: left;
        flex-shrink: 0;
        margin-right: 1rem;
    }
    
    /* Ajustes específicos para exibição dos dados do card */
    .data-table td[data-label="Assistido"] {
        flex-direction: column;
        align-items: flex-end;
    }
    
    .data-table td[data-label="Assistido"]::before {
        align-self: flex-start;
        margin-bottom: 0.25rem;
    }

    .table-actions {
        width: 100%;
        justify-content: flex-end;
        gap: 1rem;
    }
    
    /* Customização do Rodapé e Paginação da Tabela */
    .table-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
        background-color: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-md);
        margin-top: 1rem;
        padding: 1rem;
        box-shadow: var(--box-shadow);
    }
    
    /* 6. Modais Responsivos no Mobile */
    .modal-container {
        width: 95%;
        max-height: 95vh;
        border-radius: var(--border-radius-md);
    }
    
    .modal-header {
        padding: 1rem 1.25rem;
    }
    
    .modal-body {
        padding: 1.25rem;
    }
    
    .modal-footer {
        padding: 1rem 1.25rem;
        flex-direction: column-reverse; /* Botão principal fica por cima no celular */
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        width: 100%; /* Botões ocupam largura total */
    }

    /* 7. Toast Responsivo */
    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem; /* Centraliza no celular */
    }
    
    .toast {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    /* Ajuste fino para celulares muito pequenos (iPhone SE, etc) */
    .stats-grid {
        grid-template-columns: 1fr; /* 1 coluna */
    }
    
    .header-right-group .btn {
        padding: 0.5rem 0.75rem; /* Botão Nova Ação mais compacto */
    }
    
    .header-right-group .btn span:not(.material-symbols-outlined) {
        display: none; /* Oculta a palavra "Nova Ação" e deixa apenas o símbolo "+" */
    }
}

/* ==========================================================================
   TELA DE SELEÇÃO DE MÓDULOS (PORTAL)
   ========================================================================== */
.portal-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #ffffff 0%, #008C28 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2rem;
    overflow-y: auto;
}

.portal-container-box {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    animation: loginFadeIn 0.5s ease-out;
}

.portal-header-box {
    text-align: center;
    color: #004d16;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.portal-header-box h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.portal-header-box p {
    font-size: 0.95rem;
    color: #008C28;
}

.portal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

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

.portal-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 140, 40, 0.15);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    color: #004d16;
    transition: var(--transition);
    position: relative;
}

.portal-card.active {
    cursor: pointer;
}

.portal-card.active:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
}

.portal-card.disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.portal-card-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    background-color: var(--success);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    letter-spacing: 0.5px;
}

.portal-card-badge.status-soon {
    background-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
}

.portal-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 0.5rem;
    color: #004d16;
}

.portal-card-sub {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--accent-color);
    letter-spacing: 0.5px;
}

.portal-card.disabled .portal-card-sub {
    color: rgba(255, 255, 255, 0.4);
}

.portal-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex-grow: 1;
}

.portal-footer-box {
    text-align: center;
    margin-top: 1rem;
}

.btn-logout-portal {
    background: transparent;
    border: none;
    color: #008C28;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: underline;
    transition: var(--transition);
}

.btn-logout-portal:hover {
    color: #ffffff;
}

/* Botão de Voltar ao Portal na Sidebar */
.btn-back-portal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.55rem;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition);
}

.btn-back-portal:hover {
    background-color: var(--accent-color);
    color: var(--primary-color);
    border-color: var(--accent-color);
    font-weight: 700;
}

/* Fix de Rolagem nos Modais */
.modal-container form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

/* Sub-tabela expansível e detalhes */
.chevron-icon {
    transition: transform 0.25s ease;
    color: var(--text-muted);
}

.action-row.expanded .chevron-icon {
    transform: rotate(180deg);
    color: var(--primary-color);
}

.detail-row {
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.detail-cell {
    background-color: var(--bg-app);
}

.detail-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.25rem 1.5rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02), var(--box-shadow);
}

.sub-table {
    margin-top: 0.5rem;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    overflow: hidden;
}

.sub-table th {
    background-color: var(--primary-ultra-light) !important;
    padding: 0.65rem 1rem !important;
    font-size: 0.75rem !important;
    font-weight: 700 !important;
}

[data-theme="dark"] .sub-table th {
    background-color: rgba(255, 255, 255, 0.03) !important;
    color: var(--accent-color) !important;
}

.sub-table td {
    padding: 0.65rem 1rem !important;
    font-size: 0.8rem !important;
}

.text-link {
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.text-link:hover {
    text-decoration: underline;
}

/* Badge de status compacta */
.badge-status.completed {
    background-color: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-status.pending {
    background-color: var(--warning-light);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* ==========================================================================
   SERVIÇOS ADICIONAIS - Opções de Retificação / Alteração / Restauração
   ========================================================================== */
.adicional-option {
    background-color: var(--bg-app);
    border: 2px solid var(--border-color) !important;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.adicional-option:hover {
    border-color: var(--info) !important;
    color: var(--info);
    background-color: var(--info-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 140, 40, 0.15);
}

.adicional-option.selected {
    border: 2px solid var(--primary-color) !important;
    background-color: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 6px 16px rgba(7, 29, 65, 0.25);
    transform: translateY(-2px);
    font-weight: 700;
}

[data-theme="dark"] .adicional-option {
    background-color: var(--bg-card);
}

[data-theme="dark"] .adicional-option.selected {
    border-color: var(--primary-color) !important;
    background-color: var(--primary-color) !important;
    color: white !important;
}

/* ==========================================================================
   TIMELINE DE ACOMPANHAMENTO DE CERTIDÃO
   ========================================================================== */
.timeline-card {
    background: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: 1.25rem 2rem;
    transition: var(--transition);
}

.timeline-card:hover {
    border-color: rgba(0, 140, 40, 0.3);
    box-shadow: 0 4px 16px rgba(7, 29, 65, 0.07);
}

[data-theme="dark"] .timeline-card {
    background: rgba(255,255,255,0.03);
}

.timeline-etapas {
    display: flex;
    align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
}

.timeline-etapas::-webkit-scrollbar { display: none; }

.etapa-conector {
    flex: 1;
    height: 3px;
    min-width: 16px;
    background: var(--border-color);
    margin-top: 19px;
    border-radius: 2px;
    transition: background 0.4s ease;
}

.etapa-conector.conector-ativo {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.etapa-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    min-width: 90px;
    max-width: 150px;
    text-align: center;
    flex-shrink: 0;
}

.etapa-bolinha {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    border: 3px solid var(--border-color);
    background: var(--bg-card);
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.etapa-feita .etapa-bolinha {
    background: var(--success);
    border-color: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.etapa-proxima .etapa-bolinha {
    background: var(--bg-card);
    border-color: var(--info);
    color: var(--info);
    animation: pulseEtapa 2.2s infinite;
}

@keyframes pulseEtapa {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 140, 40, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(0, 140, 40, 0); }
}

.etapa-futura .etapa-bolinha {
    background: var(--bg-app);
    border-color: var(--border-color);
    color: var(--text-muted);
}

.etapa-label {
    font-size: 0.67rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1.3;
    word-break: break-word;
    transition: color 0.3s ease;
}

.etapa-feita .etapa-label { color: var(--success); }
.etapa-proxima .etapa-label { color: var(--info); font-weight: 700; }

.quick-action-btn {
    margin-top: 0.35rem;
    padding: 0.3rem 0.55rem;
    font-size: 0.65rem;
    font-weight: 700;
    border: none;
    border-radius: 20px;
    background: var(--info);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1.3;
    white-space: normal;
    box-shadow: 0 2px 8px rgba(0, 140, 40, 0.35);
}

.quick-action-btn:hover {
    background: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(7, 29, 65, 0.25);
}

.quick-action-btn:active { transform: translateY(0); }

/* Toast: transição suave garantida */
.toast { transition: opacity 0.3s ease, transform 0.3s ease !important; }

/* ==========================================================================
   MOBILE RESPONSIVENESS OVERRIDES (ADDED)
   ========================================================================== */
@media (max-width: 768px) {
    /* Esconder o thead nas tabelas */
    .data-table thead, .data-table th {
        display: none !important;
    }

    /* Transformar tbody em flex container pra agrupar cards */
    .data-table tbody {
        display: flex !important;
        flex-direction: column;
        gap: 1rem;
    }

    /* Transformar tr em cards independentes */
    .data-table tr {
        display: flex !important;
        flex-direction: column;
        background-color: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-lg);
        padding: 1rem;
        box-shadow: var(--box-shadow);
        position: relative;
    }

    /* O detalhe (linha debaixo expansível) não deve parecer um card avulso, deve grudar com o de cima */
    .data-table tr.detail-row[style*="table-row"], 
    .data-table tr.detail-row.open-detail {
        display: block !important;
        margin-top: -1rem;
        border-top: 1px dashed var(--border-color);
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        background: var(--bg-card);
        padding: 1rem 0.25rem;
    }

    /* Resetar td para flex row (lado a lado com label) */
    .data-table td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        text-align: right;
        font-size: 0.85rem;
    }

    /* O último td não precisa de borda */
    .data-table td:last-child {
        border-bottom: none;
    }

    /* O rótulo em si */
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.5px;
        margin-right: 1rem;
        text-align: left;
    }

    /* Célula do toggle (chevron) e ações sem label */
    .data-table td.toggle-expansion-cell,
    .data-table td:not([data-label]) {
        justify-content: center;
    }

    .data-table td.toggle-expansion-cell::before,
    .data-table td:not([data-label])::before {
        display: none !important;
    }
    
    .data-table td.detail-cell {
        padding: 0 !important;
        display: block !important;
    }
    
    /* Modais responsivos */
    .modal-container {
        width: 95% !important;
        max-width: 95vw !important;
        max-height: 95vh !important;
        margin: 0 auto;
    }

    .modal-body {
        padding: 1rem !important;
    }

    .modal-header, .modal-footer {
        padding: 0.75rem 1rem !important;
    }

    /* Linha do tempo de tramitação */
    .timeline-card {
        padding: 0.75rem 0.5rem !important;
        border: none !important;
        background: transparent !important;
    }

    .timeline-etapas {
        padding-bottom: 1rem;
        gap: 0;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .etapa-item {
        min-width: 95px;
        padding: 0 0.25rem;
    }

    .etapa-label {
        font-size: 0.65rem !important;
    }

    .etapa-conector {
        min-width: 20px;
    }

    /* Timeline header em telas pequenas */
    .timeline-card > div:first-child {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
    
    .timeline-card > div:first-child button {
        align-self: flex-start;
        margin-left: 0 !important;
    }
}
