@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #1f2847;
    --bg-input: #0d1326;
    --border-color: rgba(99, 140, 255, 0.12);
    --border-active: rgba(99, 140, 255, 0.35);
    --text-primary: #e8ecf4;
    --text-secondary: #8994a8;
    --text-muted: #5a6478;
    --accent-blue: #638cff;
    --accent-blue-glow: rgba(99, 140, 255, 0.2);
    --accent-teal: #36d6b5;
    --accent-teal-glow: rgba(54, 214, 181, 0.15);
    --accent-purple: #a78bfa;
    --accent-orange: #fb923c;
    --accent-rose: #f472b6;
    --gradient-primary: linear-gradient(135deg, #638cff 0%, #a78bfa 100%);
    --gradient-teal: linear-gradient(135deg, #36d6b5 0%, #638cff 100%);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 32px rgba(99, 140, 255, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    overscroll-behavior-y: none;
}

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

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform var(--transition-smooth);
}
.sidebar-brand { padding: 24px 20px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 14px; }
.brand-icon { width: 44px; height: 44px; background: var(--gradient-primary); border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 22px; box-shadow: 0 4px 16px rgba(99, 140, 255, 0.3); }
.brand-text h1 { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.brand-text span { font-size: 11px; color: var(--text-secondary); }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(150, 150, 150, 0.3); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(150, 150, 150, 0.5); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; transition: all var(--transition-fast); font-size: 13.5px; font-weight: 500; position: relative; user-select: none; }
.nav-item:hover { background: rgba(99, 140, 255, 0.06); color: var(--text-primary); }
.nav-item.active { background: rgba(99, 140, 255, 0.1); color: var(--accent-blue); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--accent-blue); border-radius: 0 4px 4px 0; }
.nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--border-color); }
.connection-status { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-teal); box-shadow: 0 0 8px var(--accent-teal); animation: pulse 2s infinite; }
.status-dot.offline { background: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ==================== MAIN ==================== */
.main-content { flex: 1; margin-left: 260px; }
.top-bar { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; background: rgba(17, 24, 39, 0.7); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 50; }
.page-title { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.page-title span { color: var(--accent-blue); }
.search-box { position: relative; width: 320px; }
.search-box input { width: 100%; padding: 10px 16px 10px 40px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-lg); color: var(--text-primary); font-size: 13px; font-family: 'Inter', sans-serif; outline: none; transition: all var(--transition-fast); }
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.search-box .search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border-color); color: var(--text-primary); font-size: 20px; padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.page-container { padding: 28px 32px; }
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ==================== STATS ==================== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 32px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 22px 24px; position: relative; overflow: hidden; transition: all var(--transition-smooth); }
.stat-card:hover { border-color: var(--border-active); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 3px 3px 0 0; }
.stat-card:nth-child(1)::before { background: var(--gradient-primary); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--accent-teal), #22d3ee); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--accent-purple), var(--accent-rose)); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--accent-orange), #fbbf24); }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; line-height: 1; margin-bottom: 4px; }
.stat-card:nth-child(1) .stat-value { color: var(--accent-blue); }
.stat-card:nth-child(2) .stat-value { color: var(--accent-teal); }
.stat-card:nth-child(3) .stat-value { color: var(--accent-purple); }
.stat-card:nth-child(4) .stat-value { color: var(--accent-orange); }
.stat-icon { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 38px; opacity: 0.1; }

/* ==================== SECTION ==================== */
.section { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); margin-bottom: 24px; overflow: hidden; }
.section-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--border-color); }
.section-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.section-title .icon { font-size: 18px; }

/* ==================== TABLE ==================== */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th { padding: 12px 16px; text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); background: rgba(10, 14, 26, 0.4); border-bottom: 1px solid var(--border-color); white-space: nowrap; }
.data-table tbody tr { transition: background var(--transition-fast); cursor: pointer; }
.data-table tbody tr:hover { background: rgba(99, 140, 255, 0.04); }
.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid rgba(99, 140, 255, 0.06); color: var(--text-primary); white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ==================== BADGES ==================== */
.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }
.badge-blue { background: rgba(99, 140, 255, 0.12); color: var(--accent-blue); }
.badge-teal { background: rgba(54, 214, 181, 0.12); color: var(--accent-teal); }
.badge-purple { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); }

