/* Variables de Color (Inspirado en marca MIDVE automotriz) */
:root {
    --primary-color: #E63946; /* Rojo MIDVE */
    --primary-hover: #D62828;
    --dark-bg: #1D1E22; /* Gris oscuro para sidebar */
    --dark-text: #F1FAEE;
    --light-bg: #F4F6F8; /* Fondo principal gris muy claro */
    --white: #FFFFFF;
    --text-main: #333333;
    --text-muted: #6C757D;
    --border-color: #E0E4E8;
    
    /* Estados */
    --success: #2A9D8F;
    --warning: #F4A261;
    --danger: #E63946;
    
    /* Sombras y Radios */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    background-color: var(--light-bg);
    color: var(--text-main);
    margin: 0;
}

.app-wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* --- LOGIN SCREEN (AUTOMOTIVE REDESIGN) --- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #111111 0%, #1D1E22 100%);
    position: relative;
    overflow: hidden;
    transition: opacity 0.5s ease;
}

.login-container.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Fondo decorativo automotriz */
.login-bg-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(45deg, 
            rgba(255, 255, 255, 0.02) 0px, 
            rgba(255, 255, 255, 0.02) 2px, 
            transparent 2px, 
            transparent 10px
        );
    z-index: 1;
}

.login-gears {
    position: absolute;
    z-index: 2;
    color: rgba(255, 255, 255, 0.03);
}

.gear-1 {
    font-size: 400px;
    top: -100px;
    right: -100px;
    animation: spinRight 30s linear infinite;
}

.gear-2 {
    font-size: 250px;
    bottom: -50px;
    left: -50px;
    animation: spinLeft 20s linear infinite;
}

.gear-3 {
    font-size: 150px;
    top: 30%;
    left: 10%;
    animation: spinRight 15s linear infinite;
}

@keyframes spinRight {
    100% { transform: rotate(360deg); }
}

@keyframes spinLeft {
    100% { transform: rotate(-360deg); }
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(40px); }
    100% { opacity: 1; transform: translateY(0); }
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.1);
    width: 100%;
    max-width: 420px;
    text-align: center;
    position: relative;
    z-index: 10;
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border-top: 4px solid var(--primary-color);
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 42px;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 8px;
    letter-spacing: -1px;
}

.login-logo i {
    filter: drop-shadow(0 4px 6px rgba(230, 57, 70, 0.3));
}

.login-logo span { 
    color: #1A1A1A; 
}

.login-card h2 { 
    font-size: 16px; 
    color: var(--text-muted); 
    margin-bottom: 30px; 
    font-weight: 500; 
}

.login-card .form-group { 
    text-align: left; 
}

.login-card .form-group label {
    font-weight: 600;
    color: #4A4A4A;
}

.login-card input {
    background-color: #F8FAFC;
    border: 1px solid #E2E8F0;
    transition: border-color 0.3s, box-shadow 0.3s;
    padding: 14px;
    font-size: 15px;
}

.login-card input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.1);
}

.login-card .btn-primary {
    transition: all 0.3s ease;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-top: 10px;
}

.login-card .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(230, 57, 70, 0.3);
    background-color: #C1121F;
}

