:root {
    /* ══════════════════════════════════════════
       DESIGN SYSTEM TOKENS — SINGLE SOURCE OF TRUTH
       ══════════════════════════════════════════ */

    /* Brand Colors */
    --primary: #6366f1;
    --primary-hover: #7c83ff;
    --primary-glow: rgba(99, 102, 241, 0.15);
    --accent: #10b981;
    --error: #ef4444;
    --warn: #f59e0b;
    --info: #38bdf8;

    /* Surface Colors */
    --bg-main: #0b1220;
    --bg-surface: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.85);
    --card-border: rgba(148, 163, 184, 0.12);
    --input-bg: rgba(15, 23, 42, 0.9);
    --glass: rgba(30, 41, 59, 0.95);
    --hover-bg: rgba(255, 255, 255, 0.04);

    /* Text */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    /* Spacing Scale (4px base) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;

    /* Border Radius */
    --radius-xl: 24px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --radius-pill: 100px;

    /* Shadows */
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
    --shadow-card-hover: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --shadow-glow-primary: 0 4px 15px rgba(99, 102, 241, 0.3);
    --shadow-glow-success: 0 4px 15px rgba(16, 185, 129, 0.2);

    /* Transitions */
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.2s var(--ease-out);
    --transition-normal: 0.3s var(--ease-out);

    /* Layout */
    --sidebar-w: 260px;
    --content-max-w: 1600px;
    --page-padding: 2rem 3rem;
}


body.light-mode {
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.05);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --input-bg: #ffffff;
    --glass: rgba(255, 255, 255, 0.95);
    --hover-bg: #f1f5f9;
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.1);
    
    /* Variáveis NOC Light */
    --noc-bg: #f8fafc;
    --noc-card-bg: #ffffff;
    --noc-card-hover: #f1f5f9;
    --noc-card-border: rgba(0, 0, 0, 0.08);
    --noc-text-main: #0f172a;
    --noc-text-secondary: #475569;
    --noc-text-muted: #64748b;
}

/* Base Adjustments for Light Mode */
body.light-mode {
    background: var(--bg-main) !important;
}

body.light-mode .sidebar {
    background: var(--glass);
    border-right: 1px solid var(--card-border);
    box-shadow: 10px 0 30px rgba(0,0,0,0.03);
}

body.light-mode .nav-item:hover {
    background: var(--hover-bg);
}

body.light-mode .card,
body.light-mode .modal-content {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.02) !important;
}

body.light-mode th {
    background: #f1f5f9;
    color: var(--text-main);
    border-bottom: 2px solid #e2e8f0;
}

body.light-mode tr {
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
}

body.light-mode tr:hover {
    background: #f8fafc !important;
}

body.light-mode td {
    color: var(--text-main);
}

body.light-mode .status-indicator {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: var(--text-muted);
}

body.light-mode h1, body.light-mode h2, body.light-mode h3, 
body.light-mode h4, body.light-mode .page-title {
    color: var(--text-main);
}

body.light-mode .custom-input, 
body.light-mode select, 
body.light-mode textarea {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: var(--text-main);
}

body.light-mode .summary-mini-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

body.light-mode .summary-card-venc, 
body.light-mode .summary-card-finance {
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', sans-serif; }

button, .btn {
    border: none;
    outline: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
}

body {
    background: var(--bg-main);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background var(--transition-normal), color var(--transition-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.dark-mode {
    background: radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.04) 0%, transparent 40%),
                radial-gradient(circle at 100% 100%, rgba(56, 189, 248, 0.03) 0%, transparent 40%),
                var(--bg-main) !important;
}

.app-container { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); background: var(--glass); 
    border-right: 1px solid var(--card-border); display: flex; flex-direction: column;
    padding: 1.5rem 0.85rem; position: fixed; height: 100vh; z-index: 9999; 
    box-shadow: 10px 0 30px rgba(0,0,0,0.2); 
    overflow-y: auto; scrollbar-width: none;
    top: 0; left: 0;
}
.sidebar::-webkit-scrollbar { display: none; }

.logo {
    display: flex; align-items: center; gap: 0.75rem; font-size: 1.1rem; font-weight: 700;
    margin-bottom: 2rem; padding: 0 0.5rem; color: var(--text-main);
    white-space: nowrap; letter-spacing: -0.3px;
}
.logo img { width: 28px !important; height: 28px !important; border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

.nav-section-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    padding: 1rem 0.8rem 0.5rem;
    opacity: 0.7;
}

nav { display: flex; flex-direction: column; gap: 0.3rem; flex: 1; }
.nav-item {
    background: transparent; border: none; color: var(--text-muted); padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm); display: flex; align-items: center; gap: 0.8rem; font-size: 0.85rem;
    font-weight: 500; cursor: pointer; transition: all var(--transition-fast);
    text-decoration: none !important;
}
.nav-item i { font-size: 1.2rem; width: 22px; text-align: center; }
.nav-item:hover { background: var(--hover-bg); color: var(--text-main); }
.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary); font-weight: 600;
}

.bot-status { 
    margin-top: auto; 
    padding: 1.5rem 0.5rem 0.5rem; 
    border-top: 1px solid var(--card-border); 
}

.status-indicator { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
    font-size: 0.8rem; 
    color: var(--text-muted); 
    font-weight: 700; 
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03); 
    border-radius: 12px; 
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05); 
    justify-content: center;
    transition: all 0.3s ease;
    cursor: default;
    letter-spacing: 0.02em;
}

.status-indicator.status-online {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.15);
    color: #fff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.05);
}

.status-indicator.status-pending {
    background: rgba(245, 158, 11, 0.05);
    border-color: rgba(245, 158, 11, 0.15);
    color: var(--warn);
}

.status-indicator .dot { 
    width: 8px; 
    height: 8px; 
    border-radius: 50%; 
    background: #475569; 
    position: relative;
    transition: all 0.3s ease;
}

.status-indicator.status-online .dot { 
    background: var(--accent); 
    box-shadow: 0 0 10px var(--accent); 
}

.status-indicator.status-online .dot::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 1px solid var(--accent);
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

.status-indicator.status-pending .dot { 
    background: var(--warn); 
    box-shadow: 0 0 8px var(--warn);
}

.status-indicator.status-offline .dot {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

.logout-container { margin-top: 0.25rem; }
.logout-btn {
    width: 100%; 
    background: linear-gradient(to right, rgba(244, 63, 94, 0.05), rgba(244, 63, 94, 0.01)); 
    color: #cbd5e1; 
    border: 1px solid rgba(244, 63, 94, 0.15); 
    padding: 0.8rem 1rem; 
    border-radius: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.75rem; 
    font-size: 0.85rem; 
    font-weight: 700; 
    cursor: pointer; 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}
.logout-btn::before { display: none; }
.logout-btn i { font-size: 1.2rem; color: var(--error); transition: 0.2s ease; }
.logout-btn:hover { 
    background: rgba(239, 68, 68, 0.1); 
    color: #fff; 
    border-color: rgba(239, 68, 68, 0.2);
    transform: translateY(-1px);
}
.logout-btn:hover i { color: #fff; }

.content { position: relative; z-index: 10; flex: 1; margin-left: var(--sidebar-w) !important; width: calc(100% - var(--sidebar-w)); max-width: 100%; padding: var(--page-padding); }
header { margin-bottom: var(--sp-6); }
header h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.5px; margin-bottom: var(--sp-1); color: var(--text-main); }
header p { font-size: 0.95rem; color: var(--text-muted); font-weight: 400; opacity: 0.9; }

.tab-content { display: none; }
.tab-content.active { display: block; animation: slideUpFade 0.4s ease; }
@keyframes slideUpFade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & Stats - Premium Spacing */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--sp-6); margin-bottom: var(--sp-6); }
.card { 
    background: var(--card-bg); 
    border-radius: var(--radius-xl); 
    padding: var(--sp-6); 
    border: 1px solid var(--card-border); 
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-card);
}
.card:hover {
    box-shadow: var(--shadow-card-hover);
}
.stat-card { display: flex; align-items: center; gap: 1.5rem; }
.stat-card i { font-size: 1.6rem; background: rgba(255, 255, 255, 0.03); padding: 1rem; border-radius: 16px; border: 1px solid var(--card-border); }
.color-whatsapp { color: var(--accent); } .color-panels { color: var(--primary); }
.stat-label { text-transform: uppercase; font-size: 0.7rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.3rem; letter-spacing: 0.5px; opacity: 0.8; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text-main); line-height: 1.1; }

.terminal-container {
    background: #020617; border-radius: var(--radius-lg); padding: 2rem; font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem; height: 400px; overflow-y: auto; border: 1px solid var(--card-border);
}
.log-line { margin-bottom: 0.75rem; padding: 0.5rem 1rem; border-radius: 8px; border-left: 3px solid transparent; }
.log-line.success { border-left-color: var(--accent); } .log-line.error { border-left-color: var(--error); }

/* Panel Grid & Cards Premium */
/* Panel Grid & Cards Premium ELITE */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-5); }
.panel-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-xl);
    padding: 1.2rem !important;
    border: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-card);
}
.panel-card:hover {
    transform: translateY(-4px);
    border-color: rgba(148, 163, 184, 0.2);
    box-shadow: var(--shadow-card-hover);
}
.panel-header-top { display: flex; justify-content: space-between; align-items: flex-start; }
.panel-brand { display: flex; align-items: center; gap: 0.85rem; }
.panel-icon-box {
    width: 48px; height: 48px; 
    background: rgba(255, 255, 255, 0.03);
    color: var(--primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    border: 1px solid var(--card-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.panel-info-main { display: flex; flex-direction: column; gap: 0.2rem; }
.panel-tag { 
    background: rgba(56, 189, 248, 0.1); color: var(--primary); padding: 0.2rem 0.6rem; border-radius: 6px; 
    font-size: 0.6rem; font-weight: 800; text-transform: uppercase; width: fit-content;
}
.panel-title { font-size: 1.15rem; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.panel-url { 
    font-size: 0.75rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; opacity: 0.6; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.panel-creds { 
    background: rgba(2, 6, 23, 0.6); padding: 0.75rem 1rem; border-radius: 12px; 
    font-size: 0.8rem; color: var(--text-muted); border: 1px solid rgba(255, 255, 255, 0.03);
    display: flex; flex-direction: column; gap: 0.35rem;
}
.panel-creds-row { display: flex; justify-content: space-between; align-items: center; }
.panel-creds-label { font-weight: 600; font-size: 0.7rem; text-transform: uppercase; opacity: 0.5; color: #94a3b8; }
.panel-creds-value { color: var(--text-main); font-weight: 500; font-family: 'JetBrains Mono', monospace; }
.panel-creds-value.pass { letter-spacing: 2px; opacity: 0.6; }

.icon-btn-group { display: flex; gap: 0.5rem; }
.icon-btn, .icon-btn-secondary, .icon-btn-danger {
    background: rgba(255, 255, 255, 0.04); 
    border: 1px solid var(--card-border); 
    color: var(--text-muted);
    width: 36px; height: 36px; border-radius: var(--radius-xs); cursor: pointer; transition: all var(--transition-fast);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.icon-btn:hover, .icon-btn-secondary:hover { background: rgba(255, 255, 255, 0.1); color: #fff; transform: translateY(-2px); border-color: rgba(148, 163, 184, 0.25); }
.icon-btn-danger:hover { background: rgba(239, 68, 68, 0.15); color: var(--error); border-color: rgba(239, 68, 68, 0.3); transform: translateY(-2px); }

.add-panel-card {
    background: transparent; border: 1px dashed rgba(255, 255, 255, 0.15); border-radius: 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem;
    cursor: pointer; min-height: 180px; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); color: var(--text-muted);
}
.add-panel-card:hover { border-color: var(--primary); color: var(--primary); background: var(--hover-bg); transform: translateY(-2px); }
.add-panel-card i { font-size: 2rem; }
.add-panel-card span { font-size: 0.9rem; font-weight: 500; }

/* Modals - Compacto */
.modal {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(2, 6, 23, 0.9);
    backdrop-filter: blur(12px); z-index: 2000; align-items: center; justify-content: center; padding: 1.5rem;
}
.modal.active { display: flex; }

/* Feedback visual para campos clicáveis no perfil do cliente */
#profile-info-list span[onclick]:hover {
    color: var(--primary) !important;
    text-decoration: underline;
}
.modal-content { 
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-xl); 
    padding: 2.5rem; width: 100%; max-width: 550px; position: relative; animation: slideUpModal 0.5s ease;
    backdrop-filter: blur(20px);
}

/* Modal de Comprovante Específico */
.image-view-card {
    max-width: 600px !important;
    padding: 0 !important; /* Removemos o padding para a imagem aproveitar as bordas */
    display: flex !important;
    flex-direction: column;
    align-items: center;
    overflow-y: auto; /* Permite rolar o comprovante para baixo */
    max-height: 90vh !important; /* Limita apenas a altura do card */
    background: transparent !important;
    border: none !important;
}

#modal-receipt-img {
    width: 100% !important;
    height: auto !important; /* Deixamos ela livre para ser comprida */
    border-radius: 16px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.8);
    background: #fff;
    margin-bottom: 20px;
}

.close-btn {
    position: fixed; /* Botão fica sempre visível no canto superior direito */
    top: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    transition: all 0.3s ease;
}
.close-btn:hover { transform: scale(1.1) rotate(90deg); }

.image-wrapper { width: 100%; }

/* .modal-content h2 { display: none; } */

.custom-input, .custom-select, input, select, textarea {
    width: 100%;
    background: var(--input-bg) !important;
    border: 1px solid var(--card-border) !important;
    padding: 0.85rem 1rem !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-main) !important;
    font-size: 0.95rem !important;
    outline: none !important;
    transition: all var(--transition-fast) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.custom-input:focus, .custom-select:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--primary) !important;
    background: rgba(15, 23, 42, 1) !important;
    box-shadow: 0 0 0 3px var(--primary-glow) !important;
}
input:invalid, select:invalid, textarea:invalid {
    border-color: rgba(244, 63, 94, 0.4);
}
input:focus:invalid, select:focus:invalid, textarea:focus:invalid {
    border-color: var(--error) !important;
    box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.2) !important;
}

