/* styles.css - Sistema HIS PERÚ (MINSA)
   Diseño de Alta Estética Sanitaria, Accesibilidad Senior-First y Soporte Vectorial */

:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-glow: rgba(2, 132, 199, 0.18);

  --accent-teal: #0d9488;
  --accent-emerald: #10b981;
  --accent-emerald-light: #d1fae5;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fef3c7;
  --accent-rose: #f43f5e;
  --accent-rose-light: #ffe4e6;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-input: #ffffff;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-white: #ffffff;

  --border-light: #e2e8f0;
  --border-focus: #0284c7;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.12);
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-base);
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-size: 15px;
}

/* ==========================================================
   1. BARRA LATERAL (SIDEBAR)
   ========================================================== */
.sidebar {
  width: 270px;
  background-color: var(--bg-sidebar);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
  z-index: 20;
}

.sidebar-header {
  padding: 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
  position: relative;
}

/* Controles para Drawer Móvil / Tablet (Ocultos en desktop) */
.btn-sidebar-toggle {
  display: none;
}

.btn-sidebar-close {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.logo-badge {
  background: linear-gradient(135deg, #0284c7, #0d9488);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4);
}

.logo-text h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-text p {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-links {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  font-size: 14.5px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: var(--text-white);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.2), rgba(13, 148, 136, 0.15));
  color: #38bdf8;
  font-weight: 600;
  border-left: 3px solid #38bdf8;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
  background: #090e1a;
}

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

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
  font-size: 14px;
}

.user-meta {
  overflow: hidden;
}

.user-meta .name {
  font-size: 13.5px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.user-meta .role {
  font-size: 11.5px;
  color: #38bdf8;
}

/* ==========================================================
   2. CONTENEDOR PRINCIPAL Y BARRA SUPERIOR (TOPBAR)
   ========================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  background: #ffffff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-left h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

/* Reloj y Fecha Sincronizada */
.live-clock-badge {
  background: #f1f5f9;
  border: 1px solid var(--border-light);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-clock-badge .dot {
  width: 8px;
  height: 8px;
  background: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-emerald);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Chip de Suscripción */
.subscription-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.subscription-chip.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.subscription-chip.danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
}

/* Botones Principales */
.btn-primary {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--accent-emerald);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: all 0.2s;
}

.btn-success:hover {
  background-color: #059669;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: #334155;
  border: 1px solid var(--border-light);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-outline:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* ==========================================================
   3. CONTENIDO PRINCIPAL SCROLLEABLE
   ========================================================== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 60px 24px;
}

.tab-view {
  display: none;
}

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

/* Tarjetas y Secciones */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}

.section-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header .helper-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Grillas de Formulario */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

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

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

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

/* Inputs y Selects Senior-Friendly */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  color: #0f172a;
  background: var(--bg-input);
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
  color: #94a3b8;
}

/* Campos compactos en altura para la Sección 1 (Datos Oficiales Hoja HIS) */
#sheet-ipress-name,
#sheet-ipress-code,
#sheet-upss-name,
#sheet-turno {
  height: 38px;
  padding: 6px 12px;
  font-size: 15px;
}

/* Campos compactos en altura para la Sección 2 (Identificación del Paciente) */
#patient-firstname,
#patient-lastname,
#patient-hc,
#patient-birthdate,
#patient-edad,
#patient-tipo-edad,
#record-dia,
#patient-financiador,
#patient-etnia,
#patient-distrito,
#patient-centro-poblado,
#patient-gestante-select {
  height: 38px;
  padding: 6px 12px;
  font-size: 15px;
}

#group-sexo,
#group-cond-estab,
#group-cond-serv {
  height: 38px;
  box-sizing: border-box;
}

#group-sexo .pill-btn,
#group-cond-estab .pill-btn,
#group-cond-serv .pill-btn {
  padding: 0 8px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Campos compactos en altura para Evaluación Antropométrica y Hemoglobina */
