:root {
    color-scheme: dark;
    --bg-base: #090b10;
    --bg-surface: #11151f;
    --bg-elevated: #171c29;
    --bg-hover: #1e2536;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text-primary: #f3f5f8;
    --text-secondary: #9ba3b5;
    --text-muted: #646d82;
    --accent-primary: #10b981;
    --accent-primary-dim: rgba(16, 185, 129, 0.14);
    --accent-blue: #3b82f6;
    --accent-blue-dim: rgba(59, 130, 246, 0.14);
    --accent-amber: #f59e0b;
    --accent-amber-dim: rgba(245, 158, 11, 0.14);
    --accent-red: #ef4444;
    --accent-red-dim: rgba(239, 68, 68, 0.14);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: #2b3548 #0d111a;
}

/* Barra de scroll personalizada en Tema Oscuro (WebKit / Chrome / Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #0d111a;
    border-left: 1px solid var(--border-subtle);
}

::-webkit-scrollbar-thumb {
    background: #2b3548;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3e4c66;
}

::-webkit-scrollbar-corner {
    background: #0d111a;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   PANTALLA DE LOGIN (BLOQUEO CON USUARIO Y CONTRASEÑA)
   ========================================================================== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 15%, #132328 0%, #090b10 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.auth-overlay.hidden {
    display: none;
}

.auth-card {
    width: 100%;
    max-width: 410px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 10px;
    margin-bottom: 22px;
}

.auth-logo-img {
    height: 40px;
    width: auto;
    max-width: 210px;
    object-fit: contain;
    display: block;
    margin: 0 auto 2px;
    /* Desplazamiento óptico hacia la izquierda para que la palabra SINTEGIA quede centrada sobre Outbound Engine */
    transform: translateX(-13.5%);
}

.sidebar-logo-img {
    height: 34px;
    width: auto;
    max-width: 185px;
    object-fit: contain;
    display: block;
    margin: 0 auto 4px;
    /* Desplazamiento óptico hacia la izquierda para alinear SINTEGIA con Outbound Engine */
    transform: translateX(-13.5%);
}

.auth-brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-primary-dim);
    border: 1px solid var(--accent-primary);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.auth-card h1 {
    font-size: 18px;
    font-weight: 600;
}

.auth-card p.sub {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 22px;
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.app-shell {
    display: grid;
    grid-template-columns: 288px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    padding: 6px 10px 20px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 18px;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--accent-primary);
    font-weight: 500;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-btn {
    width: 100%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.15s ease;
}

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

.nav-btn.active {
    background: var(--accent-primary-dim);
    border-color: rgba(16, 185, 129, 0.35);
    color: var(--text-primary);
    font-weight: 600;
}

.nav-badge {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 99px;
    background: var(--bg-elevated);
    color: var(--text-secondary);
}

.nav-badge.unread {
    background: var(--accent-primary);
    color: #04130d;
    font-weight: 700;
}

.sidebar-footer {
    border-top: 1px solid var(--border-subtle);
    padding-top: 14px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ==========================================================================
   CONTENIDO Y COMPONENTES
   ========================================================================== */
.main-area {
    padding: 28px 34px;
    overflow-y: auto;
    max-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.topbar h2 {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar-sub {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    margin: 6px 0 4px;
    font-variant-numeric: tabular-nums;
}

.kpi-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 20px;
}

/* Botones e Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.btn:hover {
    background: var(--bg-hover);
}

.btn-primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #03150e;
}

.btn-primary:hover {
    filter: brightness(1.08);
    background: var(--accent-primary);
}

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

.input, .select, .textarea {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: var(--font-sans);
}

.textarea {
    min-height: 110px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-group {
    margin-bottom: 14px;
}

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

/* Badges y Barras de Progreso */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-green {
    background: var(--accent-primary-dim);
    color: var(--accent-primary);
}

.badge-blue {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
}

.badge-amber {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
}

.badge-red {
    background: var(--accent-red-dim);
    color: var(--accent-red);
}

.progress-track {
    width: 100%;
    height: 8px;
    background: var(--bg-base);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #34d399);
    border-radius: 99px;
}

/* Tablas */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 11px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: top;
    white-space: nowrap;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.015);
}

/* ==========================================================================
   UNIBOX DE 3 COLUMNAS (Hilos + Chat + Diagnóstico Web de Claude)
   ========================================================================== */
.unibox-layout {
    display: grid;
    grid-template-columns: 300px 1fr 340px;
    gap: 16px;
    height: calc(100vh - 135px);
}

.unibox-col {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.unibox-col-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    font-size: 13.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.thread-item {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border-subtle);
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}

.thread-item:hover {
    background: var(--bg-elevated);
}

/* Conversación NO LEÍDA: margen izquierdo esmeralda + fondo destacado + negrita */
.thread-item.unread {
    border-left-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.thread-item.unread .thread-company,
.thread-item.unread .thread-snippet {
    font-weight: 700;
    color: #ffffff;
}

/* Conversación LEÍDA */
.thread-item.read {
    opacity: 0.85;
}

.thread-item.active {
    background: var(--bg-hover);
    border-left-color: var(--accent-primary);
    opacity: 1;
}

.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #f59e0b;
    margin-right: 6px;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

.msg-list {
    flex: 1;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #0d111a;
}

/* ==========================================================================
   VISTA REALISTA DE CLIENTE DE CORREO (TEMA BLANCO / PAPEL CON LETRA NEGRA REAL)
   Usado en Simulador de 3 Steps, Mensajes del Unibox y Editor de Respuesta
   ========================================================================== */
.email-paper-card {
    background: #ffffff;
    color: #111827;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.email-paper-card.inbound-card {
    border-left: 5px solid #10b981;
}

.email-paper-card.outbound-card {
    border-left: 5px solid #3b82f6;
}

.email-paper-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 14px;
    color: #334155;
    font-size: 12px;
}

.email-paper-subject {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    margin-top: 4px;
}

.email-paper-body {
    padding: 15px 16px;
    background: #ffffff;
    color: #111827;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13.5px;
    line-height: 1.6;
    white-space: pre-wrap;
}

.email-paper-composer {
    width: 100%;
    background: #ffffff;
    color: #111827;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    padding: 12px 14px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13.5px;
    line-height: 1.55;
    min-height: 92px;
    resize: vertical;
}

.email-paper-composer::placeholder {
    color: #64748b;
}

.email-paper-composer:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* ==========================================================================
   MODAL DE CONFIRMACIÓN SEGURA (ELIMINACIÓN DE CAMPAÑA / LEAD)
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 14, 0.78);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9500;
    padding: 20px;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-box {
    width: 100%;
    max-width: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 26px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

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

.btn-danger:hover {
    filter: brightness(1.1);
    background: var(--accent-red);
}

.claude-audit-box {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-sm);
    padding: 13px;
    font-size: 12.5px;
    white-space: pre-wrap;
    color: #dbeafe;
    line-height: 1.55;
}

.chip {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent-primary);
    margin: 2px;
    cursor: pointer;
}

.view-section {
    display: none;
}

.view-section.active {
    display: block;
}

@media (max-width: 1100px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .unibox-layout, .grid-2 {
        grid-template-columns: 1fr;
        height: auto;
    }
}