.input-label-premium {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-icon-group {
    display: flex;
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all var(--transition-normal);
}
.input-icon-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.input-icon-group .icon-box {
    padding: 0 1rem;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid var(--card-border);
    color: var(--text-muted);
}
.input-icon-group input { border: none !important; background: transparent !important; }

.form-row { margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 1rem; margin-top: 2rem; width: 100%; }
.btn { 
    flex: 1; 
    padding: 0.85rem 1.75rem; 
    border-radius: var(--radius-md); 
    border: none; 
    font-weight: 800; 
    cursor: pointer; 
    transition: all var(--transition-normal); 
    font-size: 0.95rem; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.75rem; 
    letter-spacing: 0.02em; 
    position: relative;
    overflow: hidden;
}

.btn.primary { 
    background: var(--primary) !important; 
    color: #ffffff !important; 
    box-shadow: var(--shadow-glow-primary) !important;
}

.btn.primary:hover { 
    background: var(--primary-hover) !important; 
    transform: translateY(-2px); 
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.45) !important; 
}

.btn.secondary { 
    background: var(--bg-surface) !important; 
    border: 1px solid var(--card-border) !important; 
    color: #ffffff !important; 
}

.btn.secondary:hover { 
    background: rgba(51, 65, 85, 0.8) !important; 
    border-color: rgba(148, 163, 184, 0.25) !important; 
    transform: translateY(-2px); 
}

/* Novo Design do Modal de Clientes */
.modal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: var(--sp-6);
    background: rgba(255, 255, 255, 0.03);
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
}

.modal-tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all var(--transition-fast);
    font-size: 0.88rem;
}

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

.modal-tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-glow-primary);
}

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

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Input Icon Group (consolidated) */
.input-icon-group {
    display: flex;
    align-items: stretch;
    background: var(--input-bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--card-border);
    margin-bottom: 1rem;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.input-icon-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-icon-group .icon-box {
    width: 45px;
    min-width: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border-right: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 1.15rem;
}

.input-icon-group input, 
.input-icon-group select, 
.input-icon-group textarea {
    flex: 1;
    background: transparent !important;
    border: none !important;
    padding: 0.8rem 1rem !important;
    color: var(--text-main) !important;
    outline: none !important;
    width: 100%;
    box-shadow: none !important;
}

.input-icon-group textarea {
    min-height: 80px;
    resize: vertical;
}

/* Input Label (consolidated) */
.input-label-premium {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.input-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.6;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    display: block;
}

/* Switches Premium */
.switch-premium {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

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

.switch-premium .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.05);
    transition: .4s;
    border-radius: 34px;
    border: 1px solid rgba(255,255,255,0.1);
}

.switch-premium .slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: #94a3b8;
    transition: .4s;
    border-radius: 50%;
}

.switch-premium input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary-glow);
}

.switch-premium input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--bg-dark);
}

.filter-group {
    transition: all 0.3s ease;
}
.filter-group:hover {
    background: rgba(255,255,255,0.05) !important;
    border-color: rgba(255,255,255,0.2) !important;
}

.filter-btn {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.filter-btn:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.filter-btn.active {
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 600;
    border-color: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* Switches Customizados */
.switch-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    cursor: pointer;
    user-select: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    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: #334155;
    transition: .4s;
    border-radius: 34px;
}

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

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

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

.switch-label {
    font-size: 0.95rem;
    color: var(--text-main);
}

.alert-note {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.1);
    color: var(--warn);
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}


/* Dashboard Table - Professional Edge */
.table-container { 
    overflow-x: auto; 
    overflow-y: auto !important; 
    padding-bottom: var(--sp-2); 
    min-height: 250px; 
    max-height: 60vh;
    -webkit-overflow-scrolling: touch; 
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    background: transparent;
    
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Custom Scrollbar for WebKit (Chrome, Safari, Edge) */
.table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.table-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: var(--radius-xs);
}
.table-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xs);
}
.table-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mini Cards Financeiros (Aba Clientes) */
.finance-highlights {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: nowrap; /* Garante que fiquem sempre em linha */
}

.summary-mini-card {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--card-border);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    min-width: 100px;
    transition: all var(--transition-normal);
    position: relative;
    overflow: visible;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.summary-mini-card:hover {
    background: rgba(255, 255, 255, 0.03);
    transform: translateY(-2px);
    border-color: rgba(148, 163, 184, 0.25);
}

.summary-mini-card .label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.summary-mini-card .value {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
    white-space: nowrap;
}

.summary-mini-card.total { border-bottom: 2px solid var(--primary); }
.summary-mini-card.custo { border-bottom: 2px solid var(--error); }
.summary-mini-card.lucro { border-bottom: 2px solid var(--accent); }

/* Tema Claro para Mini Cards */
body.light-mode .summary-mini-card {
    background: #ffffff;
    border-color: #cbd5e1;
}
body.light-mode .summary-mini-card .value {
    color: #0f172a !important;
}

@media (max-width: 768px) {
    .finance-highlights {
        width: 100%;
        justify-content: space-between;
    }
    .summary-mini-card {
        flex: 1;
        min-width: 0;
        padding: 0.4rem 0.6rem;
    }
    .summary-mini-card .value {
        font-size: 0.85rem;
    }
}
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: auto; }
th { 
    text-align: left; 
    padding: var(--sp-2) var(--sp-3); 
    font-size: 0.75rem; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    border-bottom: 1px solid var(--card-border); 
    font-weight: 600; 
    white-space: nowrap;
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}
td { 
    background: transparent; 
    padding: var(--sp-2) var(--sp-3) !important; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 0.85rem; 
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
    transition: all var(--transition-fast);
}
tr:last-child td { border-bottom: none; }
tbody tr { 
    transition: all var(--transition-fast); 
}

tbody tr:hover td { 
    background: rgba(99, 102, 241, 0.1) !important; /* Realce com tom azulado do sistema */
    color: #fff; 
}

tbody tr:hover td:first-child { 
    box-shadow: inset 4px 0 0 var(--primary); /* Barra lateral de foco */
    border-top-left-radius: var(--radius-sm); 
    border-bottom-left-radius: var(--radius-sm); 
}

tbody tr:hover td:last-child { 
    border-top-right-radius: var(--radius-sm); 
    border-bottom-right-radius: var(--radius-sm); 
}

/* Coluna Info - permitir quebra e limitar largura */
td:nth-child(6) { max-width: 280px; white-space: normal; word-break: break-word; }

/* Remover regras de bordas arredondadas antigas dos td */
td:first-child { max-width: 180px; }
td:last-child { text-align: center; overflow: visible; }

/* Column Widths Refined - Legibilidade */
.col-contato { width: 180px; font-weight: 600; color: #ffffff !important; }
.col-usuario { width: 120px; text-align: left; opacity: 0.9; }
.col-zap { width: 110px; color: var(--primary); }
.col-servidor { width: 80px; }
.col-valor { width: 85px; font-weight: 600; text-align: left; }
.col-venc { width: 100px; color: var(--text-muted); }
.col-status { width: 105px; }
.col-pendencia { width: 110px; text-align: center; }
.col-recibo { width: 180px; min-width: 180px; text-align: center; overflow: visible; }

.status-badge { 
    padding: var(--sp-1) var(--sp-2); border-radius: var(--radius-xs); font-size: 0.7rem; 
    font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
    letter-spacing: 0.2px; text-transform: capitalize;
}
.status-badge.sucesso { background: rgba(16, 185, 129, 0.1); color: var(--accent); }
.status-badge.erro { background: rgba(244, 63, 94, 0.1); color: var(--error); }
.status-badge.aviso { background: rgba(245, 158, 11, 0.1); color: var(--warn); }
.status-badge.info { background: rgba(56, 189, 248, 0.1); color: var(--primary); }

.alerta-badge {
    background: var(--warn); color: #000; padding: 3px 10px; border-radius: var(--radius-xs);
    font-size: 0.7rem; font-weight: 800; cursor: pointer; transition: all var(--transition-normal);
    position: relative; display: inline-flex; align-items: center; gap: 4px;
}
.alerta-badge:hover { transform: scale(1.05); filter: brightness(1.1); box-shadow: 0 0 15px rgba(245, 158, 11, 0.4); }

.alerta-tooltip {
    position: absolute;
    top: 140%; /* Move para baixo do badge */
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    width: 280px;
    background: #0f172a;
    border: 1px solid rgba(245, 158, 11, 0.5);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: 0 15px 35px rgba(0,0,0,0.6);
    z-index: 99999;
    visibility: hidden;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    text-align: left;
    backdrop-filter: blur(8px);
}

.alerta-badge:hover .alerta-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Seta apontando para cima agora */
.alerta-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent rgba(245, 158, 11, 0.5) transparent;
}

/* Garante que o TD não corte o conteúdo */
.col-alerta { overflow: visible !important; position: relative; }
tbody tr:hover { z-index: 10; position: relative; } /* Faz a linha atual ficar sobre as outras no hover */

.tooltip-header {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--warn);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tooltip-item {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 0.6rem;
    margin-bottom: 0.6rem;
    border-left: 3px solid var(--warn);
}

.tooltip-item-title {
    font-weight: 700;
    color: #fff;
    font-size: 0.75rem;
    margin-bottom: 2px;
}

.tooltip-item-msg {
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 1.4;
}

.tooltip-item-date {
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.5;
    margin-top: 4px;
}

.tooltip-footer {
    font-size: 0.65rem;
    text-align: center;
    color: var(--primary);
    margin-top: 0.5rem;
    font-weight: 600;
    opacity: 0.8;
}

/* Light mode support for tooltips */
body.light-mode .alerta-tooltip {
    background: #ffffff;
    border-color: #f59e0b;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    color: #000;
}
body.light-mode .tooltip-item {
    background: #f8fafc;
}
body.light-mode .tooltip-item-title { color: #000; }
body.light-mode .tooltip-item-msg { color: #334155; }


.input-desc { display: block; font-size: 0.6rem; color: var(--text-muted); margin-top: 4px; line-height: 1.2; }

.col-actions { display: flex; gap: 4px; justify-content: flex-end; }

.receipt-link { 
    background: rgba(56, 189, 248, 0.08); color: var(--primary); width: 26px; height: 26px;
    border-radius: 6px; border: 1px solid rgba(56, 189, 248, 0.15); cursor: pointer; 
    transition: all 0.3s ease; display: inline-flex; align-items: center; justify-content: center;
}
.receipt-link:hover { background: var(--primary); color: var(--bg-dark); transform: scale(1.1); }

.icon-btn {
    width: 28px; height: 28px; font-size: 0.9rem;
}

.search-bar { margin-bottom: 0.8rem !important; }
.search-bar input { padding: 0.5rem 0.5rem 0.5rem 2.8rem !important; font-size: 0.85rem; }
.receipt-link:hover { background: var(--primary); color: var(--bg-dark); transform: scale(1.1); }

/* Login Page Styles */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #0f172a 0%, #020617 100%);
    color: var(--text-main);
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 3rem 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUpFade 0.6s ease;
}

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

.login-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 1rem;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-form .input-group {
    margin-bottom: 1.5rem;
}

.login-form .input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-wrapper {
    position: relative;
}

.login-form input {
    padding-left: 3rem !important;
}

.login-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 14px;
    border: none;
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 1rem;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.login-error {
    color: var(--error);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 1rem;
    display: none;
}

/* Estilos Adicionais para Clientes */
.custom-select {
    width: 100%; 
    background: rgba(0,0,0,0.2); 
    border: 1px solid var(--card-border); 
    padding: 0.8rem 1rem; 
    border-radius: 12px; 
    color: white;
    outline: none;
}
.custom-select option { background: var(--card-bg); color: white; }

.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 15px var(--primary-glow); }

/* === TABELA DE CLIENTES — Layout fixo e compacto === */
#clients-tab .table-container {
    overflow-x: hidden !important;
    overflow-y: auto;
    max-height: 75vh;
}
#clients-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
#clients-table th, #clients-table td { padding: 0.7rem 0.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; }
#clients-table td.col-recibo { overflow: visible; }

/* Cabeçalho Sticky com fundo sólido */
#clients-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #1e293b;
    border-bottom: 2px solid rgba(148,163,184,0.18);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* Larguras de colunas — soma = 100% (ajustado para STATUS não truncar) */
.col-contato  { width: 14%; font-weight: 500; }
.col-usuario  { width: 9%; }
.col-zap      { width: 12%; color: var(--text-muted); }
.col-servidor { width: 8%; }
.col-pgto     { width: 6%; opacity: 0.9; }
.col-valor    { width: 7%; font-weight: 600; color: var(--text-main) !important; }
.col-venc     { width: 10%; color: var(--text-muted); }
.col-alerta   { width: 5%; text-align: center; }
.col-status   { width: 14%; white-space: nowrap !important; overflow: visible !important; text-overflow: clip !important; }
.col-recibo   { width: 15%; min-width: 150px; }

/* Botões de ação compactos */
.col-actions { display: flex; gap: 4px; justify-content: flex-start; align-items: center; flex-wrap: nowrap; }
.col-actions .icon-btn { width: 28px; height: 28px; min-width: 28px; font-size: 0.95rem; padding: 0; flex: 0 0 28px; }