#record-peso,
#record-talla,
#record-hb,
#record-pc,
#record-pab,
#record-fur {
  height: 38px;
  padding: 6px 10px;
  font-size: 14.5px;
}

/* Input Destacado de DNI */
.dni-search-box {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.dni-search-box .form-control {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #0369a1;
  background: #f0f9ff;
  border-color: #7dd3fc;
}

.btn-search-dni {
  background: #0284c7;
  color: white;
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-search-dni:hover {
  background: #0369a1;
}

/* Botones de Selección Rápida (Pill Switches para N/C/R y P/D/R) */
.pill-group {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  gap: 2px;
}

.pill-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.pill-btn:hover {
  background: rgba(255, 255, 255, 0.6);
}

.pill-btn.active {
  background: #0284c7;
  color: white;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.3);
}

/* Pestañas de Especialidades Médicas */
.profession-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.prof-tab-btn {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.prof-tab-btn:hover {
  background: #e2e8f0;
}

.prof-tab-btn.active {
  background: #0284c7;
  color: white;
  border-color: #0284c7;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

/* Grilla de Kits de 1 Clic */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.preset-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.preset-card:hover {
  border-color: #0284c7;
  background: #f0f9ff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.preset-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.preset-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.preset-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 12px;
  margin-top: 6px;
}

.badge-actividad {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e0f2fe;
  color: #0284c7;
  border: 1px solid #bae6fd;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* Buscador Predictivo Fuzzy */
.search-fuzzy-wrapper {
  position: relative;
  margin-bottom: 18px;
}

.search-fuzzy-input {
  width: 100%;
  padding: 14px 18px 14px 44px;
  font-size: 16px;
  border: 2px solid #94a3b8;
  border-radius: var(--radius-md);
  outline: none;
  background: #ffffff;
}

.search-fuzzy-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.search-icon-pos {
  position: absolute;
  left: 14px;
  top: 15px;
  color: #64748b;
}

.fuzzy-dropdown,
.slot-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1.5px solid #0284c7;
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 270px;
  overflow-y: auto;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: none;
}

.slot-dropdown.code-dropdown {
  min-width: 360px;
  right: 0;
  left: auto;
}

.btn-add-slot-dashed {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  background: #ffffff;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-md);
  color: #0284c7;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
  margin-bottom: 12px;
}

.btn-add-slot-dashed:hover {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0369a1;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.12);
}

.btn-text-subtle {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-text-subtle:hover {
  background: #f1f5f9;
  color: #0f172a;
  border-color: #cbd5e1;
}

.fuzzy-item {
  padding: 11px 16px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

.fuzzy-item:hover {
  background: #f0f9ff;
}

.fuzzy-item .code-chip {
  background: #0284c7;
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 12px;
}

.fuzzy-item .label-text {
  font-weight: 600;
  color: #1e293b;
  font-size: 14px;
}

.fuzzy-item .lab-hint {
  font-size: 11.5px;
  color: #059669;
  font-weight: 500;
}

/* Casillas de Diagnósticos 1, 2, 3 */
.dx-slot-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 12px;
}

.dx-slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.dx-slot-header h4 {
  font-size: 14.5px;
  font-weight: 700;
  color: #1e293b;
}

/* Cuadro Guía Explicativo en Vivo */
.live-help-box {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
}

.live-help-box .icon {
  color: #d97706;
  font-size: 20px;
  flex-shrink: 0;
}

.live-help-box .text {
  font-size: 13.5px;
  color: #78350f;
  line-height: 1.5;
}

/* ==========================================================
   4. TABLA DE REGISTROS DEL DÍA
   ========================================================== */
.table-responsive {
  overflow-x: auto;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: #f8fafc;
  color: #334155;
  font-weight: 700;
  padding: 10px 8px;
  text-align: left;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
  font-size: 12px;
}

.data-table td {
  padding: 8px 8px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.data-table tr:hover {
  background: #f8fafc;
}

/* Sub-items alineados fila por fila para Diagnósticos, Códigos y LABs */
.table-subitem {
  min-height: 24px;
  display: flex;
  align-items: center;
  margin: 3px 0;
  font-size: 11.5px;
  line-height: 1.3;
}
.table-subitem.center {
  justify-content: center;
}

.code-chip {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-family: monospace;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-block;
}

.lab-pill {
  display: inline-block;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 4px;
  border-radius: 4px;
  text-align: center;
  min-width: 22px;
  box-sizing: border-box;
}

.lab-empty {
  display: inline-block;
  color: #94a3b8;
  font-weight: 500;
  font-size: 11px;
  text-align: center;
  min-width: 22px;
}

/* ==========================================================
   DROPDOWN AUTOCOMPLETADO IPRESS
   ========================================================== */
.ipress-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 280px;
  background: #ffffff;
  border: 1.5px solid #0284c7;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-height: 240px;
  overflow-y: auto;
  z-index: 1050;
  display: none;
}

.ipress-dropdown::-webkit-scrollbar {
  width: 6px;
}
.ipress-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.ipress-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease;
}
.ipress-item:last-child {
  border-bottom: none;
}
.ipress-item:hover {
  background: #f0f9ff;
}
.ipress-item.habitual {
  background: #fefce8;
  border-left: 4px solid #eab308;
}
.ipress-item.habitual:hover {
  background: #fef9c3;
}
.ipress-item .ipress-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 5px;
}
.ipress-item .ipress-meta {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}
.ipress-tag-habitual {
  background: #fef08a;
  color: #854d0e;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: auto;
}

/* ==========================================================
   5. MODALES Y VENTANAS EMERGENTES
   ========================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 20000 !important;
  display: none;
}

.modal-overlay.active {
  display: flex !important;
}

#modal-terms-privacy {
  z-index: 25000;
}

.modal-card {
  background: white;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  padding: 24px 28px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 12px;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 22px;
  color: #94a3b8;
  cursor: pointer;
}

.btn-close-modal:hover {
  color: #0f172a;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-rose); }
.toast.warning { border-left: 4px solid var(--accent-amber); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ================================================================
   NUEVOS ESTILOS: DESLINDE LEGAL, PLANES DINÁMICOS Y AUTENTICACIÓN
   ================================================================ */

/* Banner de Deslinde Legal (Zona 1 y general) */
.legal-disclaimer-banner {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #64748b;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #475569;
}

.legal-disclaimer-banner i {
  color: #64748b;
  flex-shrink: 0;
  margin-top: 2px;
}

.legal-disclaimer-modal {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 3.5px solid #d97706;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #92400e;
  margin: 14px 0;
  text-align: left;
}

/* Grilla de Planes en Modal */
.plans-modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 16px 0 20px 0;
  text-align: left;
}