/* ==================== BUTTONS ==================== */
.btn { padding: 9px 18px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif; transition: all var(--transition-fast); display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--gradient-primary); color: white; box-shadow: 0 2px 12px rgba(99, 140, 255, 0.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99, 140, 255, 0.4); }
.btn-secondary { background: var(--bg-input); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-secondary:hover { border-color: var(--accent-blue); color: var(--text-primary); }
.btn-teal { background: linear-gradient(135deg, var(--accent-teal), #22d3ee); color: #0a0e1a; font-weight: 700; }
.btn-teal:hover { transform: translateY(-1px); }
.btn-purple { background: linear-gradient(135deg, var(--accent-purple), var(--accent-rose)); color: white; }
.btn-purple:hover { transform: translateY(-1px); }
.btn-sm { padding: 5px 12px; font-size: 11.5px; }
.btn-action { background: rgba(99,140,255,0.1); color: var(--accent-blue); border: 1px solid rgba(99,140,255,0.2); padding: 5px 10px; font-size: 11px; }
.btn-action:hover { background: rgba(99,140,255,0.2); }

/* ==================== PATIENT DETAIL ==================== */
.patient-header { display: flex; align-items: center; gap: 20px; padding: 28px 24px; background: linear-gradient(135deg, rgba(99, 140, 255, 0.06) 0%, rgba(167, 139, 250, 0.04) 100%); border-bottom: 1px solid var(--border-color); }
.patient-avatar { width: 64px; height: 64px; background: var(--gradient-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: white; flex-shrink: 0; }
.patient-info h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 4px; }
.patient-meta { display: flex; gap: 20px; flex-wrap: wrap; }
.patient-meta span { font-size: 12.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 5px; }
.back-btn { background: none; border: 1px solid var(--border-color); color: var(--text-secondary); padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-family: 'Inter', sans-serif; transition: all var(--transition-fast); display: flex; align-items: center; gap: 6px; }
.back-btn:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

/* ==================== RX GRID ==================== */
.rx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px 24px; }
.rx-eye { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 16px; }
.rx-eye-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.od { background: var(--accent-blue); }
.dot.oi { background: var(--accent-teal); }
.rx-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rx-field { text-align: center; }
.rx-field label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; display: block; margin-bottom: 4px; }
.rx-field .value { font-size: 17px; font-weight: 700; color: var(--text-primary); }

/* ==================== MODAL ==================== */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px); z-index: 200; justify-content: center; align-items: flex-start; padding: 40px 20px; overflow-y: auto; }
.modal-overlay.active { display: flex; }
.modal { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); width: 100%; max-width: 640px; animation: modalSlide 0.3s ease; }
.modal-xl { max-width: 900px; }
@keyframes modalSlide { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-color); }
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: all var(--transition-fast); }
.modal-close:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.modal-body { padding: 24px; max-height: 65vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* ==================== FORMS ==================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.col-2 { grid-column: span 2; }
.form-group.col-full { grid-column: 1 / -1; }
.form-group label { font-size: 11.5px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.form-group input, .form-group select, .form-group textarea { padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13.5px; font-family: 'Inter', sans-serif; outline: none; transition: all var(--transition-fast); }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--accent-blue-glow); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group select { cursor: pointer; }
.form-section-title { font-size: 13px; font-weight: 700; color: var(--accent-blue); text-transform: uppercase; letter-spacing: 0.5px; padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 8px; }

/* ==================== TABS ==================== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); padding-bottom: 0; margin-bottom: 20px; overflow-x: auto; flex-wrap: nowrap; }
.tab { padding: 10px 16px; background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 12.5px; font-weight: 600; font-family: 'Inter', sans-serif; border-bottom: 2px solid transparent; transition: all var(--transition-fast); white-space: nowrap; }
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }
.tab-content { display: none; animation: fadeIn 0.2s ease; }
.tab-content.active { display: block; }

/* ==================== RX FORM GRID ==================== */
.rx-form-grid { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 12px; }
.rx-form-header { display: grid; grid-template-columns: 50px repeat(4, 1fr); gap: 8px; margin-bottom: 8px; }
.rx-form-header span { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; font-weight: 600; text-align: center; }
.rx-form-row { display: grid; grid-template-columns: 50px repeat(4, 1fr); gap: 8px; align-items: center; margin-bottom: 6px; }
.rx-label { font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.rx-form-row input { padding: 8px 10px; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-primary); font-size: 13px; font-family: 'Inter', sans-serif; text-align: center; outline: none; transition: all var(--transition-fast); }
.rx-form-row input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 2px var(--accent-blue-glow); }