/* Stripe Level: Esconder actions da tabela até que se passe o mouse (apenas em desktop) */
@media (hover: hover) {
    .col-actions .icon-btn {
        opacity: 0;
        transform: scale(0.95);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    tbody tr:hover .col-actions .icon-btn {
        opacity: 1;
        transform: scale(1);
    }
    .col-actions .icon-btn:hover {
        transform: scale(1.05); /* Pequeno lift no botao focado */
    }
}

/* Botão oculto por padrão (estilo hamburger) */
.mobile-only-btn {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1001; /* Garante que o botão fique acima de quase tudo no header */
}
.mobile-only-btn:hover {
    background: var(--primary-glow);
    color: var(--primary);
   }

/* ====== UNIFIED SUB-NAVIGATION (Config + Messages) ====== */
.config-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--sp-8);
}

.config-sidebar-nav .card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    transition: all var(--transition-normal);
}

.config-nav-btn, .msg-nav-btn {
    width: 100%;
    color: var(--text-muted) !important;
    font-weight: 500 !important;
    padding: 0.8rem 1rem !important;
    border-radius: var(--radius-sm) !important;
    text-align: left !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.8rem !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    transition: all var(--transition-fast) !important;
    font-size: 0.88rem !important;
}

.config-nav-btn i, .msg-nav-btn i {
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
}

/* Removed: Hover and active-highlight rules (consolidated to global shell) */

/* Removed: Legacy fragmented media queries (moved to unified global block at the end of the file) */


/* Novos Cartões de Dashboard */
.dashboard-grid { display: flex; flex-direction: column; gap: 2rem; margin-bottom: 2rem; width: 100%; }
.dashboard-section-title { font-size: 0.9rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; text-align: center; margin-bottom: 1.5rem; position: relative; }
.dashboard-section-title::after { content: ''; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); width: 40px; height: 3px; background: var(--primary); border-radius: 2px; }

.summary-row { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important; gap: 0.75rem !important; width: 100% !important; margin-bottom: 1rem; }

/* Cards de Vencimento - Premium Redesign */
.venc-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.venc-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    display: flex;
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    box-shadow: var(--shadow-card);
}
.venc-card:hover {
    transform: translateY(-3px);
    border-color: rgba(148, 163, 184, 0.25);
    box-shadow: var(--shadow-card-hover);
}
.venc-card.active-filter {
    transform: translateY(-2px);
    box-shadow: inset 0 0 0 1px currentColor, 0 8px 25px rgba(0,0,0,0.4) !important;
    background: rgba(255,255,255,0.08) !important;
}
.venc-card:active { transform: translateY(-1px); }

/* Texto de Ação Oculto */
.venc-action-text {
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    transform: translateX(-5px);
}
.venc-card:hover .venc-action-text, .venc-card.active-filter .venc-action-text {
    opacity: 0.8;
    transform: translateX(0);
}

/* Tinted backgrounds per type */
.venc-ativos { background: rgba(16, 185, 129, 0.04); border-color: rgba(16, 185, 129, 0.15); color: #10b981; }
.venc-vencidos { background: rgba(244, 63, 94, 0.04); border-color: rgba(244, 63, 94, 0.15); color: #f43f5e; }
.venc-ontem { background: rgba(251, 113, 133, 0.04); border-color: rgba(251, 113, 133, 0.12); color: #fb7185; }
.venc-hoje { background: rgba(245, 158, 11, 0.04); border-color: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.venc-amanha { background: rgba(250, 204, 21, 0.04); border-color: rgba(250, 204, 21, 0.12); color: #facc15; }
.venc-em-2-dias { background: rgba(96, 165, 250, 0.04); border-color: rgba(96, 165, 250, 0.15); color: #60a5fa; }

.venc-accent {
    width: 4px;
    min-height: 100%;
    flex-shrink: 0;
    border-radius: 4px 0 0 4px;
}
.venc-body {
    padding: 0.9rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.venc-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.venc-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: 0.3px;
}
.venc-title i { font-size: 0.95rem; }
.venc-badge {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 7px;
    border-radius: 6px;
    letter-spacing: 0.3px;
}
.venc-bottom {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.venc-count {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--text-main);
    letter-spacing: -0.5px;
}
.venc-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,0.5);
    font-family: 'Outfit', sans-serif;
}

/* Hover glow por tipo */
.venc-ativos:hover { box-shadow: 0 8px 25px rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.25); }
.venc-vencidos:hover { box-shadow: 0 8px 25px rgba(244, 63, 94, 0.15); border-color: rgba(244, 63, 94, 0.25); }
.venc-ontem:hover { box-shadow: 0 8px 25px rgba(251, 113, 133, 0.15); border-color: rgba(251, 113, 133, 0.25); }
.venc-hoje:hover { box-shadow: 0 8px 25px rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.25); }
.venc-amanha:hover { box-shadow: 0 8px 25px rgba(250, 204, 21, 0.12); border-color: rgba(250, 204, 21, 0.2); }
.venc-em-2-dias:hover { box-shadow: 0 8px 25px rgba(96, 165, 250, 0.15); border-color: rgba(96, 165, 250, 0.25); }

/* Light Mode */
body.light-mode .venc-card { background: #fff; border-color: #e2e8f0; }
body.light-mode .venc-card:hover { background: #f8fafc; box-shadow: 0 10px 30px rgba(0,0,0,0.08); }
body.light-mode .venc-count { color: #0f172a; }
body.light-mode .venc-value { color: #64748b; }
body.light-mode .venc-badge { background: #f1f5f9; }

/* Responsivo */
@media (max-width: 1200px) { .venc-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .venc-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .venc-grid { grid-template-columns: 1fr; } }

/* Faturamento e Lucro - Cards Consolidados Premium */
.fin-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-normal);
    display: flex;
    flex-direction: column;
}
.fin-card:hover {
    transform: translateY(-4px);
    border-color: rgba(148, 163, 184, 0.25);
    box-shadow: var(--shadow-card-hover);
    background: rgba(255,255,255,0.07);
}
.fin-card-featured {
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(16, 185, 129, 0.06);
}
.fin-card-featured:hover {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}

.fin-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.2rem 1.2rem 0;
}
.fin-card-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.fin-card-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    display: block;
}
.fin-card-date {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    display: block;
    margin-top: 1px;
}

.fin-card-total {
    padding: 1rem 1.2rem 0.5rem;
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
}
.fin-card-total-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.5px;
}
.fin-card-total-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.fin-card-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem 1rem;
}
.fin-metric {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 10px;
    padding: 0.7rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.fin-metric-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.fin-metric-label i { font-size: 0.85rem; }
.fin-metric-value {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Outfit', sans-serif;
}
.fin-metric-count {
    font-size: 0.6rem;
    color: var(--text-muted);
    opacity: 0.7;
}

.fin-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.2rem;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.06);
    margin-top: auto;
}
.fin-footer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    gap: 2px;
}
.fin-footer-label {
    font-size: 0.55rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.fin-footer-item.plus .fin-footer-value { color: #10b981; font-weight: 700; font-size: 0.85rem; }
.fin-footer-item.minus .fin-footer-value { color: #f43f5e; font-weight: 700; font-size: 0.85rem; }
.fin-footer-item.profit .fin-footer-value { color: #38bdf8; font-weight: 800; font-size: 0.85rem; }
.fin-footer-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.06);
}

/* Light Mode */
body.light-mode .fin-card { background: #ffffff; border-color: #e2e8f0; }
body.light-mode .fin-card:hover { background: #f8fafc; box-shadow: 0 12px 40px rgba(0,0,0,0.08); }
body.light-mode .fin-card-featured { background: rgba(16, 185, 129, 0.04); border-color: rgba(16, 185, 129, 0.2); }
body.light-mode .fin-card-total-value { color: #0f172a; }
body.light-mode .fin-metric { background: #f1f5f9; }
body.light-mode .fin-metric-value { color: #0f172a; }
body.light-mode .fin-card-footer { background: #f8fafc; border-top-color: #e2e8f0; }
body.light-mode .fin-footer-divider { background: #e2e8f0; }

/* Responsivo */
@media (max-width: 1024px) {
    .fin-card-total-value { font-size: 1.3rem; }
}
@media (max-width: 768px) {
    .fin-card-row-grid { grid-template-columns: 1fr; }
}




/* Modo Privacidade (Eye Icon) */
.privacy-blurred {
    filter: blur(10px) !important;
    user-select: none !important;
    pointer-events: none !important;
    opacity: 0.6;
    transition: filter 0.3s ease;
}
/* Navegação de Submenu */
.nav-submenu {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.5rem;
}
.submenu-item {
    margin-left: 0.5rem !important;
    padding: 0.5rem 0.9rem !important;
    font-size: 0.8rem !important;
    opacity: 0.8;
}
.submenu-item.active {
    background: rgba(99, 102, 241, 0.08) !important;
    color: var(--primary) !important;
}

/* Configurações Internas (Sistema) */
.sub-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}
.sub-tab-content.active {
    display: block;
}
.timeline-item {
    position: relative;
}
.timeline-item ul li {
    margin-bottom: 0.5rem;
}
/* Estilos de Botão de Alternância de Visibilidade de Senha */
.password-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
    transition: color var(--transition-fast);
    z-index: 10;
}
.password-toggle:hover {
    color: var(--primary);
}

.premium-swal { border-radius: 16px !important; border: 1px solid rgba(255,255,255,0.08) !important; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7) !important; z-index: 99999 !important; }
.swal2-container { z-index: 99999 !important; }

/* ==========================================
   MODAL DE COBRANÇAS PREMIUM
   ========================================== */

/* Estilos de Abas (Segmented Control) */
#cobranca-modal .tab-btn.active {
    background: var(--primary) !important;
    color: var(--bg-main) !important;
    box-shadow: 0 4px 12px var(--primary-glow);
}

#cobranca-modal .tab-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05) !important;
    color: white !important;
}

/* Seletores de Dias (Custom Buttons) */
.days-selector {
    padding: 0.5rem;
}

.day-check {
    position: relative;
    cursor: pointer;
}

.day-check input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.day-check span {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.day-check:hover span {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.day-check input:checked + span {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.15);
}

/* Multi-selects com Scroll Customizado e Modais */
.custom-scrollbar::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.client-modal-body::-webkit-scrollbar,
.info-modal-body::-webkit-scrollbar,
.payment-modal-body::-webkit-scrollbar,
.modal form::-webkit-scrollbar,
select[multiple]::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.client-modal-body::-webkit-scrollbar-track,
.info-modal-body::-webkit-scrollbar-track,
.payment-modal-body::-webkit-scrollbar-track,
.modal form::-webkit-scrollbar-track,
select[multiple]::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.client-modal-body::-webkit-scrollbar-thumb,
.info-modal-body::-webkit-scrollbar-thumb,
.payment-modal-body::-webkit-scrollbar-thumb,
.modal form::-webkit-scrollbar-thumb,
select[multiple]::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.2);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.client-modal-body::-webkit-scrollbar-thumb:hover,
.info-modal-body::-webkit-scrollbar-thumb:hover,
.payment-modal-body::-webkit-scrollbar-thumb:hover,
.modal form::-webkit-scrollbar-thumb:hover,
select[multiple]::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Grupo de Filtros Select Multiple */
.filter-group select {
    background: rgba(0, 0, 0, 0.3) !important;
    font-size: 0.85rem !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 12px !important;
    outline: none !important;
    cursor: pointer;
    color: var(--text-main) !important;
    padding: 0.5rem !important;
}

.filter-group select option {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 2px;
    background: var(--card-bg);
    color: var(--text-main);
}

.filter-group select option:checked {
    background: var(--primary) !important;
    color: #000000 !important;
}

/* Light Mode Override */
body.light-mode .filter-group select {
    background: #ffffff !important;
    border-color: #e0e5f2 !important;
    color: #1b2559 !important;
}
body.light-mode .filter-group select option {
    background: #ffffff;
    color: #1b2559;
}
body.light-mode .filter-group select option:checked {
    background: #4318ff !important;
    color: #ffffff !important;
}


/* ==========================================
   RESPONSIVIDADE (MOBILE & TABLET)
   ========================================== */

/* Botão de Menu Mobile (Escondido no Desktop) */
.mobile-only-btn {
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 45px;
    height: 45px;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.5rem;
}

/* New Dashboard Header Controls */
.app-version-badge-container {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 14px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    z-index: 100;
}

.header-icon-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    transform: translateY(-1px);
}

.infra-status-mini {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.infra-status-mini .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4b5563;
    position: relative;
}

.infra-status-mini.status-online { color: var(--noc-emerald); }
.infra-status-mini.status-online .dot { 
    background: var(--noc-emerald); 
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4); 
}
.infra-status-mini.status-online .dot::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: inherit;
    animation: noc-pulse 2s infinite;
}

.infra-status-mini.status-offline { color: var(--noc-rose); }
.infra-status-mini.status-offline .dot { background: var(--noc-rose); }

.infra-status-mini.status-degraded { color: var(--noc-amber); }
.infra-status-mini.status-degraded .dot { background: var(--noc-amber); }

@media (max-width: 1024px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-105%); left: 0; width: 280px; transition: transform 0.3s ease; z-index: 9999; }
    .sidebar.mobile-active { transform: translateX(0); }
    .content { margin-left: 0; padding: 1rem; }
    .mobile-only-btn { display: flex; }
    .sidebar .nav-item span { display: inline !important; opacity: 1 !important; visibility: visible !important; }
    .sidebar .nav-item { justify-content: flex-start !important; }

    .content header .app-version-badge-container {
        position: relative !important;
        margin-bottom: 1rem;
            display: inline-flex !important;
    }

    /* Overlay ao abrir menu - Elevado o Z-Index para ficar sob a sidebar mas sobre o conteúdo */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.7);
        backdrop-filter: blur(4px);
        z-index: 9990; /* Quase o mesmo que a sidebar (9999) */
    }
    .sidebar-overlay.active { display: block; animation: fadeInOverlay 0.3s ease; }

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

    /* Ajuste de grids */
    .stats-row, .summary-row {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }

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

    /* Cards do dashboard em coluna */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }

    /* Ajuste de Modais */
    .modal-content {
        padding: 1.5rem;
        max-width: 95%;
        margin: 10px;
        max-height: 95vh;
        overflow-y: auto;
    }

    .modal-actions {
        flex-direction: column;
    }

    /* Tabs laterais das configs viram coluna */
    .config-container {
        grid-template-columns: 1fr;
    }

    .config-sidebar-nav {
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .config-sidebar-nav .card {
        flex-direction: row !important;
        overflow-x: auto;
        width: 100%;
        min-width: 100%;
        gap: 0.5rem !important;
        background: rgba(0,0,0,0.15) !important;
    }

    .config-nav-btn, .msg-nav-btn {
        white-space: nowrap;
        padding: 0.6rem 1rem !important;
        font-size: 0.8rem !important;
        flex-shrink: 0;
    }
    /* Tabelas com Scroll Horizontal */
    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Ajuste de cards de resumo */
    .summary-card-venc, .summary-card-finance {
        width: 100%;
    }

    .summary-mini-card {
        width: calc(50% - 5px);
        min-width: unset;
    }

    /* Resolver sobreposição do card de versão no cabeçalho mobile */
    header div[style*="position: absolute"] {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        margin-bottom: 0.5rem;
        width: fit-content;
        float: right;
    }
    
    header h1 {
        clear: both;
    }
}

