/* ==========================================================================
   INTRANET BENICORP - SISTEMA DE DISEÑO CORPORATIVO (GOOGLE STITCH)
   Basado en: Stitch "App Benicorp" (Corporate Energy & Logistics)
   Colores planos y enteros, alto contraste, tipografía Manrope + Inter.
   ========================================================================== */

:root,
[data-theme="benicorp"],
[data-theme="light"] {
    /* Superficies y Fondos Planos (Sin Degradados) */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-surface: #f3f4f5;
    --bg-surface-hover: #e9ecef;
    --bg-input: #ffffff;
    --bg-sidebar: #001851;
    --bg-sidebar-hover: #002266;
    --bg-sidebar-active: #002b7f;
    
    /* Bordes Nítidos de 1px */
    --border-color: #e2e8f0;
    --border-focus: #002b7f;
    --border-dark: #cbd5e1;
    
    /* Paleta de Marca Oficial Benicorp (Colores Enteros) */
    --brand-primary: #001851;
    --brand-blue: #002b7f;
    --brand-cyan: #002b7f; /* Reemplazo de cyan por azul corporativo */
    --brand-red: #e31e24;
    --brand-emerald: #00a651;
    --brand-amber: #d97706;
    --brand-rose: #dc2626;
    
    /* Tipografía Corporativa y Textos de Alto Contraste */
    --font-headline: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    --text-primary: #191c1d;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-highlight: #002b7f;
    
    /* Sombras Sutiles y Rápidas (Cero Neón) */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    
    --sidebar-width: 260px;
    --header-height: 64px;
}

/* Tema Oscuro Plano (Flat Dark Mode Profesional) */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-input: #0f172a;
    --bg-sidebar: #0a0f1d;
    --bg-sidebar-hover: #1e293b;
    --bg-sidebar-active: #2563eb;
    
    --border-color: #334155;
    --border-focus: #3b82f6;
    --border-dark: #475569;
    
    --brand-primary: #3b82f6;
    --brand-blue: #2563eb;
    --brand-cyan: #38bdf8;
    --brand-red: #ef4444;
    --brand-emerald: #10b981;
    --brand-amber: #f59e0b;
    --brand-rose: #f87171;
    
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-highlight: #60a5fa;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

/* Densidad Compacta */
[data-density="compact"] {
    --header-height: 54px;
}
[data-density="compact"] .form-control {
    padding: 6px 10px;
    font-size: 0.84rem;
}
[data-density="compact"] .table td, [data-density="compact"] .table th {
    padding: 8px 12px;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-headline);
    font-weight: 700;
    color: var(--text-primary);
}

/* Scrollbar Corporativa */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-blue);
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */

.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar Sólido Azul Marino Benicorp */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 20;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 40px;
    overflow: hidden;
}

.brand-logo-full {
    height: 34px;
    max-width: 175px;
    width: auto;
    object-fit: contain;
    opacity: 1;
    transform: scale(1);
    transform-origin: center;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: block;
}

.brand-logo-morph {
    position: absolute;
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 6px;
    opacity: 0;
    transform: scale(0.65);
    transform-origin: center;
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.nav-menu {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    padding: 14px 12px 6px 12px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    border: 1px solid transparent;
}

.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
    color: #ffffff;
}

.nav-item.active {
    background-color: var(--bg-sidebar-active);
    color: #ffffff;
    font-weight: 600;
    border-left: 4px solid var(--brand-red);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-item svg {
    width: 19px;
    height: 19px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--brand-red);
    color: #ffffff;
    font-size: 0.7rem;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 700;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background-color: #00123d;
}

.user-mini-card {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-blue);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 0.85rem;
}

.user-meta {
    flex: 1;
    overflow: hidden;
}

