/* ==========================================================================
   BIOLAB LIS ENTERPRISE - DESIGN SYSTEM & GLOBAL STYLES
   ========================================================================== */

/* Typography & Variables */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Colors */
  --primary: #2e8bff;
  --primary-hover: #1a73e8;
  --primary-light: #eaf3ff;
  --bg-main: #f5f5f7;
  --bg-card: #ffffff;
  --text-main: #1c1c1e;
  --text-muted: #86868b;
  --text-light: #aeaeab;
  --border-color: #e5e5ea;
  
  /* Status Colors */
  --success: #34c759;
  --success-light: #eafaf1;
  --warning: #ff9500;
  --warning-light: #fff9e6;
  --danger: #ff3b30;
  --danger-light: #ffebe9;
  --info: #007aff;
  --info-light: #e6f2ff;

  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Layout */
  --sidebar-width: 260px;
  --header-height: 70px;
  --border-radius: 12px;
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-subtle: 0 4px 20px -2px rgba(28, 28, 30, 0.05), 0 2px 8px -1px rgba(28, 28, 30, 0.02);
  --shadow-medium: 0 10px 30px -5px rgba(28, 28, 30, 0.08), 0 4px 12px -2px rgba(28, 28, 30, 0.03);
  --shadow-premium: 0 20px 40px -10px rgba(46, 139, 255, 0.12), 0 1px 3px rgba(0, 0, 0, 0.02);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: 100vh;
  height: 100dvh;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Layout Wrapper */
.app-container {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ==========================================================================
   SIDEBAR NAV (LATERAL FIJA)
   ========================================================================== */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, #1a73e8 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: var(--shadow-premium);
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.logo-subtitle {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
}

.sidebar-menu {
  flex: 1;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  border-radius: var(--border-radius);
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}

.menu-item:hover {
  background-color: var(--bg-main);
  color: var(--text-main);
}

.menu-item.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.menu-item i {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.sidebar-footer {
  padding: 8px 20px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Desktop sidebar collapse state */
@media (min-width: 769px) {
  .app-container.desktop-collapsed .sidebar {
    display: none !important;
  }

  .app-container.desktop-collapsed .mobile-menu-btn {
    display: flex !important;
  }
}

/* ==========================================================================
   MAIN CONTENT & HEADER
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.global-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 90;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.sede-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-main);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  transition: var(--transition-smooth);
}

.sede-selector-wrapper:hover {
  border-color: var(--primary);
}

.sede-selector-wrapper i {
  color: var(--primary);
}

.sede-select {
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-main);
  cursor: pointer;
  outline: none;
  padding-right: 6px;
}

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


.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 1px solid var(--border-color);
  padding-left: 16px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  border: 2px solid #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
}

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

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-main);
}

.user-role-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.5px;
}

/* Main Workspace */
.workspace-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  position: relative;
}

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

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

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

/* ==========================================================================
   UI COMPONENTS & CARDS
   ========================================================================== */
.view-title-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.view-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-help-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  vertical-align: middle;
}

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

.view-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.card {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-subtle);
  padding: 12px;
  margin-bottom: 12px;
  min-width: 0;
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--primary);
}

/* Grid System */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row {
  display: flex;
  align-items: flex-end; /* Align inputs to the bottom when labels wrap or have different heights */
  gap: 8px;
  margin-bottom: 6px;
}

#modal-digitar .form-row {
  align-items: flex-start;
}

.form-row .form-group {
  flex: 1;
  min-width: 0; /* Prevents flex items from overflowing due to intrinsic input widths (e.g. date inputs) */
  margin-bottom: 0;
}

label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
}

label .required {
  color: var(--danger);
  margin-left: 2px;
}

input, select, textarea {
  width: 100%;
  min-width: 0; /* Ensures controls shrink inside flex columns instead of overflowing */
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: #fff;
  font-size: 13.5px;
  transition: var(--transition-smooth);
  outline: none;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

input, select {
  height: 34px;
}

input[type="date"] {
  width: 100%;
  min-width: 0 !important;
  box-sizing: border-box;
}

input[type="date"]::-webkit-datetime-edit {
  display: inline-flex;
  align-items: center;
  height: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

input:disabled, select:disabled, textarea:disabled {
  background-color: var(--bg-main);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow-premium);
}

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

.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-color);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: rgba(255, 59, 48, 0.15);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--danger);
  color: #fff;
}

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

.btn-sm {
  height: 28px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 6px;
}

/* ==========================================================================
   TABLES & PAGINATION
   ========================================================================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

/* Evitar que S/. y los valores se partan en dispositivos móviles */
.text-nowrap, .currency-nowrap {
  white-space: nowrap !important;
}

th.col-fecha, td.col-fecha,
th.col-estado, td.col-estado,
th.col-importe, td.col-importe,
th.col-acciones, td.col-acciones,
th.col-id, td.col-id {
  white-space: nowrap;
}

th {
  background-color: var(--bg-main);
  padding: 10px 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
  white-space: nowrap;
}

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