@media (max-width: 768px) {
  .plans-modal-grid {
    grid-template-columns: 1fr;
  }
}

.plan-modal-card {
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: #ffffff;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.plan-modal-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.08);
}

.plan-modal-card.highlight {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.12);
}

.plan-badge-tag {
  position: absolute;
  top: -10px;
  right: 12px;
  background: #2563eb;
  color: white;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.plan-card-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.plan-card-price {
  font-size: 22px;
  font-weight: 800;
  color: #1e3a8a;
  margin-bottom: 8px;
}

.plan-card-price span {
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
}

.plan-card-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
  margin-bottom: 12px;
}

.plan-card-features {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 11.5px;
  color: #334155;
}

.plan-card-features li {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.plan-card-features li i {
  color: #16a34a;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Recuperación de Contraseña */
.recovery-level-card {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
  background: #f8fafc;
}

.recovery-level-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.badge-instant {
  background: #dcfce7;
  color: #166534;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-manual-wait {
  background: #fee2e2;
  color: #991b1b;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.support-warning-box {
  background: #fff1f2;
  border: 1.5px dashed #f43f5e;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #9f1239;
  margin-bottom: 12px;
}

/* Enlaces de alternancia de login/registro */
.auth-switch-link {
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

.auth-switch-link:hover {
  color: var(--primary-light);
}

/* Botón Iniciar Sesión en Sidebar cuando no autenticado */
.sidebar-auth-cta {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.sidebar-auth-cta:hover {
  opacity: 0.95;
}

/* ================================================================
   ZONA DE CARGA INTERACTIVA DE EXCEL PARA USUARIOS
   ================================================================ */
.excel-dropzone {
  border: 2px dashed #93c5fd;
  background: #f8fafc;
  border-radius: 12px;
  padding: 26px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.excel-dropzone:hover,
.excel-dropzone.dragover {
  border-color: #0284c7;
  background: #f0f9ff;
  transform: translateY(-1px);
}

.excel-dropzone-icon {
  width: 46px;
  height: 46px;
  color: #0284c7;
  margin-bottom: 10px;
  transition: transform 0.2s;
}

.excel-dropzone:hover .excel-dropzone-icon {
  transform: scale(1.08);
}

.excel-dropzone-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.excel-dropzone-subtitle {
  font-size: 12.5px;
  color: #64748b;
  max-width: 480px;
  line-height: 1.4;
}

.excel-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 700;
  margin-top: 12px;
}

/* ==========================================================
   BOTONES DE ACCIÓN DE ALTA VISIBILIDAD (LLENADO FICHA HIS)
   ========================================================== */
.action-buttons-wrapper {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.action-buttons-wrapper:hover {
  box-shadow: 0 14px 30px -5px rgba(0, 0, 0, 0.08);
}

.btn-action-large {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 320px;
  text-align: left;
}

.btn-action-large:hover {
  transform: translateY(-2px);
}

.btn-action-large:active {
  transform: translateY(1px);
}

.btn-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-action-icon svg {
  width: 26px;
  height: 26px;
}

.btn-action-text {
  display: flex;
  flex-direction: column;
}

.btn-action-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
  line-height: 1.25;
}

.btn-action-sub {
  font-size: 12.5px;
  opacity: 0.9;
  font-weight: 500;
  margin-top: 2px;
}

/* Botón 1: Validar y Registrar Atención (Verde Esmeralda Vibrante) */
.btn-success-vibrant {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 6px 20px -3px rgba(16, 185, 129, 0.45);
}

.btn-success-vibrant .btn-action-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.btn-success-vibrant:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 10px 25px -3px rgba(16, 185, 129, 0.55);
}

/* Botón 2: Imprimir Hoja HIS en PDF (Azul Zafiro Gradiente) */
.btn-print-vibrant {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 6px 20px -3px rgba(37, 99, 235, 0.45);
}

.btn-print-vibrant .btn-action-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.btn-print-vibrant:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow: 0 10px 25px -3px rgba(37, 99, 235, 0.55);
}

/* Botón Gradiente Primario Universal */
.btn-primary-gradient {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
}

/* ==========================================================
   MODAL CLOSE ICON
   ========================================================== */
.modal-close-icon {
  position: absolute;
  top: 14px;
  right: 18px;
  background: transparent;
  border: none;
  font-size: 26px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.modal-close-icon:hover {
  color: #0f172a;
  background: #f1f5f9;
}

/* ==========================================================
   PÁGINA PRINCIPAL PÚBLICA (LANDING PAGE DE BIENVENIDA)
   ========================================================== */
.landing-public-welcome {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* TOPBAR */
.landing-topbar {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 14px 32px;
  width: 100%;
  box-sizing: border-box;
}

.landing-topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.landing-logo-badge {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  font-weight: 900;
  font-size: 17px;
  letter-spacing: 1px;
  padding: 8px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.landing-brand-text {
  display: flex;
  flex-direction: column;
}

.landing-brand-title {
  font-size: 19px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin: 0;
}

.landing-brand-subtitle {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  margin-top: 2px;
}

.landing-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-topbar-plans {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  color: #1e3a8a;
  border: 1.5px solid #bfdbfe;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-topbar-plans:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1d4ed8;
}

.btn-topbar-login {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease;
}

.btn-topbar-login:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
}

/* HERO CONTAINER */
.landing-hero-container {
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 24px 60px 24px;
  text-align: center;
  box-sizing: border-box;
}

/* BADGES ROW */
.landing-badges-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.landing-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.badge-icon {
  font-size: 14px;
  line-height: 1;
}

.landing-badge-green {
  background: #ecfdf5;
  border: 1.5px solid #a7f3d0;
  color: #065f46;
}

.landing-badge-blue {
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #1e40af;
}

.landing-badge-amber {
  background: #fef3c7;
  border: 1.5px solid #fde68a;
  color: #92400e;
}

/* HEADLINE */
.landing-hero-title {
  font-size: 40px;
  font-weight: 900;
  color: #0f172a;
  line-height: 1.2;
  letter-spacing: -0.8px;
  margin-bottom: 18px;
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

/* SUBTITLE */
.landing-hero-subtitle {
  font-size: 16.5px;
  color: #475569;
  line-height: 1.65;
  max-width: 780px;
  margin: 0 auto 36px auto;
  font-weight: 450;
}

/* CTA CENTER ZONE */
.landing-cta-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 56px;
}

.landing-cta-buttons-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 18px;
}

/* Botón 1: Iniciar Sesión (Grande y llamativo) */
.btn-hero-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  padding: 16px 38px;
  border-radius: 12px;
  font-size: 16.5px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 25px -4px rgba(37, 99, 235, 0.45);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 220px;
}

.btn-hero-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px -4px rgba(37, 99, 235, 0.55);
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.btn-hero-primary:active {
  transform: translateY(1px);
}

/* Botón 2: Ver Planes (Llamativo) */
.btn-hero-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  color: #1e3a8a;
  border: 2px solid #93c5fd;
  padding: 15px 30px;
  border-radius: 12px;
  font-size: 15.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 170px;
}

.btn-hero-secondary:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.18);
}

