/**
 * ============================================
 * ERP PCI CLIMA - Estilos Principales
 * ============================================
 * 
 * Diseño moderno con color primario #f33b19
 * Estilo profesional y distintivo
 */

/* ============================================
   VARIABLES CSS (valores por defecto)
   ============================================ */
:root {
    /* Colores principales */
    --primary: #f33b19;
    --primary-dark: #d12d10;
    --primary-light: #ff5c3d;
    --primary-rgb: 243, 59, 25;
    
    --secondary: #1e293b;
    --secondary-light: #334155;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    
    /* Fondos */
    --bg-body: #f8fafc;
    --bg-sidebar: #1e293b;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    
    /* Textos */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #ffffff;
    
    /* Bordes */
    --border-color: #e2e8f0;
    --border-radius: 0.625rem;
    --border-radius-lg: 0.875rem;
    --border-radius-sm: 0.375rem;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Dimensiones */
    --sidebar-width: 270px;
    --sidebar-collapsed-width: 72px;
    --header-height: 68px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Tipografía */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ============================================
   RESET Y BASE
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--bg-sidebar) 0%, #0f172a 100%);
    color: var(--text-light);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    min-height: var(--header-height);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    color: var(--text-light);
    font-weight: 700;
    font-size: 1.125rem;
}

.logo-icon {
    width: 38px;
    height: 38px;
    color: var(--primary);
    flex-shrink: 0;
}

.logo-icon svg {
    width: 100%;
    height: 100%;
}

.logo-text {
    white-space: nowrap;
    letter-spacing: -0.025em;
}

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

.sidebar-toggle {
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-light);
    width: 34px;
    height: 34px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    opacity: 0.7;
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.15);
    opacity: 1;
}

/* Navegación Sidebar */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.25rem 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.nav-section {
    margin-bottom: 1.75rem;
}

.nav-section-title {
    padding: 0.5rem 1.5rem;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.65);
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 2px 0;
    font-weight: 500;
    font-size: 0.9375rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-light);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.15) 0%, transparent 100%);
    color: var(--text-light);
    border-left-color: var(--primary);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-item.active svg {
    opacity: 1;
    color: var(--primary-light);
}

.nav-item span {
    white-space: nowrap;
}

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

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.875rem;
}

/* Sidebar Footer - User Menu */
.sidebar-footer {
    padding: 1rem 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    position: relative;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: rgba(255,255,255,0.08);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
    color: white;
}

.user-info {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chevron-icon {
    opacity: 0.5;
    transition: var(--transition);
}

.user-menu:hover .chevron-icon {
    opacity: 0.8;
}

.sidebar.collapsed .user-info,
.sidebar.collapsed .chevron-icon {
    display: none;
}

/* User Dropdown */
.user-dropdown {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 1rem;
    right: 1rem;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 100;
    overflow: hidden;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.user-dropdown .dropdown-item:hover {
    background: var(--bg-hover);
}

.user-dropdown .dropdown-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}

.user-dropdown .dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.user-dropdown .text-danger {
    color: var(--danger);
}

.user-dropdown .text-danger svg {
    color: var(--danger);
}

/* ============================================
   CONTENIDO PRINCIPAL
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* Header */
.main-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 1.75rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 1rem;
}

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

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

.page-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Búsqueda Global */
.global-search {
    position: relative;
}

.global-search .search-input {
    width: 280px;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    background: var(--bg-hover);
    transition: var(--transition);
}

.global-search .search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.global-search .search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Contenido de página */
.page-content {
    padding: 1.75rem;
    flex: 1;
}

/* ============================================
   TARJETAS
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-hover);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* ============================================
   ESTADÍSTICAS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--stat-color, var(--primary));
    opacity: 0;
    transition: var(--transition);
}

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

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon.info {
    background: rgba(14, 165, 233, 0.1);
    color: var(--info);
}

.stat-content {
    flex: 1;
    min-width: 0;
}

.stat-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.025em;
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--danger);
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

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

.btn svg {
    width: 18px;
    height: 18px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

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

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #0d9668;
    color: white;
}

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

.btn-danger:hover {
    background: #dc2626;
    color: white;
}

.btn-sm {
    padding: 0.4375rem 0.875rem;
    font-size: 0.8125rem;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

.btn-lg {
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-label .required {
    color: var(--danger);
    margin-left: 0.125rem;
}

.form-control {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}

.form-control:disabled {
    background: var(--bg-hover);
    cursor: not-allowed;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.form-control.is-valid {
    border-color: var(--success);
}

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

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.form-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.invalid-feedback {
    font-size: 0.8125rem;
    color: var(--danger);
    margin-top: 0.375rem;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

/* Checkbox & Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.form-check-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.form-check-label {
    font-size: 0.9375rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* ============================================
   TABLAS
   ============================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-color);
}

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

.table th,
.table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-hover);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

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

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

.table tbody tr:last-child td {
    border-bottom: none;
}

.table td {
    color: var(--text-primary);
}

.table .text-muted {
    color: var(--text-muted);
}

/* Table Actions */
.table-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.table-actions .btn-icon {
    width: 32px;
    height: 32px;
    opacity: 0.7;
}