tr:hover td {
  background-color: rgba(46, 139, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-success { background-color: var(--success-light); color: var(--success); }
.badge-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-danger { background-color: var(--danger-light); color: var(--danger); }
.badge-info { background-color: var(--info-light); color: var(--info); }

/* Pagination Control */
.pagination-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 8px;
  flex-wrap: wrap;
  gap: 10px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* Tabs */
.tabs-container {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  gap: 8px;
}

.tab-btn {
  padding: 9px 15px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: var(--text-main);
}

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

/* ==========================================================================
   MODAL COMPONENT
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: rgba(28, 28, 30, 0.8);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background-color: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  width: 90%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.modal-overlay.active .modal-box {
  transform: translateY(0);
}

.modal-box > form {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Prueba Modal - Wider */
#modal-prueba .modal-box {
  max-width: 1050px;
  width: 95%;
}

/* Reference Value Row Cards */
.ref-row-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-left: 4px solid var(--primary, #4f6ef7);
  border-radius: 4px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: box-shadow 0.2s ease;
}

.ref-row-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ref-row-criteria,
.ref-row-values {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.ref-row-criteria .ref-field,
.ref-row-values .ref-field {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.ref-row-criteria .ref-field label,
.ref-row-values .ref-field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted, #8a8a8a);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ref-row-criteria .ref-field select,
.ref-row-criteria .ref-field input,
.ref-row-values .ref-field select,
.ref-row-values .ref-field input {
  width: 100%;
  height: 32px;
  font-size: 12.5px;
  padding: 4px 8px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.ref-row-criteria .ref-field select:focus,
.ref-row-criteria .ref-field input:focus,
.ref-row-values .ref-field select:focus,
.ref-row-values .ref-field input:focus {
  border-color: var(--primary, #4f6ef7);
  box-shadow: 0 0 0 2px rgba(79, 110, 247, 0.12);
}

.ref-row-delete-btn {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.ref-row-delete-btn:hover {
  background: #fecaca;
}

/* Vet Species Row */
.vet-species-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-left: 4px solid #10b981;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vet-species-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.vet-row-line {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: nowrap;
}

.vet-row-line .ref-field {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.vet-row-line .ref-field label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted, #8a8a8a);
  margin-bottom: 3px;
  white-space: nowrap;
}

.vet-row-line .ref-field select,
.vet-row-line .ref-field input {
  width: 100%;
  height: 32px;
  font-size: 12.5px;
  padding: 4px 8px;
  border: 1px solid #d4d4d4;
  border-radius: 6px;
  background: #fff;
  outline: none;
  transition: border-color 0.2s;
}

.vet-row-line .ref-field select:focus,
.vet-row-line .ref-field input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.12);
}

/* Reference section helper tip */
.ref-helper-tip {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #1e40af;
  line-height: 1.6;
  margin-bottom: 12px;
}

.ref-helper-tip strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12.5px;
}

.ref-helper-tip ul {
  margin: 0;
  padding-left: 18px;
}

.ref-helper-tip ul li {
  margin-bottom: 2px;
}

/* Fuente/Interpretacion global section */
.prueba-fuente-section {
  margin-top: 16px;
  border-top: 1px solid var(--border-color, #e5e7eb);
  padding-top: 16px;
}

.prueba-fuente-section label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-main, #1f2937);
}

.prueba-fuente-section textarea {
  margin-top: 4px;
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.prueba-fuente-section textarea:focus {
  border-color: var(--primary, #4f6ef7);
  box-shadow: 0 0 0 2px rgba(79, 110, 247, 0.12);
}

#modal-ticket .modal-box {
  width: max-content;
  min-width: 1100px;
  max-width: 95vw;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: var(--transition-smooth);
}

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

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

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

/* ==========================================================================
   MODULE SPECIFIC WORKFLOW STYLES
   ========================================================================== */

/* 1. Dashboard Overview Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 20px;
  margin-bottom: 16px;
}

.stat-card {
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-subtle);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.primary { background-color: var(--primary-light); color: var(--primary); }
.stat-icon.success { background-color: var(--success-light); color: var(--success); }
.stat-icon.warning { background-color: var(--warning-light); color: var(--warning); }
.stat-icon.info { background-color: var(--info-light); color: var(--info); }
.stat-icon.info { background-color: var(--info-light); color: var(--info); }

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

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

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

/* 2. Matriz de Tarifarios Dynamic Grid */
.matrix-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.matrix-table th,
.matrix-table td {
  padding: 4px 6px !important;
  font-size: 12px !important;
}

.matrix-table tbody tr:nth-child(even) td {
  background-color: #f5f9ff;
}

.matrix-table input {
  padding: 3px 4px !important;
  width: 75px !important;
  text-align: center !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  height: 24px !important;
}

.matrix-table input:focus {
  background-color: var(--primary-light);
}

/* 3. Catalog - Complex Parameters Editor */
.param-editor-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.param-editor-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background-color: var(--bg-main);
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.param-editor-row input {
  background-color: #fff;
  padding: 8px 12px;
}

/* 4. Billing Module Order Form */
.billing-order-container {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow-medium);
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-size: 13.5px;
  border-bottom: 1px solid #f2f2f5;
}

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

.search-result-item:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.test-selection-list {
  margin-top: 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.test-selection-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-color);
}

.test-selection-item:last-child {
  border-bottom: none;
}

.test-selection-details {
  display: flex;
  flex-direction: column;
}

.test-selection-name {
  font-size: 13.5px;
  font-weight: 600;
}

.test-selection-type {
  font-size: 11px;
  color: var(--text-muted);
}

.checkout-summary-card {
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 14px 16px;
  position: sticky;
  top: 20px;
  box-shadow: var(--shadow-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-muted);
}

.summary-row.total {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
  margin-top: 4px;
}

.summary-value {
  color: var(--text-main);
  font-weight: 600;
}

.summary-row.total .summary-value {
  color: var(--primary);
}

/* 5. Microbiograma / Antibiograma triple option button */
.antibiogram-btn-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.antibiogram-btn {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  border: none;
  background-color: var(--bg-main);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.antibiogram-btn.active.S { background-color: var(--success); color: #fff; }
.antibiogram-btn.active.I { background-color: var(--warning); color: #fff; }
.antibiogram-btn.active.R { background-color: var(--danger); color: #fff; }

/* 6. Intelligent Validation Input Alertas */
.clinical-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.clinical-input-wrapper input {
  padding-right: 80px;
}

.clinical-input-wrapper.alert-out-of-range input {
  border-color: var(--danger) !important;
  background-color: var(--danger-light);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
  color: #c91e14;
  font-weight: 600;
}

.clinical-unit-label {
  position: absolute;
  right: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.alert-message-tooltip {
  display: none;
  font-size: 11px;
  color: var(--danger);
  font-weight: 600;
  margin-top: 4px;
  align-items: center;
  gap: 4px;
}

.clinical-input-wrapper.alert-out-of-range + .alert-message-tooltip {
  display: flex;
}

/* Drag and Drop simulator styling */
.drag-drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.drag-drop-zone:hover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.drag-drop-zone i {
  font-size: 32px;
  color: var(--primary);
}

.uploaded-pdf-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background-color: var(--info-light);
  color: var(--info);
  border: 1px solid rgba(0, 122, 255, 0.15);
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
}

/* 7. Tickets & Reports Preview Layouts */
.ticket-wrapper {
  background-color: #fff;
  width: 80mm;
  padding: 5px; /* Reducido para maximizar espacio */
  border: 1px solid #ccc;
  margin: 0 auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11.9px; /* Reducido 15% de 14px */
  font-weight: 700; /* Thicker for thermal */
  color: #000;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  box-sizing: border-box;
  line-height: 1.12; /* Reducido 20% */
}

.ticket-header {
  text-align: center;
  margin-bottom: 9.6px; /* Reducido 20% de 12px */
  line-height: 1.12; /* Reducido 20% de 1.4 */
}

.ticket-logo {
  font-weight: 900;
  font-size: 13.6px; /* Reducido 15% de 16px */
  letter-spacing: 1px;
}

.ticket-divider {
  border-top: 1px dashed #000;
  margin: 6.4px 0; /* Reducido 20% de 8px */
}

.ticket-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3.2px; /* Reducido 20% de 4px */
}

.ticket-barcode-sim {
  margin: 15px 0 5px 0;
  height: 45px;
  background: repeating-linear-gradient(
    90deg,
    #000,
    #000 2px,
    #fff 2px,
    #fff 6px
  );
  width: 100%;
}

.ticket-barcode-text {
  text-align: center;
  font-size: 9.35px; /* Reducido 15% de 11px */
  letter-spacing: 2px;
  font-weight: 900;
}

/* Elegant A4 Report styling (Print and Screen preview) */
.report-preview-a4 {
  background-color: #fff;
  width: 100%;
  max-width: 800px;
  min-height: 1000px;
  margin: 0 auto;
  border: 1px solid var(--border-color);
  padding: 45px;
  box-shadow: var(--shadow-medium);
  font-family: 'Plus Jakarta Sans', sans-serif;
  color: #2c3e50;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.report-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.report-header-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.report-logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.report-logo-icon {
  width: 44px;
  height: 44px;
  background-color: var(--primary);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
}

.report-logo-text {
  line-height: 1.2;
}

.report-title-label {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.report-subtitle-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.report-header-legal {
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.report-patient-card {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 15px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 20px;
  font-size: 12px;
}

.report-patient-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.report-patient-field .value {
  font-weight: 600;
  color: var(--text-main);
  font-size: 12.5px;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}

.report-table th {
  background-color: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  padding: 4px 12px;
  border: none;
}

.report-table td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-main);
}

.report-table tr:hover td {
  background-color: transparent;
}

.report-table tr.out-of-range td {
  background-color: rgba(255, 59, 48, 0.05);
}

.report-table tr.exam-header-row td {
  background-color: #f8fafc;
  font-weight: 700;
  color: var(--primary);
  font-size: 12px;
  border-bottom: 1px solid var(--border-color);
}

.report-table tr.exam-header-row:not(:first-child) td {
  border-top: 2px solid var(--border-color);
}

.result-flag-danger {
  color: var(--danger);
  font-weight: 700;
  background-color: var(--danger-light);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-size: 10px;
}

.report-footer-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 30px;
}

.report-notes {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 450px;
  line-height: 1.5;
}

.report-signature-block {
  text-align: center;
  width: 200px;
}

.signature-line {
  border-top: 1px solid var(--text-main);
  margin-bottom: 6px;
}

.signature-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
}

.signature-role {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Embedded PDF Iframe mockup */
.pdf-viewer-mockup {
  width: 100%;
  height: 500px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
  border-radius: var(--border-radius);
}

.pdf-viewer-mockup i {
  font-size: 48px;
  color: var(--danger);
}

/* ==========================================================================
   TOAST NOTIFICATIONS (PREMIUM ALERTS)
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20000 !important;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  background-color: #fff;
  border-left: 4px solid var(--primary);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  padding: 16px 20px;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  animation: slideInToast 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.toast-error {
  border: 1px solid rgba(231, 76, 60, 0.3);
  border-left: 4px solid var(--danger);
}

.toast.toast-success {
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-left: 4px solid var(--success);
}

.toast.toast-warning {
  border: 1px solid rgba(241, 196, 15, 0.3);
  border-left: 4px solid var(--warning);
}

.toast.fade-out {
  animation: fadeOutToast 0.3s ease forwards;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
}
.toast-error .toast-icon { color: var(--danger); }
.toast-success .toast-icon { color: var(--success); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-main);
}

.toast-message {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 0;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}

.toast-close:hover {
  color: var(--text-main);
}

@keyframes slideInToast {
  0% { transform: translateX(120%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOutToast {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

/* Se removió el @media print global para evitar conflictos con la función de impresión aislada de printElement. */

/* ==========================================================================
   RESPONSIVE DESIGN (MÓVILES Y TABLETS PEQUEÑAS)
   ========================================================================== */
@media (max-width: 1024px) {
  /* Header Adjustments */
  .global-header {
    padding: 0 16px;
  }
  
  .header-left {
    gap: 10px;
  }
  
  .sede-select {
    max-width: 120px;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .user-role-badge,
  .user-name {
    display: none; /* Hide extra text to save space */
  }

  #session-timer {
    margin-left: 5px !important;
    padding: 4px 6px !important;
    font-size: 11px !important;
  }
  #session-timer i {
    width: 12px !important;
    height: 12px !important;
    margin-right: 3px !important;
  }

  /* Sidebar Mobile Layout (Off-canvas) */
  .sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100vh;
  height: 100dvh;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  /* Backdrop for Sidebar */
  .mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
  height: 100dvh;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .mobile-backdrop.active {
    display: block;
    opacity: 1;
  }

  /* Hamburguer Menu Button */
  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 8px;
    cursor: pointer;
    background: var(--bg-main);
    border-radius: 8px;
    color: var(--text-main);
  }

  /* Modals */
  .modal-box {
    width: 95% !important;
    max-width: none !important;
    margin: 20px auto;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
  
  /* Layout Modules */
  .billing-order-container {
    grid-template-columns: 1fr !important;
    gap: 16px;
  }
  
  .left-panel, .right-panel {
    border-right: none;
    width: 100%;
    overflow-y: visible;
    padding: 16px;
  }

  /* Tables Overflow (Scroll horizontal) */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  
  table td, table th {
    padding: 6px !important; /* Reducir padding en móviles para ganar espacio */
  }

  /* Forms and Filters */
  .form-row {
    flex-direction: column !important; /* Stack form inputs vertically */
    align-items: stretch !important;   /* Reset align-items for mobile vertical layout */
    gap: 10px;
  }

  .search-bar {
    max-width: 100%;
  }

  /* ==========================================
     GLOBAL RESPONSIVE OVERRIDES
     ========================================== */
  
  /* Universal Grids -> 1 Column */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }
  
  /* Catch-all for inline styles that use grids (e.g., config panels) 
     Excluimos auto-fit y auto-fill porque esas ya son responsivas por naturaleza */
  div[style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]) {
    grid-template-columns: 1fr !important;
  }
  
  /* Catch-all for inline flex that splits horizontally (e.g., headers with buttons) */
  .view-title-container {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px;
  }
  
  /* Make main action buttons full width on mobile */
  .view-title-container .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Wrap tabs so they don't overflow */
  .tabs-container {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 8px;
    height: auto !important;
    padding-bottom: 8px;
  }
  
  .tab-btn {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
    border-bottom: 2px solid transparent !important;
  }

  /* Specific fix for Historia Clinica Layout */
  #historia-workspace {
    grid-template-columns: 1fr !important;
  }
  
  /* Form Rows */
  .form-row {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }

  /* Override specific hardcoded widths in inputs wrapper */
  .card > div[style*="display: flex; gap: 12px"] {
    flex-direction: column !important;
  }
  .card > div > div[style*="max-width: 400px"] {
    max-width: 100% !important;
  }
  .card select, .card input[type="text"] {
    width: 100% !important;
  }

  /* Compact dashboard tables on mobile so they fit perfectly without scrolling */
  #view-dashboard .table-wrapper table {
    min-width: 100% !important;
  }
  #view-dashboard .table-wrapper table th,
  #view-dashboard .table-wrapper table td {
    padding: 6px 4px !important;
    font-size: 11px !important;
  }
}