.btn-hero-secondary:active {
  transform: translateY(1px);
}

/* Enlace Registro Debajo */
.landing-register-link-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  color: #64748b;
  font-weight: 500;
  flex-wrap: wrap;
}

.landing-link-button {
  background: transparent;
  border: none;
  color: #2563eb;
  font-weight: 700;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
  transition: color 0.15s ease;
}

.landing-link-button:hover {
  color: #1d4ed8;
}

/* FEATURES GRID */
.landing-features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-top: 10px;
  text-align: left;
}

@media (max-width: 860px) {
  .landing-features-grid {
    grid-template-columns: 1fr;
  }
}

.landing-feature-card {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 28px 24px;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
}

.landing-feature-card:hover {
  transform: translateY(-4px);
  border-color: #cbd5e1;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.07);
}

.landing-feature-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.landing-feature-icon svg {
  width: 26px;
  height: 26px;
}

.landing-feature-card h3 {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
  line-height: 1.3;
}

.landing-feature-card p {
  font-size: 14px;
  color: #64748b;
  line-height: 1.55;
  margin: 0;
}

/* FOOTER */
.landing-footer {
  margin-top: auto;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
  padding: 24px;
  text-align: center;
}

/* ==========================================================
   ESTADO DE BLOQUEO DE ALTA SEGURIDAD (ANTI-BYPASS)
   ========================================================== */