/* User Status Badges */
.user-status-badge { padding: var(--sp-1) var(--sp-2); border-radius: 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; }
.user-status-badge.admin { background: rgba(99, 102, 241, 0.1); color: var(--primary); }
.user-status-badge.user { background: rgba(16, 185, 129, 0.1); color: var(--accent); }
.user-status-badge.pending { background: rgba(245, 158, 11, 0.1); color: var(--warn); }

@media (max-width: 480px) {
    header h1 { font-size: 1.5rem; }
    
    .summary-mini-card {
        width: 100%;
    }

    /* Filtros na aba de clientes */
    #filters-container {
        flex-direction: column;
        align-items: stretch !important;
    }

    .filter-group {
        width: 100%;
    }

    .search-container {
        width: 100% !important;
    }

    /* Botões na aba de mensagens */
    .msg-nav-btn {
        width: 100%;
    }
}

/* Utilitário para animação da sidebar */
body.sidebar-open {
    overflow: hidden;
}

/* Pulso verde para check de conexão */
@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

/* Combobox Premium - Sistema de Busca Inteligente */
.combobox-premium {
    position: relative;
    width: 100%;
}
.combobox-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9999;
    background: var(--card-bg);
    border: 1px solid var(--primary);
    border-radius: 12px;
    margin-top: 5px;
    padding: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    list-style: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    animation: slideUpFade 0.2s ease;
}
.combobox-results li {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.combobox-results li:last-child { border-bottom: none; }
.combobox-results li:hover {
    background: var(--primary);
    color: #000;
    font-weight: 600;
}
.combobox-results li.no-results {
    color: var(--text-muted);
    font-style: italic;
    cursor: default;
    background: transparent !important;
    text-align: center;
    padding: 1.5rem;
}
/* Custom Premium Dropdown */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
}

.dropdown-trigger:hover {
    background: var(--hover-bg);
    border-color: var(--primary);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: #1e293b;
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    z-index: 10000;
    padding: 0.75rem;
    display: none;
    max-height: 450px;
    overflow-y: auto;
    animation: dropdownFade 0.2s ease;
}

.dropdown-menu.show {
    display: block;
}

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

.dropdown-section {
    margin-bottom: 0.8rem;
}

.dropdown-section-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0.5rem 0.5rem 0.25rem 0.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 0.4rem;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: var(--hover-bg);
    color: var(--text-main);
}

.dropdown-item.active {
    background: var(--primary-glow);
    color: var(--primary);
    font-weight: 600;
}

.dropdown-item i {
    font-size: 1.1rem;
    opacity: 0.7;

}

/* ==========================================
   UX PREMIUM: LOADING, TOASTS & FEEDBACK
   ========================================== */

/* 1. Skeleton Loading & Shimmer */
.skeleton {
    position: relative;
    overflow: hidden !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border-radius: 6px;
}

.skeleton::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background-image: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0,
        rgba(255, 255, 255, 0.05) 20%,
        rgba(255, 255, 255, 0.08) 60%,
        rgba(255, 255, 255, 0)
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

/* Skeleton Table Rows */
.skeleton-row td {
    padding: 0.75rem !important;
}
.skeleton-row td > .skeleton-box {
    height: 12px;
    width: 80%;
    margin: 4px 0;
}

/* 2. Toast Notifications */
#toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    min-width: 280px;
    max-width: 420px;
    padding: 1rem 1.25rem;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 500;
    animation: toastSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.2s ease;
}

.toast.removing {
    opacity: 0;
    transform: translateX(40px);
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast i { font-size: 1.25rem; }
.toast.success { border-left: 4px solid #10b981; }
.toast.success i { color: #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.error i { color: #ef4444; }
.toast.info { border-left: 4px solid #38bdf8; }
.toast.info i { color: #38bdf8; }

/* 3. Empty State */
.empty-state-container {
    padding: 5rem 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.empty-state-icon {
    font-size: 3.5rem;
    color: var(--text-muted);
    opacity: 0.3;
    margin-bottom: 0.5rem;
}

.empty-state-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.empty-state-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.5;
}

/* 4. Action Feedback: Button Loading */
.btn-loading {
    position: relative !important;
    color: transparent !important;
    pointer-events: none !important;
}

.btn-loading i, .btn-loading span {
    visibility: hidden;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: calc(50% - 10px);
    left: calc(50% - 10px);
    border: 3px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    border-top-color: #fff;
    animation: btnSpin 0.6s linear infinite;
}

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

/* 5. Micro-interactions */
.fade-in {
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}


/* ==========================================
   UTILITÁRIOS DE GRID RESPONSIVO (NOC/FINANCE)
   ========================================== */
.responsive-grid {
    display: grid !important;
    gap: 1.5rem !important;
}

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

/* Custom Grids para o NOC */
.grid-noc-main { grid-template-columns: 1.2fr 0.8fr; }
.grid-noc-sla  { grid-template-columns: repeat(4, 1fr); }

/* Responsividade Progressiva */
@media (max-width: 1200px) {
    .grid-noc-sla { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1024px) {
    .grid-3, .grid-noc-main, .grid-noc-sla {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================
   CORREÇÃO DE DESIGN - MOBILE FIRST (768px)
   ========================================== */
@media (max-width: 768px) {
    .venc-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .fin-card-row-grid { grid-template-columns: 1fr 1fr; }
    
    #clients-table thead { display: none; }
    #clients-table, #clients-table tbody, #clients-table tr, #clients-table td {
        display: block;
        width: 100%;
    }
    #clients-table tbody tr {
        background: var(--card-bg);
        border: 1px solid var(--card-border);
        border-radius: 16px;
        margin-bottom: 0.75rem;
        padding: 0.9rem 1rem;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }
    #clients-table td { padding: 0.2rem 0 !important; border: none !important; font-size: 0.88rem; color: var(--text-muted); }
    #clients-table td.col-contato { font-size: 1rem; font-weight: 700; color: var(--text-main) !important; display: block; }
    #clients-table td.col-usuario, #clients-table td.col-zap, #clients-table td.col-servidor, #clients-table td.col-venc {
        display: inline-flex;
        margin-right: 0.5rem;
    }
    #clients-table td.col-recibo { display: flex !important; width: 100%; border-top: 1px solid var(--card-border) !important; margin-top: 0.6rem; }
}

@media (max-width: 480px) {
    .fin-card-row-grid { grid-template-columns: 1fr !important; }
}

/* ==========================================================================
   NOC V3: PREMIUM MISSION CONTROL (Unified with Design System)
   ========================================================================== */
:root {
    --noc-bg: #060b18;
    --noc-card-bg: rgba(255, 255, 255, 0.03);
    --noc-card-hover: rgba(255, 255, 255, 0.06);
    --noc-card-border: var(--card-border);
    --noc-text-main: var(--text-main);
    --noc-text-secondary: #9ca3af;
    --noc-text-muted: #6b7280;
    --noc-font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --noc-primary: var(--primary);
    --noc-emerald: var(--accent);
    --noc-amber: var(--warn);
    --noc-rose: #f43f5e;
    --noc-sky: #0ea5e9;
}

.noc-theme {
    background: radial-gradient(circle at 0% 0%, rgba(99, 102, 241, 0.12) 0%, transparent 35%),
                radial-gradient(circle at 100% 100%, rgba(56, 189, 248, 0.08) 0%, transparent 35%),
                var(--noc-bg) !important;
}

.noc-cockpit-wrapper {
    min-height: 100vh;
    color: var(--noc-text-main);
    padding: 2rem;
    font-family: 'Inter', -apple-system, sans-serif;
    max-width: var(--content-max-w);
    margin: 0 auto;
}

/* 1. Header & Hero Section */
.noc-hero-section {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.noc-hero-content h1 {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.noc-hero-content p {
    font-size: 0.9rem;
    color: var(--noc-text-secondary);
    font-weight: 400;
}

.noc-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--noc-card-border);
    padding: 10px 20px;
    border-radius: 12px;
    margin-bottom: 2.5rem;
    backdrop-filter: blur(8px);
}

.noc-header-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--noc-card-border);
    color: var(--noc-text-secondary);
}

.status-online .status-dot-pulse { background: var(--noc-emerald); box-shadow: 0 0 10px rgba(16, 185, 129, 0.4); }
.status-degraded .status-dot-pulse { background: var(--noc-amber); box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
.status-offline .status-dot-pulse { background: var(--noc-rose); box-shadow: 0 0 10px rgba(244, 63, 94, 0.4); }

/* Status: Disabled (Feature Flag Off) */
.dot-disabled { background: #6b7280; box-shadow: none; animation: none !important; }
.dot-disabled::after { display: none; }

.noc-header-badge.online {
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.15);
    color: var(--noc-emerald);
}

.noc-header-badge.critical {
    background: rgba(244, 63, 94, 0.05);
    border-color: rgba(244, 63, 94, 0.15);
    color: var(--noc-rose);
}

.status-dot-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
    background: #4b5563;
}

.status-dot-pulse::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: inherit;
    animation: noc-pulse 2s infinite;
}

@keyframes noc-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(2.5); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* 2. Sub-navigation Tabs */
.ops-nav-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--sp-3);
    background: rgba(255, 255, 255, 0.02);
    padding: var(--sp-2);
    border-radius: var(--radius-md);
    width: fit-content;
    border: 1px solid var(--noc-card-border);
    margin-bottom: 2.5rem;
    backdrop-filter: blur(10px);
}

.ops-btn {
    background: transparent;
    border: none;
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--noc-text-secondary);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.ops-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.ops-btn.active {
    background: var(--noc-primary);
    color: #fff;
    box-shadow: var(--shadow-glow-primary);
}

/* Operational Panels Logic */
.ops-panel {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.ops-panel.active {
    display: block;
}

/* 1.1 Layout Containers */
.noc-view-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* 2. Advanced Metrics Grid (The "Linear" Look) */
.noc-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 2rem;
}

.noc-metric-card {
    background: var(--noc-card-bg);
    border: 1px solid var(--noc-card-border);
    padding: var(--sp-6);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

.noc-metric-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: var(--noc-card-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.noc-metric-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

.noc-metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.noc-metric-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--noc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.noc-metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--noc-text-main);
    letter-spacing: -0.04em;
    font-family: var(--noc-font-mono);
}

.noc-metric-footer {
    margin-top: 10px;
    font-size: 0.68rem;
    color: var(--noc-text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 3. Strategic KPI Section (Enhanced Density) */
.noc-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 2rem;
}

.noc-kpi-card {
    background: var(--noc-card-bg);
    border: 1px solid var(--noc-card-border);
    padding: var(--sp-6);
    border-radius: var(--radius-md);
    text-align: left;
    transition: all var(--transition-normal);
    backdrop-filter: blur(8px);
}

.noc-kpi-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    background: rgba(99, 102, 241, 0.03);
    transform: translateY(-2px);
}

.noc-kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.noc-kpi-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--noc-text-secondary);
    margin-top: 10px;
}

.noc-kpi-sub {
    font-size: 0.7rem;
    margin-top: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 4. SLA & Reliability Specialized Markers */
.sla-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    margin-top: 16px;
    overflow: hidden;
}

.sla-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--noc-emerald), #34d399);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
    border-radius: 10px;
}

/* 5. Incident Stack Header & View All */
.ops-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 4px;
}