/* ==========================================================================
   TABLET & MOBILE FIXES (Ocultar ID Orden hasta iPads/Tablets)
   ========================================================================== */
@media (max-width: 1200px) {
  /* Ocultar columna ID Orden en Historial, Resultados y Dashboard para ahorrar espacio */
  #view-dashboard .table-wrapper table th.col-id,
  #view-dashboard .table-wrapper table td.col-id,
  #view-historial-ordenes .table-wrapper table th.col-id,
  #view-historial-ordenes .table-wrapper table td.col-id,
  #view-resultados .table-wrapper table th.col-id,
  #view-resultados .table-wrapper table td.col-id {
    display: none !important;
  }
}

/* Base style for mobile button (hidden on desktop) */
.mobile-menu-btn {
  display: none;
}

/* Toggle Switch Styles */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  margin-bottom: 12px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .toggle-slider {
  background-color: var(--primary, #2563eb);
}
input:checked + .toggle-slider:before {
  transform: translateX(20px);
}
.toggle-label-text {
  display: inline-block;
  vertical-align: top;
  margin-left: 8px;
  line-height: 24px;
  font-size: 14px;
  color: var(--text-color, #333);
  font-weight: 500;
}

/* Promociones Panel Grid Responsive */
.responsive-promo-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
}
@media (max-width: 992px) {
  .responsive-promo-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* ==========================================================================
   ADVANCED RESPONSIVE FILTER GRID & TICKET MODAL FIXES
   ========================================================================== */

/* Base Filters Row & Column Layout */
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.filter-col {
  flex: 1;
  min-width: 150px;
}

.filters-actions-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters-actions-group input[type="date"] {
  min-width: 0 !important;
  max-width: 180px;
  flex: 1;
}

/* Card Filters System - Responsive Flexbox */
.card-filters-grid {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  align-items: flex-end !important;
  margin-bottom: 20px !important;
}

.card-filters-grid > div {
  flex: 1 1 auto !important;
  min-width: 140px !important;
  max-width: 250px !important;
  box-sizing: border-box !important;
}

.card-filters-grid .filter-col-search {
  flex: 2 1 240px !important;
  min-width: 180px !important;
}

.card-filters-grid .filter-col-date,
.card-filters-grid .filter-col-select {
  flex: 1 1 auto !important;
  min-width: 0 !important;
}

.card-filters-grid .filter-col-buttons {
  flex: 1 1 auto !important;
  display: flex !important;
  gap: 8px !important;
  justify-content: flex-end !important;
  max-width: none !important; /* Let buttons align to the right naturally */
}

.card-filters-grid .filter-col-buttons .btn {
  height: 38px;
  white-space: nowrap;
}

/* Viewport Adjustments for tablets & iPads (max-width: 992px) */
@media (max-width: 992px) {
  .billing-order-container {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
  
  #modal-ticket .modal-box {
    width: 95vw !important;
    min-width: unset !important;
    max-width: none !important;
  }
  
  .card-filters-grid {
    gap: 10px !important;
  }
  
  .card-filters-grid .filter-col-date,
  .card-filters-grid .filter-col-select {
    max-width: none !important;
  }
}

/* Viewport Adjustments for mobile & tablet devices (max-width: 1024px) */
@media (max-width: 1024px) {
  .workspace-content {
    padding: 16px !important;
  }
  
  .view-title {
    font-size: 20px !important;
  }
  
  .filters-row, .card-filters-grid {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  
  .card-filters-grid .filter-col-search {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .card-filters-grid > div {
    max-width: 100% !important;
    width: 100% !important;
    flex: 1 1 auto !important;
  }
  
  .filter-col {
    max-width: none !important;
    width: 100% !important;
  }
  
  .filters-actions-group,
  .card-filters-grid .filter-col-buttons {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  
  .filters-actions-group input[type="date"] {
    width: 100% !important;
  }
  
  .filters-actions-group .btn {
    width: 100%;
    grid-column: span 1;
  }
}

/* Specific Adjustments for small phones (max-width: 576px) */
@media (max-width: 576px) {
  .card-filters-grid .filter-col-buttons {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  
  .card-filters-grid .filter-col-buttons .btn {
    width: 100% !important;
  }
  
  .filters-actions-group {
    grid-template-columns: 1fr !important;
  }
  
  .filters-actions-group .btn {
    grid-column: span 1 !important;
  }
}

/* Patient Grid Header in Digitization Modal */
@media (max-width: 992px) {
  .patient-grid-header {
    grid-template-columns: 1fr 1fr !important;
  }
}
@media (max-width: 576px) {
  .patient-grid-header {
    grid-template-columns: 1fr !important;
    padding: 10px 14px !important;
  }
}

/* Custom Tube Label Roll Styles (50mm x 25mm) */
.labels-container {
  background: transparent;
  width: 50mm;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 12px; /* Espaciado limpio entre etiquetas en pantalla */
  margin: 0 auto;
}

.label-sticker {
  background: #fff;
  width: 50mm;
  height: 25mm;
  box-sizing: border-box;
  padding: 1.5mm;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  page-break-after: always;
  break-after: page;
  /* On screen styling */
  border: 1px solid #d1d5db;
  border-radius: 2px;
}

@media print {
  .no-print, .no-print-helper {
    display: none !important;
  }

  .labels-container {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    gap: 0 !important;
    width: 50mm !important;
    margin: 0 !important;
  }
  
  .label-sticker {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: 50mm !important;
    height: 25mm !important;
    margin: 0 !important;
    padding: 1mm 1.5mm !important;
  }
}

/* Patient view styling for filters inherits unified flexbox structure */

/* Tighter padding for all workspace tables to fit more information */
table:not(.report-table) th, 
table:not(.report-table) td {
  padding: 8px 14px !important;
  font-size: 13px !important;
}

/* Specific column widths & container styles for the Historial table to optimize screen space */
#view-historial-ordenes .table-wrapper {
  overflow-x: auto;
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--card-bg, #fff);
}

#view-historial-ordenes table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

#view-historial-ordenes .col-acciones {
  width: 160px;
  min-width: 160px;
  max-width: 165px;
  text-align: center;
}
#view-historial-ordenes .col-id {
  width: 120px;
  min-width: 120px;
}
#view-historial-ordenes .col-fecha {
  width: 100px;
  min-width: 100px;
}
#view-historial-ordenes .col-sede {
  width: 95px;
  min-width: 95px;
}
#view-historial-ordenes .col-paciente {
  min-width: 190px;
}
#view-historial-ordenes .col-referencia {
  width: 95px;
  min-width: 90px;
}
#view-historial-ordenes .col-medico {
  width: 90px;
  min-width: 85px;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#view-historial-ordenes .col-importe {
  width: 95px;
  min-width: 95px;
  text-align: right;
  white-space: nowrap;
}
#view-historial-ordenes .col-estado {
  width: 110px;
  min-width: 110px;
  text-align: center;
  white-space: nowrap;
}