.app-hard-locked {
  pointer-events: none !important;
  user-select: none !important;
  filter: blur(2px) grayscale(60%);
  opacity: 0.65;
}

/* ==========================================================
   18. ADAPTACIONES RESPONSIVAS: TABLETS, IPADS Y CELULARES
   ========================================================== */

/* 1. TABLETS, IPADS Y PANTALLAS COMPACTAS (<= 1024px) */
@media (max-width: 1024px) {
  .content {
    padding: 18px 18px 60px 18px;
  }

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

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

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

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .action-buttons-wrapper {
    padding: 20px;
    margin: 25px 0 45px 0;
  }

  .btn-action-large {
    min-width: 260px;
    padding: 16px 22px;
  }

  .landing-features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
  }
}

/* 2. DRAWER DE NAVEGACIÓN Y COMPACTACIÓN EN TABLETS VERTICALES (<= 992px) */
@media (max-width: 992px) {
  /* Conversión de Sidebar a Drawer Deslizable */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 10000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 6px 0 35px rgba(0, 0, 0, 0.55);
  }

  /* Backdrop oscuro */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  /* Botón hamburguesa en Topbar */
  .btn-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    cursor: pointer;
    color: #1e293b;
    flex-shrink: 0;
    transition: all 0.2s ease;
  }

  .btn-sidebar-toggle:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
  }

  /* Botón cerrar en encabezado de sidebar */
  .btn-sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    width: 32px;
    height: 32px;
    cursor: pointer;
    border-radius: 6px;
    margin-left: auto;
    transition: all 0.2s ease;
  }

  .btn-sidebar-close:hover {
    background: #1e293b;
    color: #ffffff;
  }

  .main-wrapper {
    width: 100%;
  }

  .topbar {
    padding: 10px 16px;
  }

  .topbar-left h1 {
    font-size: 17px;
  }
}