.ops-section-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--noc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.ops-view-all-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--noc-card-border);
    padding: var(--sp-2) 18px;
    border-radius: var(--radius-xs);
    color: var(--noc-text-main);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.ops-view-all-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(148, 163, 184, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Incident Table - see consolidated .noc-table-v2 below */

/* 4. Operational Console (Premium Terminal) */
.noc-console-v2 {
    background: rgba(6, 11, 24, 0.6) !important;
    border: 1px solid var(--noc-card-border) !important;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-top: 1.5rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    backdrop-filter: blur(15px);
}

.console-header-v2 {
    background: rgba(255,255,255,0.02);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.console-stream-badge {
    font-family: var(--noc-font-mono);
    font-size: 0.65rem;
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.console-stream-badge::before {
    content: '';
    width: 6px; height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: live-pulse-slow 2s infinite;
}

.console-feed-v2 {
    height: 500px;
    padding: 24px;
    font-family: var(--noc-font-mono);
    font-size: 0.82rem;
    overflow-y: auto;
    color: var(--noc-text-secondary);
    line-height: 1.8;
    background: transparent;
    scroll-behavior: smooth;
}

.console-feed-v2::-webkit-scrollbar { width: 5px; }
.console-feed-v2::-webkit-scrollbar-track { background: transparent; }
.console-feed-v2::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 10px; }
.console-feed-v2::-webkit-scrollbar-thumb:hover { background: var(--noc-primary); }

.log-line { 
    margin-bottom: 8px; 
    border-left: 2px solid transparent; 
    padding: 4px 16px; 
    border-radius: 0 6px 6px 0;
    transition: all 0.2s ease; 
    background: rgba(255,255,255,0.01);
}

.log-line:hover { 
    background: rgba(255,255,255,0.03); 
    color: #fff; 
}

.log-ok { color: var(--noc-emerald); border-left-color: var(--noc-emerald); background: rgba(16, 185, 129, 0.02); }
.log-warn { color: var(--noc-amber); border-left-color: var(--noc-amber); background: rgba(245, 158, 11, 0.02); }
.log-error { color: var(--noc-rose); border-left-color: var(--noc-rose); background: rgba(244, 63, 94, 0.02); }
.log-healing { color: var(--noc-sky); border-left-color: var(--noc-sky); background: rgba(14, 165, 233, 0.02); }

/* 5. Incident Table (SaaS Style) */
.noc-table-v2 {
    width: 100%;
    border-collapse: collapse;
}

.noc-table-v2 th {
    padding: 16px 20px;
    text-align: left;
    font-size: 0.62rem;
    color: var(--noc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 800;
    border-bottom: 1px solid var(--noc-card-border);
    background: rgba(255,255,255,0.01);
}

.noc-table-v2 td {
    padding: 16px 20px;
    font-size: 0.8rem;
    color: var(--noc-text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.noc-table-v2 tr:last-child td { border-bottom: none; }
.noc-table-v2 tr:hover { background: rgba(255, 255, 255, 0.02); }

.noc-status-badge {
    padding: var(--sp-1) 10px;
    border-radius: var(--radius-xs);
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid transparent;
}

.status-badge-success { background: rgba(16, 185, 129, 0.1); color: #10b981; border-color: rgba(16, 185, 129, 0.2); }
.status-badge-failed { background: rgba(239, 68, 68, 0.1); color: #ef4444; border-color: rgba(239, 68, 68, 0.2); }
.status-badge-healing { background: rgba(6, 182, 212, 0.1); color: #06b6d4; border-color: rgba(6, 182, 212, 0.2); }

.vencidos { background-color: #ef4444; color: white; }

.healing-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-4);
}

.action-card-v2 {
    background: var(--noc-card-bg);
    border: 1px solid var(--noc-card-border);
    padding: var(--sp-6);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    cursor: pointer;
    transition: all var(--transition-normal);
    backdrop-filter: blur(10px);
}

.action-card-v2:hover {
    transform: translateY(-4px);
    border-color: var(--noc-primary);
    background: var(--noc-card-hover);
    box-shadow: var(--shadow-card-hover);
}

.action-icon-v2 {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    color: #fff;
    border: 1px solid var(--noc-card-border);
}

.action-card-v2.active .action-icon-v2 { 
    background: rgba(16, 185, 129, 0.1); 
    color: var(--noc-emerald); 
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.1);
}

.action-info-v2 h4 { font-size: 0.95rem; font-weight: 700; color: #fff; margin-bottom: 4px; }
.action-info-v2 p { font-size: 0.75rem; color: var(--noc-text-secondary); line-height: 1.4; }

/* Animations */
.live-pulse-slow {
    animation: noc-live-pulse 2s infinite ease-in-out;
}

@keyframes noc-live-pulse {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Responsive Overrides */
@media (max-width: 1400px) {
    .noc-metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .noc-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .noc-metrics-grid { grid-template-columns: 1fr; }
    .noc-kpi-grid { grid-template-columns: 1fr; }
    .noc-hero-section { flex-direction: column; align-items: flex-start; gap: 20px; }
    .noc-status-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* NOC LITE (Dashboard Preview) */
.noc-card-lite {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(56, 189, 248, 0.05) 100%), rgba(255, 255, 255, 0.02) !important;
    border: 1px solid var(--noc-card-border) !important;
    backdrop-filter: blur(10px);
}

.noc-lite-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.noc-lite-status {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.noc-shield {
    width: 64px;
    height: 64px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--noc-emerald);
    position: relative;
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.1);
}

.noc-lite-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--noc-text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.noc-lite-metrics {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.mini-stat {
    font-size: 0.75rem;
    color: var(--noc-text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-stat b {
    color: #fff;
    font-family: var(--noc-font-mono);
}

.btn-noc-recovery {
    background: linear-gradient(135deg, var(--noc-rose) 0%, #be123c 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3) !important;
}

.btn-noc-recovery:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(244, 63, 94, 0.5) !important;
}



/* ====== POLISH FINAL TEMA CLARO ====== */
body.light-mode .app-container { background: #f8fafc !important; }
body.light-mode .sidebar { box-shadow: 2px 0 10px rgba(0,0,0,0.02) !important; }
body.light-mode .nav-item.active { background: #4f46e5 !important; color: #fff !important; }
body.light-mode .nav-item.active i { color: #fff !important; }
body.light-mode .card-header h2 { color: #0f172a !important; }
body.light-mode .summary-card-venc, body.light-mode .summary-card-finance { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important; }
body.light-mode .finance-label { color: #475569 !important; }
body.light-mode .finance-val { color: #0f172a !important; font-weight: 700; }
body.light-mode .status-online { color: #10b981 !important; }
body.light-mode .status-offline { color: #ef4444 !important; }
body.light-mode .status-pending { color: #f59e0b !important; }
body.light-mode .stat-label { color: #64748b !important; }
body.light-mode .stat-value { color: #0f172a !important; }
body.light-mode .noc-header-badge { background: #f1f5f9; border-color: #e2e8f0; color: #475569; }
body.light-mode .noc-hero-content h1 { color: #0f172a !important; }
body.light-mode .ops-btn:hover { background: #f1f5f9; color: #0f172a; }
body.light-mode .ops-nav-container { background: #f1f5f9; border-color: #e2e8f0; }

/* ==============================================================
   ULTIMATE SAAS PREMIUM SHELL LAYOUT (AUDITED & SAFE)
   ============================================================== */

/* 1. Global Shell Layout & Spacing */
body .app-container .content {
    max-width: var(--content-max-w, 1600px);
    margin: 0 auto;
}

body .content header,
body .content .noc-hero-section {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

body .content header h1, 
body .content header h2, 
body .content .noc-hero-content h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
    margin: 0;
    line-height: 1.2;
}

body .content header p, 
body .content .noc-hero-content p {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 400;
    margin: 0;
}

/* NOC Hero cleanup */
body .content .noc-hero-section {
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
}

/* 2. Padronizar Containers Principais (Submenus laterais) */
/* Necessita !important pois o HTML possui style="..." inline */
.config-container {
    display: grid !important;
    grid-template-columns: 260px 1fr !important;
    gap: 2rem !important;
    margin-top: 0 !important;
    align-items: start !important;
}

/* Unificando o Submenu Lateral (Mensagens, Config) */
.config-sidebar-nav .card, 
.config-sidebar-nav, 
.msg-nav-sidebar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    box-shadow: var(--shadow-card);
}

/* NOC e Histórico Sub-nav (Topo) */
.ops-nav-container {
    flex-direction: row; 
    overflow-x: auto;
    padding: 0.5rem;
    margin-bottom: 2rem;
    border-radius: var(--radius-xl);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-card);
}

/* Unificando botoes de nav interna */
.config-nav-btn, .msg-nav-btn, .ops-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}
body .content .config-nav-btn:hover, 
body .content .msg-nav-btn:hover, 
body .content .ops-btn:hover {
    background: rgba(99, 102, 241, 0.12) !important;
    color: #c7d2fe !important;
}

body .content .config-nav-btn.active-highlight, 
body .content .msg-nav-btn.active-highlight, 
body .content .ops-btn.active {
    background: linear-gradient(135deg, #6366f1, #7c83ff) !important;
    color: #fff !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35) !important;
    border: none !important;
}

/* 3. Cards Padrao (Premium Dark Slate) */
body .content .card, 
body .content .noc-metric-card, 
body .content .noc-kpi-card, 
body .content .premium-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-fast);
}
body .content .card:hover, 
body .content .noc-metric-card:hover, 
body .content .noc-kpi-card:hover, 
body .content .premium-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: rgba(99, 102, 241, 0.2);
}

/* 4. Padronizacao de Tabelas Global */
body .content .table-container {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    border: 1px solid var(--card-border);
    overflow-x: auto;
    overflow-y: visible;
    box-shadow: var(--shadow-card);
    margin-bottom: 2rem;
    
    /* Esconde a barra de rolagem visualmente, mas mantém a função */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
body .content .table-container::-webkit-scrollbar {
    display: none;
}
body .content table { width: 100%; border-collapse: collapse; }

/* (Removido: regra global last-child que causava scroll horizontal) */
body .content thead th {
    background: rgba(255,255,255,0.02);
    padding: 1.2rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--card-border);
    text-align: left;
}
body .content tbody td {
    padding: 1.2rem 1.5rem;
    font-size: 0.9rem;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255,255,255,0.03);
    vertical-align: middle;
}
body .content tbody tr:hover td { background: rgba(255,255,255,0.01); }
body .content tbody tr:last-child td { border-bottom: none; }

/* 5. Inputs & Selects Globais Seguros (Evita quebrar modals SweetAlert) */
body .custom-input, 
body .custom-select, 
body input[type="text"]:not(.swal2-input), 
body input[type="number"]:not(.swal2-input), 
body input[type="date"]:not(.swal2-input), 
body select:not(.swal2-select) {
    background: var(--input-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    color: var(--text-main);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    width: 100%;
}
body .custom-input:focus, 
body .custom-select:focus, 
body input[type="text"]:not(.swal2-input):focus, 
body select:not(.swal2-select):focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    outline: none;
}

/* Limpar estilização dupla no HTML legado usando !important pontualmente */
#sub-msg-modelos, #sub-msg-cobrancas, #sub-msg-fila, .ops-panel, .sub-tab-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}
.card.premium-card { border-top: none !important; }

/* 6. Botoes Globais Seguros */
body .content .btn.primary { background: var(--primary); color: white; font-weight: 600; border: none; box-shadow: var(--shadow-glow-primary); border-radius: var(--radius-md); padding: 0.8rem 1.5rem; }
body .content .btn.primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4); }
body .content .btn.secondary { background: rgba(255,255,255,0.05); color: var(--text-main); border: 1px solid var(--card-border); font-weight: 600; border-radius: var(--radius-md); padding: 0.8rem 1.5rem; }
body .content .btn.secondary:hover { background: rgba(255,255,255,0.1); }
body .content .btn.danger { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.3); font-weight: 600; border-radius: var(--radius-md); padding: 0.8rem 1.5rem; }
body .content .btn.danger:hover { background: var(--error); color: white; }

/* ==========================================================================
   TEMA CLARO (LIGHT MODE PREMIUM SAAS)
   Redefinição completa e absoluta das variáveis e componentes para o modo claro
   ========================================================================== */
body.light-mode {
    /* Superfícies e Fundos */
    --bg-main: #f6f8fb !important;
    --bg-surface: #ffffff !important;
    --card-bg: #f8fafc !important;
    --input-bg: #ffffff !important;
    --hover-bg: rgba(15, 23, 42, 0.04) !important;
    --glass: rgba(255, 255, 255, 0.95) !important;
    
    /* Bordas */
    --card-border: rgba(15, 23, 42, 0.10) !important;
    
    /* Textos (Invertidos) */
    --text-main: #0f172a !important;
    --text-muted: #475569 !important;
    --text-soft: #64748b !important;
    
    /* Cores Globais */
    --primary: #6366f1 !important;
    --primary-hover: #4f46e5 !important;
    --success: #059669 !important;
    --warning: #d97706 !important;
    --danger: #dc2626 !important;
    
    /* Sombras (Mais suaves) */
    --shadow-card: 0 4px 12px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02) !important;
    --shadow-card-hover: 0 10px 25px rgba(15, 23, 42, 0.08) !important;
    --shadow-glow-primary: 0 4px 15px rgba(99, 102, 241, 0.25) !important;
}

/* Força a herança das variáveis e texto escuro para todos os elementos problemáticos */
body.light-mode,
body.light-mode .content,
body.light-mode .sidebar,
body.light-mode .card,
body.light-mode .premium-card,
body.light-mode .modal-content,
body.light-mode .ui-modal-shell,
body.light-mode .swal2-popup,
body.light-mode table,
body.light-mode th,
body.light-mode td,
body.light-mode input,
body.light-mode select,
body.light-mode textarea {
    color: var(--text-main) !important;
}

/* 1. Sidebar e Menus */
body.light-mode .sidebar {
    background: #ffffff !important;
    border-right: 1px solid var(--card-border) !important;
}
body.light-mode .nav-item {
    color: var(--text-muted) !important;
}
body.light-mode .nav-item:hover, 
body.light-mode .nav-item.active {
    background: var(--hover-bg) !important;
    color: var(--primary) !important;
}
body.light-mode .nav-item.active {
    background: var(--primary-glow) !important;
}

/* 2. Tabelas Premium Light */
body.light-mode thead th,
body.light-mode #clients-table thead th {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border-bottom: 2px solid rgba(15, 23, 42, 0.06) !important;
}
body.light-mode tbody tr:hover td {
    background: #f8fafc !important;
    color: var(--text-main) !important;
}
body.light-mode .status-indicator {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
}

/* 3. Textos forçados que estavam invisíveis (Brancos hardcoded) */
body.light-mode h1, body.light-mode h2, body.light-mode h3, 
body.light-mode h4, body.light-mode h5, body.light-mode h6,
body.light-mode .page-title,
body.light-mode td.col-contato,
body.light-mode td.col-valor,
body.light-mode .noc-metric-value,
body.light-mode .noc-kpi-val,
body.light-mode strong,
body.light-mode b,
body.light-mode label {
    color: #0f172a !important;
}
body.light-mode p,
body.light-mode span,
body.light-mode .text-muted,
body.light-mode .fin-footer-label,
body.light-mode .noc-metric-label,
body.light-mode .noc-kpi-label {
    color: #475569 !important;
}

/* 4. Inputs e Selects Globais */
body.light-mode .custom-input,
body.light-mode select,
body.light-mode textarea,
body.light-mode .swal2-input,
body.light-mode .swal2-select,
body.light-mode .swal2-textarea {
    background: #ffffff !important;
    border: 1px solid rgba(15, 23, 42, 0.15) !important;
    color: #0f172a !important;
}

/* Fix para <option> nativo e listas/dropdowns customizados */
body.light-mode select option,
body.light-mode .dropdown-menu,
body.light-mode .select-options,
body.light-mode .custom-select-list {
    background: #ffffff !important;
    color: #0f172a !important;
}
body.light-mode .dropdown-menu,
body.light-mode .select-options,
body.light-mode .custom-select-list {
    border: 1px solid rgba(15, 23, 42, 0.12) !important;
}
body.light-mode .dropdown-menu li,
body.light-mode .select-options li,
body.light-mode .custom-select-list li {
    color: #0f172a !important;
}
body.light-mode .dropdown-menu li:hover,
body.light-mode .select-options li:hover,
body.light-mode .custom-select-list li:hover {
    background: #eef2ff !important;
    color: #1e293b !important;
}
body.light-mode .dropdown-menu .selected,
body.light-mode .select-options .selected,
body.light-mode .custom-select-list .selected,
body.light-mode select option:checked {
    background: var(--primary) !important;
    color: #ffffff !important;
}

body.light-mode .custom-input::placeholder,
body.light-mode .swal2-input::placeholder {
    color: #94a3b8 !important;
}
body.light-mode .custom-input:focus,
body.light-mode select:focus,
body.light-mode .swal2-input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

/* 5. Modais e SweetAlert (Fundo Branco) */
body.light-mode .modal-content,
body.light-mode .ui-modal-shell,
body.light-mode .swal2-popup {
    background: #ffffff !important;
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.15) !important;
}
body.light-mode .modal-header,
body.light-mode .swal2-title {
    border-bottom: 1px solid rgba(15, 23, 42, 0.06) !important;
    color: #0f172a !important;
}

/* 6. Botões Claros */
body.light-mode .icon-btn, 
body.light-mode .icon-btn-secondary {
    background: #f1f5f9 !important;
    border: 1px solid rgba(15, 23, 42, 0.06) !important;
    color: #475569 !important;
}
body.light-mode .icon-btn:hover, 
body.light-mode .icon-btn-secondary:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}
body.light-mode .btn.secondary {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
}
body.light-mode .btn.secondary:hover {
    background: #f1f5f9 !important;
}

/* 7. Submenus Internos */
body.light-mode .config-nav-btn,
body.light-mode .msg-nav-btn,
body.light-mode .ops-btn {
    color: var(--text-muted) !important;
    background: transparent !important;
}
body.light-mode .config-nav-btn:hover,
body.light-mode .msg-nav-btn:hover,
body.light-mode .ops-btn:hover {
    background: rgba(15, 23, 42, 0.04) !important;
    color: var(--text-main) !important;
}
body.light-mode .config-nav-btn.active-highlight,
body.light-mode .msg-nav-btn.active-highlight,
body.light-mode .ops-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35) !important;
}

/* 8. NOC Hero e Componentes Fixos */
body.light-mode .noc-hero-section,
body.light-mode .console-feed-v2,
body.light-mode .noc-metrics-grid,
body.light-mode .whatsapp-qr-card,
body.light-mode .qr-card-content,
body.light-mode .ops-nav-container,
body.light-mode .table-container {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}
body.light-mode .log-line {
    color: #334155 !important;
}

/* 7. Correção: Gestor de Campos Padrão — Alinhamento input + botão "Adicionar" */
#options-manager-container .card > div:last-child {
    display: grid !important;
    grid-template-columns: 1fr 44px !important;
    gap: 0.5rem !important;
    align-items: center !important;
}
#options-manager-container .card > div:last-child input[type="text"] {
    width: 100% !important;
    min-width: 0 !important;
    height: 44px !important;
    padding: 0.6rem 0.8rem !important;
    box-sizing: border-box !important;
}
#options-manager-container .card > div:last-child .btn.primary {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: var(--radius-xs) !important;
    flex-shrink: 0 !important;
}

/* 8. Correção: WhatsApp QR Code Card Layout */
body .content .whatsapp-qr-card {
    max-width: 820px !important;
    width: 100%;
    margin: 48px auto 64px auto !important;
    border-radius: 24px;
    background: rgba(30, 41, 59, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 24px 60px rgba(0,0,0,0.28);
    overflow: hidden;
}
body .content .whatsapp-qr-card .qr-card-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 32px;
    align-items: center;
    padding: 32px;
}
body .content .whatsapp-qr-card h2 {
    font-size: 24px;
    line-height: 1.15;
    font-weight: 800;
    margin: 0 0 12px;
    color: #f8fafc;
}
body .content .whatsapp-qr-card p {
    font-size: 15px;
    line-height: 1.6;
    color: #94a3b8;
    max-width: 380px;
    margin: 0;
}
body .content .whatsapp-qr-card .qr-frame {
    background: #fff;
    padding: 16px;
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
}
body .content .whatsapp-qr-card #qr-image {
    width: 280px;
    height: 280px;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

/* ==========================================================================
   GLOBAL MOBILE RESPONSIVENESS (1024px, 768px, 480px)
   Ajuste absoluto e seguro para todo o sistema sem alterar lógicas.
   ========================================================================== */

/* --- 1024px (Tablets & Laptops Pequenos) --- */
@media (max-width: 1024px) {
    /* Submenus Internos viram abas horizontais roláveis */
    .config-container, .ops-layout, .msg-layout {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }
    .config-sidebar-nav, .ops-nav-container, .msg-nav {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        padding-bottom: 0.5rem !important;
        margin-bottom: 1rem !important;
        border-right: none !important;
        border-bottom: 1px solid var(--card-border) !important;
    }
    .config-nav-btn, .ops-btn, .msg-nav-btn {
        flex: 0 0 auto !important;
        border-radius: var(--radius-sm) !important;
    }
    
    /* Otimizar barra superior */
    .top-toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }
    .search-bar { width: 100% !important; max-width: none !important; }
    
    /* Dashboard Cards */
    .dashboard-grid, .summary-row, .noc-metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* --- 768px (Smartphones) --- */
@media (max-width: 768px) {
    /* 1. Estrutura Global: Evitar quebra horizontal */
    body { overflow-x: hidden !important; width: 100% !important; }
    body .app-container { flex-direction: column !important; overflow-x: hidden !important; }
    body .app-container .content {
        margin-left: 0 !important;
        padding: 1rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    /* 2. Sidebar como Drawer Lateral com animação suave */
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 280px !important;
        height: 100vh !important;
        transform: translateX(-105%) !important;
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: 20px 0 60px rgba(0,0,0,0.6) !important;
        z-index: 9999 !important;
        visibility: hidden;
    }
    .sidebar.mobile-active {
        transform: translateX(0) !important;
        visibility: visible !important;
    }
    .mobile-only-btn { display: flex !important; }
    
    /* 3. Cards em Coluna Única (Dashboard, NOC, Mensagens) */
    .dashboard-grid, .summary-row, .noc-metrics-grid, .panel-grid, .profile-layout, .msg-templates-grid {
        grid-template-columns: 1fr !important;
    }
    .summary-card, .premium-card, .card, .noc-metric-card, .noc-kpi-card {
        padding: 1rem !important;
    }
    
    /* 4. Tabelas e Container Seguro (Scroll Apenas Interno) */
    .table-container, #clients-tab .table-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin: 0 -1rem !important; /* Estica a tabela até a borda da tela */
        padding: 0 1rem !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
    }
    table, #clients-table {
        min-width: 800px !important; /* Força que as colunas não sejam esmagadas */
    }
    
    /* 5. Modais Limitados (Caber na tela e rolar) */
    .modal-content, .ui-modal-shell {
        padding: 1.25rem !important;
        border-radius: var(--radius-lg) !important;
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 90vh !important;
        margin: 5vh auto !important;
        overflow-y: auto !important;
    }
    .form-row {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    .modal-actions, .filter-actions {
        flex-direction: column !important;
    }
    .modal-actions button, .filter-actions button {
        width: 100% !important;
        margin: 0 0 0.5rem 0 !important;
        padding: 0.8rem 1rem !important; /* Area mínima de toque 44px */
    }
    
    /* 6. WhatsApp QR Code Card Responsivo */
    body .content .whatsapp-qr-card .qr-card-content {
        grid-template-columns: 1fr !important;
        text-align: center !important;
        padding: 24px !important;
        gap: 24px !important;
    }
    body .content .whatsapp-qr-card p {
        max-width: none !important;
        margin: 0 auto !important;
    }
    body .content .whatsapp-qr-card #qr-image {
        width: 220px !important;
        height: 220px !important;
        margin: 0 auto !important;
    }
}

/* --- 480px (Smartphones Pequenos) --- */
@media (max-width: 480px) {
    header h1 { font-size: 1.25rem !important; }
    header h2 { font-size: 1.1rem !important; }
    
    .fin-footer-row {
        flex-direction: column !important;
        gap: 0.5rem !important;
        align-items: flex-start !important;
    }
    
    .nav-item { padding: 0.8rem 1rem !important; } /* Aumentar área de clique */
    
    /* Gestor de Campos Padrão (Inputs na vertical) */
    #options-manager-container .card > div:last-child {
        grid-template-columns: 1fr !important;
    }
    #options-manager-container .card > div:last-child .btn.primary {
        width: 100% !important;
    }
}

/* ===== SAFE UI FIX LAYER ===== */

/* 1. OVERFLOW (PRINCIPAL CAUSA DE BUG) */
.card,
.table-container,
.tab-content,
.main-container {
    overflow: visible !important;
}

/* 2. DROPDOWNS E MENUS */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute !important;
    z-index: 9999 !important;
}

/* 3. Z-INDEX (CAMADAS) */
.sidebar { z-index: 1000; }
.header { z-index: 1100; }
.modal { position: fixed; z-index: 10000; }
.swal2-container { z-index: 11000 !important; }

/* 4. ABAS (SPA) */
.tab-content {
    position: relative;
    width: 100%;
}

/* 5. TABELAS (BUG COMUM) */
.table-responsive {
    overflow-x: auto;
    overflow-y: visible !important;
}

/* ===== PREMIUM SAAS UI LAYER ===== */

:root {
  --premium-bg: #0f172a;
  --premium-surface: #111827;
  --premium-card: #1e293b;
  --premium-card-soft: rgba(255,255,255,0.04);
  --premium-border: rgba(148,163,184,0.18);
  --premium-text: #f8fafc;
  --premium-muted: #94a3b8;
  --premium-primary: #6366f1;
  --premium-primary-hover: #4f46e5;
  --premium-success: #22c55e;
  --premium-warning: #f59e0b;
  --premium-danger: #ef4444;
  --premium-radius-sm: 8px;
  --premium-radius-md: 12px;
  --premium-radius-lg: 16px;
  --premium-shadow: 0 18px 45px rgba(0,0,0,0.22);
  --premium-shadow-soft: 0 8px 24px rgba(0,0,0,0.16);
}

/* CARDS */
.card,
.stat-card,
.metric-card,
.health-card,
.noc-card {
  border-radius: var(--premium-radius-lg);
  border: 1px solid var(--premium-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025));
  box-shadow: var(--premium-shadow-soft);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover,
.stat-card:hover,
.metric-card:hover,
.health-card:hover,
.noc-card:hover {
  transform: translateY(-1px);
  border-color: rgba(129,140,248,0.36);
  box-shadow: var(--premium-shadow);
}

/* BOTÕES */
button,
.btn,
.action-btn {
  border-radius: 10px;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
}

button:hover,
.btn:hover,
.action-btn:hover {
  transform: translateY(-1px);
}

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

button:disabled,
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

/* TABELAS */
table {
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--premium-muted);
  font-weight: 700;
}

tbody tr {
  transition: background .15s ease;
}

tbody tr:hover {
  background: rgba(99,102,241,0.07);
}

td, th {
  border-bottom: 1px solid rgba(148,163,184,0.12);
}

/* FILTROS / INPUTS */
input,
select,
textarea,
.filter-input,
.search-input {
  border-radius: 10px;
  border: 1px solid var(--premium-border);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input:focus,
select:focus,
textarea:focus,
.filter-input:focus,
.search-input:focus {
  outline: none;
  border-color: rgba(99,102,241,0.7);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}

/* MODAIS */
.modal-content,
.swal2-popup {
  border-radius: 18px !important;
  border: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow);
}

.modal-header {
  border-bottom: 1px solid rgba(148,163,184,0.14);
}

.modal-footer {
  border-top: 1px solid rgba(148,163,184,0.14);
}

/* BADGES / STATUS */
.badge,
.status-badge,
.status-pill {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  letter-spacing: .02em;
}

/* DROPDOWNS */
.dropdown-menu {
  border-radius: 12px;
  border: 1px solid var(--premium-border);
  box-shadow: var(--premium-shadow);
  backdrop-filter: blur(10px);
}

.dropdown-menu a,
.dropdown-menu button,
.dropdown-item {
  border-radius: 8px;
  transition: background .15s ease;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover,
.dropdown-item:hover {
  background: rgba(99,102,241,0.12);
}

/* ESPAÇAMENTO GERAL */
.section-header,
.page-header {
  margin-bottom: 20px;
}

.card,
.table-container,
.filters-container {
  padding: clamp(14px, 1.4vw, 22px);
}

/* ===== PREMIUM UI HOTFIX v2 — DROPDOWNS, MODALS & CONTAINERS ===== */

/* 1. Selects e Dropdowns */
select,
select option {
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

select:focus {
  border-color: rgba(99,102,241,.75) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,.18) !important;
}

.dropdown-menu {
  background: #0f172a !important;
  color: #f8fafc !important;
  border: 1px solid rgba(148,163,184,.22) !important;
  box-shadow: 0 18px 45px rgba(0,0,0,.32) !important;
  z-index: 9999 !important;
}

.dropdown-item,
.dropdown-menu a,
.dropdown-menu button {
  color: #f8fafc !important;
}

.dropdown-item:hover,
.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background: rgba(99,102,241,.16) !important;
  color: #fff !important;
}

/* 2. Modais cortados */
.modal-content {
  max-height: 92vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  box-sizing: border-box;
  display: flex !important;
  flex-direction: column !important;
}

.modal-body {
  flex: 1;
}

.modal-footer {
  flex-shrink: 0 !important;
  position: sticky !important;
  bottom: -1px !important;
  background: #1e293b !important;
  z-index: 10 !important;
  border-top: 1px solid rgba(148,163,184,0.14) !important;
}

/* 3. Overflow Global e SPA */
.main-container,
.tab-content {
  overflow: hidden !important;
  position: relative !important;
}

.card,
.table-container {
  overflow: visible !important;
}

.table-responsive {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

/* 4. Padding/Containers */
.table-container table {
  width: 100%;
}

.card > .card-body,
.table-container {
  box-sizing: border-box;
}

/* 5. NOC / Histórico de Atividades */
td,
th {
  vertical-align: middle;
}

td {
  word-break: break-word;
}

td .info,
.message,
.log-message {
  overflow-wrap: anywhere;
}

/* 6. Z-Index Absoluto */
.modal { z-index: 10000 !important; }
.swal2-container { z-index: 11000 !important; }

/* ===== PREMIUM UI HOTFIX v3 — MODAL & TABLE CONTAINMENT ===== */

/* 1. CORRIGIR MODAIS LONGOS E CENTRALIZAR */
.modal,
.modal-overlay,
.modal-backdrop {
  overflow-y: auto !important;
  align-items: flex-start !important;
  padding: 24px 12px !important;
}

.modal-content,
.client-modal,
.payment-modal,
.info-modal {
  max-height: calc(100vh - 48px) !important;
  overflow-y: auto !important;     /* Era hidden — cortava a tabela de pagamentos */
  overflow-x: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
  margin: auto !important;
}

/* Modal de informações do cliente: scroll próprio, sem flex-column (a seção de pagamentos fica fora do grid) */
#client-info-modal .modal-content {
  display: block !important;       /* Remove flex para não cortar conteúdo fora do .modal-body */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 2rem !important;
}

.modal-body,
.client-modal-body,
.info-modal-body,
.payment-modal-body {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-bottom: 32px !important;
}

.modal-footer,
.client-modal-footer,
.payment-modal-footer {
  flex-shrink: 0 !important;
  position: relative !important;
  bottom: auto !important;
  background: #1e293b !important;
  border-top: 1px solid rgba(148,163,184,.16) !important;
  z-index: 5 !important;
}

/* 2. CORRIGIR MODAL DE INFORMAÇÕES DO CLIENTE */
/* REMOVIDO: contain: layout paint estava clippando a tabela de pagamentos */
.client-info-modal,
#clientInfoModal,
.info-modal {
  contain: style; /* apenas isola estilos, sem clippar paint */
}

/* IMPORTANTE: .modal-content NÃO deve ter contain:paint — cortava a seção de pagamentos */
.modal-content {
  contain: none;
}

.client-info-modal .modal-body,
#clientInfoModal .modal-body,
.info-modal .modal-body {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: calc(100vh - 160px) !important;
}

.client-info-modal *,
#clientInfoModal *,
.info-modal * {
  box-sizing: border-box;
}

.client-info-modal td,
.client-info-modal .info-value,
#clientInfoModal .info-value {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 3. CORRIGIR LISTA DE CLIENTES / HEADER DA TABELA */
.clients-table-container,
.table-container,
.table-responsive {
  position: relative !important;
  overflow-x: auto !important;
  overflow-y: auto !important;
}

table thead,
.clients-table thead {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background: #1e293b !important;
}

table thead th,
.clients-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 21 !important;
  background: #1e293b !important;
  box-shadow: 0 1px 0 rgba(148,163,184,.18), 0 8px 16px rgba(15,23,42,.35) !important;
}