/* Grid compacto para botones de acción en Historial (Máximo 2 filas) */
.historial-acciones-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  align-items: center;
  max-width: 158px;
  margin: 0 auto;
}

.historial-acciones-grid .btn-icon-action {
  width: 27px !important;
  height: 27px !important;
  min-width: 27px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 6px !important;
  font-size: 11px !important;
  flex-shrink: 0 !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.historial-acciones-grid .btn-icon-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.historial-acciones-grid .btn-icon-action svg {
  width: 13.5px !important;
  height: 13.5px !important;
}

/* Responsive adjustments for filters on mobile screens */
@media (max-width: 768px) {
  .card-filters-grid {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .card-filters-grid > div {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .card-filters-grid .filter-col-buttons {
    flex-direction: row !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  .card-filters-grid .filter-col-buttons .btn {
    flex: 1 !important;
    width: 100% !important;
    height: 36px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
  }

  .card-filters-grid input,
  .card-filters-grid select {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: 36px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
  }
}

/* Sidebar Sede actions widget styling */
.sede-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sede-actions-grid .btn {
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  text-decoration: none;
}

.sede-actions-grid .btn .lbl-action {
  display: none; /* Hide label on PC/Desktop */
}

.sede-actions-grid .btn .lbl-action-wa-pc {
  display: inline-block; /* Show on PC/Desktop */
  font-size: 12px;
  font-weight: 600;
}

.sede-actions-grid .btn i,
.sede-actions-grid .btn svg {
  display: inline-block;
  vertical-align: middle;
}

/* Mobile responsive styling for Sede actions */
@media (max-width: 768px) {
  .sede-actions-grid {
    grid-template-columns: 1fr !important; /* Stack vertically on mobile */
    gap: 6px !important;
  }

  .sede-actions-grid .btn {
    height: 36px !important;
    padding: 0 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
  }

  .sede-actions-grid .btn i,
  .sede-actions-grid .btn svg {
    display: none !important; /* Hide icons on mobile */
  }

  .sede-actions-grid .btn .lbl-action {
    display: inline-block !important; /* Show text label on mobile */
    font-size: 11.5px !important;
    font-weight: 600 !important;
  }

  .sede-actions-grid .btn .lbl-action-wa-pc {
    display: none !important; /* Hide WA text on mobile since WhatsApp is shown */
  }
}

/* --- Clinical SVG Charts Styling --- */
.live-chart-preview-box {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-small);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
}

.live-chart-preview-box:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-medium);
}

.live-chart-preview-box svg {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* Print optimizations for SVG charts */
@media print {
  .report-table tr {
    page-break-inside: avoid;
  }
  .report-table tr td svg {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

/* Responsive adjustments for 3-column ticket modal */
@media (max-width: 1150px) {
  #modal-ticket .modal-body {
    flex-direction: column !important;
    align-items: center !important;
    gap: 30px !important;
    padding: 20px !important;
  }
  #modal-ticket .modal-box {
    width: 95vw !important;
    min-width: unset !important;
    max-width: 100% !important;
  }
  #modal-ticket #section-consentimiento, 
  #modal-ticket div[style*="border-left"] {
    border-left: none !important;
    padding-left: 0 !important;
    border-top: 1px dashed var(--border-color);
    padding-top: 20px;
    width: 100% !important;
  }
}

/* Formula & Tooltip Styles */
.formula-computed {
  background-color: #e8f5e9 !important;
  border: 1px solid #81c784 !important;
  color: #2e7d32 !important;
  font-weight: 600 !important;
}

.formula-tooltip-container:hover .formula-tooltip-text {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Unification and responsive adjustments for Custom Date Containers */
#dashboard-custom-date-container,
#crm-custom-date-container,
#historial-custom-date-container,
#resultados-custom-date-container {
  display: none;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  flex: 2 1 300px !important;
  min-width: 280px !important;
}

@media (max-width: 992px) {
  #dashboard-custom-date-container,
  #crm-custom-date-container,
  #historial-custom-date-container,
  #resultados-custom-date-container {
    flex: 1 1 100% !important;
    min-width: unset !important;
    width: 100% !important;
  }
}