.user-meta .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta .user-role {
    font-size: 0.72rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Sidebar Collapsed (Contraído) */
.sidebar.collapsed {
    width: 70px;
}

.sidebar.collapsed .brand-header {
    padding: 0 8px;
    justify-content: center;
}

.sidebar.collapsed .brand-logo-full {
    opacity: 0;
    transform: scale(0.7);
    pointer-events: none;
}

.sidebar.collapsed .brand-logo-morph {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

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

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
    position: relative;
    border-radius: var(--radius-sm);
}

.sidebar.collapsed .nav-item.active {
    border-left: none;
    border-radius: var(--radius-sm);
    box-shadow: inset 4px 0 0 var(--brand-red);
}

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

.sidebar.collapsed .nav-item .nav-badge {
    display: none !important;
}

.sidebar.collapsed .user-meta {
    display: none;
}

.sidebar.collapsed .sidebar-footer {
    padding: 14px 0;
    display: flex;
    justify-content: center;
}

.sidebar.collapsed .user-mini-card {
    justify-content: center;
}

/* ==========================================================================
   TOPBAR & MAIN CONTENT
   ========================================================================== */

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.topbar {
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    gap: 20px;
    z-index: 10;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breadcrumb-module {
    font-family: var(--font-headline);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.breadcrumb-module span {
    color: var(--text-muted);
    font-weight: 500;
}

.azure-status-badge {
    display: none !important;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-badge-select {
    display: flex;
    align-items: center;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    gap: 6px;
}

.role-badge-select label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.role-badge-select select {
    background: transparent;
    border: none;
    color: var(--brand-blue);
    font-size: 0.85rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
}

.role-badge-select select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

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

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

.btn-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

.view-section {
    display: none;
    max-width: 1280px;
    margin: 0 auto;
}

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

/* ==========================================================================
   VIEW HEADERS & BOTONES SÓLIDOS
   ========================================================================== */

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

.view-header-title h2 {
    font-size: 1.45rem;
    color: var(--text-primary);
}

.view-header-title p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.view-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font-body);
}

.btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

/* Botón Primario: Azul Sólido Benicorp */
.btn-primary {
    background-color: var(--brand-blue);
    color: #ffffff;
    border-color: var(--brand-blue);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
}

/* Botón Secundario: Blanco con Borde Sutil */
.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-dark);
}

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

.btn-success {
    background-color: var(--brand-emerald);
    color: #ffffff;
    border-color: var(--brand-emerald);
}

.btn-success:hover {
    filter: brightness(0.92);
}

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

.btn-danger:hover {
    filter: brightness(0.92);
}

/* ==========================================================================
   FORMULARIO Y TARJETAS CORPORATIVAS
   ========================================================================== */

/* Pestañas del Formulario */
.form-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    padding-bottom: 6px;
}

.form-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.form-tab-btn.active {
    color: #ffffff;
    background-color: var(--brand-blue);
}

.tab-step-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
}

.form-tab-btn.active .tab-step-num {
    background: #ffffff;
    color: var(--brand-blue);
}

.tab-pane {
    display: none;
}

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

/* Tarjetas (Boxing Style) */
.card-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header-title {
    font-family: var(--font-headline);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header-title .tag-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--brand-blue);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
}

.card-body {
    padding: 24px;
}

/* Búsqueda de RUC Sutil */
.ruc-search-subtle-container {
    padding: 0;
    margin-bottom: 20px;
}

.ruc-form-group {
    max-width: 520px;
}