tbody tr,
tbody td {
  position: relative;
  z-index: 1;
}

/* 4. EVITAR OVERFLOW GLOBAL PERIGOSO */
.main-container,
.tab-content,
.content-area,
.page-content {
  overflow: hidden !important;
}

/* Apenas cards fora de modais e sem conteúdo scrollável recebem overflow:hidden
   IMPORTANTE: Excluímos .modal-content para não cortar a tabela de pagamentos */
.card:not(.modal-content) {
  overflow: visible;
}

/* 11. Melhorias e Documentação (Responsividade Premium) */
.changelog-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.docs-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

.doc-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0; /* Importante para grid item não estourar */
}

@media (max-width: 1400px) {
    .docs-grid-container {
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    }
}

@media (max-width: 1200px) {
    .docs-grid-container {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

@media (max-width: 768px) {
    .docs-grid-container {
        grid-template-columns: 1fr;
    }
    
    .doc-card {
        padding: 1.2rem !important;
    }
}

.dropdown,

.dropdown-wrapper,
.actions-dropdown {
  overflow: visible !important;
}

.dropdown-menu {
  z-index: 9999 !important;
}

/* 5. CORRIGIR ÁREA INFERIOR DO MODAL DE CLIENTE */
.client-form,
.client-modal form,
.modal form {
  min-height: 0 !important;
  flex: 1 1 auto !important;
  overflow-y: auto !important;
}

.client-modal .modal-body,
#clientModal .modal-body {
  padding-bottom: 96px !important;
}

.client-modal .modal-footer,
#clientModal .modal-footer,
.modal form .modal-footer {
  margin-top: 16px !important;
  position: relative !important;
  transform: none !important;
}

/* ===== PREMIUM UI HOTFIX v4 — RESTORE PAGE SCROLL ===== */

html,
body {
  height: auto !important;
  min-height: 100% !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

.main-container,
.content-area,
.page-content,
.tab-content {
  overflow-x: hidden !important;
  overflow-y: visible !important;
  min-height: 0 !important;
}

.tab-content.active {
  overflow-y: visible !important;
}

#clients-tab,
#dashboard-tab,
#mensagens-tab,
#operations-tab,
#config-tab,
#logs-tab,
#panels-tab {
  overflow-y: visible !important;
}

/* Table-containers fora de modais: scroll horizontal */
.table-container,
.clients-table-container {
  overflow-x: auto !important;
  overflow-y: visible !important;
}

/* Table-container e seção de pagamentos DENTRO do modal de informações do cliente */
#client-info-modal .table-container,
#profile-payments-section {
  overflow-x: auto !important;
  overflow-y: visible !important;
  display: block !important;
}