@media (max-width: 768px) {
  #dashboard-custom-date-container,
  #crm-custom-date-container,
  #historial-custom-date-container,
  #resultados-custom-date-container {
    flex-direction: row;
    gap: 8px;
  }
  #dashboard-custom-date-container > div,
  #crm-custom-date-container > div,
  #historial-custom-date-container > div,
  #resultados-custom-date-container > div {
    flex: 1 1 0px;
    width: 100%;
  }
}

@media (max-width: 768px) {
  .col-codigo-tarifa {
    display: none !important;
  }
}

/* 2.5 Catalog of Tests Table Configurations */
.pruebas-table {
  width: 100% !important;
  table-layout: fixed !important;
}

.pruebas-table th,
.pruebas-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Column 1: Código */
.pruebas-table th:nth-child(1),
.pruebas-table td:nth-child(1) {
  width: 95px !important;
  white-space: nowrap !important;
}

/* Column 2: Prueba */
.pruebas-table th:nth-child(2),
.pruebas-table td:nth-child(2) {
  width: 220px !important;
  white-space: normal !important;
  word-break: break-word !important;
}

/* Column 3: Tipo */
.pruebas-table th:nth-child(3),
.pruebas-table td:nth-child(3) {
  width: 110px !important;
  white-space: normal !important;
}