.login-card a {
    transition: color 0.2s;
}
.login-card a:hover { 
    color: var(--primary-color) !important; 
    text-decoration: underline !important;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background-color: var(--dark-bg);
    color: var(--dark-text);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.logo i {
    font-size: 28px;
}

.subtitle {
    font-size: 12px;
    color: #A0AAB5;
    margin-top: 4px;
    margin-left: 40px;
}

.nav-links {
    list-style: none;
    padding: 20px 0;
    flex-grow: 1;
}

.nav-item {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-weight: 500;
    color: #A0AAB5;
    transition: all 0.2s;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover {
    color: var(--white);
    background-color: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: var(--white);
    background-color: var(--primary-color);
    border-left: 4px solid var(--white);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-logout {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--dark-text);
    padding: 10px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-logout:hover {
    background-color: rgba(255,255,255,0.1);
}

/* --- MAIN CONTENT --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.top-header {
    background-color: var(--white);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-main);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.notification-bell {
    position: relative;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}

.notification-bell .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-muted);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- VIEWS CONTAINER --- */
.view-container {
    padding: 32px;
    flex-grow: 1;
    overflow-y: auto;
}

.view {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.view.active {
    display: block;
}

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

/* --- CARDS & UI ELEMENTS --- */
.card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

/* --- DASHBOARD KPIs --- */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.card.kpi {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    border-left: 4px solid var(--success);
}

.card.kpi.alert {
    border-left: 4px solid var(--danger);
}

.kpi-info h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.kpi-info .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background-color: rgba(42, 157, 143, 0.1);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.card.kpi.alert .kpi-icon {
    background-color: rgba(230, 57, 70, 0.1);
    color: var(--danger);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* --- TABLES --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

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

.data-table th {
    background-color: #F8FAFC;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

.data-table td {
    font-size: 14px;
}

.badge-stock {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.stock-ok { background: #E3FCEF; color: #006644; }
.stock-low { background: #FFFAE6; color: #FF8B00; }
.stock-out { background: #FFEBE6; color: #BF2600; }
.stock-negative { background: #fdeaea; color: #e63946; border: 1px solid #e63946; }

/* --- BUTTONS & INPUTS --- */
button {
    cursor: pointer;
    border: none;
    font-weight: 500;
    transition: 0.2s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-success {
    background-color: var(--success);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
}

.btn-success:hover { background-color: #238578; }

.btn-small {
    padding: 6px 12px;
    background-color: #E2E8F0;
    border-radius: 4px;
    font-size: 12px;
    color: var(--text-main);
}

.btn-small:hover { background-color: #CBD5E1; }

.action-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 16px;
    width: 300px;
}

.search-box i {
    color: var(--text-muted);
    font-size: 20px;
}

.search-box input {
    border: none;
    padding: 12px;
    width: 100%;
    outline: none;
    font-size: 14px;
}

/* --- SEARCH VIEW --- */
.search-massive-container {
    text-align: center;
    padding: 40px 0;
}

.search-massive-container h2 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.search-massive-container p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.search-massive-box {
    display: flex;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.search-massive-box input {
    flex-grow: 1;
    padding: 16px 20px;
    border: none;
    font-size: 16px;
    outline: none;
}

.search-massive-box button {
    border-radius: 0;
    padding: 0 30px;
    font-size: 16px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.part-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.part-card h4 { font-size: 16px; color: var(--primary-color); }
.part-card .sku { font-size: 12px; color: var(--text-muted); }
.part-card .price { font-size: 20px; font-weight: 700; }
.part-card .stock-info { font-size: 14px; display: flex; align-items: center; gap: 8px; }

/* --- POS (VENTAS) --- */
.pos-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    height: calc(100vh - 150px);
}

.pos-products {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    overflow-y: auto;
}

.pos-ticket {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.product-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.product-item:hover {
    border-color: var(--primary-color);
    background-color: rgba(230, 57, 70, 0.05);
}

.product-item i { font-size: 32px; color: var(--text-muted); }
.product-item span { font-size: 13px; font-weight: 500; }
.product-item strong { color: var(--primary-color); }

.ticket-items {
    flex-grow: 1;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    padding: 16px 0;
}

.ticket-item-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

.ticket-totals {
    margin-bottom: 20px;
}

.total-row {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    margin-bottom: 8px;
}

.grand-total {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    border-top: 2px dashed var(--border-color);
    padding-top: 12px;
}

.full-width { width: 100%; }
.large-btn { font-size: 16px; padding: 16px; }
.mb-3 { margin-bottom: 16px; }

/* Utilities */
.alert-list { list-style: none; }
.alert-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.alert-item:last-child { border-bottom: none; }
.empty-cart-msg { text-align: center; color: var(--text-muted); padding: 40px 0; }

/* --- MODAL SYSTEM --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.65); /* Slate-900 with transparency */
    backdrop-filter: blur(4px);
    display: none;
    align-items: center; justify-content: center;
    z-index: 10000;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    animation: modalAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden; /* Important for border radius and fixed header/footer */
}

@keyframes modalAppear {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Modal Sizes */
.modal-sm { max-width: 400px; }
.modal-md { max-width: 600px; }
.modal-lg { max-width: 850px; }
.modal-xl { max-width: 1100px; }

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 24px;
    background: linear-gradient(135deg, #1D1E22 0%, #333333 100%);
    color: white;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: white !important;
    display: flex;
    align-items: center;
    gap: 10px;
}
.close-modal { 
    background: rgba(255, 255, 255, 0.1); 
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px; 
    color: white; 
    transition: 0.2s;
}
.close-modal:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.modal-body { 
    padding: 24px; 
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb { background-color: #CBD5E1; border-radius: 10px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    background-color: #F8FAFC;
    border-top: 1px solid var(--border-color);
}

/* Sections inside Modal Body */
.modal-section {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}
.modal-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .modal-overlay { padding: 10px; }
    .modal-content { max-height: 95vh; border-radius: 12px; }
    .modal-body { padding: 16px; }
    .form-row { flex-direction: column; gap: 0; }
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer button { width: 100%; }
}

.payment-total-display {
    text-align: center; font-size: 18px; margin-bottom: 20px;
    background: var(--light-bg); padding: 15px; border-radius: var(--radius-md);
}
.payment-total-display strong { font-size: 28px; color: var(--primary-color); display: block; }
.payment-methods-form { display: flex; flex-direction: column; gap: 12px; }
.payment-row { display: flex; align-items: center; justify-content: space-between; }
.payment-label { display: flex; align-items: center; gap: 8px; font-weight: 500; width: 140px; }
.pay-input { width: 100px; padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; text-align: right; }
.payment-summary { border-top: 1px dashed var(--border-color); padding-top: 15px; margin-top: 15px; }

/* --- COMPRAS (FACTURAS) --- */
.purchase-form { display: flex; flex-direction: column; gap: 16px; }
.form-row { display: flex; gap: 16px; }
.form-group { display: flex; flex-direction: column; flex: 1; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select {
    padding: 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    outline: none; font-size: 14px;
}
.price-simulation { background: var(--light-bg); padding: 20px; border-radius: var(--radius-md); }
.sim-row { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 15px; }
.sim-divider { border-top: 1px solid #D1D5DB; margin: 15px 0; }
.text-primary { color: var(--primary-color); font-weight: 600; }
.text-success { color: var(--success); font-weight: 700; }
.text-small { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

/* --- COTIZACIONES (MODAL & PRINT) --- */
.print-header { display: flex; justify-content: space-between; border-bottom: 2px solid var(--primary-color); padding-bottom: 20px; margin-bottom: 20px; }
.print-logo i { font-size: 40px; color: var(--primary-color); vertical-align: middle; }
.print-logo h1 { display: inline-block; margin-left: 10px; color: var(--text-dark); vertical-align: middle; }
.print-company-info { font-size: 12px; color: var(--text-muted); }
.print-quote-title { text-align: right; font-size: 24px; font-weight: bold; color: var(--primary-color); }
.print-quote-title span { font-size: 16px; color: var(--text-main); font-weight: normal; }

.print-meta { display: flex; justify-content: space-between; margin-bottom: 30px; font-size: 13px; }
.print-meta-box { border: 1px solid #ccc; padding: 15px; border-radius: 4px; width: 48%; }
.text-right { text-align: right; }

.print-table { width: 100%; border-collapse: collapse; margin-bottom: 30px; font-size: 13px; }
.print-table th, .print-table td { padding: 10px; border-bottom: 1px solid #ddd; }
.print-table th { background: #f4f4f4; text-align: left; font-weight: bold; }

.print-totals { width: 300px; float: right; font-size: 14px; margin-bottom: 40px; }
.print-total-row { display: flex; justify-content: space-between; padding: 5px 0; }
.print-grand-total { border-top: 2px solid #333; border-bottom: 2px solid #333; padding: 10px 0; margin-top: 10px; font-weight: bold; font-size: 20px; color: #111; }

.print-footer { clear: both; border-top: 1px solid #ddd; padding-top: 20px; font-size: 12px; }

/* Media Query de Impresión */
@media print {
    body * {
        visibility: hidden;
    }
    #print-template, #print-template * {
        visibility: visible;
    }
    #print-template {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block !important;
        padding: 20px;
    }
    
    /* Ocultar elementos de UI */
    .sidebar, .top-header, .action-bar, .modal-overlay {
        display: none !important;
    }
    
    @page {
        margin: 0.5cm;
    }
}

/* =============================================
   BUSCADOR INTELIGENTE - MÓDULO DE VENTAS
   ============================================= */

.smart-search-box {
    margin-bottom: 10px;
}

.smart-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
    overflow: hidden;
}

.smart-search-input-wrap:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230,57,70,0.1);
}

.smart-search-icon {
    padding: 0 10px 0 14px;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.smart-search-input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    padding: 11px 6px;
    font-size: 14px;
    background: transparent;
    color: var(--text-main);
}

.smart-search-clear {
    background: none;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    font-size: 18px;
    transition: color 0.15s;
}
.smart-search-clear:hover { color: var(--danger); }

.smart-search-filters {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.smart-search-filters select {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 12px;
    background: var(--white);
    color: var(--text-main);
    cursor: pointer;
    outline: none;
}
.smart-search-filters select:focus {
    border-color: var(--primary-color);
}

/* Grid de resultados */
.sales-results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding-right: 2px;
}

.sales-results-grid::-webkit-scrollbar { width: 4px; }
.sales-results-grid::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Tarjeta de resultado */
.sales-result-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.sales-result-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.sales-card-no-stock {
    opacity: 0.55;
    background: #fafafa;
}

.sales-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}

.sales-card-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
    margin-bottom: 5px;
}

.sales-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sales-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 500;
}

.sales-tag.oem {
    background: #e8f4fd;
    color: #1565c0;
}

.sales-tag.brand {
    background: #fce4ec;
    color: #c62828;
}

.sales-tag.cat {
    background: #f3e5f5;
    color: #6a1b9a;
}

.sales-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.sales-card-sku {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.sales-card-price {
    font-size: 17px;
    font-weight: 700;
    color: var(--primary-color);
}

.sales-result-card button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #ccc;
}

/* =============================================
   BADGES DE APLICACIONES VEHICULARES
   ============================================= */

.app-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.app-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    background: #e3f2fd;
    color: #0d47a1;
    border: 1px solid #bbdefb;
    font-weight: 500;
    white-space: nowrap;
}

.app-badge-more {
    background: #fce4ec;
    color: #880e4f;
    border-color: #f8bbd0;
}

/* Filas dinámicas de aplicaciones en modal */
.app-form-row {
    display: grid;
    grid-template-columns: 2fr 2fr 1fr 1fr auto;
    gap: 6px;
    align-items: center;
}

.app-form-row input {
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}

.app-form-row input:focus {
    border-color: #1565c0;
    box-shadow: 0 0 0 2px rgba(21, 101, 192, 0.1);
}

/* =============================================
   PANEL DE FILTROS AVANZADOS (INVENTARIO)
   ============================================= */

.adv-filter-panel {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.adv-filter-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.adv-filter-search {
    position: relative;
    flex: 2;
    min-width: 220px;
}

.adv-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    pointer-events: none;
}

.adv-filter-search input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.adv-filter-search input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230,57,70,0.08);
}

.adv-filter-chips {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    flex: 3;
}

.adv-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
}

.adv-filter-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.adv-filter-group select {
    padding: 8px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s;
    background: white;
}

.adv-filter-group select:focus {
    border-color: #1565c0;
    box-shadow: 0 0 0 2px rgba(21,101,192,0.1);
}

.adv-clear-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: 1.5px solid #e0e4e8;
    border-radius: var(--radius-md);
    background: white;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    height: 38px;
}

.adv-clear-btn:hover {
    background: #fce4ec;
    border-color: var(--danger);
    color: var(--danger);
}

.adv-filter-status {
    display: none;
    font-size: 12px;
    color: #1565c0;
    background: #e3f2fd;
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 10px;
    font-weight: 500;
}

/* =============================================
   PANELES DE COMPRAS — PRODUCTO EXIST./NUEVO
   ============================================= */

.purchase-info-panel {
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 4px;
    animation: fadeSlideIn 0.2s ease;
}

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

.purchase-panel-exist {
    background: #f0fff4;
    border: 1.5px solid #a8d5b5;
}

.purchase-panel-new {
    background: #fff8e1;
    border: 1.5px solid #ffe082;
}

.purchase-panel-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.purchase-panel-exist .purchase-panel-title { color: #2e7d32; }
.purchase-panel-new  .purchase-panel-title { color: #e65100; }

.purchase-panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-bottom: 4px;
}

.pinfo-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: rgba(255,255,255,0.7);
    border-radius: 6px;
    padding: 7px 10px;
    border: 1px solid rgba(0,0,0,0.06);
}

.pinfo-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.pinfo-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
}

.purchase-recalc-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    padding-top: 10px;
    border-top: 1px dashed #b0c4b1;
}

/* =============================================
   CAMPANA DE NOTIFICACIONES
   ============================================= */

.notif-bell-wrap {
    position: relative;
}

.notif-bell-btn {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text-color);
    transition: background 0.2s;
}
.notif-bell-btn:hover { background: var(--light-bg); }

/* Animación urgente para críticas */
.notif-bell-urgent {
    animation: bellShake 0.6s infinite alternate;
    color: #d32f2f !important;
}
@keyframes bellShake {
    0%   { transform: rotate(-12deg); }
    100% { transform: rotate(12deg); }
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #d32f2f;
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    border: 2px solid var(--card-bg, #fff);
}

.notif-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 340px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    z-index: 9999;
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    border: 1px solid #eee;
    overflow: hidden;
}
@media (max-width: 480px) {
    .notif-panel {
        width: calc(100vw - 40px);
        right: -60px; /* Offset to center better on mobile */
    }
}
.notif-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-weight: 700;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}

.notif-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}
.notif-action-btn:hover { color: var(--primary-color); background: #f0f0f0; }

.notif-filter-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
    background: #fafafa;
}
.notif-tab {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
}
.notif-tab.active {
    background: var(--primary-color);
    color: #fff;
}
.notif-tab:hover:not(.active) { background: #eee; }

.notif-list {
    max-height: 320px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
    position: relative;
}
.notif-item:hover { background: #f9f9f9; }
.notif-item.notif-read { opacity: 0.6; }

.notif-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
}

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notif-item-msg {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.4;
}
.notif-item-date {
    font-size: 10px;
    color: #bbb;
    margin-top: 3px;
}
.notif-unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    margin-top: 4px;
}

/* =============================================
   MENÚ DE PERFIL
   ============================================= */

.profile-wrap {
    position: relative;
}

.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 5px 10px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.profile-btn:hover {
    border-color: #ddd;
    background: var(--light-bg);
}

.profile-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 220px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    z-index: 9999;
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    border: 1px solid #eee;
    overflow: hidden;
}
@media (max-width: 480px) {
    .profile-menu {
        width: 200px;
        right: -10px;
    }
}
.profile-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.profile-menu-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #7c3aed 100%);
    color: #fff;
}
.profile-menu-header .avatar {
    color: #fff;
    background: rgba(255,255,255,0.2);
}

.profile-menu-divider {
    height: 1px;
    background: #f0f0f0;
    margin: 4px 0;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    text-align: left;
    transition: background 0.15s;
}
.profile-menu-item:hover { background: #f5f5f5; }
.profile-menu-item i { font-size: 17px; }

.profile-menu-item-danger { color: #d32f2f !important; }
.profile-menu-item-danger:hover { background: #fff3f3 !important; }

/* Btn-small para acciones de tabla */
.btn-small {
    padding: 5px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s;
}
.btn-small:hover { opacity: 0.8; }
.btn-small.btn-outline {
    background: #f0f0f0;
    color: var(--text-color);
    border: 1px solid #ddd;
}
.btn-small.btn-success {
    background: var(--success);
    color: #fff;
}

/* badge-stock para tabla usuarios */
.badge-stock {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    display: inline-block;
}
/* --- TOAST SYSTEM --- */
#toast-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary-color);
}

.toast.show {
    transform: translateX(0);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast-warning i {
    color: var(--warning);
}

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

.toast-success i {
    color: var(--success);
}

.toast i {
    font-size: 20px;
}

.toast span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}/* --- SISTEMA DE AUTORIZACIONES Y NOTIFICACIONES --- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.notif-actions button {
    transition: transform 0.2s, background-color 0.2s;
}

.notif-actions button:hover {
    transform: translateY(-1px);
}

.notif-item.critical {
    border-left: 4px solid var(--danger);
}

.notif-item.warning {
    border-left: 4px solid var(--warning);
}

#auth-waiting-modal .modal-content {
    border-top: 4px solid var(--primary-color);
}
b o d y . m o d a l - o p e n   {   o v e r f l o w :   h i d d e n   ! i m p o r t a n t ;   }   . m o d a l - o v e r l a y . a c t i v e   {   d i s p l a y :   f l e x ;   z - i n d e x :   1 0 0 0 0 ;   }  

/* =============================================
   MEJORAS VISUALES / UX EN MÓDULO DE COMPRAS
   ============================================= */

/* 1. EFECTO HOVER (MOUSE) EN COMPRAS */
#view-purchases input:not(:disabled),
#view-purchases select:not(:disabled) {
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

#view-purchases input:not(:disabled):hover,
#view-purchases select:not(:disabled):hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

#view-purchases input:not(:disabled):focus,
#view-purchases select:not(:disabled):focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.15);
}

/* Hover en las filas del detalle de factura */
#purchase-invoice-body tr {
    transition: background-color 0.2s ease, transform 0.15s ease;
}

#purchase-invoice-body tr:hover {
    background-color: #f8fafc;
}

/* Hover y estilos del buscador autocomplete en compras */
.purchase-search-item {
    padding: 11px 15px;
    border-bottom: 1px solid #edf2f7;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    text-align: left;
}

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

.purchase-search-item:hover {
    background-color: rgba(230, 57, 70, 0.06); /* Rojo MIDVE suave */
    box-shadow: inset 4px 0 0 var(--primary-color);
}

.purchase-search-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.purchase-search-item-header strong {
    font-size: 13.5px;
    color: var(--text-main);
    font-weight: 700;
}

.purchase-search-item-brand {
    font-size: 10.5px;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

.purchase-search-item-name {
    font-size: 12px;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.purchase-search-no-results {
    padding: 14px;
    color: var(--text-muted);
    font-size: 12.5px;
    text-align: center;
}

/* 2. PRODUCTO SELECCIONADO (ANIMACIÓN GLOW EN PANEL DE PRODUCTO) */
@keyframes panelGlowPulse {
    0% {
        box-shadow: 0 0 0 0px rgba(42, 157, 143, 0.4);
        transform: scale(0.995);
    }
    50% {
        box-shadow: 0 0 18px 4px rgba(42, 157, 143, 0.3);
        transform: scale(1.006);
    }
    100% {
        box-shadow: 0 0 0 0px rgba(42, 157, 143, 0);
        transform: scale(1);
    }
}

.panel-highlight-active {
    animation: panelGlowPulse 0.85s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* 3. DETALLE DE FACTURA E ÍTEMS (HIGHLIGHT EN FILA Y CARD) */
@keyframes rowHighlightPulse {
    0% {
        background-color: rgba(42, 157, 143, 0.28);
        box-shadow: inset 0 0 10px rgba(42, 157, 143, 0.2);
    }
    100% {
        background-color: transparent;
        box-shadow: none;
    }
}

.row-highlight-active {
    animation: rowHighlightPulse 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes cardPulseSuccess {
    0% {
        transform: translateY(0) scale(1);
        box-shadow: var(--shadow-md);
    }
    25% {
        transform: translateY(-4px) scale(1.008);
        box-shadow: 0 12px 24px rgba(42, 157, 143, 0.22), 0 0 0 2px rgba(42, 157, 143, 0.2);
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: var(--shadow-md);
    }
}

.card-pulse-success-active {
    animation: cardPulseSuccess 0.9s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Estilos para el Buscador de Repuestos en Cotización */
#quote-search-results {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    border-radius: 8px;
    margin-top: 5px;
    z-index: 1050;
    width: auto;
    left: 15px;
    right: 15px;
    position: absolute;
    top: 100%;
    max-height: 350px;
    overflow-y: auto;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    background-color: #ffffff;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

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

.search-result-item:hover {
    background-color: #f8fafc;
    box-shadow: inset 4px 0 0 0 var(--primary-color);
}

.search-result-item:active {
    background-color: #f1f5f9;
}

.search-result-item .badge-sku {
    font-weight: 700;
    font-size: 11px;
    color: #475569;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.search-result-item .badge-oem {
    font-weight: 700;
    font-size: 11px;
    color: #9a3412;
    background: #ffedd5;
    border: 1px solid #fed7aa;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.03em;
}

.search-result-item .item-price {
    font-weight: 800;
    font-size: 14px;
    color: var(--primary-color);
}

.search-result-item .app-badge-normal {
    font-size: 10px;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 2px;
    display: inline-block;
}

.search-result-item .app-badge-highlight {
    font-size: 10px;
    color: #1e3a8a;
    background: #dbeafe;
    border: 1px solid #bfdbfe;
    padding: 2px 6px;
    border-radius: 4px;
    margin: 2px;
    display: inline-block;
    font-weight: 700;
    box-shadow: 0 0 4px rgba(59, 130, 246, 0.25);
}