/* Tabela de pagamentos dentro do modal — sticky relativo ao scroll do modal-content */
#profile-payments-table thead,
#profile-payments-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 99999 !important;
  background-color: #1e293b !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.8) !important;
  border-bottom: 2px solid rgba(148,163,184,0.2) !important;
}

#profile-payments-body {
  position: relative !important;
  z-index: 1 !important;
}

#profile-payments-body tr,
#profile-payments-body tr:hover,
#profile-payments-body td {
  z-index: 1 !important;
  transform: none !important;
}

.modal,
.modal-overlay,
.modal-backdrop {
  overflow-y: auto !important;
}

/* O overflow:hidden no modal-content cortava a tabela de pagamentos — removido */
.modal-content {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

.modal-body {
  overflow-y: auto !important;
}

/* ===== PREMIUM UI HOTFIX v5 — CLIENTS TABLE STICKY HEADER ===== */

.clients-table-container,
.clients-list,
.table-container {
  position: relative !important;
}

.clients-table-container table,
.clients-list table,
.table-container table {
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

.clients-table-container thead,
.clients-list thead,
.table-container thead {
  position: sticky !important;
  top: 0 !important;
  z-index: 50 !important;
  background: #1e293b !important;
}

.clients-table-container thead tr,
.clients-list thead tr,
.table-container thead tr {
  background: #1e293b !important;
  position: relative !important;
  z-index: 51 !important;
}

.clients-table-container thead th,
.clients-list thead th,
.table-container thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 52 !important;
  background: #1e293b !important;
  color: #94a3b8 !important;
  box-shadow:
    0 1px 0 rgba(148,163,184,.22),
    0 12px 18px rgba(15,23,42,.92) !important;
}

.clients-table-container tbody,
.clients-list tbody,
.table-container tbody {
  position: relative !important;
  z-index: 1 !important;
}

.clients-table-container tbody tr,
.clients-list tbody tr,
.table-container tbody tr,
.clients-table-container tbody td,
.clients-list tbody td,
.table-container tbody td {
  position: relative !important;
  z-index: 1 !important;
  background-clip: padding-box !important;
}

/* Criar máscara visual abaixo do cabeçalho para impedir texto vazando */
.clients-table-container thead::after,
.clients-list thead::after,
.table-container thead::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -14px;
  height: 14px;
  background: linear-gradient(to bottom, #1e293b, rgba(30,41,59,0));
  pointer-events: none;
  z-index: 49;
}

/* ===== PREMIUM UI HOTFIX v6 — DISABLE CLIENTS STICKY HEADER ===== */

.clients-table-container thead,
.clients-list thead,
#clients-tab thead,
#clients-tab table thead,
#clients-tab table thead tr,
#clients-tab table thead th,
.clients-table-container thead tr,
.clients-table-container thead th,
.clients-list thead tr,
.clients-list thead th {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  transform: none !important;
}

#clients-tab table thead,
.clients-table-container thead,
.clients-list thead {
  background: #1e293b !important;
}

#clients-tab table thead th,
.clients-table-container thead th,
.clients-list thead th {
  background: #1e293b !important;
  color: #94a3b8 !important;
  box-shadow: none !important;
}

#clients-tab thead::after,
.clients-table-container thead::after,
.clients-list thead::after {
  display: none !important;
  content: none !important;
}

#clients-tab tbody,
#clients-tab tbody tr,
#clients-tab tbody td {
  position: static !important;
  z-index: auto !important;
}

/* ===== PREMIUM UI HOTFIX v7 — CLIENTS TABLE INTERNAL SCROLL ===== */

/* 1. Reativar container de scroll apenas na lista de clientes */
#clients-tab .table-container,
#clients-tab .clients-table-container,
#clients-tab .table-responsive {
  max-height: calc(100vh - 330px) !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
  position: relative !important;
  scrollbar-gutter: stable !important;
}

/* 2. Restaurar sticky somente no cabeçalho da tabela de clientes */
#clients-tab table thead,
#clients-tab table thead tr {
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  background: #1e293b !important;
}

/* 3. Cada TH precisa ser sticky e ter fundo sólido */
#clients-tab table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 101 !important;
  background: #1e293b !important;
  color: #94a3b8 !important;
  box-shadow:
    0 1px 0 rgba(148,163,184,.22),
    0 10px 14px rgba(15,23,42,.95) !important;
}

/* 4. Garantir que linhas nunca fiquem acima do header */
#clients-tab table tbody,
#clients-tab table tbody tr,
#clients-tab table tbody td {
  position: static !important;
  z-index: auto !important;
  transform: none !important;
}

/* 5. Fundo das células para evitar transparência visual */
#clients-tab table tbody td {
  background: #1e293b !important;
}

/* 6. Remover pseudo-elementos problemáticos dos hotfixes anteriores */
#clients-tab thead::after,
#clients-tab table thead::after,
#clients-tab .clients-table-container thead::after,
#clients-tab .table-container thead::after {
  display: none !important;
  content: none !important;
}

/* 7. Garantir que a tabela ocupe largura correta */
#clients-tab table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* 8. Evitar que o card inteiro corte de forma errada */
#clients-tab .card,
#clients-tab .table-card {
  overflow: hidden !important;
}

/* 9. Em telas menores, reduzir altura calculada */
@media (max-height: 800px) {
  #clients-tab .table-container,
  #clients-tab .clients-table-container,
  #clients-tab .table-responsive {
    max-height: calc(100vh - 280px) !important;
  }
}

/* ===== CLIENTS TABLE FINAL FIX — REAL DOM SELECTORS ===== */

/* 1. Resetar regras de z-index zumbis nos TDs que estavam fatiando o cabeçalho */
#clients-body,
#clients-body tr,
#clients-body td {
  position: static !important;
  z-index: auto !important;
  transform: none !important;
  background-color: #1e293b !important;
}

/* 2. Devolver posição relativa apenas para a coluna de alerta (para o tooltip funcionar) */
#clients-body td.col-alerta {
  position: relative !important;
  z-index: auto !important;
}

/* 3. Definir rolagem apenas no container real da tabela */
#clients-tab .table-container {
  overflow-y: auto !important;
  overflow-x: auto !important;
  max-height: calc(100vh - 260px) !important;
  position: relative !important;
  scrollbar-gutter: stable !important;
}

/* 4. Garantir que a tabela não cole bordas estranhas que quebram sticky */
#clients-table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  position: relative !important;
  z-index: 1 !important;
}