/* Column 4: Detalles Analíticos / Parámetros */
.pruebas-table th:nth-child(4),
.pruebas-table td:nth-child(4) {
  width: 380px !important;
  white-space: normal !important;
  word-break: break-word !important;
}

/* Column 5: Origen */
.pruebas-table th:nth-child(5),
.pruebas-table td:nth-child(5) {
  width: 110px !important;
  white-space: nowrap !important;
}

/* Specific styling for bajas fields */
.pruebas-table th.th-prueba-baja,
.pruebas-table td.td-prueba-baja {
  width: 115px !important;
  white-space: nowrap !important;
}

/* Column 6: Acciones */
.pruebas-table th:last-child,
.pruebas-table td:last-child {
  width: 115px !important;
  white-space: nowrap !important;
}

/* =========================================
   LOGIN PORTAL (ROE/BioProyect Aesthetic)
   ========================================= */
.login-portal-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(135deg, #e0ecff 0%, #ffffff 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-family);
}

/* Background decorative shapes */
.login-portal-wrapper::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40vh;
  background-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1440 320" xmlns="http://www.w3.org/2000/svg"><path fill="%23dbeafe" fill-opacity="0.5" d="M0,256L48,229.3C96,203,192,149,288,154.7C384,160,480,224,576,218.7C672,213,768,139,864,128C960,117,1056,171,1152,197.3C1248,224,1344,224,1392,224L1440,224L1440,320L1392,320C1344,320,1248,320,1152,320C1056,320,960,320,864,320C768,320,672,320,576,320C480,320,384,320,288,320C192,320,96,320,48,320L0,320Z"></path></svg>');
  background-size: cover;
  background-position: bottom;
  z-index: -1;
}