.ruc-input-action-group {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.ruc-input-action-group .form-control {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-query-sunat-subtle {
    height: 38px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 600;
    flex-shrink: 0;
}

.ruc-validation-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    display: none;
    margin-left: 8px;
}

.ruc-validation-badge.valid {
    display: inline-block;
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.ruc-validation-badge.invalid {
    display: inline-block;
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.ruc-validation-badge.loading {
    display: inline-block;
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Grilla de Estado y Condición */
.status-condition-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.status-input {
    font-weight: 700 !important;
    text-align: center;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    min-width: 0;
    width: 100%;
    padding: 9px 4px;
}

/* Grillas de Formulario */
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px 20px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 16px 20px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group.col-span-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

[data-theme="dark"] .form-group label {
    color: #cbd5e1;
}

.form-group label .badge-sunat-field {
    font-size: 0.65rem;
    background: #e0f2fe;
    color: #0369a1;
    padding: 1px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 700;
}

/* Campos de Formulario */
.form-control {
    background-color: var(--bg-input);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: 0.88rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    min-width: 0;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(0, 43, 127, 0.12);
}

.form-control[readonly] {
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    border-color: var(--border-color);
    cursor: default;
}

textarea.form-control {
    resize: vertical;
    min-height: 72px;
}

/* Condiciones Comerciales Dinámicas */
.condicion-card-row {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 1.2fr 40px;
    gap: 12px;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.condicion-card-row:hover {
    border-color: var(--border-dark);
}

@media (max-width: 860px) {
    .condicion-card-row {
        grid-template-columns: 1fr;
    }
}

/* Selector Companion Tag */
.companion-tag-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    user-select: none;
    white-space: nowrap;
}

.companion-tag-btn.active {
    background-color: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.companion-tag-btn.inactive {
    background-color: var(--bg-surface);
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* Checklist Documental */
.checklist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
}

.checklist-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.checklist-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-blue);
    margin-top: 3px;
    cursor: pointer;
}

.checklist-content {
    flex: 1;
}

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

.checklist-obs {
    margin-top: 6px;
}

.checklist-obs input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.78rem;
    color: var(--text-primary);
}

.doc-upload-zone {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.file-input-hidden {
    display: none;
}

.btn-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: var(--bg-secondary);
    color: var(--brand-blue);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-upload-label:hover {
    background-color: var(--bg-surface);
}

.doc-uploaded-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: #dcfce7;
    border: 1px solid #86efac;
    color: #166534;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.74rem;
    font-weight: 600;
    text-decoration: none;
}

.contact-card-row {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) 40px;
    gap: 12px;
    align-items: center;
}

.approval-panel-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

/* Barra Flotante de Acciones */
.form-action-bar {
    position: sticky;
    bottom: 20px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-md);
    z-index: 15;
    margin-top: 24px;
}

/* ==========================================================================
   DIRECTORIO & TABLAS (HIGH CONTRAST)
   ========================================================================== */

.table-responsive {
    overflow-x: auto;
}

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

.table th {
    background-color: var(--bg-primary);
    color: #475569;
    font-weight: 700;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-primary);
    font-size: 0.86rem;
}

[data-theme="dark"] .table td {
    border-bottom-color: var(--border-color);
}

.table tbody tr:hover {
    background-color: var(--bg-surface);
}