/* 3. CELULARES Y SMARTPHONES (<= 768px) */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  .topbar {
    padding: 8px 12px;
    gap: 8px;
  }

  .topbar-left {
    gap: 8px;
    min-width: 0;
  }

  .topbar-left h1 {
    font-size: 15px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .live-clock-badge {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
    flex-shrink: 0;
  }

  .subscription-chip {
    font-size: 11px;
    padding: 4px 8px;
    gap: 4px;
  }

  #btn-imprimir-hoja-top {
    padding: 7px 10px;
    font-size: 12px;
  }

  #btn-nueva-atencion-top {
    padding: 7px 10px;
    font-size: 12px;
  }

  .content {
    padding: 12px 10px 50px 10px;
  }

  .form-card {
    padding: 14px 12px;
    margin-bottom: 12px;
    border-radius: 12px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 12px;
  }

  .section-header h3 {
    font-size: 15px;
  }

  .section-header .helper-text {
    font-size: 11.5px;
  }

  /* Grillas colapsables para celular */
  .grid-6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .grid-4 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .grid-3 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Adaptación específica de ranuras de diagnóstico */
  .dx-slot-card {
    padding: 12px 10px;
    border-radius: 10px;
    margin-bottom: 12px;
  }

  .dx-slot-header h4 {
    font-size: 13.5px;
  }

  .dx-slot-card .grid-4 {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dx-slot-card .grid-4 .field-group[style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }

  /* Los valores LAB 1, 2, 3 en celular se mantienen en 3 columnas compactas y legibles */
  .dx-slot-card .grid-3 {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 6px;
    margin-top: 8px;
  }

  .dx-slot-card .grid-3 .field-group label {
    font-size: 11px;
  }

  .dx-slot-card .grid-3 .form-control {
    padding: 8px 4px;
    font-size: 13px;
    text-align: center;
  }

  .pill-group {
    flex-wrap: wrap;
    gap: 4px;
  }

  .pill-btn {
    padding: 6px 8px;
    font-size: 11.5px;
  }

  /* Botones de acción grandes a ancho completo */
  .action-buttons-wrapper {
    margin: 20px 0 45px 0;
    padding: 16px 12px;
    border-radius: 14px;
  }

  .action-buttons-wrapper > div:first-child {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .btn-action-large {
    min-width: unset;
    width: 100%;
    padding: 14px 16px;
    border-radius: 12px;
  }

  .btn-action-title {
    font-size: 14px;
    letter-spacing: 0;
  }

  .btn-action-sub {
    font-size: 11.5px;
  }

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

  .btn-action-icon svg {
    width: 22px;
    height: 22px;
  }

  /* Landing Page Móvil */
  .landing-header-inner {
    padding: 12px 14px;
  }

  .landing-logo h2 {
    font-size: 16px;
  }

  .landing-header-actions {
    gap: 6px;
  }

  .btn-topbar-plans {
    padding: 6px 10px;
    font-size: 12px;
  }

  .btn-topbar-login {
    padding: 6px 12px;
    font-size: 12px;
  }

  .landing-hero-container {
    padding: 24px 14px 36px 14px;
  }

  .landing-badges-row {
    gap: 6px;
  }

  .landing-badge {
    padding: 5px 9px;
    font-size: 11px;
  }

  .landing-hero-title {
    font-size: 21px;
    line-height: 1.25;
    margin-bottom: 12px;
  }

  .landing-hero-subtitle {
    font-size: 13.5px;
    line-height: 1.45;
    margin-bottom: 20px;
  }

  .landing-cta-buttons-row {
    flex-direction: column;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    gap: 10px;
  }

  .btn-hero-primary {
    width: 100%;
    justify-content: center;
    padding: 13px 18px;
    font-size: 15px;
  }

  .btn-hero-secondary {
    width: 100%;
    justify-content: center;
    padding: 13px 18px;
    font-size: 15px;
  }

  .landing-features-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 20px;
  }

  .landing-feature-card {
    padding: 20px 16px;
    border-radius: 14px;
  }

  /* Modales en Móvil */
  .modal-overlay {
    padding: 10px;
  }

  .modal-card {
    width: 100%;
    max-width: 100%;
    padding: 18px 14px;
    max-height: 94vh;
    border-radius: 16px;
  }

  .plans-modal-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .plan-modal-card {
    padding: 12px 14px;
  }
}