.table-actions .btn-icon:hover {
    opacity: 1;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    white-space: nowrap;
}

.badge-primary {
    background: rgba(var(--primary-rgb), 0.12);
    color: var(--primary);
}

.badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

.badge-info {
    background: rgba(14, 165, 233, 0.12);
    color: #0284c7;
}

.badge-secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* ============================================
   ALERTAS
   ============================================ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    font-size: 0.9375rem;
    animation: slideIn 0.3s ease;
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.alert span {
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    opacity: 0.6;
    transition: var(--transition);
}

.alert-close:hover {
    opacity: 1;
}

.alert-close svg {
    width: 18px;
    height: 18px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #065f46;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #991b1b;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #92400e;
}

.alert-info {
    background: rgba(14, 165, 233, 0.1);
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: #075985;
}

/* ============================================
   MODALES
   ============================================ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-backdrop.show,
.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Modal container - cubre toda la pantalla */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal.show,
.modal.active {
    display: flex;
}

/* Modal background/overlay */
.modal-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Modal box - la caja del contenido */
.modal-box {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 2;
    width: 90%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-box.modal-lg,
.modal-lg .modal-box {
    max-width: 720px;
}

.modal-box.modal-xl,
.modal-xl .modal-box {
    max-width: 960px;
}

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

.modal-head h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-head button {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0;
}

.modal-head button:hover {
    color: var(--text-primary);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 0.25rem;
    line-height: 1;
    border-radius: var(--border-radius-sm);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

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

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

/* ============================================
   TABS
   ============================================ */
/* Estilo moderno de tabs (pill style) */
.tabs-nav {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tabs-nav .tab,
.tabs-nav a.tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    border: none;
    background: none;
    cursor: pointer;
    transition: var(--transition);
}

.tabs-nav .tab:hover,
.tabs-nav a.tab:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

.tabs-nav .tab.active,
.tabs-nav a.tab.active {
    background: var(--bg-primary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab-count {
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    margin-left: 0.25rem;
}

/* Estilo alternativo de tabs (underline style) */
.tabs {
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0;
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.tab-item {
    padding: 0.875rem 1.25rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    white-space: nowrap;
}

.tab-item:hover {
    color: var(--text-primary);
}

.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* ============================================
   PAGINACIÓN
   ============================================ */
.pagination-nav {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    list-style: none;
}

.pagination-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.pagination-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination-link.active {
    background: var(--primary);
    color: white;
}

.pagination-dots {
    padding: 0 0.5rem;
    color: var(--text-muted);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    color: var(--border-color);
}

.empty-state h3 {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* ============================================
   LOADING / SPINNER
   ============================================ */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-in {
    animation: slideIn 0.3s ease;
}

/* ============================================
   UTILIDADES
   ============================================ */
.text-primary { color: var(--primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }

.fw-bold { font-weight: 600; }
.fw-normal { font-weight: 400; }

.text-center { text-align: center; }
.text-end { text-align: right; }

.d-flex { display: flex; }
.d-none { display: none; }
.d-block { display: block; }

.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

.me-1 { margin-right: 0.25rem; }
.me-2 { margin-right: 0.5rem; }
.me-3 { margin-right: 1rem; }

.ms-auto { margin-left: auto; }

.p-0 { padding: 0; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.w-100 { width: 100%; }

/* ============================================
   SIDEBAR OVERLAY (móvil)
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .global-search {
        display: none;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .page-content {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .main-header {
        padding: 0 1rem;
    }
    
    .page-title {
        font-size: 1.125rem;
    }
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary) 0%, #0f172a 100%);
    padding: 1rem;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 2.5rem 2rem;
    text-align: center;
    color: white;
}

.login-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.login-logo img {
    max-height: 55px;
    width: auto;
    max-width: 100%;
}

.login-logo svg {
    width: 64px;
    height: 64px;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-header p {
    opacity: 0.9;
    font-size: 0.9375rem;
}

.login-body {
    padding: 2rem;
}

.login-footer {
    padding: 1rem 2rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Resumen inline en cabecera */
.resumen-inline {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.resumen-inline .badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
}

/* Botones de acción en tabla */
.btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-outline-danger {
    border-color: var(--danger);
    color: var(--danger);
}

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

/* Tabla más compacta */
.table-hover tbody tr:hover {
    background-color: var(--bg-hover);
}

/* Card footer */
.card-footer {
    background: var(--bg-hover);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

/* ============================================
   TABLA COMPACTA PARA LÍNEAS DE OFERTA
   ============================================ */
.table-compact,
#tablaLineas {
    width: 100%;
    font-size: 0.8125rem;
}

.table-compact th,
.table-compact td,
#tablaLineas th,
#tablaLineas td {
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
}

.table-compact th,
#tablaLineas th {
    font-size: 0.75rem;
    padding: 0.5rem;
}

/* Filas de líneas más compactas */
#tablaLineas tbody tr td {
    padding: 0.35rem 0.5rem;
    line-height: 1.3;
}

/* Capítulos con estilo diferenciado pero compacto */
#tablaLineas .linea-capitulo td {
    padding: 0.4rem 0.5rem;
    background: linear-gradient(135deg, #fff5f0 0%, #ffe8e0 100%);
    border-bottom: 2px solid var(--primary);
}

/* Botones de acción más pequeños */
#tablaLineas .btn-group-sm .btn {
    padding: 0.2rem 0.4rem;
}

#tablaLineas .btn-group-sm svg {
    width: 12px;
    height: 12px;
}

/* Totales compactos */
#tablaLineas tfoot tr td {
    padding: 0.4rem 0.5rem;
}

#tablaLineas tfoot .total-final {
    background: var(--primary);
    color: white;
}

#tablaLineas tfoot .total-final td {
    color: white;
    font-weight: bold;
}