/* 5. Destruir as tentativas de sticky no Thead/Tr. O Sticky vai SÓ no TH. */
#clients-table thead,
#clients-table thead tr {
  position: static !important;
  z-index: auto !important;
  transform: none !important;
}

/* 6. A mágica real: TH com sticky e alto z-index no nível correto */
#clients-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 9999 !important;
  background: #1e293b !important;
  color: #94a3b8 !important;
  box-shadow: 0 4px 10px -2px rgba(0, 0, 0, 0.6) !important;
  border-bottom: 2px solid rgba(148,163,184,0.1) !important;
  background-clip: padding-box !important;
}

/* 7. Matar pseudo-elementos bugados das versões anteriores */
#clients-table thead::after,
#clients-table thead th::after,
#clients-tab thead::after,
#clients-tab .table-container thead::after {
  display: none !important;
  content: none !important;
}

/* 8. Media query para telas menores */
@media (max-height: 800px) {
  #clients-tab .table-container {
    max-height: calc(100vh - 220px) !important;
  }
}

/* 7. Garantir que a tabela ocupe largura correta */
#clients-tab table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

/* 8. Evitar que o card inteiro corte de forma errada */
#clients-tab .card,
#clients-tab .table-card {
  overflow: hidden !important;
}

/* 9. Em telas menores, reduzir altura calculada */
@media (max-height: 800px) {
  #clients-tab .table-container,
  #clients-tab .clients-table-container,
  #clients-tab .table-responsive {
    max-height: calc(100vh - 280px) !important;
  }
}

/* ===== CLIENTS TABLE ULTIMATE FIX — FINAL RESOLUTION ===== */

/* 1. Neutralizar TOTALMENTE qualquer transparência ou posicionamento das linhas (exceto opacidade intencional) */
#clients-body,
#clients-body tr,
#clients-body td {
  position: static !important;
  z-index: auto !important;
  transform: none !important;
  background-color: #1e293b !important; 
}
/* Força opacidade 1 apenas se não tiver opacidade inline explícita (como no Ponto N) */
#clients-body tr:not([style*="opacity"]) td,
#clients-body td:not([style*="opacity"]) {
  opacity: 1 !important;
}

/* 2. Devolver posição relativa estritamente para tooltips e badges */
#clients-body td.col-alerta,
#clients-body td.col-status,
#clients-body td.col-recibo {
  position: relative !important;
  z-index: auto !important;
}

/* 3. Container da tabela com scroll interno e máscara superior nula */
#clients-tab .table-container {
  overflow-y: auto !important;
  overflow-x: auto !important;
  max-height: calc(100vh - 260px) !important;
  position: relative !important;
  scrollbar-gutter: stable !important;
  background-color: #1e293b !important;
}

/* 4. Tabela Real */
#clients-table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  background-color: #1e293b !important;
}

/* 5. Cabeçalho (TH) - A Correção Mestra:
   - Fundo 100% opaco para não deixar ver o conteúdo por baixo.
   - Background-clip: border-box para cobrir a área da borda (evita o gap de 2px).
   - Z-index massivo para ganhar de qualquer animação de fade-in.
*/
#clients-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 99999 !important;
  background-color: #1e293b !important; /* Cor sólida e idêntica ao fundo */
  color: #94a3b8 !important;
  background-clip: border-box !important;
  /* Sombra sólida inferior para "cortar" o texto que passa por baixo */
  box-shadow: 0 1px 0 #1e293b, 0 4px 10px rgba(0,0,0,0.8) !important;
  border-bottom: 1px solid rgba(148,163,184,0.15) !important;
}

/* 6. Matar de vez todos os pseudo-elementos e máscaras dos hotfixes v3-v7 */
#clients-table thead::after,
#clients-table thead th::after,
#clients-tab thead::after,
#clients-tab .table-container thead::after,
.clients-table-container thead::after,
.clients-list thead::after,
.table-container thead::after {
  display: none !important;
  content: none !important;
}

/* 7. Ajuste para Light Mode (se estiver ativo) */
body.light-mode #clients-table thead th,
body.light-mode #clients-body td,
body.light-mode #clients-tab .table-container {
  background-color: #ffffff !important;
  color: #0f172a !important;
  box-shadow: 0 1px 0 #ffffff, 0 4px 6px rgba(0,0,0,0.05) !important;
}

/* 8. Media query para telas menores */
@media (max-height: 800px) {
  #clients-tab .table-container {
    max-height: calc(100vh - 220px) !important;
  }
}

/* ===== CLIENTS TABLE FINAL REFINEMENT — VISUAL SEPARATION ===== */

#clients-tab .table-container {
  overflow-y: auto !important;
  overflow-x: auto !important;
  max-height: calc(100vh - 280px) !important;
  position: relative !important;
  scrollbar-gutter: stable !important;
  background-color: #1e293b !important;
}

#clients-table {
  width: 100% !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
}

#clients-table thead {
  position: sticky !important;
  top: 0 !important;
  z-index: 1000 !important;
  background-color: #1e293b !important;
}

#clients-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 1001 !important;
  background-color: #1e293b !important;
  color: #94a3b8 !important;
  border-bottom: 2px solid rgba(148, 163, 184, 0.15) !important;
  box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.4) !important;
  padding: 16px 12px !important;
  text-transform: uppercase !important;
  font-size: 0.75rem !important;
  letter-spacing: 0.05em !important;
  background-clip: padding-box !important;
}

#clients-body tr td {
  background-color: #1e293b !important;
  position: static !important;
  z-index: 1 !important;
}

body.light-mode #clients-table thead,
body.light-mode #clients-table thead th {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-bottom: 2px solid #e2e8f0 !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

body.light-mode #clients-body tr td {
  background-color: #ffffff !important;
}

/* ===== CLIENTS TABLE STACKING CONTEXT FIX — ULTIMATE LAYER ===== */

#clients-table thead,
#logs-table thead,
#daily-receipts-table thead,
#users-table thead,
#manual-actions-table thead,
#queue-pending-table thead,
#queue-history-table thead,
#queue-failed-table thead {
  position: sticky !important;
  top: 0 !important;
  z-index: 99999 !important; /* Elevado ao máximo para vencer o tbody */
  background-color: #1e293b !important;
}

#clients-table thead th,
#logs-table thead th,
#daily-receipts-table thead th,
#users-table thead th,
#manual-actions-table thead th,
#queue-pending-table thead th,
#queue-history-table thead th,
#queue-failed-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 99999 !important;
  background-color: #1e293b !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.8) !important;
  border-bottom: 2px solid rgba(148,163,184,0.2) !important;
}

/* Forçar o tbody a ficar em uma camada inferior ao thead */
#clients-body,
#logs-body,
#daily-receipts-body,
#users-table-body,
#manual-actions-table-body,
#queue-table-body,
#queue-history-body,
#queue-failed-body {
  position: relative !important;
  z-index: 1 !important;
}

/* Neutralizar qualquer hover ou animação que suba a camada das linhas do corpo */
#clients-body tr, 
#clients-body tr:hover,
#clients-body td,
#logs-body tr,
#logs-body tr:hover,
#logs-body td,
#daily-receipts-body tr,
#daily-receipts-body tr:hover,
#daily-receipts-body td,
#users-table-body tr,
#users-table-body tr:hover,
#users-table-body td,
#manual-actions-table-body tr,
#manual-actions-table-body tr:hover,
#manual-actions-table-body td,
#queue-table-body tr,
#queue-table-body tr:hover,
#queue-table-body td,
#queue-history-body tr,
#queue-history-body tr:hover,
#queue-history-body td,
#queue-failed-body tr,
#queue-failed-body tr:hover,
#queue-failed-body td {
  z-index: 1 !important;
  /* Retirar transformações que criam novos stacking contexts no corpo */
  transform: none !important; 
}

/* Garantir que o container não tenha paddings que desalinhem o sticky */
#clients-tab .table-container,
#logs-tab .table-container,
#dashboard-tab .table-container,
#mensagens-tab .table-container,
#manual-actions-tab .table-container,
#config-sistema-tab .table-container {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

body.light-mode #clients-table thead,
body.light-mode #clients-table thead th,
body.light-mode #logs-table thead,
body.light-mode #logs-table thead th,
body.light-mode #daily-receipts-table thead,
body.light-mode #daily-receipts-table thead th,
body.light-mode #users-table thead,
body.light-mode #users-table thead th,
body.light-mode #manual-actions-table thead,
body.light-mode #manual-actions-table thead th,
body.light-mode #queue-pending-table thead,
body.light-mode #queue-pending-table thead th,
body.light-mode #queue-history-table thead,
body.light-mode #queue-history-table thead th,
body.light-mode #queue-failed-table thead,
body.light-mode #queue-failed-table thead th {
  background-color: #ffffff !important;
  z-index: 99999 !important;
}

body.light-mode #clients-body {
  z-index: 1 !important;
}

/* ===== PREMIUM UI HOTFIX v8 — ALERT POPOVER LAYER ===== */

/*
 * Root cause: previous hotfixes set #clients-body tr { z-index: 1 !important },
 * trapping .alerta-tooltip (z-index: 99999) inside each row's stacking context.
 * Rows below the hovered one paint over the tooltip because they share z-index: 1.
 *
 * Fix: Use :has() to lift the row containing the hovered alert badge above its
 * siblings. No overflow changes to .table-container or .card are needed.
 */

/* 1. When a row contains a hovered alert badge, elevate it above sibling rows */
#clients-body tr:has(.alerta-badge:hover) {
  z-index: 9000 !important;
  position: relative !important;
}

/* 2. Ensure .col-alerta cell allows the tooltip to overflow */
#clients-body td.col-alerta {
  position: relative !important;
  overflow: visible !important;
  z-index: auto !important;
}

/* 3. Reinforce .alerta-tooltip stacking above everything in the tbody */
#clients-body .alerta-tooltip {
  z-index: 12000 !important;
  isolation: isolate;
}

/* 4. Support for .tooltip-up class (added by layout.js when badge is near bottom) */
.alerta-badge.tooltip-up .alerta-tooltip {
  top: auto !important;
  bottom: 140% !important;
  transform: translateX(-50%) translateY(10px) !important;
}

.alerta-badge.tooltip-up:hover .alerta-tooltip {
  transform: translateX(-50%) translateY(0) !important;
}

.alerta-badge.tooltip-up .alerta-tooltip::after {
  top: 100% !important;
  bottom: auto !important;
  border-color: rgba(245, 158, 11, 0.5) transparent transparent transparent !important;
}

/* 5. Light mode support for the elevated row */
body.light-mode #clients-body tr:has(.alerta-badge:hover) {
  z-index: 9000 !important;
}

/* ===== PREMIUM UI HOTFIX v9 — RESTORE ALERT TOOLTIP DIRECTION ===== */

#clients-body tr:has(.alerta-badge:hover),
#clients-body td.col-alerta,
#clients-body .alerta-badge {
  overflow: visible !important;
}

#clients-body tr:has(.alerta-badge:hover) {
  position: relative !important;
  z-index: 12000 !important;
}

#clients-body td.col-alerta {
  position: relative !important;
  z-index: 12001 !important;
}

#clients-body .alerta-badge {
  position: relative !important;
  z-index: 12002 !important;
}

#clients-body .alerta-tooltip {
  position: absolute !important;
  z-index: 12003 !important;
  max-width: 360px !important;
  min-width: 260px !important;
}

.alerta-badge.tooltip-up .alerta-tooltip {
  top: auto !important;
  bottom: calc(100% + 12px) !important;
  transform: translateX(-50%) !important;
}

.alerta-badge.tooltip-up:hover .alerta-tooltip {
  transform: translateX(-50%) !important;
}

.alerta-badge.tooltip-up .alerta-tooltip::after {
  top: 100% !important;
  bottom: auto !important;
  border-color: rgba(245,158,11,.55) transparent transparent transparent !important;
}

.alerta-badge:not(.tooltip-up) .alerta-tooltip {
  bottom: auto !important;
  top: calc(100% + 12px) !important;
  transform: translateX(-50%) !important;
}

.alerta-badge:not(.tooltip-up) .alerta-tooltip::after {
  bottom: 100% !important;
  top: auto !important;
  border-color: transparent transparent rgba(245,158,11,.55) transparent !important;
}

/* ===== ALERT TOOLTIP ROLLBACK v10 ===== */

#clients-body tr:has(.alerta-badge:hover),
#clients-body td.col-alerta,
#clients-body .alerta-badge,
#clients-body .alerta-tooltip {
  z-index: auto !important;
  isolation: auto !important;
}

.alerta-badge.tooltip-up .alerta-tooltip,
.alerta-badge:not(.tooltip-up) .alerta-tooltip {
  top: auto !important;
  bottom: auto !important;
  transform: none !important;
}

.alerta-badge .alerta-tooltip {
  display: none !important;
}

#alertTooltipPortal {
  position: fixed;
  z-index: 999999;
  display: none;
  min-width: 280px;
  max-width: 360px;
  background: #111827;
  color: #f8fafc;
  border: 1px solid rgba(245,158,11,.55);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55);
  padding: 14px;
  pointer-events: auto;
}

#alertTooltipPortal.is-visible {
  display: block;
}

#alertTooltipPortal[data-placement="top"]::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: rgba(245,158,11,.55);
}

#alertTooltipPortal[data-placement="bottom"]::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: rgba(245,158,11,.55);
}

/* Fix header visibility */
#clients-table thead,
#clients-table thead tr,
#clients-table thead th {
  position: sticky !important;
  top: 0 !important;
  z-index: 9999999 !important;
  background-color: #1e293b !important;
}

body.light-mode #clients-table thead,
body.light-mode #clients-table thead tr,
body.light-mode #clients-table thead th {
  background-color: #ffffff !important;
}
