/* ==========================================
    1. VARIABLES GLOBALES Y RESET BÁSICO
    ========================================== */
:root {
    --primary: #2563eb; 
    --secondary: #1e40af; 
    --accent: #10b981; 
    --danger: #ef4444; 
    --warning: #f59e0b;
    --bg-main: #f8fafc; 
    --bg-card: #ffffff; 
    --text-dark: #0f172a; 
    --text-muted: #64748b;
    --text-gray: #475569;
    --border: #e2e8f0; 
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1); 
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', system-ui, sans-serif; }
body { background-color: var(--bg-main); color: var(--text-dark); display: flex; height: 100vh; overflow: hidden; }

/* ==========================================
    2. SIDEBAR E INTERFAZ BASE
    ========================================== */
.sidebar { width: 280px; background: #0f172a; color: white; display: flex; flex-direction: column; overflow-y: auto; flex-shrink: 0; transition: var(--transition); border-right: 1px solid #1e293b; }
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid #1e293b; display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: bold; color: white; background: #0b1120; }
.nav-section { padding: 1.2rem 0 0.5rem 1.5rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; font-weight: bold; }
.nav-item { padding: 0.8rem 1.5rem; display: flex; align-items: center; gap: 12px; color: #94a3b8; text-decoration: none; transition: var(--transition); border-left: 4px solid transparent; font-size: 0.95rem; margin: 2px 0; }
.nav-item:hover { background: #1e293b; color: white; border-left-color: #475569; }
.nav-item.active { background: #1e293b; color: #38bdf8; border-left-color: #38bdf8; font-weight: 600; }

.main-wrapper { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 70px; background: white; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 2rem; flex-shrink: 0; box-shadow: var(--shadow-sm); z-index: 10; }
.topbar-user { display: flex; align-items: center; gap: 15px; font-weight: 600; }
.btn-logout { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer; font-weight: bold; transition: var(--transition); }
.btn-logout:hover { background: var(--danger); color: white; }

.content-area { flex: 1; padding: 2rem; overflow-y: auto; background: var(--bg-main); }
.panel { display: none; animation: fadeIn 0.3s ease; }
.panel.active { display: block; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.panel-header h2 { font-size: 1.8rem; color: #0f172a; font-weight: 800; letter-spacing: -0.5px; }
.card { background: white; border-radius: 16px; padding: 1.5rem; box-shadow: var(--shadow-sm); border: 1px solid var(--border); margin-bottom: 1.5rem; transition: var(--transition); }

/* CLASES PARA EL MENÚ HAMBURGUESA Y OVERLAY */
.btn-menu-mobile { display: none; background: transparent; border: none; color: var(--primary); cursor: pointer; padding: 5px; margin-right: 10px; }
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.5); z-index: 9998; display: none; opacity: 0; transition: opacity 0.3s ease; backdrop-filter: blur(2px); }
.sidebar-overlay.active { display: block; opacity: 1; }

/* ==========================================
    3. DASHBOARD PREMIUM
    ========================================== */
.dash-header-wrap { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; }
.dash-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.kpi-card { background: white; border-radius: 16px; padding: 1.5rem; box-shadow: 0 4px 20px rgba(0,0,0,0.03); border: 1px solid rgba(226, 232, 240, 0.8); display: flex; align-items: center; gap: 1.2rem; transition: transform 0.3s ease; position: relative; overflow: hidden; }
.kpi-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(0,0,0,0.08); border-color: #cbd5e1; }

.kpi-icon { width: 54px; height: 54px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; flex-shrink: 0; box-shadow: inset 0 2px 4px rgba(255,255,255,0.5); }
.kpi-icon.green { background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%); color: #15803d; border: 1px solid #86efac; }
.kpi-icon.blue { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); color: #1d4ed8; border: 1px solid #93c5fd; }
.kpi-icon.orange { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #b45309; border: 1px solid #fcd34d; }
.kpi-icon.purple { background: linear-gradient(135deg, #f3e8ff 0%, #e9d5ff 100%); color: #7e22ce; border: 1px solid #d8b4fe; }

.kpi-info { flex: 1; }
.kpi-title { font-size: 0.8rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.kpi-value { font-size: 2rem; font-weight: 900; color: #0f172a; line-height: 1; margin-bottom: 6px; letter-spacing: -0.5px; }
.kpi-trend { font-size: 0.8rem; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 50px; }
.trend-up { background: #ecfdf5; color: #10b981; }
.trend-down { background: #fef2f2; color: #ef4444; }
.trend-neutral { background: #f1f5f9; color: #64748b; }

.dash-main-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
@media(max-width: 1100px) { .dash-main-grid { grid-template-columns: 1fr; } }

.quick-action-btn { display: flex; align-items: center; gap: 12px; padding: 1rem 1.2rem; background: white; border: 1px solid var(--border); border-radius: 12px; color: var(--text-dark); font-weight: 600; text-decoration: none; transition: 0.2s; box-shadow: var(--shadow-sm); }
.quick-action-btn:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); transform: translateX(4px); box-shadow: var(--shadow-md); }
.quick-action-btn .icon { font-size: 1.5rem; background: #f1f5f9; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }

.stat-card { background: white; padding: 1.5rem; border-radius: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.stat-card.orange { border-left: 4px solid var(--warning); background: linear-gradient(to right, #fffbeb, #ffffff); }
.stat-card.green { border-left: 4px solid var(--accent); background: linear-gradient(to right, #ecfdf5, #ffffff); }
.stat-card.red { border-left: 4px solid var(--danger); background: linear-gradient(to right, #fef2f2, #ffffff); }
.stat-title { color: var(--text-muted); font-size: 0.9rem; font-weight: 600; text-transform: uppercase; }
.stat-value { font-size: 2rem; font-weight: 800; color: #1e293b; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }

/* ==========================================
    4. TABLAS PREMIUM
    ========================================== */
.table-responsive { overflow-x: auto; background: white; border-radius: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); width: 100%; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; }
tbody tr:hover { background: #f1f5f9; }

.table-premium { width: 100%; border-collapse: separate; border-spacing: 0 10px; margin-top: -10px; }
.table-premium th { background: transparent; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border: none; padding: 0.5rem 1.5rem; }
.table-premium tbody tr { background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: transform 0.2s ease, box-shadow 0.2s ease; border-radius: 12px;}
.table-premium tbody tr:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); z-index: 10; position: relative; background: white; }
.table-premium td { padding: 1.2rem 1.5rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); vertical-align: middle; background: white; }
.table-premium td:first-child { border-left: 1px solid var(--border); border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.table-premium td:last-child { border-right: 1px solid var(--border); border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

.badge { padding: 0.3rem 0.8rem; border-radius: 50px; font-size: 0.8rem; font-weight: bold; }
.bg-success { background: #dcfce7; color: #166534; }
.bg-warning { background: #fef3c7; color: #b45309; }
.bg-danger { background: #fee2e2; color: #b91c1c; }
.bg-info { background: #e0f2fe; color: #0369a1; }
.bg-gray { background: #f1f5f9; color: #475569; }

/* ==========================================
    5. COMPONENTES PREMIUM Y BOTONES
    ========================================== */
.btn-filter { padding: 0.5rem 1.2rem; border: none; background: transparent; border-radius: 6px; font-size: 0.9rem; font-weight: 600; color: var(--text-gray); cursor: pointer; transition: all 0.2s ease; }
.btn-filter:hover { color: var(--primary); }
.btn-filter.active { background: white; color: var(--primary); box-shadow: 0 2px 5px rgba(0,0,0,0.08); }

.btn-icon-premium { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--border); background: white; cursor: pointer; transition: all 0.2s ease; }
.btn-icon-premium svg { width: 18px; height: 18px; stroke-width: 2; }
.btn-pay { color: #10b981; } .btn-pay:hover { background: #10b981; color: white; border-color: #10b981; box-shadow: 0 4px 6px rgba(16,185,129,0.2); transform: translateY(-2px); }
.btn-edit { color: #3b82f6; } .btn-edit:hover { background: #3b82f6; color: white; border-color: #3b82f6; box-shadow: 0 4px 6px rgba(59,130,246,0.2); transform: translateY(-2px); }
.btn-delete { color: #ef4444; } .btn-delete:hover { background: #ef4444; color: white; border-color: #ef4444; box-shadow: 0 4px 6px rgba(239,68,68,0.2); transform: translateY(-2px); }

.btn-estado-premium { font-size: 0.75rem; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: 6px; border: 1px solid var(--primary); background: #eff6ff; color: var(--primary); cursor: pointer; transition: all 0.2s ease; display: inline-flex; align-items: center; gap: 6px; }
.btn-estado-premium:hover { background: var(--primary); color: white; box-shadow: 0 4px 6px rgba(37,99,235,0.2); }

.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.3px; }
.status-pendiente { background: #fef3c7; color: #d97706; }
.status-confirmada { background: #dbeafe; color: #2563eb; }
.status-completada { background: #dcfce7; color: #166534; }
.status-cancelada { background: #fee2e2; color: #b91c1c; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.dot-pendiente { background: #f59e0b; box-shadow: 0 0 5px #f59e0b; }
.dot-confirmada { background: #3b82f6; box-shadow: 0 0 5px #3b82f6; }
.dot-completada { background: #10b981; box-shadow: 0 0 5px #10b981; }
.dot-cancelada { background: #ef4444; box-shadow: 0 0 5px #ef4444; }

.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: white; padding: 1rem 1.5rem; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; color: var(--text-dark); font-weight: 600; animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards; border-left: 5px solid; }
.toast.success { border-left-color: var(--accent); } 
.toast.error { border-left-color: var(--danger); } 
.toast.warning { border-left-color: var(--warning); } 
.toast.info { border-left-color: var(--primary); }
.toast-icon { font-size: 1.2rem; }

.btn { padding: 0.6rem 1.2rem; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; font-size: 0.95rem; transition: var(--transition); display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); color: white; box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2); }
.btn-primary:hover { background: linear-gradient(135deg, var(--secondary) 0%, #1e3a8a 100%); color: white; box-shadow: 0 6px 12px rgba(37, 99, 235, 0.3); }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-dark); }
.btn-outline:hover { background: #f8fafc; border-color: var(--text-muted); }
.btn-danger { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); color: white; }
.btn-danger:hover { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); color: white; box-shadow: 0 6px 10px rgba(220, 38, 38, 0.3); }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.header-with-btn { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 2px solid #f1f5f9; padding-bottom: 0.8rem; }

/* ==========================================
    6. FORMULARIOS Y CAJAS DE TEXTO
    ========================================== */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.form-group { margin-bottom: 1rem; width: 100%; }
.form-group label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-dark); }
.form-control { width: 100%; padding: 0.8rem; border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; outline: none; transition: var(--transition); background: white; box-sizing: border-box; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.form-control:read-only { background-color: #f1f5f9; color: var(--text-muted); cursor: not-allowed; }

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

textarea.form-control { resize: vertical; min-height: 80px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 1.5rem; width: 100%; max-width: 500px; }

/* ==========================================
    7. FICHAS CLÍNICAS Y TABS INTERNOS
    ========================================== */
.ficha-tabs { display: flex; gap: 0; margin-bottom: 1rem; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.ficha-tab { padding: 1rem 1.5rem; font-size: 1.1rem; color: var(--text-muted); cursor: pointer; transition: var(--transition); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.ficha-tab:hover { color: var(--primary); }
.ficha-tab.active { color: var(--text-dark); font-weight: 600; border-bottom-color: var(--text-dark); }

.ficha-section { display: none; animation: fadeIn 0.3s ease; padding-top: 1rem; }
.ficha-section.active { display: block; }

.section-title-ficha { color: var(--primary); font-size: 1rem; font-weight: bold; margin-bottom: 1rem; }

.panel-box { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; }

.check-group { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; cursor: pointer; font-size: 0.95rem; color: var(--text-dark); }
.check-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.radio-group { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.95rem; }
.radio-group input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.table-lensometria { width: 100%; border-collapse: collapse; text-align: center; }
.table-lensometria th { font-size: 0.75rem; color: var(--text-muted); padding-bottom: 10px; border: none; background: transparent;}
.table-lensometria td { padding: 5px; border: none;}
.table-lensometria .form-control { text-align: center; }

.category-nav { display: flex; gap: 10px; overflow-x: auto; padding: 10px 0; margin-bottom: 1.5rem; }
.btn-pill-filter { padding: 0.6rem 1.5rem; border-radius: 50px; border: 1px solid var(--border); background: white; color: var(--text-dark); cursor: pointer; transition: all 0.2s ease; font-weight: 600; white-space: nowrap; font-size: 0.9rem; }
.btn-pill-filter:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.btn-pill-filter.active[data-cat="Todos"] { background: var(--text-dark); color: white; border-color: var(--text-dark); box-shadow: 0 4px 6px rgba(15,23,42,0.2); }
.btn-pill-filter.active[data-cat="Armazones"] { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 4px 6px rgba(37,99,235,0.2); }
.btn-pill-filter.active[data-cat="Lunas/Cristales"] { background: #9333ea; color: white; border-color: #9333ea; box-shadow: 0 4px 6px rgba(147,51,234,0.2); }
.btn-pill-filter.active[data-cat="Lentes Solares"] { background: #f97316; color: white; border-color: #f97316; box-shadow: 0 4px 6px rgba(249,115,22,0.2); }
.btn-pill-filter.active[data-cat="Lentes de Contacto"] { background: #0891b2; color: white; border-color: #0891b2; box-shadow: 0 4px 6px rgba(8,145,178,0.2); }
.btn-pill-filter.active[data-cat="Accesorios"] { background: var(--accent); color: white; border-color: var(--accent); box-shadow: 0 4px 6px rgba(16,185,129,0.2); }
.stock-bullet { font-size: 1.4rem; margin-right: 8px; line-height: 1; }

/* ==========================================
    8. MODALES GLOBALES
    ========================================== */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.8); display: none; justify-content: center; align-items: center; z-index: 2000; padding: 1rem; backdrop-filter: blur(4px); }
.modal-content { background: white; padding: 2rem; border-radius: 16px; width: 100%; max-width: 600px; box-shadow: var(--shadow-lg); animation: popIn 0.3s ease-out; max-height: 90vh; overflow-y: auto; }

/* Estilos de Impresión */
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area { position: absolute; left: 0; top: 0; width: 100%; border: none !important; padding: 0 !important; }
    .modal-overlay { background: transparent; position: absolute; }
    .modal-content { box-shadow: none; width: 100%; max-width: 100%; margin: 0; padding: 0; }
    .no-print { display: none !important; }
    .main-wrapper, .sidebar { display: none !important; }
}

/* ANIMACIONES CSS */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { 0% { opacity: 0; transform: scale(0.95); } 100% { opacity: 1; transform: scale(1); } }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; display: none; } }

/* ==========================================
    9. MODALES ESTILO APPLE (SEGURIDAD Y SISTEMA)
    ========================================== */
.apple-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center; z-index: 9999;
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
}
.apple-modal-overlay.active { opacity: 1; visibility: visible; }
.apple-modal {
    background: #ffffff; border-radius: 20px; padding: 30px 24px; width: 90%; max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(0.95) translateY(10px); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}
.apple-modal-overlay.active .apple-modal { transform: scale(1) translateY(0); }
.apple-modal-icon {
    width: 60px; height: 60px; background: #f1f5f9; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 1.8rem; margin: 0 auto 15px auto;
}
.apple-modal h3 { margin: 0 0 10px 0; color: #0f172a; font-size: 1.3rem; font-weight: 700; }
.apple-modal p { margin: 0 0 20px 0; color: #64748b; font-size: 0.95rem; line-height: 1.5; }
.apple-actions { display: flex; gap: 10px; margin-top: 10px; }
.apple-btn {
    flex: 1; padding: 12px 5px; border-radius: 12px; font-size: 0.95rem; font-weight: 600; cursor: pointer;
    border: none; transition: all 0.2s;
}
.apple-btn-confirm { background: #2563eb; color: white; }
.apple-btn-confirm:hover { background: #1d4ed8; }

/* ==========================================
    10. RESPONSIVIDAD (MÓVILES Y TABLETAS) BLINDADA Y OPTIMIZADA
    ========================================== */

/* TABLETS Y MÓVILES (hasta 1024px) */
@media (max-width: 1024px) {
    body { display: flex !important; flex-direction: column !important; height: 100vh !important; }
    
    .btn-menu-mobile { display: block !important; margin-right: 15px; }

    .sidebar { 
        position: fixed !important;
        top: 0 !important;
        left: -300px !important; /* Oculto por defecto */
        width: 280px !important;
        height: 100% !important;
        min-height: 100vh !important;
        flex-direction: column !important;
        background: #0f172a !important;
        z-index: 9999 !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border-right: 1px solid #1e293b !important;
        box-shadow: none !important;
        padding-top: 10px !important;
    }
    
    .sidebar.open {
        left: 0 !important;
        box-shadow: 10px 0 25px rgba(0,0,0,0.5) !important;
    }

    .sidebar-header { display: flex !important; } 
    .nav-section { display: block !important; }    
    
    .nav-item { 
        display: flex !important; 
        border-bottom: none !important; 
        border-left: 4px solid transparent !important; 
        padding: 0.8rem 1.5rem !important; 
        height: auto !important; 
        margin: 2px 0 !important; 
        align-items: center !important;
        font-size: 0.95rem !important;
    }
    .nav-item.active { border-left-color: #38bdf8 !important; background: #1e293b !important; }

    .sidebar > div[style*="padding"] { display: block !important; padding: 1.5rem !important; }
    .sidebar > div[style*="padding"] > a { margin: 0 !important; white-space: normal !important; font-size: 0.9rem !important;}

    .main-wrapper { width: 100% !important; flex: 1 !important; overflow: hidden !important; }
}

/* 📱 MÓVILES PEQUEÑOS (hasta 768px) - ESTILO APPLE OPTIMIZADO 📱 */
@media (max-width: 768px) {
    body { background-color: #f2f2f7 !important; }
    
    /* TOPBAR REESCRITO */
    .topbar { 
        padding: 8px 15px !important; 
        flex-direction: row !important; 
        height: 55px !important; 
        gap: 5px !important; 
        border-bottom: 1px solid #c6c6c8 !important; 
        box-shadow: none !important; 
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        align-items: center !important;
    }
    
    #lbl-fecha-actual { display: none !important; }
    .btn-menu-mobile { margin-right: 0 !important; }

    .topbar-user { 
        flex-direction: row !important; 
        justify-content: flex-end !important; 
        align-items: center !important; 
        flex: 1 !important; 
        gap: 5px !important;
    }
    
    .topbar-user button.btn-outline { display: none !important; }
    
    .topbar-user span { 
        font-size: 0.95rem !important; 
        font-weight: 700 !important; 
        color: #000 !important;
        text-align: right !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        padding: 0 10px !important;
        display: block !important;
        max-width: 140px;
    }
    
    .topbar-user button.btn-logout {
        width: auto !important;
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
        border-radius: 12px !important;
        background: rgba(239, 68, 68, 0.1) !important;
        color: #ef4444 !important;
        border: none !important;
        flex-shrink: 0;
        font-weight: 600 !important;
    }

    .content-area { padding: 12px !important; }
    
    /* TÍTULOS Y CABECERAS */
    h2 { font-size: 1.4rem !important; font-weight: 700 !important; letter-spacing: -0.5px !important; color: #000 !important;}
    .header-with-btn { flex-direction: column !important; align-items: flex-start !important; gap: 12px !important; border-bottom: none !important; margin-bottom: 15px !important; padding-bottom: 0 !important;}
    .header-with-btn div p { font-size: 0.85rem !important; color: #8e8e93 !important;}
    .header-with-btn button { width: 100% !important; padding: 12px !important; border-radius: 14px !important; font-size: 1rem !important; background: #007aff !important; border: none !important; box-shadow: 0 4px 10px rgba(0,122,255,0.2) !important;}
    
    /* FIX: CABECERA REPORTES FINANCIEROS (Para que el botón y los filtros no desborden la pantalla) */
    #tab-reportes .header-with-btn > div:last-child {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }
    #tab-reportes .header-with-btn > div:last-child > div {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        scrollbar-width: none;
    }
    #tab-reportes .header-with-btn > div:last-child > div::-webkit-scrollbar { display: none; }
    
    /* CARDS Y DASHBOARD */
    .card { padding: 16px !important; border-radius: 20px !important; border: none !important; box-shadow: 0 2px 12px rgba(0,0,0,0.04) !important; margin-bottom: 15px !important; background: white !important;}
    .dash-kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
    .kpi-card { padding: 15px !important; flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; border-radius: 20px !important; border: none !important; box-shadow: 0 2px 10px rgba(0,0,0,0.03) !important; background: white !important;}
    .kpi-icon { width: 36px !important; height: 36px !important; font-size: 1.1rem !important; border-radius: 10px !important; margin-bottom: 5px; }
    .kpi-value { font-size: 1.4rem !important; letter-spacing: -0.5px !important; }
    .kpi-title { font-size: 0.7rem !important; line-height: 1.1 !important; color: #8e8e93 !important; font-weight: 600 !important;}
    .kpi-trend { font-size: 0.7rem !important; padding: 4px 8px !important; border-radius: 8px !important;}

    /* 🚨 TABLAS TIPO LISTA DE IPHONE (iCloud Style) APLICADO A TODAS LAS TABLAS 🚨 */
    .table-responsive { background: transparent !important; box-shadow: none !important; border: none !important; overflow: visible !important; padding: 0 !important; margin: 0 !important; }
    
    .table-responsive table { min-width: 100% !important; margin-top: 0 !important; border-spacing: 0 !important; display: flex !important; flex-direction: column !important; gap: 12px !important; }
    .table-responsive thead { display: none !important; }
    .table-responsive tbody { display: flex !important; flex-direction: column !important; gap: 12px !important; }
    .table-responsive tbody tr { display: flex !important; flex-direction: column !important; background: white !important; border-radius: 16px !important; padding: 16px !important; margin: 0 !important; border: none !important; box-shadow: 0 1px 8px rgba(0,0,0,0.04) !important; position: relative !important; }
    
    .table-responsive tbody td { display: flex !important; flex-direction: column !important; justify-content: flex-start !important; align-items: flex-start !important; border: none !important; padding: 4px 0 !important; width: 100% !important; text-align: left !important; border-bottom: none !important; }
    .table-responsive tbody td > div { align-items: flex-start !important; text-align: left !important; width: 100% !important; }
    .table-responsive tbody td br { display: none; }
    
    .table-responsive tbody td:last-child { margin-top: 10px !important; padding-top: 12px !important; border-top: 1px solid #e5e5ea !important; flex-direction: row !important; justify-content: center !important;}
    .table-responsive tbody td:last-child > div { justify-content: space-around !important; width: 100% !important; flex-direction: row !important; }
    .table-responsive tbody td:last-child button { flex: 1; margin: 0 5px; }

    /* Ajustes específicos Pacientes */
    #tabla-pacientes tr td:nth-child(2) { order: -3; }
    #tabla-pacientes tr td:nth-child(3) { order: -2; flex-direction: row !important; gap: 10px; margin-top: 8px;}
    #tabla-pacientes tr td:nth-child(1) { order: -1; position: absolute; right: 16px; top: 16px; width: auto !important; padding: 0 !important;}
    #tabla-pacientes tr td:nth-child(1) code { background: #f2f2f7 !important; border: none !important; color: #8e8e93 !important; font-size: 0.75rem !important; border-radius: 8px !important;}
    
    /* Ajustes específicos Órdenes */
    #tabla-pedidos-global tr td:nth-child(1) { padding-bottom: 10px !important; border-bottom: 1px dashed #e2e8f0 !important; margin-bottom: 5px !important; }
    #tabla-pedidos-global tr td:nth-child(3) > div { flex-direction: row !important; align-items: center !important; justify-content: space-between !important; }
    
    /* Ajustes específicos Inventario */
    #tabla-inventario tr td:nth-child(4) { flex-direction: row !important; justify-content: space-between !important; align-items: center !important; background: #f8fafc !important; padding: 10px !important; border-radius: 8px !important; margin-top: 5px !important; }

    /* 🚨 FIX: BUSCADOR ESTILO APPLE Y SUPERPOSICIÓN DE LA LUPA 🚨 */
    .search-bar { max-width: 100% !important; margin-bottom: 15px !important; }
    
    /* Regla súper estricta para asegurar que ninguna caja de texto con lupa pierda su margen izquierdo */
    input#search-paciente, 
    input#search-citas, 
    input#search-pedidos-global, 
    input#search-inventario, 
    input#inputBusquedaPacCita, 
    input#inputBusquedaProd, 
    input#inputBusquedaCat,
    input#search-fichas-perfil,
    input#search-pedidos-perfil,
    div[style*="position: relative"] > input.form-control { 
        padding-left: 45px !important; 
        border-radius: 12px !important; 
        background: #e3e3e8 !important; 
        border: none !important; 
        height: 40px !important; 
        box-shadow: none !important; 
        color: #000 !important;
    }
    
    .search-bar input::placeholder { color: #8e8e93 !important; }
    .search-bar span { color: #8e8e93 !important; }
    
    /* Ajuste contenedor buscador y filtros (Órdenes y Citas) para que no se aprieten */
    div[style*="display: flex; gap: 15px; margin-bottom: 1.5rem; align-items: center; flex-wrap: wrap;"] {
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 15px !important;
    }
    div[style*="display: flex; gap: 15px; margin-bottom: 1.5rem; align-items: center; flex-wrap: wrap;"] > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Contenedor de los botones de filtro (Todas, Pendientes, etc) */
    div[style*="background: #f1f5f9; padding: 4px; border-radius: 8px; border: 1px solid var(--border); margin-left: auto;"] {
        margin-left: 0 !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        scrollbar-width: none;
    }
    div[style*="background: #f1f5f9; padding: 4px; border-radius: 8px; border: 1px solid var(--border); margin-left: auto;"]::-webkit-scrollbar { display: none; }

    /* Filtros Píldora Generales */
    div[style*="overflow-x: auto"] { margin-bottom: 10px; padding-bottom: 5px; border: none !important; background: transparent !important; flex-wrap: nowrap !important; overflow-x: auto !important; -webkit-overflow-scrolling: touch; scrollbar-width: none;}
    div[style*="overflow-x: auto"]::-webkit-scrollbar { display: none; }
    .btn-filter { background: white !important; border-radius: 16px !important; box-shadow: 0 1px 4px rgba(0,0,0,0.05) !important; white-space: nowrap !important; border: none !important; padding: 8px 16px !important; color: #8e8e93 !important;}
    .btn-filter.active { background: #007aff !important; color: white !important; font-weight: 600 !important;}

    div[style*="background: #e0f2fe"] { background: white !important; border-radius: 20px !important; border: none !important; flex-direction: column !important; align-items: stretch !important; gap: 15px !important; padding: 1.2rem !important; box-shadow: 0 2px 12px rgba(0,0,0,0.04) !important;}
    div[style*="background: #e0f2fe"] > div { flex-direction: row !important; align-items: center !important; text-align: left !important; }
    div[style*="background: #e0f2fe"] h3 { color: #000 !important; }
    div[style*="background: #e0f2fe"] p { color: #8e8e93 !important; }
    div[style*="background: #e0f2fe"] button { width: 100% !important; background: #f2f2f7 !important; color: #007aff !important; border: none !important; border-radius: 12px !important; font-weight: 600 !important;}

    /* 🚨 FIX: TABLAS DE REFRACCIÓN Y LENSOMETRÍA (Evitar que se aplaste, Permitir Scroll) 🚨 */
    .table-lensometria { display: block !important; overflow-x: auto !important; white-space: nowrap !important; -webkit-overflow-scrolling: touch;}
    .table-lensometria tbody { display: table-row-group !important; }
    .table-lensometria tbody tr { display: table-row !important; padding: 0 !important; border: none !important; box-shadow: none !important; background: transparent !important;}
    .table-lensometria tbody td { display: table-cell !important; padding: 5px !important; }

    /* Cuadrícula de Refracción Subjetiva Ficha Médica */
    #f-refraccion div[style*="grid-template-columns: 40px 80px"] {
        display: grid !important;
        grid-template-columns: 40px 70px 75px 75px 75px 75px 75px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 10px;
    }
    #f-refraccion div[style*="grid-template-columns: 40px 80px"]::-webkit-scrollbar { display: none; }
    
    /* Refracción miniatura en el Historial del paciente */
    td > div[style*="grid-template-columns: 35px"] {
        display: grid !important;
        grid-template-columns: 35px 45px 45px 45px 45px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* 📱 MÓVILES PEQUEÑOS Y MODALES (hasta 480px) 📱 */
@media (max-width: 480px) {
    .ficha-tabs { flex-direction: row !important; flex-wrap: nowrap !important; overflow-x: auto !important; padding-bottom: 10px !important; -webkit-overflow-scrolling: touch; border-bottom: none !important; margin-bottom: 10px !important; scrollbar-width: none;}
    .ficha-tabs::-webkit-scrollbar { display: none; }
    .ficha-tab { border: none !important; background: white !important; border-radius: 16px !important; box-shadow: 0 1px 5px rgba(0,0,0,0.05) !important; white-space: nowrap !important; padding: 10px 16px !important; margin-right: 10px !important; font-size: 0.9rem !important; color: #8e8e93 !important;}
    .ficha-tab.active { background: #007aff !important; color: white !important; font-weight: bold !important; }
    
    .modal-content { padding: 1.5rem !important; margin: 15px !important; width: auto !important; border-radius: 24px !important; }
    .modal-content h2 { font-size: 1.3rem !important; }
    
    .form-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
    
    /* Aplicar borde redondeado y padding a los inputs normales, EXCEPTO a los que son buscadores para no borrarles el margen izquierdo de la lupa */
    .form-control:not([id*="search"]):not([id*="Busqueda"]) { 
        border-radius: 12px !important; 
        background: #f2f2f7 !important; 
        border: none !important; 
        padding: 12px !important;
    }
    
    .form-group label { color: #8e8e93 !important; font-size: 0.8rem !important;}
}


/* ==========================================
   SIDEBAR FUTURISTA + COLAPSABLE + MARCA DINÁMICA
   Se agrega al final para no romper la lógica existente.
   ========================================== */
:root {
    --sidebar-wide: 292px;
    --sidebar-mini: 84px;
    --sidebar-bg-a: #020617;
    --sidebar-bg-b: #0f172a;
    --sidebar-line: rgba(148, 163, 184, 0.16);
    --sidebar-glow: rgba(56, 189, 248, 0.28);
}

.sidebar.futuristic-sidebar {
    width: var(--sidebar-wide);
    background:
        radial-gradient(circle at 12% 0%, rgba(59, 130, 246, 0.32), transparent 32%),
        radial-gradient(circle at 100% 18%, rgba(14, 165, 233, 0.18), transparent 30%),
        linear-gradient(180deg, var(--sidebar-bg-a) 0%, var(--sidebar-bg-b) 46%, #020617 100%);
    border-right: 1px solid var(--sidebar-line);
    box-shadow: 18px 0 45px rgba(15, 23, 42, 0.18);
    position: relative;
    overflow-x: hidden;
    transition: width .28s cubic-bezier(.4, 0, .2, 1), box-shadow .28s ease;
}

.sidebar.futuristic-sidebar::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, rgba(255,255,255,0.035), transparent 34%),
        repeating-linear-gradient(180deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 44px);
    opacity: .72;
}

.sidebar.futuristic-sidebar::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg, transparent, rgba(56,189,248,.65), transparent);
    opacity: .85;
}

.sidebar.futuristic-sidebar > * {
    position: relative;
    z-index: 1;
}

.sidebar.futuristic-sidebar .sidebar-header {
    min-height: 92px;
    padding: 1.15rem 1rem 1rem 1.05rem;
    background: rgba(2, 6, 23, .36);
    border-bottom: 1px solid var(--sidebar-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.brand-wrap {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: .82rem;
}

.brand-logo-shell {
    width: 48px;
    height: 48px;
    border-radius: 17px;
    background:
        linear-gradient(145deg, rgba(56,189,248,.22), rgba(37,99,235,.10)),
        rgba(15,23,42,.86);
    border: 1px solid rgba(125, 211, 252, .26);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,.12),
        0 12px 28px rgba(14,165,233,.16);
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
}

.brand-logo-shell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: white;
}

.brand-logo-fallback {
    font-size: 1.45rem;
    filter: drop-shadow(0 6px 12px rgba(56,189,248,.24));
}

.brand-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.brand-name {
    color: #f8fafc;
    font-size: 1.13rem;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: -.03em;
    max-width: 172px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.brand-subtitle {
    color: #7dd3fc;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .9;
}

.sidebar-collapse-btn {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(125, 211, 252, .18);
    background: rgba(15, 23, 42, .74);
    color: #bae6fd;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform .2s ease, background .2s ease, border-color .2s ease, color .2s ease;
    flex: 0 0 auto;
}

.sidebar-collapse-btn:hover {
    background: rgba(37, 99, 235, .26);
    border-color: rgba(125, 211, 252, .45);
    color: #ffffff;
    transform: translateY(-1px);
}

.nav-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .9rem .7rem 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(125,211,252,.35) transparent;
}

.nav-scroll-area::-webkit-scrollbar { width: 6px; }
.nav-scroll-area::-webkit-scrollbar-thumb {
    background: rgba(125,211,252,.35);
    border-radius: 999px;
}

.sidebar.futuristic-sidebar .nav-section {
    padding: 1rem .65rem .45rem;
    color: #718096;
    font-size: .69rem;
    letter-spacing: .14em;
    font-weight: 900;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar.futuristic-sidebar .nav-section span {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}

.sidebar.futuristic-sidebar .nav-section span::before {
    content: "";
    width: 16px;
    height: 1px;
    background: linear-gradient(90deg, rgba(56,189,248,.72), transparent);
    display: inline-block;
}

.sidebar.futuristic-sidebar .nav-item,
.sidebar.futuristic-sidebar .optotipo-action {
    position: relative;
    display: flex;
    align-items: center;
    gap: .8rem;
    min-height: 46px;
    padding: .74rem .82rem;
    margin: .18rem 0;
    border-radius: 15px;
    border: 1px solid transparent;
    border-left: 1px solid transparent;
    color: #a6b4c8;
    background: transparent;
    text-decoration: none;
    font-size: .95rem;
    font-weight: 700;
    transition:
        background .22s ease,
        color .22s ease,
        border-color .22s ease,
        transform .22s ease,
        box-shadow .22s ease;
}

.sidebar.futuristic-sidebar .nav-item::before,
.sidebar.futuristic-sidebar .optotipo-action::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 15px;
    background: linear-gradient(90deg, rgba(56,189,248,.18), transparent 62%);
    opacity: 0;
    transition: opacity .22s ease;
    pointer-events: none;
}

.sidebar.futuristic-sidebar .nav-icon {
    width: 31px;
    height: 31px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    flex: 0 0 31px;
    background: rgba(148, 163, 184, .10);
    border: 1px solid rgba(148, 163, 184, .12);
    font-size: 1.05rem;
    transition: transform .22s ease, background .22s ease, border-color .22s ease;
}

.sidebar.futuristic-sidebar .nav-label {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.futuristic-sidebar .nav-item:hover,
.sidebar.futuristic-sidebar .optotipo-action:hover {
    color: #f8fafc;
    background: rgba(15, 23, 42, .58);
    border-color: rgba(125, 211, 252, .16);
    transform: translateX(3px);
}

.sidebar.futuristic-sidebar .nav-item:hover::before,
.sidebar.futuristic-sidebar .optotipo-action:hover::before {
    opacity: 1;
}

.sidebar.futuristic-sidebar .nav-item:hover .nav-icon,
.sidebar.futuristic-sidebar .optotipo-action:hover .nav-icon {
    background: rgba(56, 189, 248, .16);
    border-color: rgba(125, 211, 252, .32);
    transform: scale(1.04);
}

.sidebar.futuristic-sidebar .nav-item.active {
    color: #ffffff;
    background:
        linear-gradient(90deg, rgba(37, 99, 235, .70), rgba(14, 165, 233, .26)),
        rgba(15, 23, 42, .80);
    border-color: rgba(125, 211, 252, .36);
    box-shadow:
        0 12px 30px rgba(37, 99, 235, .20),
        inset 0 1px 0 rgba(255,255,255,.12);
    font-weight: 900;
}

.sidebar.futuristic-sidebar .nav-item.active::after {
    content: "";
    position: absolute;
    right: 10px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #67e8f9;
    box-shadow: 0 0 16px rgba(103,232,249,.95);
}

.sidebar.futuristic-sidebar .nav-item.active .nav-icon {
    background: rgba(255, 255, 255, .16);
    border-color: rgba(255, 255, 255, .24);
}

.sidebar-footer-action {
    padding: .85rem .85rem 1rem;
    border-top: 1px solid var(--sidebar-line);
    background: rgba(2, 6, 23, .42);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.sidebar.futuristic-sidebar .optotipo-action {
    justify-content: flex-start;
    background:
        linear-gradient(135deg, rgba(16,185,129,.22), rgba(37,99,235,.20)),
        rgba(15,23,42,.76);
    border-color: rgba(125, 211, 252, .20);
    color: #e0f2fe;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

/* Estado colapsado en escritorio */
body.sidebar-collapsed .sidebar.futuristic-sidebar {
    width: var(--sidebar-mini);
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .nav-section span {
    opacity: 0;
    width: 0;
    max-width: 0;
    overflow: hidden;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .sidebar-header {
    padding-left: .8rem;
    padding-right: .62rem;
    justify-content: center;
    gap: .35rem;
    flex-direction: column;
}

body.sidebar-collapsed .brand-logo-shell {
    width: 44px;
    height: 44px;
    border-radius: 15px;
}

body.sidebar-collapsed .sidebar-collapse-btn .collapse-icon {
    transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-collapse-btn {
    width: 30px;
    height: 30px;
    border-radius: 10px;
}

body.sidebar-collapsed .nav-scroll-area {
    padding-left: .55rem;
    padding-right: .55rem;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-section {
    padding: .72rem 0 .32rem;
    text-align: center;
    height: 18px;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-section::after {
    content: "";
    display: block;
    width: 28px;
    height: 1px;
    margin: 0 auto;
    background: linear-gradient(90deg, transparent, rgba(125,211,252,.42), transparent);
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item,
body.sidebar-collapsed .sidebar.futuristic-sidebar .optotipo-action {
    justify-content: center;
    padding: .72rem .3rem;
    gap: 0;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item.active::after {
    right: 7px;
}

body.sidebar-collapsed .sidebar-footer-action {
    padding-left: .55rem;
    padding-right: .55rem;
}

/* Blindaje móvil: mantiene drawer normal y evita colapsado dentro del celular/tablet */
@media (max-width: 1024px) {
    .sidebar.futuristic-sidebar {
        width: 280px !important;
        left: -300px !important;
        background:
            radial-gradient(circle at 12% 0%, rgba(59, 130, 246, 0.32), transparent 32%),
            linear-gradient(180deg, #020617 0%, #0f172a 55%, #020617 100%) !important;
    }

    .sidebar.futuristic-sidebar.open {
        left: 0 !important;
    }

    .sidebar-collapse-btn {
        display: none !important;
    }

    body.sidebar-collapsed .sidebar.futuristic-sidebar {
        width: 280px !important;
    }

    body.sidebar-collapsed .brand-copy,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .nav-section span {
        opacity: 1 !important;
        width: auto !important;
        max-width: none !important;
        overflow: visible !important;
        pointer-events: auto !important;
    }

    body.sidebar-collapsed .sidebar.futuristic-sidebar .sidebar-header {
        min-height: 82px !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        padding: 1rem !important;
    }

    body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item,
    body.sidebar-collapsed .sidebar.futuristic-sidebar .optotipo-action {
        justify-content: flex-start !important;
        gap: .8rem !important;
        padding: .74rem .82rem !important;
    }

    .sidebar.futuristic-sidebar .sidebar-header { display: flex !important; }
    .sidebar.futuristic-sidebar .nav-section { display: block !important; }
    .sidebar.futuristic-sidebar .nav-item { display: flex !important; }
}

/* Ajuste de impresión: el menú se oculta como antes */
@media print {
    .sidebar.futuristic-sidebar,
    .sidebar-collapse-btn {
        display: none !important;
    }
}


/* ==========================================================
   SIDEBAR PROFESIONAL V2 - 2026-05-25
   Cambio visual solamente. No altera lógica, IDs, onclicks,
   permisos, sincronización ni estructura de datos.
   ========================================================== */
:root {
    --sidebar-pro-width: 292px;
    --sidebar-pro-mini: 82px;
    --sidebar-pro-bg: #07111f;
    --sidebar-pro-bg-2: #0b1628;
    --sidebar-pro-surface: rgba(255, 255, 255, .055);
    --sidebar-pro-surface-hover: rgba(255, 255, 255, .085);
    --sidebar-pro-border: rgba(148, 163, 184, .16);
    --sidebar-pro-border-strong: rgba(125, 211, 252, .34);
    --sidebar-pro-text: #d7e2f2;
    --sidebar-pro-muted: #8fa1b7;
    --sidebar-pro-soft: #64748b;
    --sidebar-pro-accent: #38bdf8;
    --sidebar-pro-accent-2: #2563eb;
}

.sidebar.futuristic-sidebar {
    width: var(--sidebar-pro-width) !important;
    background:
        radial-gradient(circle at 12% 0%, rgba(56, 189, 248, .13), transparent 28%),
        radial-gradient(circle at 100% 18%, rgba(37, 99, 235, .11), transparent 30%),
        linear-gradient(180deg, var(--sidebar-pro-bg) 0%, var(--sidebar-pro-bg-2) 52%, #060b16 100%) !important;
    border-right: 1px solid var(--sidebar-pro-border) !important;
    box-shadow: 18px 0 44px rgba(2, 6, 23, .28);
    color: var(--sidebar-pro-text);
}

.sidebar.futuristic-sidebar::before {
    opacity: .45 !important;
}

.sidebar.futuristic-sidebar .sidebar-header {
    min-height: 92px !important;
    padding: 1.05rem 1rem !important;
    background: rgba(2, 6, 23, .36) !important;
    border-bottom: 1px solid var(--sidebar-pro-border) !important;
    box-shadow: none !important;
    gap: .7rem !important;
}

.sidebar.futuristic-sidebar .brand-wrap {
    min-width: 0;
    gap: .78rem !important;
}

.sidebar.futuristic-sidebar .brand-logo-shell {
    width: 54px !important;
    height: 54px !important;
    border-radius: 18px !important;
    background:
        linear-gradient(180deg, rgba(255,255,255,.94), rgba(226,232,240,.98)) !important;
    border: 1px solid rgba(255,255,255,.28) !important;
    box-shadow:
        0 14px 26px rgba(2, 6, 23, .24),
        inset 0 1px 0 rgba(255,255,255,.86) !important;
    overflow: hidden;
}

.sidebar.futuristic-sidebar .brand-logo-shell img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    padding: 3px !important;
}

.sidebar.futuristic-sidebar .brand-logo-fallback {
    font-size: 1.45rem !important;
}

.sidebar.futuristic-sidebar .brand-copy {
    min-width: 0;
}

.sidebar.futuristic-sidebar .brand-name {
    color: #f8fafc !important;
    font-size: 1.2rem !important;
    line-height: 1.05 !important;
    font-weight: 900 !important;
    letter-spacing: -.02em !important;
    text-transform: uppercase;
    max-width: 155px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.futuristic-sidebar .brand-subtitle {
    color: var(--sidebar-pro-accent) !important;
    font-size: .72rem !important;
    font-weight: 800 !important;
    letter-spacing: .16em !important;
    text-transform: uppercase !important;
    margin-top: .28rem !important;
}

.sidebar-collapse-btn {
    width: 38px !important;
    height: 38px !important;
    border-radius: 14px !important;
    border: 1px solid var(--sidebar-pro-border-strong) !important;
    background: rgba(15, 23, 42, .68) !important;
    color: #e0f2fe !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.08) !important;
}

.sidebar-collapse-btn:hover {
    background: rgba(37, 99, 235, .22) !important;
    border-color: rgba(125, 211, 252, .58) !important;
    transform: translateY(-1px) !important;
}

.nav-scroll-area {
    padding: .78rem .72rem 1rem !important;
}

.sidebar.futuristic-sidebar .nav-section {
    padding: 1rem .65rem .42rem !important;
    color: var(--sidebar-pro-muted) !important;
    font-size: .68rem !important;
    letter-spacing: .15em !important;
    font-weight: 850 !important;
}

.sidebar.futuristic-sidebar .nav-section span::before {
    width: 18px !important;
    background: linear-gradient(90deg, var(--sidebar-pro-accent), transparent) !important;
    opacity: .72 !important;
}

.sidebar.futuristic-sidebar .nav-item,
.sidebar.futuristic-sidebar .optotipo-action {
    min-height: 48px !important;
    padding: .7rem .78rem !important;
    margin: .18rem 0 !important;
    border-radius: 14px !important;
    border: 1px solid transparent !important;
    color: #b7c5d8 !important;
    background: transparent !important;
    font-size: .95rem !important;
    font-weight: 740 !important;
    letter-spacing: -.01em !important;
    box-shadow: none !important;
}

.sidebar.futuristic-sidebar .nav-item::before,
.sidebar.futuristic-sidebar .optotipo-action::before {
    border-radius: 14px !important;
    background: linear-gradient(90deg, rgba(56, 189, 248, .12), rgba(37, 99, 235, .035) 65%, transparent) !important;
}

.sidebar.futuristic-sidebar .nav-icon {
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
    border-radius: 12px !important;
    background: rgba(148, 163, 184, .105) !important;
    border: 1px solid rgba(148, 163, 184, .16) !important;
    font-size: 1rem !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04) !important;
}

.sidebar.futuristic-sidebar .nav-label {
    color: inherit;
    line-height: 1.15;
}

.sidebar.futuristic-sidebar .nav-item:hover,
.sidebar.futuristic-sidebar .optotipo-action:hover {
    color: #f8fafc !important;
    background: var(--sidebar-pro-surface-hover) !important;
    border-color: var(--sidebar-pro-border) !important;
    transform: translateX(2px) !important;
}

.sidebar.futuristic-sidebar .nav-item:hover .nav-icon,
.sidebar.futuristic-sidebar .optotipo-action:hover .nav-icon {
    background: rgba(56, 189, 248, .12) !important;
    border-color: rgba(125, 211, 252, .28) !important;
    transform: none !important;
}

.sidebar.futuristic-sidebar .nav-item.active {
    color: #ffffff !important;
    background:
        linear-gradient(90deg, rgba(37, 99, 235, .82), rgba(14, 165, 233, .18)),
        rgba(15, 23, 42, .78) !important;
    border-color: rgba(125, 211, 252, .38) !important;
    box-shadow:
        0 10px 24px rgba(37, 99, 235, .18),
        inset 3px 0 0 rgba(125, 211, 252, .95),
        inset 0 1px 0 rgba(255,255,255,.09) !important;
    font-weight: 850 !important;
}

.sidebar.futuristic-sidebar .nav-item.active::after {
    right: 12px !important;
    width: 6px !important;
    height: 6px !important;
    background: #7dd3fc !important;
    box-shadow: 0 0 0 4px rgba(125, 211, 252, .12) !important;
}

.sidebar.futuristic-sidebar .nav-item.active .nav-icon {
    background: rgba(255, 255, 255, .14) !important;
    border-color: rgba(255, 255, 255, .24) !important;
}

.sidebar-footer-action {
    padding: .85rem .82rem 1rem !important;
    background: linear-gradient(180deg, rgba(2,6,23,.10), rgba(2,6,23,.42)) !important;
    border-top: 1px solid var(--sidebar-pro-border) !important;
    box-shadow: 0 -12px 28px rgba(2, 6, 23, .20);
}

.sidebar.futuristic-sidebar .optotipo-action {
    background:
        linear-gradient(135deg, rgba(20, 184, 166, .18), rgba(37, 99, 235, .16)),
        rgba(15,23,42,.68) !important;
    border-color: rgba(125, 211, 252, .22) !important;
    color: #e6f7ff !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar {
    width: var(--sidebar-pro-mini) !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .sidebar-header {
    min-height: 96px !important;
    padding: .78rem .56rem !important;
    justify-content: center !important;
    gap: .48rem !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .brand-logo-shell {
    width: 46px !important;
    height: 46px !important;
    border-radius: 16px !important;
}

body.sidebar-collapsed .sidebar-collapse-btn {
    width: 32px !important;
    height: 32px !important;
    border-radius: 12px !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item,
body.sidebar-collapsed .sidebar.futuristic-sidebar .optotipo-action {
    justify-content: center !important;
    min-height: 46px !important;
    padding: .62rem .26rem !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-icon {
    width: 36px !important;
    height: 36px !important;
    flex-basis: 36px !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item.active {
    box-shadow:
        0 8px 20px rgba(37, 99, 235, .18),
        inset 0 0 0 1px rgba(125, 211, 252, .24) !important;
}

body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item.active::after {
    right: 8px !important;
    top: 10px !important;
}

@media (max-width: 1024px) {
    .sidebar.futuristic-sidebar {
        width: min(88vw, 318px) !important;
        left: calc(-1 * min(88vw, 318px) - 24px) !important;
        box-shadow: 22px 0 50px rgba(2, 6, 23, .44) !important;
    }

    .sidebar.futuristic-sidebar.open {
        left: 0 !important;
    }

    .sidebar.futuristic-sidebar .sidebar-header {
        min-height: 86px !important;
        padding: .95rem !important;
    }

    .sidebar.futuristic-sidebar .brand-name {
        max-width: 180px !important;
    }

    body.sidebar-collapsed .sidebar.futuristic-sidebar {
        width: min(88vw, 318px) !important;
    }

    body.sidebar-collapsed .sidebar.futuristic-sidebar .nav-item,
    body.sidebar-collapsed .sidebar.futuristic-sidebar .optotipo-action {
        min-height: 48px !important;
    }
}

@media print {
    .sidebar.futuristic-sidebar,
    .sidebar-collapse-btn,
    .sidebar-footer-action {
        display: none !important;
    }
}



/* ==========================================
   REPORTE PDF DE ÓRDENES DE TRABAJO
   ========================================== */
.ordenes-reporte-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    border: 1px solid #bfdbfe;
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.ordenes-reporte-info {
    min-width: 240px;
    flex: 1;
}

.ordenes-reporte-title {
    color: var(--text-dark);
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.ordenes-reporte-sub {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.ordenes-reporte-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.ordenes-reporte-controls .form-control {
    width: auto;
    min-width: 170px;
    height: 42px;
    margin: 0;
    background: white;
}

.ordenes-reporte-controls .btn {
    height: 42px;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .ordenes-reporte-card {
        align-items: stretch;
    }

    .ordenes-reporte-controls {
        width: 100%;
        justify-content: stretch;
    }

    .ordenes-reporte-controls .form-control,
    .ordenes-reporte-controls .btn {
        width: 100%;
    }
}


/* ==========================================
   REDISEÑO PROFESIONAL - AGENDA DE CITAS
   Conserva IDs y eventos originales del módulo.
   ========================================== */
#tab-citas.agenda-panel {
    animation: fadeIn 0.28s ease;
}

.agenda-hero {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 1.25rem;
    margin-bottom: 1.35rem;
    padding: 1.65rem;
    border-radius: 24px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 52%, #eff6ff 100%);
    border: 1px solid rgba(191, 219, 254, 0.85);
    box-shadow: 0 20px 55px rgba(15, 23, 42, 0.07);
    position: relative;
    overflow: hidden;
}
.agenda-hero::after {
    content: "";
    position: absolute;
    right: -80px;
    bottom: -100px;
    width: 230px;
    height: 230px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    pointer-events: none;
}
.agenda-hero-copy { position: relative; z-index: 1; max-width: 760px; }
.agenda-eyebrow {
    display: inline-flex;
    margin-bottom: 0.55rem;
    color: #2563eb;
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.agenda-hero h2 {
    margin: 0;
    color: #0f172a;
    font-size: clamp(1.9rem, 3vw, 2.75rem);
    line-height: 1;
    font-weight: 950;
    letter-spacing: -0.055em;
}
.agenda-hero p {
    margin-top: 0.72rem;
    color: #64748b;
    font-size: 1rem;
    line-height: 1.55;
    font-weight: 560;
}
.agenda-hero-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 210px;
    position: relative;
    z-index: 1;
}
.agenda-primary-btn {
    min-height: 50px;
    border-radius: 15px !important;
    padding: 0.85rem 1.25rem !important;
    font-size: 1rem !important;
    box-shadow: 0 16px 34px rgba(37, 99, 235, 0.25) !important;
}
.agenda-primary-btn span { font-weight: 950; }

.agenda-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.agenda-kpi-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 124px;
    padding: 1.15rem;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid rgba(226, 232, 240, 0.95);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.055);
    position: relative;
    overflow: hidden;
}
.agenda-kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: #2563eb;
}
.agenda-kpi-icon {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.55rem;
    flex: 0 0 54px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
}
.agenda-kpi-title {
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.055em;
}
.agenda-kpi-value {
    color: #0f172a;
    font-size: 2rem;
    line-height: 1;
    font-weight: 950;
    margin: 0.35rem 0;
}
.agenda-kpi-sub { color: #94a3b8; font-size: 0.84rem; font-weight: 650; }
.agenda-kpi-blue::before { background: #2563eb; }
.agenda-kpi-blue .agenda-kpi-icon { background: #eff6ff; border-color: #bfdbfe; }
.agenda-kpi-orange::before { background: #f59e0b; }
.agenda-kpi-orange .agenda-kpi-icon { background: #fffbeb; border-color: #fde68a; }
.agenda-kpi-green::before { background: #10b981; }
.agenda-kpi-green .agenda-kpi-icon { background: #ecfdf5; border-color: #a7f3d0; }
.agenda-kpi-red::before { background: #ef4444; }
.agenda-kpi-red .agenda-kpi-icon { background: #fef2f2; border-color: #fecaca; }

.agenda-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 315px;
    gap: 1.25rem;
    align-items: start;
}
.agenda-board,
.agenda-side-panel {
    min-width: 0;
}
.agenda-board {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 22px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.055);
    overflow: hidden;
}
.agenda-toolbar-pro {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    border-bottom: 1px solid #e2e8f0;
}
.agenda-search-box {
    position: relative;
    flex: 1;
    max-width: 470px;
}
.agenda-search-box span {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.05rem;
    color: #94a3b8;
    pointer-events: none;
}
.agenda-search-box input#search-citas {
    height: 48px !important;
    padding-left: 44px !important;
    border-radius: 16px !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.7) !important;
    color: #0f172a !important;
    font-size: 0.98rem !important;
}
.agenda-search-box input#search-citas:focus {
    background: #ffffff !important;
    border-color: #93c5fd !important;
    box-shadow: 0 0 0 4px rgba(37,99,235,0.10) !important;
}
.agenda-filter-group {
    display: flex;
    gap: 6px;
    padding: 5px;
    border-radius: 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    overflow-x: auto;
    max-width: 100%;
}
.agenda-filter-group .btn-filter {
    min-height: 38px;
    border-radius: 12px !important;
    padding: 0.45rem 0.85rem !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #475569 !important;
    border: none !important;
    white-space: nowrap;
}
.agenda-filter-group .btn-filter.active {
    background: #ffffff !important;
    color: #2563eb !important;
    box-shadow: 0 6px 16px rgba(15,23,42,0.08) !important;
}
.agenda-table-shell {
    overflow-x: auto;
    padding: 0.5rem 0.75rem 1rem;
}
.agenda-table {
    border-collapse: separate !important;
    border-spacing: 0 10px !important;
}
.agenda-table thead th {
    background: transparent !important;
    border-bottom: none !important;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.055em;
    padding: 0.75rem 1rem !important;
}
.agenda-table tbody tr.agenda-row {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 6px 18px rgba(15,23,42,0.045);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.agenda-table tbody tr.agenda-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(15,23,42,0.08);
    background: #ffffff;
}
.agenda-table tbody tr.agenda-row td {
    padding: 1rem !important;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}
.agenda-table tbody tr.agenda-row td:first-child {
    border-left: 1px solid #e2e8f0;
    border-radius: 18px 0 0 18px;
}
.agenda-table tbody tr.agenda-row td:last-child {
    border-right: 1px solid #e2e8f0;
    border-radius: 0 18px 18px 0;
}
.agenda-date-block { display: flex; flex-direction: column; gap: 0.45rem; }
.agenda-date-main { color: #0f172a; font-weight: 900; }
.agenda-time-chip {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.28rem 0.55rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 0.8rem;
    font-weight: 850;
}
.agenda-patient-cell {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.agenda-avatar {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    object-fit: cover;
    border: 2px solid #f1f5f9;
    box-shadow: 0 8px 16px rgba(15,23,42,0.08);
    flex-shrink: 0;
}
.agenda-patient-cell strong {
    display: block;
    color: #0f172a;
    font-size: 0.98rem;
    font-weight: 900;
}
.agenda-patient-cell small {
    display: block;
    margin-top: 0.18rem;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 600;
}
.agenda-motivo-cell span {
    display: inline-flex;
    padding: 0.45rem 0.65rem;
    border-radius: 12px;
    background: #f8fafc;
    color: #334155;
    font-weight: 720;
    line-height: 1.35;
}
.agenda-actions-cell {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
.agenda-actions-cell .btn-icon-premium {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}
.agenda-action-complete { background: #ecfdf5 !important; color: #10b981 !important; border-color: #a7f3d0 !important; }
.agenda-action-edit { background: #eff6ff !important; border-color: #bfdbfe !important; color: #2563eb !important; }
.agenda-action-delete { background: #fef2f2 !important; border-color: #fecaca !important; color: #ef4444 !important; }
.agenda-empty-row td { background: transparent !important; border: none !important; }
.agenda-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 190px;
    color: #64748b;
    text-align: center;
}
.agenda-empty-icon {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    border-radius: 22px;
    background: #eff6ff;
    font-size: 2rem;
}
.agenda-empty-state strong { color: #0f172a; font-size: 1.05rem; }
.agenda-empty-state span { margin-top: 0.25rem; }

.agenda-side-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.agenda-side-card {
    padding: 1.2rem;
    border-radius: 22px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 14px 32px rgba(15,23,42,0.055);
}
.agenda-side-label {
    display: block;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.45rem;
}
.agenda-side-card strong {
    display: block;
    color: #0f172a;
    font-size: 1.05rem;
    line-height: 1.35;
    font-weight: 950;
}
.agenda-side-card small,
.agenda-side-card p {
    display: block;
    margin-top: 0.45rem;
    color: #64748b;
    line-height: 1.45;
    font-size: 0.88rem;
}
.agenda-next-card {
    background:
        radial-gradient(circle at top right, rgba(37,99,235,0.10), transparent 42%),
        linear-gradient(180deg, #ffffff, #eff6ff);
    border-color: #bfdbfe;
}
.agenda-note-card {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.agenda-note-card strong { display: inline; font-size: inherit; }

@media (max-width: 1180px) {
    .agenda-kpi-grid { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .agenda-workspace { grid-template-columns: 1fr; }
    .agenda-side-panel { grid-template-columns: repeat(3, 1fr); display: grid; }
}
@media (max-width: 840px) {
    .agenda-hero { flex-direction: column; padding: 1.25rem; border-radius: 20px; }
    .agenda-hero-actions { justify-content: stretch; min-width: 0; }
    .agenda-primary-btn { width: 100%; justify-content: center; }
    .agenda-kpi-grid { grid-template-columns: 1fr; }
    .agenda-toolbar-pro { flex-direction: column; align-items: stretch; }
    .agenda-search-box { max-width: 100%; }
    .agenda-filter-group { width: 100%; }
    .agenda-side-panel { grid-template-columns: 1fr; }
}

/* ==========================================
   MÓDULOS COMERCIALES PREMIUM
   Proveedores, Órdenes de Trabajo e Inventario
   ========================================== */
.commercial-premium-panel {
    --commercial-blue: #2563eb;
    --commercial-sky: #0ea5e9;
    --commercial-green: #10b981;
    --commercial-amber: #f59e0b;
    --commercial-red: #ef4444;
    --commercial-purple: #7c3aed;
}

.module-hero.commercial-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    align-items: center;
    padding: 1.6rem 1.75rem;
    margin-bottom: 1.4rem;
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: 26px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 58%, #eff6ff 100%);
    box-shadow: 0 16px 46px rgba(15, 23, 42, 0.08);
}
.module-hero.commercial-hero::after {
    content: "";
    position: absolute;
    right: -52px;
    top: -72px;
    width: 210px;
    height: 210px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.16), transparent 68%);
    pointer-events: none;
}
.module-hero-copy { position: relative; z-index: 1; }
.module-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.55rem;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}
.module-eyebrow::before {
    content: "";
    width: 22px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), transparent);
}
.module-hero-copy h2 {
    margin: 0;
    color: #0f172a;
    font-size: clamp(1.75rem, 2.7vw, 2.7rem);
    line-height: 1;
    letter-spacing: -0.055em;
    font-weight: 950;
}
.module-hero-copy p {
    margin-top: 0.75rem;
    max-width: 780px;
    color: #64748b;
    line-height: 1.55;
    font-weight: 560;
}
.module-hero-actions {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.btn-hero-primary,
.btn-hero-secondary {
    min-height: 46px;
    border-radius: 14px !important;
    padding: 0.78rem 1.05rem !important;
    font-weight: 900 !important;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.16);
}
.btn-hero-secondary {
    background: #ffffff !important;
    border: 1px solid #bfdbfe !important;
    color: #2563eb !important;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
}

.commercial-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.commercial-kpi-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 112px;
    padding: 1.15rem;
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: 22px;
    background: #ffffff;
    box-shadow: 0 10px 32px rgba(15, 23, 42, 0.055);
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    overflow: hidden;
    position: relative;
}
.commercial-kpi-card::after {
    content: "";
    position: absolute;
    right: -40px;
    top: -42px;
    width: 110px;
    height: 110px;
    border-radius: 999px;
    opacity: 0.16;
    background: currentColor;
}
.commercial-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.10);
}
.commercial-kpi-card span {
    display: block;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}
.commercial-kpi-card strong {
    display: block;
    color: #0f172a;
    font-size: 1.95rem;
    font-weight: 950;
    line-height: 1;
    letter-spacing: -0.04em;
}
.commercial-kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex: 0 0 auto;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.64);
}
.commercial-kpi-card.blue { color: #2563eb; background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%); }
.commercial-kpi-card.sky { color: #0ea5e9; background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%); }
.commercial-kpi-card.green { color: #10b981; background: linear-gradient(135deg, #ffffff 0%, #ecfdf5 100%); }
.commercial-kpi-card.amber { color: #f59e0b; background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%); }
.commercial-kpi-card.red { color: #ef4444; background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%); }
.commercial-kpi-card.purple { color: #7c3aed; background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 100%); }
.commercial-kpi-card.blue .commercial-kpi-icon { background: #dbeafe; border: 1px solid #bfdbfe; }
.commercial-kpi-card.sky .commercial-kpi-icon { background: #e0f2fe; border: 1px solid #bae6fd; }
.commercial-kpi-card.green .commercial-kpi-icon { background: #dcfce7; border: 1px solid #bbf7d0; }
.commercial-kpi-card.amber .commercial-kpi-icon { background: #fef3c7; border: 1px solid #fde68a; }
.commercial-kpi-card.red .commercial-kpi-icon { background: #fee2e2; border: 1px solid #fecaca; }
.commercial-kpi-card.purple .commercial-kpi-icon { background: #ede9fe; border: 1px solid #ddd6fe; }

.commercial-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.2rem;
    padding: 0.75rem;
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}
.commercial-search-box {
    position: relative;
    width: min(100%, 520px);
    flex: 1 1 340px;
}
.commercial-search-box.full-search { width: 100%; }
.commercial-search-box span {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    z-index: 1;
}
.commercial-search-box input {
    min-height: 48px;
    padding-left: 45px !important;
    border: 1px solid transparent !important;
    background: #f8fafc !important;
    border-radius: 15px !important;
    box-shadow: none !important;
}
.commercial-search-box input:focus {
    background: #ffffff !important;
    border-color: #bfdbfe !important;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10) !important;
}
.commercial-filter-group {
    display: flex;
    gap: 0.35rem;
    padding: 0.35rem;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    background: #f1f5f9;
    overflow-x: auto;
}
.commercial-filter-group .btn-filter {
    min-height: 38px;
    white-space: nowrap;
    border-radius: 11px;
}

.commercial-surface-card {
    padding: 1.2rem;
    border: 1px solid rgba(226, 232, 240, 0.96);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.06);
}
.commercial-section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.2rem 0.2rem 1rem;
}
.commercial-section-head h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1.15rem;
    font-weight: 950;
    letter-spacing: -0.03em;
}
.commercial-section-head p {
    margin-top: 0.35rem;
    color: #64748b;
    font-size: 0.92rem;
}
.commercial-table-wrap {
    background: transparent !important;
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 18px !important;
    overflow: auto !important;
}
.commercial-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.commercial-table th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 900;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.9rem 1rem;
}
.commercial-table td {
    padding: 1rem;
    border-bottom: 1px solid #edf2f7;
    vertical-align: middle;
    background: #ffffff;
}
.commercial-table tbody tr:hover td {
    background: #f8fbff;
}
.commercial-table tbody tr:last-child td { border-bottom: 0; }

.provider-main,
.order-main,
.inventory-product-main {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.entity-avatar,
.inventory-thumb {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
    color: #2563eb;
    font-weight: 950;
    overflow: hidden;
}
.inventory-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.entity-title,
.order-title,
.inventory-title {
    display: block;
    color: #0f172a;
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.2;
}
.entity-sub,
.order-sub,
.inventory-sub {
    display: inline-flex;
    margin-top: 0.25rem;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 650;
}
.provider-contact-card,
.order-finance-card,
.inventory-price-card {
    display: grid;
    gap: 0.25rem;
    color: #334155;
    font-size: 0.86rem;
}
.provider-contact-card strong,
.order-finance-card strong,
.inventory-price-card strong {
    color: #0f172a;
    font-weight: 900;
}
.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    width: fit-content;
    padding: 0.38rem 0.68rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 900;
    border: 1px solid transparent;
}
.badge-soft.info { background: #e0f2fe; color: #0369a1; border-color: #bae6fd; }
.badge-soft.green { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-soft.amber { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-soft.red { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-soft.gray { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.badge-soft.purple { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.catalog-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 0.35rem 0.55rem;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-weight: 950;
    border: 1px solid #bfdbfe;
}

.orders-dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.order-date-pill {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.55rem 0.75rem;
    border-radius: 14px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #334155;
    font-size: 0.83rem;
    font-weight: 800;
}
.order-date-pill span { color: #64748b; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
.status-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
}
.order-actions-stack {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}
.finance-positive { color: #10b981 !important; }
.finance-danger { color: #ef4444 !important; }

.premium-category-nav {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    overflow-x: auto;
    padding: 0.55rem;
    margin: 0 0 1rem;
    border-radius: 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 8px 22px rgba(15,23,42,0.04);
}
.premium-category-nav .btn-pill-filter {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    padding: 0.62rem 0.95rem;
    border-radius: 999px;
    font-weight: 900;
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s ease;
}
.premium-category-nav .btn-pill-filter:hover {
    color: #2563eb;
    border-color: #bfdbfe;
    background: #eff6ff;
}
.premium-category-nav .btn-pill-filter.active {
    color: #ffffff;
    border-color: #2563eb;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    box-shadow: 0 10px 20px rgba(37,99,235,0.20);
}
.stock-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}
.stock-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    box-shadow: 0 0 0 5px rgba(16,185,129,0.12);
}
.stock-copy strong {
    color: #0f172a;
    font-size: 1.08rem;
    font-weight: 950;
}
.stock-copy span {
    display: block;
    margin-top: 0.1rem;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 750;
}
.inventory-table-wrap { padding-bottom: 0 !important; }
.commercial-empty-state {
    text-align: center;
    padding: 2.4rem !important;
    color: #64748b;
    font-weight: 750;
}
.commercial-empty-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    max-width: 420px;
}
.commercial-empty-box strong { color: #0f172a; font-size: 1.05rem; }
.commercial-empty-box span { color: #64748b; font-size: 0.92rem; }

@media (max-width: 1120px) {
    .module-hero.commercial-hero { grid-template-columns: 1fr; }
    .module-hero-actions { justify-content: flex-start; }
    .commercial-toolbar { align-items: stretch; }
    .commercial-filter-group { width: 100%; }
}
@media (max-width: 720px) {
    .module-hero.commercial-hero { padding: 1.25rem; border-radius: 22px; }
    .module-hero-copy h2 { font-size: 1.7rem; }
    .commercial-kpi-grid { grid-template-columns: 1fr; }
    .commercial-surface-card { padding: 0.85rem; border-radius: 20px; }
    .module-hero-actions .btn { width: 100%; justify-content: center; }
}

/* ==========================================
   PUNTO DE VENTA PREMIUM + VENTA MANUAL
   Restaurado sobre Agenda, Proveedores, Órdenes e Inventario premium.
   ========================================== */
.pos-premium-panel {
    --pos-blue: #2563eb;
    --pos-cyan: #06b6d4;
    --pos-green: #10b981;
    --pos-amber: #f59e0b;
    --pos-red: #ef4444;
}

.pos-hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.65rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 26px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 34%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 58%, #eef6ff 100%);
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    position: relative;
}

.pos-hero-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(180deg, var(--pos-blue), var(--pos-cyan));
}

.pos-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.55rem;
    color: #2563eb;
    font-size: 0.76rem;
    font-weight: 950;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.pos-kicker::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #10b981;
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.13);
}

.pos-hero-copy h2 {
    margin: 0;
    color: #0f172a;
    font-size: clamp(1.7rem, 3vw, 2.35rem);
    line-height: 1;
    font-weight: 950;
    letter-spacing: -0.055em;
}

.pos-hero-copy p {
    margin-top: 0.65rem;
    max-width: 760px;
    color: #64748b;
    font-size: 1rem;
    line-height: 1.45;
    font-weight: 600;
}

.pos-hero-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    position: relative;
    z-index: 1;
}

.pos-primary-btn,
.pos-ghost-btn {
    min-height: 46px;
    border-radius: 14px !important;
    font-weight: 900 !important;
    padding: 0.8rem 1rem !important;
}

.pos-grid-premium {
    display: grid;
    grid-template-columns: minmax(360px, 1.05fr) minmax(360px, 0.95fr);
    gap: 1.5rem;
    align-items: start;
}

.pos-card {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(226, 232, 240, 0.92);
    border-radius: 24px;
    padding: 1.45rem;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.07);
}

.pos-card-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.pos-icon {
    width: 54px;
    height: 54px;
    flex: 0 0 54px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 1.45rem;
    border: 1px solid transparent;
}

.pos-icon.blue {
    color: #1d4ed8;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: #93c5fd;
}

.pos-icon.green {
    color: #047857;
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: #86efac;
}

.pos-card-header h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1.28rem;
    font-weight: 950;
    letter-spacing: -0.03em;
}

.pos-card-header p {
    margin-top: 0.25rem;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.4;
}

.pos-tabs-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.pos-tab-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.46rem 0.72rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.82rem;
    font-weight: 850;
    border: 1px solid #e2e8f0;
}

.pos-tab-pill.active {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.pos-section-box {
    padding: 1rem;
    border-radius: 19px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc, #ffffff);
    margin-bottom: 1rem;
}

.pos-manual-box {
    background:
        radial-gradient(circle at top right, rgba(16, 185, 129, 0.09), transparent 34%),
        linear-gradient(180deg, #f8fafc, #ffffff);
    border-color: #bbf7d0;
}

.pos-section-title {
    color: #475569;
    font-size: 0.76rem;
    font-weight: 950;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    margin-bottom: 0.78rem;
}

.pos-product-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.7rem;
    margin-bottom: 0.9rem;
}

.pos-two-cols {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.85rem;
    align-items: end;
}

.pos-three-cols {
    display: grid;
    grid-template-columns: 155px minmax(0, 1fr) 110px;
    gap: 0.85rem;
}

.pos-align-end {
    align-self: end;
}

.pos-search-btn,
.pos-add-btn,
.pos-manual-btn {
    min-height: 48px;
    border-radius: 13px !important;
    font-weight: 900 !important;
    white-space: nowrap;
}

.pos-manual-btn {
    color: #047857 !important;
    border-color: #86efac !important;
    background: #ecfdf5 !important;
}

.pos-add-btn,
.pos-search-btn {
    color: #1d4ed8 !important;
    border-color: #bfdbfe !important;
    background: #eff6ff !important;
}

.pos-helper {
    color: #64748b;
    font-size: 0.83rem;
    line-height: 1.42;
    margin-top: 0.25rem;
}

.pos-client-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 0.75fr);
    gap: 0.85rem;
}

.pos-cart-table-wrap {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    margin: 0.4rem 0 1rem;
    background: #ffffff;
    box-shadow: var(--shadow-sm);
}

.pos-cart-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.pos-cart-table th {
    background: #f8fafc;
    color: #64748b;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.pos-cart-table td {
    padding: 0.95rem 1rem;
    border-bottom: 1px solid #eef2f7;
    vertical-align: middle;
}

.pos-cart-table tr:last-child td {
    border-bottom: 0;
}

.pos-line-main strong {
    display: block;
    color: #0f172a;
    font-weight: 900;
}

.pos-line-main small {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    color: #64748b;
    margin-top: 0.25rem;
}

.pos-line-main code {
    color: #2563eb;
    background: #eff6ff;
    border-radius: 999px;
    padding: 0.15rem 0.45rem;
    font-size: 0.75rem;
}

.pos-line-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.16rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 900;
}

.pos-line-badge.inv {
    color: #1d4ed8;
    background: #dbeafe;
}

.pos-line-badge.manual {
    color: #047857;
    background: #d1fae5;
}

.pos-remove-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
    font-size: 1.2rem;
    font-weight: 900;
    line-height: 1;
}

.pos-remove-btn:hover {
    color: #ffffff;
    background: #ef4444;
}

.pos-empty-cart {
    text-align: center;
    color: #64748b;
    padding: 2rem !important;
    font-weight: 700;
}

.pos-observacion {
    resize: vertical;
    min-height: 88px;
}

.pos-total-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-radius: 19px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 38%),
        linear-gradient(135deg, #0f172a, #1e3a8a);
    color: #ffffff;
    box-shadow: 0 18px 34px rgba(37, 99, 235, 0.22);
}

.pos-total-box span {
    display: block;
    color: #bfdbfe;
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pos-total-box strong {
    display: block;
    margin-top: 0.25rem;
    color: #ffffff;
    font-size: 2rem;
    line-height: 1;
    font-weight: 950;
}

.pos-checkout-btn {
    min-height: 52px;
    border-radius: 15px !important;
    background: #ffffff !important;
    color: #1d4ed8 !important;
    font-weight: 950 !important;
    box-shadow: none !important;
    white-space: nowrap;
}

@media (max-width: 1180px) {
    .pos-grid-premium {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .pos-hero-card,
    .pos-total-box {
        flex-direction: column;
        align-items: stretch;
    }

    .pos-hero-actions,
    .pos-checkout-btn {
        width: 100%;
    }

    .pos-product-search,
    .pos-two-cols,
    .pos-three-cols,
    .pos-client-grid {
        grid-template-columns: 1fr;
    }

    .pos-card {
        padding: 1rem;
        border-radius: 18px;
    }
}

/* ==========================================
   REPORTES FINANCIEROS INTELIGENTES - CONTABILIDAD
   ========================================== */
.finance-pro-panel {
    --finance-blue: #2563eb;
    --finance-green: #10b981;
    --finance-red: #ef4444;
    --finance-amber: #f59e0b;
    --finance-ink: #0f172a;
    --finance-muted: #64748b;
}

.finance-pro-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.5rem;
    align-items: stretch;
    padding: 1.6rem;
    border-radius: 28px;
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.18), transparent 38%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 54%, #eef6ff 100%);
    border: 1px solid rgba(191, 219, 254, 0.9);
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.08);
    margin-bottom: 1.25rem;
    position: relative;
    overflow: hidden;
}
.finance-pro-hero::before {
    content: "";
    position: absolute;
    right: -70px;
    top: -80px;
    width: 240px;
    height: 240px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
}
.finance-pro-copy, .finance-pro-actions { position: relative; z-index: 1; }
.finance-pro-eyebrow,
.section-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #2563eb;
    font-size: 0.74rem;
    font-weight: 950;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 0.55rem;
}
.finance-pro-copy h2 {
    color: #0f172a;
    font-size: clamp(2rem, 3vw, 3rem);
    line-height: 1;
    letter-spacing: -0.055em;
    margin: 0 0 0.75rem;
}
.finance-pro-copy p {
    color: #64748b;
    font-size: 1rem;
    line-height: 1.55;
    max-width: 850px;
    font-weight: 550;
}
.finance-pro-pills {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 1.15rem;
}
.finance-pro-pills span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid #dbeafe;
    background: rgba(255,255,255,0.78);
    color: #475569;
    font-size: 0.82rem;
    font-weight: 850;
}
.finance-pro-actions {
    min-width: 230px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.7rem;
}
.finance-pro-actions .btn { justify-content: center; min-height: 44px; border-radius: 14px; font-weight: 900; }

.finance-period-switch {
    display: flex;
    gap: 0.55rem;
    padding: 0.4rem;
    border-radius: 18px;
    background: #eef2f7;
    border: 1px solid #dbe3ef;
    margin-bottom: 1.2rem;
    overflow-x: auto;
}
.finance-period-btn {
    flex: 1;
    min-width: 120px;
    min-height: 44px;
    padding: 0.65rem 1rem;
    border-radius: 14px;
    background: transparent;
    color: #475569;
    font-weight: 900;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.finance-period-btn:hover { color: #2563eb; background: rgba(255,255,255,0.65); }
.finance-period-btn.active { background: #ffffff; color: #2563eb; box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08); }

.finance-ledger-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}
.ledger-kpi {
    padding: 1.25rem;
    border-radius: 22px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 30px rgba(15,23,42,0.05);
    position: relative;
    overflow: hidden;
}
.ledger-kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: #2563eb;
}
.ledger-kpi.income::before { background: #10b981; }
.ledger-kpi.expense::before { background: #ef4444; }
.ledger-kpi.utility::before { background: #2563eb; }
.ledger-kpi.receivable::before { background: #f59e0b; }
.ledger-kpi-label {
    display: block;
    color: #64748b;
    font-size: 0.78rem;
    font-weight: 950;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 0.55rem;
}
.ledger-kpi strong {
    display: block;
    color: #0f172a;
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    line-height: 1;
    font-weight: 950;
    letter-spacing: -0.04em;
}
.ledger-kpi.income strong { color: #059669; }
.ledger-kpi.expense strong { color: #dc2626; }
.ledger-kpi.utility strong { color: #1d4ed8; }
.ledger-kpi.receivable strong { color: #d97706; }
.ledger-kpi small {
    display: block;
    margin-top: 0.7rem;
    color: #64748b;
    font-weight: 650;
}

.finance-mini-kpis {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}
.finance-mini-card {
    padding: 0.95rem;
    background: rgba(255,255,255,0.92);
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    box-shadow: 0 8px 22px rgba(15,23,42,0.04);
}
.finance-mini-card span {
    display: block;
    color: #64748b;
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 950;
    letter-spacing: 0.06em;
}
.finance-mini-card strong {
    display: block;
    margin-top: 0.35rem;
    color: #0f172a;
    font-size: 1.2rem;
    font-weight: 950;
}
.finance-mini-card small { display: block; color: #94a3b8; margin-top: 0.25rem; font-weight: 650; }
.finance-mini-card.warning strong { color: #dc2626; }

.finance-accounting-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.finance-card-pro {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 1.25rem;
    box-shadow: 0 14px 36px rgba(15,23,42,0.06);
}
.finance-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}
.finance-section-header.compact { margin-bottom: 0.8rem; }
.finance-section-header h3 {
    margin: 0;
    color: #0f172a;
    font-size: 1.25rem;
    font-weight: 950;
    letter-spacing: -0.03em;
}
.finance-section-header p {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.45;
}
.finance-chart-wrap { height: 390px; width: 100%; }
.smart-report-text {
    padding: 1rem;
    border-radius: 18px;
    background: linear-gradient(180deg, #f8fafc, #ffffff);
    border: 1px solid #e2e8f0;
    color: #334155;
    line-height: 1.55;
    font-size: 0.93rem;
    font-weight: 620;
}
.smart-report-text strong { color: #0f172a; }
.smart-report-text .ok { color: #059669; font-weight: 950; }
.smart-report-text .bad { color: #dc2626; font-weight: 950; }
.smart-report-text .warn { color: #d97706; font-weight: 950; }
.smart-metrics-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 0.9rem;
}
.smart-metrics-list div {
    padding: 0.9rem;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.smart-metrics-list span {
    display: block;
    color: #64748b;
    text-transform: uppercase;
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.06em;
}
.smart-metrics-list strong {
    display: block;
    color: #0f172a;
    font-size: 1rem;
    margin-top: 0.25rem;
    font-weight: 950;
}
.smart-metrics-list small { display: block; color: #64748b; margin-top: 0.2rem; }

.finance-tables-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
.finance-table-card { padding: 1.1rem; }
.finance-table-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.finance-table-scroll { max-height: 390px; overflow: auto; border-radius: 18px; }
.finance-ledger-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 900px;
}
.finance-ledger-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}
.finance-ledger-table th,
.finance-ledger-table td {
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}
.finance-ledger-table tbody tr:hover { background: #f8fafc; }
.finance-ledger-table .right { text-align: right; }
.finance-empty { text-align: center; color: #64748b; padding: 2rem !important; }
.finance-amount-in { color: #059669; font-weight: 950; }
.finance-amount-out { color: #dc2626; font-weight: 950; }
.finance-amount-neutral { color: #334155; font-weight: 850; }
.finance-person-cell strong { display: block; color: #0f172a; font-weight: 950; }
.finance-person-cell small { display: block; color: #64748b; margin-top: 0.2rem; }
.finance-status-badge,
.finance-aging-badge,
.finance-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.34rem 0.62rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 950;
    white-space: nowrap;
}
.finance-status-badge { background: #eff6ff; color: #1d4ed8; }
.finance-aging-badge.ok { background: #ecfdf5; color: #047857; }
.finance-aging-badge.warn { background: #fffbeb; color: #b45309; }
.finance-aging-badge.bad { background: #fef2f2; color: #dc2626; }
.finance-type-badge.in { background: #ecfdf5; color: #047857; }
.finance-type-badge.out { background: #fef2f2; color: #dc2626; }
.finance-type-badge.other { background: #f1f5f9; color: #475569; }
.finance-pay-btn {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #2563eb;
    padding: 0.45rem 0.7rem;
    border-radius: 12px;
    font-weight: 900;
    white-space: nowrap;
}
.finance-pay-btn:hover { background: #2563eb; color: #fff; }

@media (max-width: 1260px) {
    .finance-ledger-kpis { grid-template-columns: repeat(2, 1fr); }
    .finance-mini-kpis { grid-template-columns: repeat(3, 1fr); }
    .finance-accounting-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .finance-pro-hero { grid-template-columns: 1fr; padding: 1.1rem; border-radius: 20px; }
    .finance-pro-actions { min-width: 0; }
    .finance-ledger-kpis,
    .finance-mini-kpis { grid-template-columns: 1fr; }
    .finance-period-btn { min-width: 105px; }
    .finance-chart-wrap { height: 310px; }
}


/* ==========================================
   BOTÓN SEGURO PARA ELIMINAR MOVIMIENTO EN LIBRO DIARIO
   ========================================== */
.finance-actions-col { width: 118px; white-space: nowrap; }
.finance-delete-btn {
    border: 1px solid #fecaca;
    background: #fff7f7;
    color: #dc2626;
    padding: 0.45rem 0.7rem;
    border-radius: 12px;
    font-weight: 900;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}
.finance-delete-btn:hover {
    background: #dc2626;
    color: #ffffff;
    border-color: #dc2626;
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.16);
    transform: translateY(-1px);
}

/* ==========================================================
   DASHBOARD + PACIENTES INTELIGENTE - 2026-05-28
   Rediseño visual y lectura operativa. No cambia estructura DB.
   ========================================================== */
.section-kicker {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    font-size: .72rem;
    font-weight: 950;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: #2563eb;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: .28rem .55rem;
    border-radius: 999px;
    margin-bottom: .55rem;
}
.danger-text { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.dashboard-pro, .patients-pro { display: flex; flex-direction: column; gap: 1.35rem; }
.dashboard-hero, .patients-hero {
    display: flex;
    justify-content: space-between;
    gap: 1.2rem;
    align-items: stretch;
    padding: 1.55rem;
    border-radius: 26px;
    border: 1px solid rgba(191, 219, 254, .75);
    background:
        radial-gradient(circle at top right, rgba(37, 99, 235, .14), transparent 36%),
        linear-gradient(135deg, #ffffff 0%, #f8fbff 55%, #eef6ff 100%);
    box-shadow: 0 20px 55px rgba(15, 23, 42, .07);
}
.dashboard-hero h2, .patients-hero h2 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 3.05rem);
    line-height: 1;
    letter-spacing: -.055em;
    color: #0f172a;
    font-weight: 950;
}
.dashboard-hero p, .patients-hero p {
    margin-top: .6rem;
    color: #64748b;
    font-size: 1.02rem;
    line-height: 1.5;
    max-width: 780px;
    font-weight: 550;
}
.dashboard-hero-actions { display: flex; flex-direction: column; justify-content: center; gap: .75rem; min-width: 220px; }
.dashboard-main-action, .patients-main-action { min-height: 50px; border-radius: 15px !important; box-shadow: 0 16px 28px rgba(37,99,235,.22); }
.dashboard-secondary-action { min-height: 46px; border-radius: 15px !important; }
.hero-mini-metrics { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.05rem; }
.hero-mini-metrics span {
    display: inline-flex;
    align-items: center;
    padding: .42rem .72rem;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #dbeafe;
    color: #475569;
    font-size: .82rem;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
}
.dashboard-kpi-grid.smart-kpis { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 1rem; }
.smart-kpi-card {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 1rem;
    align-items: center;
    min-height: 126px;
    padding: 1.15rem;
    border-radius: 22px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .055);
}
.smart-kpi-card::after {
    content: "";
    position: absolute;
    right: -46px;
    top: -46px;
    width: 120px;
    height: 120px;
    border-radius: 999px;
    background: rgba(37,99,235,.08);
}
.smart-kpi-icon {
    position: relative;
    z-index: 1;
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    border: 1px solid rgba(148,163,184,.22);
    background: #f8fafc;
}
.smart-kpi-body { position: relative; z-index: 1; min-width: 0; }
.smart-kpi-body span { display: block; color: #64748b; font-size: .76rem; font-weight: 950; text-transform: uppercase; letter-spacing: .05em; }
.smart-kpi-body strong { display: block; margin-top: .2rem; color: #0f172a; font-size: 1.85rem; line-height: 1; letter-spacing: -.04em; font-weight: 950; }
.smart-kpi-body small { display: block; margin-top: .45rem; color: #64748b; font-size: .78rem; font-weight: 750; line-height: 1.25; }
.smart-kpi-body small b { color: #0f172a; }
.kpi-green .smart-kpi-icon { background: #dcfce7; color: #15803d; border-color: #86efac; }
.kpi-red-soft .smart-kpi-icon { background: #fee2e2; color: #dc2626; border-color: #fecaca; }
.kpi-blue .smart-kpi-icon { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.kpi-orange .smart-kpi-icon { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.kpi-purple .smart-kpi-icon { background: #f3e8ff; color: #7e22ce; border-color: #e9d5ff; }
.kpi-danger .smart-kpi-icon { background: #fff1f2; color: #e11d48; border-color: #fecdd3; }
.kpi-slate .smart-kpi-icon { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.kpi-teal .smart-kpi-icon { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.dashboard-smart-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, .9fr); gap: 1.2rem; }
.dashboard-bottom-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; }
.smart-panel {
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(226,232,240,.9);
    border-radius: 24px;
    padding: 1.25rem;
    box-shadow: 0 18px 45px rgba(15,23,42,.06);
}
.smart-panel-header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1rem; }
.smart-panel-header.compact { align-items: center; }
.smart-panel-header h3 { margin: 0; color: #0f172a; font-size: 1.25rem; font-weight: 950; letter-spacing: -.035em; }
.smart-panel-header p { margin-top: .35rem; color: #64748b; font-size: .9rem; line-height: 1.35; }
.dashboard-chart-wrap { height: 360px; width: 100%; }
.dashboard-actions-panel { background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%); }
.dashboard-action-list { display: grid; gap: .75rem; }
.dash-action {
    text-decoration: none;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #0f172a;
    border-radius: 18px;
    padding: .9rem;
    display: grid;
    grid-template-columns: 48px 1fr;
    align-items: center;
    gap: .85rem;
    text-align: left;
    transition: all .22s ease;
}
.dash-action:hover { transform: translateY(-2px); border-color: #93c5fd; box-shadow: 0 14px 28px rgba(37,99,235,.11); }
.dash-action span { grid-row: span 2; width: 48px; height: 48px; border-radius: 15px; background: #eff6ff; display: flex; align-items: center; justify-content: center; font-size: 1.45rem; }
.dash-action strong { display: block; font-size: .98rem; font-weight: 950; color: #0f172a; }
.dash-action small { display: block; color: #64748b; font-size: .82rem; margin-top: .18rem; }
.smart-list { display: flex; flex-direction: column; gap: .65rem; }
.empty-state-lite { color: #64748b; font-weight: 700; padding: .9rem; background: #f8fafc; border-radius: 14px; border: 1px dashed #cbd5e1; }
.smart-list-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: .8rem;
    padding: .85rem;
    border-radius: 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.smart-list-row .row-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 13px; background: #ffffff; border: 1px solid #e2e8f0; }
.smart-list-row strong { display: block; color: #0f172a; font-weight: 950; }
.smart-list-row small { display: block; color: #64748b; margin-top: .16rem; }
.smart-list-row .row-amount { font-weight: 950; color: #dc2626; white-space: nowrap; }
.smart-list-row .row-action { justify-self: end; }

/* Pacientes inteligentes */
.patients-hero { align-items: center; }
.patients-kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(180px,1fr)); gap: 1rem; }
.patient-kpi {
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    padding: 1rem 1.1rem;
    box-shadow: 0 10px 26px rgba(15,23,42,.05);
}
.patient-kpi span { display: block; font-size: .75rem; color: #64748b; text-transform: uppercase; letter-spacing: .06em; font-weight: 950; }
.patient-kpi strong { display: block; margin-top: .25rem; font-size: 2rem; line-height: 1; color: #0f172a; font-weight: 950; }
.patient-kpi small { color: #64748b; font-weight: 750; }
.patient-kpi.danger strong { color: #dc2626; }
.patient-kpi.warning strong { color: #d97706; }
.patients-toolbar { display: grid; grid-template-columns: minmax(260px, 1fr) auto; align-items: center; gap: 1rem; }
.patients-search-wrap { position: relative; }
.patients-search-wrap span { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-size: 1.15rem; opacity: .75; }
.patients-search-wrap input { height: 52px; padding-left: 46px !important; border-radius: 16px !important; background: #f8fafc; }
.patients-filter-group { display: flex; flex-wrap: wrap; gap: .45rem; justify-content: flex-end; }
.patient-filter {
    min-height: 40px;
    padding: 0 .85rem;
    border-radius: 999px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #475569;
    font-weight: 850;
    cursor: pointer;
    transition: all .2s ease;
}
.patient-filter:hover { border-color: #93c5fd; color: #2563eb; }
.patient-filter.active { background: #2563eb; color: #ffffff; border-color: #2563eb; box-shadow: 0 10px 22px rgba(37,99,235,.2); }
.results-pill { padding: .4rem .75rem; border-radius: 999px; background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; font-size: .82rem; font-weight: 900; white-space: nowrap; }
.patients-table-card { padding: 1.1rem; }
.patients-table-responsive { border: 0; box-shadow: none; border-radius: 18px; background: transparent; }
.patients-smart-table { min-width: 1060px; border-collapse: separate; border-spacing: 0 .75rem; }
.patients-smart-table th { background: transparent; border: 0; color: #64748b; font-size: .75rem; font-weight: 950; letter-spacing: .06em; padding: .5rem .9rem; }
.patients-smart-table td {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    padding: .95rem .9rem;
    vertical-align: middle;
}
.patients-smart-table td:first-child { border-left: 1px solid #e2e8f0; border-radius: 18px 0 0 18px; }
.patients-smart-table td:last-child { border-right: 1px solid #e2e8f0; border-radius: 0 18px 18px 0; }
.patient-name-cell { display: flex; align-items: center; gap: .8rem; }
.patient-avatar {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    object-fit: cover;
    background: #f1f5f9;
    border: 2px solid #ffffff;
    box-shadow: 0 8px 18px rgba(15,23,42,.08);
}
.patient-main strong { display:block; color:#0f172a; font-size:1rem; font-weight:950; }
.patient-main small { display:block; color:#64748b; margin-top:.15rem; font-weight:750; }
.patient-code { display:inline-flex; margin-top:.35rem; padding:.25rem .5rem; border-radius:999px; background:#eff6ff; color:#2563eb; font-weight:900; font-size:.76rem; }
.patient-contact span, .patient-clinic span, .patient-money span, .patient-last span { display:block; color:#0f172a; font-weight:850; }
.patient-contact small, .patient-clinic small, .patient-money small, .patient-last small { display:block; color:#64748b; margin-top:.18rem; font-size:.8rem; }
.patient-status-chip { display:inline-flex; align-items:center; gap:.35rem; padding:.32rem .58rem; border-radius:999px; font-weight:900; font-size:.76rem; }
.chip-ok { background:#dcfce7; color:#166534; }
.chip-warn { background:#fef3c7; color:#92400e; }
.chip-info { background:#dbeafe; color:#1d4ed8; }
.chip-bad { background:#fee2e2; color:#b91c1c; }
.patient-actions { display:flex; justify-content:center; align-items:center; gap:.45rem; flex-wrap:wrap; }
.patient-actions .btn-primary { border-radius: 13px !important; min-height: 38px; }
.patient-actions .btn-icon-premium { width: 38px; height: 38px; border-radius: 13px; }
.patient-empty-row td { border-radius: 18px !important; text-align: center; color: #64748b; padding: 2rem !important; }
@media (max-width: 1200px) {
    .dashboard-kpi-grid.smart-kpis { grid-template-columns: repeat(2, minmax(190px, 1fr)); }
    .dashboard-smart-grid, .dashboard-bottom-grid { grid-template-columns: 1fr; }
    .patients-kpi-grid { grid-template-columns: repeat(2, minmax(180px,1fr)); }
    .patients-toolbar { grid-template-columns: 1fr; }
    .patients-filter-group { justify-content: flex-start; }
}
@media (max-width: 700px) {
    .dashboard-hero, .patients-hero { flex-direction: column; padding: 1.1rem; border-radius: 20px; }
    .dashboard-hero-actions { min-width: 0; }
    .dashboard-kpi-grid.smart-kpis, .patients-kpi-grid { grid-template-columns: 1fr; }
    .smart-panel { padding: 1rem; border-radius: 20px; }
    .dashboard-chart-wrap { height: 300px; }
}

/* Fix puntual dashboard/pacientes */
.dashboard-chart-insight {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.45;
}
.dashboard-chart-insight strong { color: #0f172a; }
.patient-last small { color: #64748b; }

/* ==========================================
   FIX EXPEDIENTE OPTOMÉTRICO - RX FINAL PH / AV V.P.
   Mantiene IDs existentes y solo mejora la grilla visual.
   ========================================== */
.rx-final-grid .form-control {
    min-height: 46px;
}
.rx-final-head {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
}
@media (max-width: 1180px) {
    .rx-final-grid {
        grid-template-columns: 40px repeat(8, minmax(92px, 1fr)) !important;
        overflow-x: auto;
        padding-bottom: 8px;
    }
}
body.dark-mode .rx-final-head,
body[data-theme="dark"] .rx-final-head,
html.dark-mode .rx-final-head,
html[data-theme="dark"] .rx-final-head {
    background: rgba(148, 163, 184, 0.14) !important;
    color: #dbeafe !important;
    border: 1px solid rgba(148, 163, 184, 0.18);
}
body.dark-mode .rx-final-head-ph,
body[data-theme="dark"] .rx-final-head-ph,
html.dark-mode .rx-final-head-ph,
html[data-theme="dark"] .rx-final-head-ph {
    background: rgba(14, 165, 233, 0.18) !important;
    color: #7dd3fc !important;
}
body.dark-mode .rx-final-head-final,
body[data-theme="dark"] .rx-final-head-final,
html.dark-mode .rx-final-head-final,
html[data-theme="dark"] .rx-final-head-final {
    background: rgba(16, 185, 129, 0.18) !important;
    color: #86efac !important;
}
body.dark-mode .rx-final-head-vp,
body[data-theme="dark"] .rx-final-head-vp,
html.dark-mode .rx-final-head-vp,
html[data-theme="dark"] .rx-final-head-vp {
    background: rgba(245, 158, 11, 0.18) !important;
    color: #fde68a !important;
}

/* ==========================================================
   FINANZAS: Libro Diario inteligente y gráfico contable
   Versión: finance-smart-ledger-chart-2026-05-28
   ========================================================== */
.finance-ledger-detail .ledger-title {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--text-dark);
    font-weight: 900;
    line-height: 1.2;
}
.ledger-smart-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.38rem;
    margin-top: 0.35rem;
}
.ledger-smart-tags span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.24rem 0.55rem;
    border-radius: 999px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.76rem;
    font-weight: 800;
    white-space: nowrap;
}
.ledger-smart-lines {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.45rem;
}
.ledger-smart-lines small {
    color: var(--text-muted);
    font-weight: 700;
}
.finance-ledger-smart-row.ledger-in { background: linear-gradient(90deg, rgba(16, 185, 129, 0.045), #ffffff 24%); }
.finance-ledger-smart-row.ledger-out { background: linear-gradient(90deg, rgba(239, 68, 68, 0.045), #ffffff 24%); }
.finance-ledger-smart-row.ledger-other { background: linear-gradient(90deg, rgba(148, 163, 184, 0.07), #ffffff 24%); }
.finance-date-cell {
    font-weight: 800;
    color: #334155;
    white-space: nowrap;
}
.finance-amount-out {
    color: #dc2626 !important;
    font-weight: 900;
}
.finance-amount-in {
    color: #059669 !important;
    font-weight: 900;
}

body.opticapro-dark .finance-ledger-detail .ledger-title,
body[data-theme="dark"] .finance-ledger-detail .ledger-title,
html.dark .finance-ledger-detail .ledger-title {
    color: #e5eefc;
}
body.opticapro-dark .ledger-smart-tags span,
body[data-theme="dark"] .ledger-smart-tags span,
html.dark .ledger-smart-tags span {
    background: rgba(15, 23, 42, 0.78);
    border-color: rgba(148, 163, 184, 0.28);
    color: #cbd5e1;
}
body.opticapro-dark .ledger-smart-lines small,
body[data-theme="dark"] .ledger-smart-lines small,
html.dark .ledger-smart-lines small {
    color: #94a3b8;
}
body.opticapro-dark .finance-ledger-smart-row.ledger-in,
body[data-theme="dark"] .finance-ledger-smart-row.ledger-in,
html.dark .finance-ledger-smart-row.ledger-in {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.12), rgba(15, 23, 42, 0.78) 26%);
}
body.opticapro-dark .finance-ledger-smart-row.ledger-out,
body[data-theme="dark"] .finance-ledger-smart-row.ledger-out,
html.dark .finance-ledger-smart-row.ledger-out {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.12), rgba(15, 23, 42, 0.78) 26%);
}
body.opticapro-dark .finance-ledger-smart-row.ledger-other,
body[data-theme="dark"] .finance-ledger-smart-row.ledger-other,
html.dark .finance-ledger-smart-row.ledger-other {
    background: linear-gradient(90deg, rgba(148, 163, 184, 0.10), rgba(15, 23, 42, 0.78) 26%);
}
body.opticapro-dark .finance-date-cell,
body[data-theme="dark"] .finance-date-cell,
html.dark .finance-date-cell {
    color: #dbeafe;
}


/* ==========================================================
   FIX MÓVIL TOPBAR / BOTÓN APK - 2026-06-07
   Solo afecta pantallas móviles. No modifica desktop ni lógica JS.
   ========================================================== */
@media (max-width: 768px) {
    header.topbar,
    .topbar.no-print {
        position: relative !important;
        z-index: 50 !important;
        width: 100% !important;
        height: 64px !important;
        min-height: 64px !important;
        max-height: 64px !important;
        padding: 8px 12px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        overflow: hidden !important;
        border-bottom: 1px solid #d7dbe3 !important;
        background: rgba(255, 255, 255, 0.96) !important;
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06) !important;
    }

    .btn-menu-mobile {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 0 0 42px !important;
        width: 42px !important;
        height: 42px !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 12px !important;
    }

    .btn-menu-mobile svg {
        width: 28px !important;
        height: 28px !important;
        display: block !important;
    }

    .topbar-date-apk {
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex-wrap: nowrap !important;
        gap: 0 !important;
    }

    .topbar-date-apk #lbl-fecha-actual {
        display: none !important;
    }

    .btn-download-apk {
        flex: 0 0 auto !important;
        height: 42px !important;
        min-height: 42px !important;
        max-height: 42px !important;
        margin: 0 !important;
        padding: 0 12px !important;
        border-radius: 14px !important;
        font-size: 0.78rem !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        box-shadow: 0 5px 12px rgba(37, 99, 235, 0.18) !important;
        transform: none !important;
    }

    .topbar-user {
        margin-left: auto !important;
        min-width: 0 !important;
        flex: 1 1 auto !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 8px !important;
        overflow: hidden !important;
    }

    .topbar-user button.btn-outline {
        display: none !important;
    }

    .topbar-user span {
        min-width: 0 !important;
        max-width: clamp(82px, 24vw, 165px) !important;
        padding: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        text-align: right !important;
        font-size: 0.88rem !important;
        line-height: 1.1 !important;
        flex: 1 1 auto !important;
    }

    .topbar-user button.btn-logout {
        flex: 0 0 auto !important;
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        padding: 0 11px !important;
        border-radius: 14px !important;
        font-size: 0.78rem !important;
        line-height: 1 !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 430px) {
    header.topbar,
    .topbar.no-print {
        padding: 8px 10px !important;
        gap: 7px !important;
    }

    .topbar-user span {
        display: none !important;
    }

    .btn-download-apk {
        padding: 0 11px !important;
        font-size: 0.76rem !important;
    }

    .topbar-user button.btn-logout {
        padding: 0 10px !important;
        font-size: 0.76rem !important;
    }
}

@media (max-width: 360px) {
    .btn-download-apk {
        width: 48px !important;
        min-width: 48px !important;
        padding: 0 !important;
        font-size: 0 !important;
    }

    .btn-download-apk::after {
        content: "APK";
        font-size: 0.74rem !important;
        font-weight: 800 !important;
    }

    .topbar-user button.btn-logout {
        padding: 0 9px !important;
        font-size: 0.72rem !important;
    }
}