.login-header-top {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.login-logo {
  max-height: 45px;
  object-fit: contain;
}

@media (min-width: 769px) {
  .login-logo {
    max-height: 80px; /* Aumentado 80% para escritorio */
  }
}

.login-btn-volver {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.2s;
}

.login-btn-volver:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 530px; /* Aumentado 20% desde 440px para escritorio */
  padding: 40px;
  position: relative;
  z-index: 10;
}

@media (max-width: 768px) {
  .login-portal-wrapper {
    flex-direction: column;
    justify-content: flex-start;
    padding: 20px;
    height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
  }
  .login-header-top {
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin-bottom: 20px;
  }
  .login-card {
    padding: 20px;
    margin-bottom: 40px;
  }
}

.login-title {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 24px;
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 24px;
}

.login-tab {
  flex: 1;
  text-align: center;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

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

.login-tab:hover:not(.active) {
  color: var(--text-main);
}

.login-form-content {
  display: none;
}

.login-form-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.login-group {
  margin-bottom: 16px;
}

.login-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.login-input-wrapper {
  position: relative;
}

.login-input {
  width: 100%;
  height: 44px;
  padding: 10px 16px;
  font-size: 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #f9fafb;
}

.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.15);
  background: #ffffff;
}

.login-btn-submit {
  width: 100%;
  height: 44px;
  background-color: #8bb0ff;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  margin-top: 8px;
}

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

