/* CRM PLUS - Estilo Principal */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
    --azul:        #1a6bff;
    --azul-dark:   #1452cc;
    --azul-light:  #e8f0ff;
    --azul-soft:   #f0f5ff;
    --branco:      #ffffff;
    --cinza-bg:    #f4f6fb;
    --cinza-borda: #e2e8f0;
    --cinza-texto: #4a5568;
    --cinza-claro: #718096;
    --preto:       #1a202c;
    --verde:       #22c55e;
    --vermelho:    #ef4444;
    --amarelo:     #f59e0b;
    --sombra-sm:   0 1px 3px rgba(0,0,0,.08);
    --sombra:      0 4px 16px rgba(26,107,255,.10);
    --sombra-lg:   0 8px 32px rgba(26,107,255,.16);
    --radius:      12px;
    --radius-sm:   8px;
    --sidebar-w:   260px;
    --transition:  .2s ease;
}

html { font-size: 16px; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--cinza-bg);
    color: var(--preto);
    line-height: 1.6;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }

/* ── LOGIN ─────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a6bff 0%, #1452cc 50%, #0d3899 100%);
    padding: 1.5rem;
}

.login-card {
    background: var(--branco);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--sombra-lg);
}

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

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: var(--azul);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 24px rgba(26,107,255,.35);
}

.login-logo .logo-icon svg { width: 32px; height: 32px; fill: #fff; }

.login-logo h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--preto);
    letter-spacing: -.5px;
}

.login-logo p {
    color: var(--cinza-claro);
    font-size: .875rem;
    margin-top: .25rem;
}

/* ── FORM FIELDS ───────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--cinza-texto);
    margin-bottom: .45rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .75rem 1rem;
    border: 1.5px solid var(--cinza-borda);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: .9375rem;
    color: var(--preto);
    background: var(--branco);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--azul);
    box-shadow: 0 0 0 3px rgba(26,107,255,.12);
}

.form-group textarea { resize: vertical; min-height: 110px; }

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

/* ── BUTTONS ───────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .72rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--azul);
    color: #fff;
    box-shadow: 0 4px 12px rgba(26,107,255,.30);
}
.btn-primary:hover { background: var(--azul-dark); transform: translateY(-1px); box-shadow: var(--sombra-lg); }

.btn-secondary {
    background: var(--cinza-bg);
    color: var(--cinza-texto);
    border: 1.5px solid var(--cinza-borda);
}
.btn-secondary:hover { background: var(--cinza-borda); }

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

.btn-success { background: var(--verde); color: #fff; }
.btn-success:hover { background: #16a34a; }

.btn-sm { padding: .45rem .9rem; font-size: .8125rem; }
.btn-lg { padding: .9rem 1.8rem; font-size: 1rem; width: 100%; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

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

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

/* ── SIDEBAR ───────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--preto);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-logo {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: .75rem;
}

.sidebar-logo .logo-mark {
    width: 40px; height: 40px;
    background: var(--azul);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(26,107,255,.4);
}

.sidebar-logo .logo-mark svg { width: 22px; height: 22px; fill: #fff; }

.sidebar-logo h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.3px;
}

.sidebar-logo span {
    font-size: .7rem;
    color: var(--azul);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-section {
    padding: .5rem 1.25rem .25rem;
    font-size: .65rem;
    font-weight: 700;
    color: rgba(255,255,255,.3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-top: .5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    color: rgba(255,255,255,.6);
    font-size: .9rem;
    font-weight: 500;
    border-radius: 0;
    transition: all var(--transition);
    position: relative;
    cursor: pointer;
    margin: .1rem .75rem;
    border-radius: 8px;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #fff;
}

.nav-item.active {
    background: rgba(26,107,255,.20);
    color: #fff;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--azul);
    border-radius: 0 3px 3px 0;
    left: -.75rem;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .75rem;
    border-radius: 8px;
    background: rgba(255,255,255,.05);
}

.user-avatar {
    width: 36px; height: 36px;
    background: var(--azul);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; color: #fff; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { color: rgba(255,255,255,.4); font-size: .75rem; }

.btn-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,.4);
    cursor: pointer;
    padding: .25rem;
    border-radius: 4px;
    transition: color var(--transition);
    display: flex;
}
.btn-logout:hover { color: var(--vermelho); }
.btn-logout svg { width: 16px; height: 16px; }

/* ── MAIN CONTENT ──────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── TOPBAR ────────────────────────────── */
.topbar {
    background: var(--branco);
    padding: 1rem 1.75rem;
    border-bottom: 1px solid var(--cinza-borda);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    box-shadow: var(--sombra-sm);
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cinza-texto);
    padding: .35rem;
    border-radius: var(--radius-sm);
}
.btn-menu-toggle:hover { background: var(--cinza-bg); }
.btn-menu-toggle svg { width: 22px; height: 22px; display: block; }

.page-title h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--preto);
    line-height: 1.2;
}

.page-title p {
    font-size: .8125rem;
    color: var(--cinza-claro);
    margin-top: .15rem;
}

.topbar-right { display: flex; align-items: center; gap: .75rem; }

.instancia-badge {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .4rem .85rem;
    background: var(--azul-soft);
    border-radius: 50px;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--azul);
}

.instancia-badge .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--verde);
    box-shadow: 0 0 6px rgba(34,197,94,.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* ── PAGE CONTENT ──────────────────────── */
.page-content {
    padding: 1.75rem;
    flex: 1;
}

/* ── CARDS ─────────────────────────────── */
.card {
    background: var(--branco);
    border-radius: var(--radius);
    border: 1px solid var(--cinza-borda);
    box-shadow: var(--sombra-sm);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--cinza-borda);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--preto);
    display: flex;
    align-items: center;
    gap: .6rem;
}
.card-header h2 svg { width: 18px; height: 18px; color: var(--azul); }