/* ==================== SEARCH RESULTS ==================== */
.search-results { max-height: 200px; overflow-y: auto; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-top: 4px; display: none; }
.search-results.active { display: block; }
.search-result-item { padding: 10px 14px; cursor: pointer; transition: background var(--transition-fast); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(99,140,255,0.06); font-size: 13px; }
.search-result-item:hover { background: rgba(99, 140, 255, 0.08); }
.search-result-item:last-child { border-bottom: none; }
.selected-patient { padding: 10px 14px; background: rgba(54, 214, 181, 0.08); border: 1px solid rgba(54, 214, 181, 0.2); border-radius: var(--radius-sm); margin-top: 8px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }

/* ==================== FILE UPLOAD ==================== */
.file-upload-area { border: 2px dashed var(--border-color); border-radius: var(--radius-md); padding: 30px; text-align: center; cursor: pointer; transition: all var(--transition-fast); }
.file-upload-area:hover { border-color: var(--accent-blue); background: rgba(99, 140, 255, 0.04); }
.file-upload-area p { color: var(--text-secondary); font-size: 13px; margin-top: 6px; }

/* ==================== TOAST ==================== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 14px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; animation: toastIn 0.3s ease; min-width: 280px; display: flex; align-items: center; gap: 10px; box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.toast-success { background: linear-gradient(135deg, rgba(54, 214, 181, 0.15), rgba(34, 211, 238, 0.1)); border: 1px solid rgba(54, 214, 181, 0.3); color: var(--accent-teal); }
.toast-error { background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(244, 114, 182, 0.1)); border: 1px solid rgba(239, 68, 68, 0.3); color: #f87171; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ==================== PAGINATION ==================== */
.pagination { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; border-top: 1px solid var(--border-color); }
.pagination button { padding: 6px 14px; background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-family: 'Inter', sans-serif; transition: all var(--transition-fast); }
.pagination button:hover:not(:disabled) { border-color: var(--accent-blue); color: var(--accent-blue); }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: var(--text-muted); margin: 0 8px; }

/* ==================== LOADING / EMPTY ==================== */
.loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 0; gap: 16px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border-color); border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-muted); }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ==================== PHOTO THUMB ==================== */
.foto-thumb { width: 120px; height: 120px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border-color); cursor: pointer; transition: all var(--transition-fast); }
.foto-thumb:hover { border-color: var(--accent-blue); transform: scale(1.03); }
.foto-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .top-bar { padding: 12px 16px; }
    .search-box { width: 100%; }
    .page-container { padding: 16px; }
    .rx-grid { grid-template-columns: 1fr; }
    .page-title { display: none; }
    .patient-header { flex-direction: column; text-align: center; }
    .form-grid { grid-template-columns: 1fr; }
    .form-group.col-2 { grid-column: span 1; }
    .modal { margin: 10px; }
    .tabs { gap: 0; }
    .tab { padding: 8px 10px; font-size: 11px; }
    .rx-form-grid { overflow-x: auto; }
}
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }

.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: 99; }
.sidebar-overlay.active { display: block; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==================== LOGIN ==================== */
.login-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.login-box { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-card), var(--shadow-glow); text-align: center; }
.login-header h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 24px; }
.login-box .form-group { margin-bottom: 20px; text-align: left; }
.btn-logout:hover { background: rgba(239, 68, 68, 0.1) !important; color: #f87171 !important; transform: scale(1.1); }

/* ==================== ORDEN DE TRABAJO (UI) ==================== */
.ot-numero-display { font-size: 20px; font-weight: 800; color: #e11d48; margin-bottom: 0; background: rgba(225, 29, 72, 0.1); padding: 4px 12px; border-radius: 6px; }
.ot-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 15px; margin-bottom: 15px; box-shadow: var(--shadow-sm); }
.ot-card-title { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-top: 0; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.ot-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; }
.ot-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ot-card .form-group { margin-bottom: 0; }
.ot-card label { font-size: 11px; margin-bottom: 2px; }
.ot-card input[type="text"], .ot-card input[type="date"], .ot-card input[type="number"] { padding: 6px 10px; font-size: 13px; }

.ot-table-rx { width: 100%; border-collapse: collapse; }
.ot-table-rx th { font-size: 11px; text-align: left; padding: 4px 8px; color: var(--text-muted); font-weight: 600; }
.ot-table-rx td { padding: 4px; }
.ot-table-rx input { width: 100%; text-align: center; }

.ot-table-productos { width: 100%; border-collapse: collapse; }
.ot-table-productos th { font-size: 11px; text-align: left; padding: 6px; color: var(--text-muted); border-bottom: 1px solid var(--border-color); }
.ot-table-productos td { padding: 4px; border-bottom: 1px dashed var(--border-color); }
.ot-table-productos input { width: 100%; }

.ot-totales-card { background: #f0fdf4; border-color: #bbf7d0; display: flex; flex-direction: column; justify-content: center; }
.ot-totales-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px; align-items: center; }
.ot-totales-grid label { font-weight: 700; color: #166534; font-size: 12px; text-align: right; margin: 0; }
.ot-totales-grid input { font-size: 14px; font-weight: 700; text-align: right; background: white; border: 1px solid #bbf7d0; color: #166534; }
.ot-totales-grid .input-readonly { background: transparent; border-color: transparent; font-size: 16px; }

/* Autocomplete Dropdown */
.autocomplete-dropdown { border-radius: 6px; border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.autocomplete-item { padding: 10px 14px; cursor: pointer; font-size: 14px; color: #0f172a; border-bottom: 1px solid #f1f5f9; transition: background 0.2s; }
.autocomplete-item strong { color: #000000; font-weight: 700; }
.autocomplete-item:hover { background: #e2e8f0; color: #000000; }

/* ==================== VISTA DE IMPRESIÓN ==================== */
.print-area { display: none; }

@media print {
    html, body { height: auto !important; min-height: auto !important; overflow: visible !important; margin: 0; padding: 0; background: white; }
    body > *:not(.print-area) { display: none !important; }
    .print-area { display: block !important; position: static !important; width: 100%; padding: 0; margin: 0; font-family: 'Helvetica', 'Arial', sans-serif; color: black; background: white; page-break-after: avoid; }
    
    @page { margin: 10mm; size: A4; }
    
    .print-area { display: block; }
    .print-area.print-layout-two { zoom: 0.75; }
    
    .print-ot-container { width: 100%; max-width: 800px; margin: 0 auto; border: 1px solid black; padding: 15px; border-radius: 4px; box-sizing: border-box; }
    .print-area.print-layout-two .print-ot-container { padding: 10px; page-break-inside: avoid; }
    .print-area.print-layout-two .print-ot-header { margin-bottom: 8px; padding-bottom: 8px; }
    .print-area.print-layout-two .print-ot-paciente { margin-bottom: 8px; padding: 8px; }
    .print-area.print-layout-two .print-ot-rx { margin-bottom: 8px; }
    .print-area.print-layout-two .print-ot-params { margin-bottom: 8px; padding: 5px; }
    .print-area.print-layout-two .print-ot-productos { margin-bottom: 8px; }
    
    .print-copy-separator { border-top: 2px dashed #999; margin-top: 10px; padding-top: 10px; }
    .print-ot-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid black; padding-bottom: 10px; margin-bottom: 15px; }
    .print-ot-logo img { height: 60px; object-fit: contain; }
    .print-ot-info { flex: 1; text-align: center; font-size: 10px; padding: 0 10px; }
    .p-col { flex: 1; display: flex; align-items: flex-end; }
    .p-right { justify-content: flex-end; }
    .p-val { flex: 1; border-bottom: 1px solid black; margin-left: 5px; display: inline-block; min-height: 14px; font-weight: bold; padding-left: 5px; }
    .p-right .p-val { flex: none; width: 150px; }
    
    .print-ot-rx { width: 100%; border-collapse: collapse; margin-bottom: 15px; font-size: 12px; text-align: center; }
    .print-ot-rx th, .print-ot-rx td { border: 1px solid black; padding: 6px; }
    .print-ot-rx th { background-color: #f0f0f0 !important; -webkit-print-color-adjust: exact; }
    .bold { font-weight: bold; }
    
    .print-ot-params { border: 1px solid black; padding: 8px 10px; margin-bottom: 15px; font-size: 12px; }
    .params-title { font-weight: bold; margin-bottom: 5px; }
    .params-row { display: flex; justify-content: space-between; }
    .param-val { display: inline-block; width: 40px; border-bottom: 1px solid black; text-align: center; font-weight: bold; }
    
    .print-ot-productos { border: 1px solid black; margin-bottom: 15px; }
    .productos-title { font-weight: bold; font-size: 12px; padding: 5px 10px; border-bottom: 1px solid black; }
    .print-table-prod { width: 100%; border-collapse: collapse; font-size: 12px; }
    .print-table-prod th, .print-table-prod td { padding: 6px 10px; border-bottom: 1px dotted #ccc; }
    .print-table-prod th { text-align: left; }
    .print-table-prod td { height: 20px; }
    
    .print-ot-obs { font-size: 12px; margin-bottom: 20px; min-height: 40px; }
    
    .print-ot-footer { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 40px; }
    .print-firma-box { text-align: center; width: 250px; }
    .firma-line { border-top: 1px solid black; width: 100%; margin-bottom: 5px; }
    .firma-text { font-size: 10px; font-weight: bold; }
    .print-boleta { font-size: 14px; font-weight: bold; border: 2px solid black; padding: 10px 20px; }
    .print-totales { font-size: 14px; width: 200px; }
    .tot-row { display: flex; justify-content: space-between; margin-bottom: 5px; }
    .tot-lbl { font-weight: bold; }
    .tot-val { font-weight: bold; }
}

/* Kanban / Estados LAB */
.badge-lab { padding: 4px 8px; border-radius: 12px; font-size: 11px; font-weight: bold; display: inline-block; text-align: center; }
.badge-lab.pendiente { background: #e2e8f0; color: #475569; }
.badge-lab.laboratorio { background: #dbeafe; color: #1e3a8a; }
.badge-lab.listo { background: #fef3c7; color: #92400e; }
.badge-lab.entregado { background: #dcfce7; color: #166534; }

.select-estado { padding: 4px; border-radius: 4px; border: 1px solid var(--border-color); font-size: 12px; margin-left: 5px; }

/* Fotos Thumbnails */
.ot-foto-thumb { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 2px solid var(--border-color); cursor: pointer; }
.ot-foto-thumb:hover { opacity: 0.8; }
.ot-foto-container { position: relative; display: inline-block; }
.ot-foto-remove { position: absolute; top: -5px; right: -5px; background: #ef4444; color: white; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: bold; border: none; }

/* Tabs */
.tabs-container .btn { opacity: 0.6; }
.tabs-container .btn-primary { opacity: 1; }

/* ==================== ARQUEO SPREADSHEET UX ==================== */

/* Inline payment input cells */
.pay-input {
    width: 100%;
    min-width: 55px;
    max-width: 75px;
    padding: 4px 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    text-align: right;
    outline: none;
    transition: border-color var(--transition-fast);
    -moz-appearance: textfield;
}
.pay-input::-webkit-outer-spin-button,
.pay-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.pay-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-blue-glow);
}
.pay-input:hover {
    border-color: var(--border-active);
}

/* Arqueo table rows */
.arqueo-row td {
    padding: 6px 4px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}
.arqueo-row:hover {
    background: var(--bg-card-hover);
}

/* Summary chips (small cards at bottom) */
.resumen-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    text-align: center;
    transition: all var(--transition-fast);
}
.resumen-chip:hover {
    border-color: var(--border-active);
    transform: translateY(-1px);
}
.chip-label {
    display: block;
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}
.chip-value {
    display: block;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Toast para arqueo */
.arqueo-toast {
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* html2canvas render styling */
.html2canvas-render {
    display: block !important;
    position: absolute !important;
    top: -9999px !important;
    left: 0 !important;
    background: white !important;
    color: black !important;
    font-family: 'Helvetica', 'Arial', sans-serif !important;
}
.html2canvas-render.single-copy { width: 800px; }
.html2canvas-render.double-copy {
    width: 1600px;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    padding: 20px;
    box-sizing: border-box;
}
.html2canvas-render.double-copy .print-ot-container { width: 48%; margin: 0; }
.html2canvas-render.double-copy .print-copy-separator {
    border-top: none;
    border-left: 4px dashed #999;
    margin-left: 10px;
    padding-left: 10px;
}