/* Badges / Chips Tonales Sólidos */
.badge-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-tag.aprobado,
.badge-tag.activo {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-tag.pendiente {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-tag.observado {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-tag.credito {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.badge-tag.contado {
    background-color: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

/* ==========================================================================
   KPIS Y DASHBOARD
   ========================================================================== */

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

.kpi-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--brand-blue);
}

.kpi-title {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
}

.kpi-value {
    font-family: var(--font-headline);
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.kpi-subtext {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   MODAL & TOASTS
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-width: 950px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--brand-blue);
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 0.88rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast.error {
    border-left-color: var(--brand-red);
}

.toast.success {
    border-left-color: var(--brand-emerald);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 900px) {
    .sidebar {
        width: 70px;
    }
    .brand-info, .nav-section-title, .nav-item span, .nav-badge, .user-meta {
        display: none;
    }
    .nav-item {
        justify-content: center;
        padding: 12px;
    }
    .analytics-row-360 {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   AUTOCOMPLETADO BÚSQUEDA RUC TOPBAR
   ========================================================================== */

.topbar-search-wrapper,
.topbar-search-wrap {
    position: relative;
    max-width: 540px;
    width: 100%;
}

#topbar-search-input {
    background-color: var(--bg-secondary, #ffffff) !important;
    color: var(--text-primary, #0f172a) !important;
    border: 1.5px solid var(--border-color, #cbd5e1) !important;
    border-radius: var(--radius-sm, 6px);
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#topbar-search-input::placeholder {
    color: var(--text-muted, #64748b);
    opacity: 0.85;
}

#topbar-search-input:focus {
    background-color: var(--bg-secondary, #ffffff) !important;
    color: var(--text-primary, #0f172a) !important;
    border-color: var(--brand-blue, #002b7f) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0, 43, 127, 0.18) !important;
}

#topbar-search-dropdown {
    background-color: var(--bg-card, #ffffff) !important;
    border: 1px solid var(--border-color, #cbd5e1) !important;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15) !important;
}

.search-suggestion-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    transition: background-color 0.15s ease;
    background: transparent;
}

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

.search-suggestion-item:hover {
    background-color: var(--bg-surface-hover, #f1f5f9) !important;
}

.search-suggestion-title {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary, #0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
}

.search-suggestion-meta {
    font-size: 0.74rem;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
}

/* ==========================================================================
   HOJA DEL CLIENTE 360° STYLES
   ========================================================================== */

.client-hero-card {
    transition: box-shadow 0.2s ease;
}

.tab-360-btn {
    transition: all 0.2s ease;
}

.tab-360-btn:hover {
    color: var(--brand-blue) !important;
    background: var(--bg-surface-hover) !important;
}

.tab-360-btn.active {
    color: var(--brand-blue) !important;
    border-bottom-color: var(--brand-blue) !important;
    background: var(--bg-secondary) !important;
}

/* Tooltip interactivo para gráficos SVG */
.chart-tooltip {
    position: absolute;
    background: var(--bg-sidebar);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    pointer-events: none;
    z-index: 10;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    display: none;
}

.badge-proveedor {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-proveedor.primax {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.badge-proveedor.ava {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-proveedor.benicorp {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-proveedor.petroamerica {
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #e9d5ff;
}

/* Botones de acción en tablas 360 */
.btn-action-sm {
    padding: 3px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.btn-action-sm:hover:not(:disabled) {
    background: var(--bg-surface-hover);
    border-color: var(--brand-blue);
    color: var(--brand-blue);
}

.btn-action-sm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-action-sm.danger {
    color: var(--brand-rose);
    border-color: rgba(220, 38, 38, 0.3);
}

.btn-action-sm.danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.08);
    border-color: var(--brand-rose);
}

.btn-action-sm.success {
    color: var(--brand-emerald);
    border-color: rgba(0, 166, 81, 0.3);
}

.btn-action-sm.success:hover:not(:disabled) {
    background: rgba(0, 166, 81, 0.08);
    border-color: var(--brand-emerald);
}

/* ==========================================================================
   FICHA COMERCIAL FOR-COM-04 (BENTO GRID MODERNO)
   ========================================================================== */

.ficha-bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.ficha-bento-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
}

.ficha-bento-card:hover {
    border-color: rgba(0, 43, 127, 0.25);
    box-shadow: 0 4px 12px rgba(0, 43, 127, 0.06);
}

.ficha-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.ficha-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--brand-blue);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.ficha-field-list {
    display: flex;
    flex-direction: column;
    gap: 9px;
    flex: 1;
}

.ficha-field-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.83rem;
    gap: 12px;
}

.ficha-field-label {
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
    font-weight: 500;
}

.ficha-field-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.ficha-facturacion-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.76rem;
    font-weight: 700;
    background: rgba(0, 43, 127, 0.08);
    color: var(--brand-blue);
    border: 1px solid rgba(0, 43, 127, 0.2);
}

.ficha-contact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.ficha-contact-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.ficha-contact-avatar {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-blue), #1e40af);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
}

.pricing-tier-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.pricing-tier-badge.eess {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.pricing-tier-badge.ped {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.pricing-tier-badge.general {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.pricing-tier-badge.default {
    background: #f8fafc;
    color: #94a3b8;
    border: 1px dashed #cbd5e1;
}

/* Modal Solicitud de Condiciones & Historial */
.condiciones-compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

@media (max-width: 680px) {
    .condiciones-compare-grid {
        grid-template-columns: 1fr;
    }
}

.ficha-solicitud-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.ficha-solicitud-card.pendiente {
    border-left: 3px solid var(--brand-amber);
}

.ficha-solicitud-card.aprobado {
    border-left: 3px solid var(--brand-emerald);
}

.ficha-solicitud-card.rechazado {
    border-left: 3px solid var(--brand-danger);
}

/* ==========================================================================
   MÓDULO TARIFARIO WEB OFICIAL BENICORP
   ========================================================================== */

.tarifario-app {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tarifario-filters-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.tarifario-filter-item {
    flex: 1 1 180px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tarifario-filter-item label {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
}

.tarifario-filter-item select,
.tarifario-filter-item input {
    height: 38px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.84rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.15s;
}

.tarifario-filter-item select:focus,
.tarifario-filter-item input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 2px rgba(0, 43, 127, 0.12);
}

.tarifario-grid-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

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

.tarifario-table th {
    padding: 10px 12px;
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.tarifario-table th:last-child {
    border-right: none;
}

.tarifario-table th.header-meta {
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    font-weight: 700;
}

.tarifario-table th.header-product {
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.tarifario-table th.header-product.diesel { background: #002b7f; }
.tarifario-table th.header-product.regular { background: #0f766e; }
.tarifario-table th.header-product.premium { background: #7c3aed; }
.tarifario-table th.header-product.glp { background: #ea580c; }
.tarifario-table th.header-product.gnv { background: #475569; }

.tarifario-table th.sub-header {
    font-size: 0.68rem;
    padding: 6px 8px;
}

.tarifario-table th.sub-header.venta {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary);
    font-weight: 800;
}

.tarifario-table th.sub-header.base {
    background-color: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
}

.tarifario-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    vertical-align: middle;
}

.tarifario-table td:last-child {
    border-right: none;
}

.tarifario-table tr:hover {
    background-color: var(--bg-surface-hover);
}

.cell-station .station-name {
    display: block;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.84rem;
}

.cell-station .station-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.cell-station .station-type {
    font-size: 0.70rem;
    color: var(--text-muted);
    font-style: italic;
}

.badge-red {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.badge-red-red-1 { background-color: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-red-red-2 { background-color: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-red-red-3 { background-color: #fefce8; color: #a16207; border: 1px solid #fef08a; }

.cell-price {
    text-align: right;
    font-variant-numeric: tabular-nums;
    min-width: 70px;
}

.cell-price.venta.highlight {
    font-weight: 700;
    color: var(--text-primary);
}

.cell-price.base {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.tarifario-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   WORKFLOW STEPPER PIPELINE (VALIDACIÓN Y APROBACIÓN)
   ========================================================================== */
.stepper-pipeline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 16px 0 24px 0;
    padding: 16px 20px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    min-width: 100px;
}

.step-circle {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.88rem;
    transition: all 0.25s ease;
}

.step-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    max-width: 110px;
    line-height: 1.25;
}

.step-line {
    flex: 1;
    height: 3px;
    background: var(--border-color);
    margin: 0 10px 22px 10px;
    transition: background 0.3s ease;
}

.step-item.active .step-circle {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
    color: #fff;
    box-shadow: 0 0 12px rgba(37, 99, 235, 0.45);
    transform: scale(1.1);
}

.step-item.active .step-label {
    color: var(--brand-blue);
    font-weight: 700;
}

.step-item.done .step-circle {
    background: var(--brand-emerald);
    border-color: var(--brand-emerald);
    color: #fff;
}

.step-item.done .step-label {
    color: var(--text-primary);
}

.step-line.done {
    background: var(--brand-emerald);
}

/* ==========================================================================
   MULTI-FILE UPLOAD BADGES EN CHECKLIST DOCUMENTAL
   ========================================================================== */
.doc-uploaded-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 6px;
    padding: 3px 8px;
    margin: 3px 4px 3px 0;
    font-size: 0.78rem;
    color: var(--brand-blue);
    max-width: 100%;
    word-break: break-all;
}

.doc-uploaded-pill a {
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: 500;
}

.doc-uploaded-pill a:hover {
    text-decoration: underline;
}

.doc-remove-btn {
    background: transparent;
    border: none;
    color: var(--brand-rose);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 0 3px;
    line-height: 1;
    border-radius: 3px;
}

.doc-remove-btn:hover {
    background: rgba(244, 63, 94, 0.15);
}

/* ==========================================================================
   HOJA 360 EMPTY STATE
   ========================================================================== */
#c360-empty-state {
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
}

/* ==========================================================================
   CONTROL DOCUMENTARIO BADGES & ESTILOS
   ========================================================================== */
.badge-vigente {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-por-vencer {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-vencido {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-confidencial {
    background: rgba(147, 51, 234, 0.12);
    color: #9333ea;
    border: 1px solid rgba(147, 51, 234, 0.3);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ubicacion-fisica {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
}