.card-body { padding: 1.5rem; }
.card-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--cinza-borda); background: var(--cinza-bg); }

/* ── STATS GRID ────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--branco);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--cinza-borda);
    box-shadow: var(--sombra-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }

.stat-icon.azul { background: var(--azul-light); color: var(--azul); }
.stat-icon.verde { background: #dcfce7; color: var(--verde); }
.stat-icon.amarelo { background: #fef3c7; color: var(--amarelo); }
.stat-icon.vermelho { background: #fee2e2; color: var(--vermelho); }

.stat-info .value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--preto);
    line-height: 1;
}

.stat-info .label {
    font-size: .8125rem;
    color: var(--cinza-claro);
    margin-top: .2rem;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

thead th {
    text-align: left;
    padding: .85rem 1.25rem;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--cinza-claro);
    background: var(--cinza-bg);
    border-bottom: 1px solid var(--cinza-borda);
}

tbody td {
    padding: .9rem 1.25rem;
    border-bottom: 1px solid var(--cinza-borda);
    color: var(--cinza-texto);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--azul-soft); }

/* ── BADGES ────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .65rem;
    border-radius: 50px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger   { background: #fee2e2; color: #dc2626; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: var(--azul-light); color: var(--azul-dark); }
.badge-gray     { background: var(--cinza-bg); color: var(--cinza-texto); }

/* ── ALERTS ────────────────────────────── */
.alert {
    padding: .9rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.alert-danger   { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-info     { background: var(--azul-light); color: var(--azul-dark); border: 1px solid #93c5fd; }
.alert-warning  { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: .1rem; }

/* ── TABS ──────────────────────────────── */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--cinza-borda);
    margin-bottom: 1.5rem;
    gap: .25rem;
}

.tab-btn {
    padding: .65rem 1.25rem;
    border: none;
    background: none;
    font-family: 'Inter', sans-serif;
    font-size: .9rem;
    font-weight: 600;
    color: var(--cinza-claro);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.tab-btn svg { width: 16px; height: 16px; }
.tab-btn:hover { color: var(--azul); }
.tab-btn.active { color: var(--azul); border-bottom-color: var(--azul); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── CHECKBOX LIST ─────────────────────── */
.check-list {
    border: 1.5px solid var(--cinza-borda);
    border-radius: var(--radius-sm);
    max-height: 260px;
    overflow-y: auto;
}

.check-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--cinza-borda);
    cursor: pointer;
    transition: background var(--transition);
}

.check-item:last-child { border-bottom: none; }
.check-item:hover { background: var(--azul-soft); }

.check-item input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--azul);
    cursor: pointer;
    flex-shrink: 0;
}

.check-item label {
    cursor: pointer;
    font-size: .9rem;
    color: var(--cinza-texto);
    flex: 1;
}

/* ── PROGRESS ──────────────────────────── */
.progress-bar-wrap {
    background: var(--cinza-borda);
    border-radius: 50px;
    height: 8px;
    overflow: hidden;
    margin-top: .5rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--azul), #4f9eff);
    border-radius: 50px;
    transition: width .4s ease;
}

/* ── MODAL ─────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--branco);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    animation: slideUp .25s ease;
}

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

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

.modal-header h3 { font-size: 1rem; font-weight: 700; color: var(--preto); }

.btn-modal-close {
    background: none; border: none; cursor: pointer;
    color: var(--cinza-claro); padding: .25rem; border-radius: 4px; display: flex;
}
.btn-modal-close:hover { color: var(--vermelho); background: #fee2e2; }
.btn-modal-close svg { width: 20px; height: 20px; }

.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--cinza-borda);
    display: flex;
    gap: .75rem;
    justify-content: flex-end;
}

/* ── EMPTY STATE ───────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--cinza-claro);
}
.empty-state svg {
    width: 56px; height: 56px;
    margin: 0 auto 1rem;
    color: var(--cinza-borda);
}
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--cinza-texto); margin-bottom: .5rem; }
.empty-state p { font-size: .9rem; }

/* ── SPINNER ───────────────────────────── */
.spinner {
    width: 22px; height: 22px;
    border: 2.5px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
.spinner-dark {
    border-color: rgba(26,107,255,.2);
    border-top-color: var(--azul);
}

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

/* ── INTERVALO ROW ─────────────────────── */
.intervalo-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}
.intervalo-row span { color: var(--cinza-claro); font-size: .9rem; }
.intervalo-row input { width: 90px; }

/* ── UPLOAD BOX ────────────────────────── */
.upload-box {
    border: 2px dashed var(--cinza-borda);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--cinza-bg);
}
.upload-box:hover { border-color: var(--azul); background: var(--azul-soft); }
.upload-box svg { width: 32px; height: 32px; color: var(--cinza-claro); margin-bottom: .5rem; }
.upload-box p { font-size: .875rem; color: var(--cinza-claro); }
.upload-box input[type="file"] { display: none; }

/* ── LOG AREA ──────────────────────────── */
.log-area {
    background: #1a202c;
    border-radius: var(--radius-sm);
    padding: 1rem;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: .8rem;
    line-height: 1.6;
}
.log-line { color: #a0aec0; }
.log-line.ok  { color: #68d391; }
.log-line.err { color: #fc8181; }
.log-line.info{ color: #63b3ed; }

/* ── OVERLAY SIDEBAR (mobile) ──────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

/* ── RESPONSIVE ────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.open {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .btn-menu-toggle {
        display: flex;
    }
    .page-content {
        padding: 1rem;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .topbar {
        padding: .85rem 1rem;
    }
    .instancia-badge span { display: none; }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .login-card {
        padding: 2rem 1.25rem;
    }
}