/* 4. CELULARES MUY COMPACTOS (<= 480px) */
@media (max-width: 480px) {
  .topbar-left h1 {
    font-size: 13.5px;
    max-width: 110px;
  }

  #btn-imprimir-hoja-top span {
    display: none;
  }

  #btn-imprimir-hoja-top {
    padding: 8px 10px;
    border-radius: 8px;
  }

  #btn-nueva-atencion-top span {
    display: none;
  }

  #btn-nueva-atencion-top {
    padding: 8px 10px;
    border-radius: 8px;
  }

  #subscription-status-chip {
    font-size: 10px;
    padding: 3px 6px;
  }

  .form-control {
    font-size: 16px; /* Previene el zoom automático de Safari en iPhone */
  }

  .dx-slot-card .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 6px;
  }
}

/* Spinner de Guardado y Prevención de Doble Clic */
@keyframes hisSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.his-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: hisSpin 0.7s linear infinite;
  vertical-align: middle;
}

.his-spinner-dark {
  border-color: rgba(2, 132, 199, 0.25);
  border-top-color: #0284c7;
}

.btn-saving {
  pointer-events: none !important;
  opacity: 0.82 !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}

.btn-remove-slot {
  padding: 4px 8px !important;
  font-size: 12px !important;
  color: #ef4444 !important;
  border-color: #fca5a5 !important;
  transition: all 0.15s ease;
}

.btn-remove-slot:hover {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #b91c1c !important;
}

.btn-clear-slot {
  padding: 4px 8px !important;
  font-size: 12px !important;
}

.slot-code {
  font-weight: 700;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.slot-motivo {
  width: 100%;
}

.slot-tipo-group {
  display: flex;
  gap: 4px;
}