/* Drag handle más pequeño */
#tablaLineas .drag-handle {
    width: 24px;
    padding: 0.35rem 0.25rem !important;
    cursor: grab;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Código más compacto */
#tablaLineas code {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
}

/* Tabla de costes compacta */
.table-costes th,
.table-costes td {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}

.table-costes th {
    font-size: 0.7rem;
}

/* Layout sin restricción de ancho */
.card-body.p-0 .table {
    margin: 0;
}


/* ============================================
   TABLA COMPACTA PARA LÍNEAS DE OFERTA
   ============================================ */
.table-compact th,
.table-compact td {
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
    vertical-align: middle;
}

.table-compact th {
    font-size: 0.75rem;
}

/* Capítulos con estilo diferenciado */
#tablaLineas .linea-capitulo td {
    padding: 0.4rem 0.5rem;
    background: linear-gradient(135deg, #fff5f0 0%, #ffe8e0 100%);
    border-bottom: 2px solid var(--primary);
}

/* Totales compactos */
#tablaLineas tfoot .total-final {
    background: var(--primary);
}

#tablaLineas tfoot .total-final td {
    color: white;
    font-weight: bold;
}

/* Drag handle pequeño */
#tablaLineas .drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Código compacto */
#tablaLineas code {
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
}

/* Botones de icono pequeños */
.btn-icon-sm {
    background: none;
    border: none;
    padding: 0.15rem 0.25rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    font-size: 0.8rem;
}

.btn-icon-sm:hover {
    opacity: 1;
}

/* ============================================
   ANCHO COMPLETO PARA OFERTAS
   ============================================ */
.page-content {
    padding: 1.25rem;
    width: 100%;
}

#tablaLineas {
    width: 100%;
    table-layout: auto;
}

/* Importes sin salto de línea */
.table td.text-right,
.table th.text-right {
    white-space: nowrap;
}

/* Row y columnas sin padding extra */
.page-content > .row {
    margin-left: 0;
    margin-right: 0;
}

.page-content .col-12 {
    padding-left: 0;
    padding-right: 0;
}

/* ============================================
   GRID BÁSICO (sin Bootstrap)
   ============================================ */
.row {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
    width: 100%;
}

.col-9 {
    flex: 0 0 75%;
    max-width: 75%;
}

.col-3 {
    flex: 0 0 25%;
    max-width: 25%;
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
}

.col-4 {
    flex: 0 0 33.333%;
    max-width: 33.333%;
}

/* Card dentro de columna ocupa todo */
.col-12 > .card {
    width: 100%;
}

/* Tabla dentro de card-body al 100% */
.card-body.p-0 > table {
    width: 100%;
}