.login-btn-submit:active {
  transform: scale(0.98);
}

.login-footer-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  font-size: 13px;
}

.login-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.login-link:hover {
  text-decoration: underline;
}

.login-checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.login-checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.login-checkbox-group label {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 0;
}

/* Discreet Staff Login Link */
.login-staff-discreet {
  text-align: center;
  margin-top: 30px;
  font-size: 12px;
  color: #9ca3af;
}

.login-staff-discreet span {
  color: #9ca3af;
  text-decoration: none;
  transition: color 0.2s;
  cursor: pointer;
}

.login-staff-discreet span:hover {
  color: var(--primary);
  text-decoration: underline;
}

.login-error-msg {
  color: var(--danger);
  background: var(--danger-light);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  display: none;
  align-items: center;
  gap: 6px;
}

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

/* Responsive Parameter and Reference Rows */
.param-row-flex {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 0;
}
.param-field-name { flex: 0 0 350px; }
.param-field-unit { flex: 0 0 200px; }

.param-formula-flex {
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
  margin-top: 0;
  background-color: #eef2f7;
  padding: 2px 4px;
  border-radius: 4px;
  border: 1px solid #c8d6e5;
}
.formula-field-input { flex: 1; }

.ref-row-flex {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  align-items: flex-end;
  margin-bottom: 0;
}
.ref-field-sm { width: 75px; }
.ref-field-md { width: 80px; }
.ref-field-lg { width: 110px; }
.ref-field-flex { flex: 1; }
.ref-field-btn { width: 32px; flex-shrink: 0; }

@media (max-width: 600px) {
  .param-row-flex { flex-wrap: wrap; }
  .param-field-name { flex: 1 1 100% !important; }
  .param-field-unit { flex: 1 1 100% !important; }
  .param-row-flex > button { width: 100%; margin-top: 4px; }
  
  .param-formula-flex { flex-wrap: wrap; }
  .formula-field-input { flex: 1 1 100% !important; }
  
  .ref-row-flex { flex-wrap: wrap; }
  .ref-field-sm, .ref-field-md, .ref-field-lg, .ref-field-flex { width: 48% !important; flex: 1 1 auto; }
  .ref-field-btn { width: 100% !important; margin-top: 4px; }
}

/* ==========================================
   UNIFIED RESPONSIVE PAGINATION STYLING
   ========================================== */
.lis-pagination-wrapper {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  width: 100%;
  box-sizing: border-box;
}

.lis-pagination-info-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
}

.lis-pagination-select-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.lis-page-size-select {
  width: auto !important;
  height: 32px !important;
  padding: 2px 24px 2px 8px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-color, #cbd5e1) !important;
  background-color: var(--bg-main, #f8fafc) !important;
  color: var(--text-main, #0f172a) !important;
  cursor: pointer;
}

.lis-pagination-count-text {
  font-weight: 500;
  border-left: 1px solid var(--border-color, #e2e8f0);
  padding-left: 12px;
}

.lis-pagination-buttons-side {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.lis-pag-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 6px;
}

.lis-pag-dots {
  color: var(--text-muted);
  font-size: 12px;
  padding: 0 4px;
}

@media (max-width: 640px) {
  .lis-pagination-wrapper {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px;
    gap: 10px;
  }
  .lis-pagination-info-side {
    justify-content: center;
    width: 100%;
  }
  .lis-pagination-count-text {
    border-left: none;
    padding-left: 0;
    width: 100%;
    margin-top: 2px;
  }
  .lis-pagination-buttons-side {
    justify-content: center;
    width: 100%;
  }
  .hide-on-mobile {
    display: none;
  }
  .lis-pag-btn {
    padding: 0 8px;
    height: 30px;
    min-width: 28px;
    font-size: 11px;
  }
}
