/* ═══════════════════════════════════════════════════════════════════════════
   Panel Clínico Dr. Campillo — admin.css
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Cifras ────────────────────────────────────────────────────────────────
   Cormorant Garamond usa cifras de estilo antiguo: el 3, 4, 7 y 9 bajan de la
   línea base y el 0, 1 y 2 quedan a media altura, así que "25 Sep 2026" salía
   con números de alturas distintas. Se intentó arreglar con
   `font-variant-numeric: lining-nums`, pero NO FUNCIONA: la versión que sirve
   Google Fonts no incluye la feature OpenType `lnum`, así que no hay nada que
   activar. La única solución fiable es no usar el serif para las cifras: todo
   lo que muestre números va en Montserrat (.date-display, .stat-value, …).
   `tabular-nums` sí funciona y mantiene las columnas alineadas. */
:root {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

:root {
  --bg:          #FAFAF8;
  --bg-alt:      #F2F0EB;
  --dark:        #1C1C1A;
  --gold:        #B8975A;
  --gold-light:  #D4B88A;
  --text-muted:  #6B6B68;
  --border:      #E5E0D8;
  --wa:          #25D366;
  --sidebar-w:   260px;
  --danger:      #D94040;
  --success:     #2A9D5A;
  --info:        #3B82C4;
  --warning:     #E08800;

  /* ── Agenda ───────────────────────────────────────────────────────────────
     La agenda es una herramienta de trabajo que el equipo mira todo el día, así
     que usa una superficie neutra en vez del crema de marca: más contraste con
     las citas de colores y mejor legibilidad a lo largo de una jornada. El
     dorado se reserva para botones y acentos. El resto del panel no cambia. */
  --cal-surface: #FFFFFF;   /* fondo de las columnas */
  --cal-today:   #FFFBF2;   /* columna del día de hoy */
  --cal-closed:  #F1F1EF;   /* fuera de horario dentro de un día abierto */
  --cal-offday:  #E9E9E6;   /* día entero cerrado (jue-dom) */
  --cal-line:    #E8E8E4;   /* línea de hora en punto */
  --cal-line-2:  #F4F4F1;   /* línea de media hora */
  --cal-header:  #FBFBFA;   /* cabeceras de día/profesional */
}

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

body {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  background: var(--bg-alt);
  color: var(--dark);
  line-height: 1.5;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .brand {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .02em;
}
.sidebar-logo .brand span { color: var(--gold-light); font-style: italic; }
.sidebar-logo .subtitle {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.4);
  margin-top: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 2px 6px;
  border-radius: 3px;
  display: inline-block;
  margin-top: 2px;
}
.role-admin      { background: rgba(184,151,90,.25); color: var(--gold-light); }
.role-assistant  { background: rgba(59,130,196,.2);  color: #7DB3E0; }
.role-reception  { background: rgba(42,157,90,.2);   color: #6AD4A0; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.3);
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover    { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active   { background: rgba(184,151,90,.15); color: var(--gold-light); }
.nav-item svg      { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.nav-item .badge {
  margin-left: auto;
  background: var(--gold);
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
}
.nav-item.hidden { display: none; }

/* Regla genérica: `.hidden` la pone admin.js sobre cualquier elemento con
   data-role-min cuyo rol no llegue. Sin esta regla solo desaparecían los
   .nav-item, y la etiqueta de sección "Configuración" seguía visible para
   recepción — un encabezado suelto sin nada debajo. Lleva !important porque
   compite con el display propio de cada componente (.nav-section-label es
   block, .stat-card es flex). */
.hidden { display: none !important; }

.sidebar-footer {
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Main content ────────────────────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  /* Sin esto, un contenido ancho (la semana de la agenda) estiraba toda la
     página más allá de la ventana y dejaba fuera "Nueva cita". Cada bloque
     ancho se desliza dentro de su propio contenedor. */
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--dark);
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-body { padding: 28px; flex: 1; max-width: 1280px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 600;
}

/* ── Stats row ───────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.stat-value { font-family: 'Montserrat', sans-serif; font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }  /* cifras: nunca el serif */
.stat-sub   { font-size: 12px; color: var(--text-muted); }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-alt); }

.patient-row { cursor: pointer; }
.patient-name { font-weight: 600; color: var(--dark); }
.patient-email { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--dark); color: #fff; }
.btn-primary:hover  { background: #333; }
.btn-gold     { background: var(--gold); color: #fff; }
.btn-gold:hover     { background: var(--gold-light); }
.btn-ghost    { background: transparent; color: var(--dark); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg-alt); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { opacity: .85; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: 6px; background: transparent; border: 1px solid var(--border); cursor: pointer; display: inline-flex; align-items: center; }
.btn-icon:hover { background: var(--bg-alt); }

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  /* Cifras siempre en Montserrat: dentro de un título en serif, el contador
     heredaba Cormorant y sus números desalineados ("648", un "0" como "o"). */
  font-family: 'Montserrat', sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-confirmed  { background: #D1FAE5; color: #065F46; }
.badge-new        { background: #E0E7FF; color: #3730A3; }
.badge-cancelled  { background: #FEE2E2; color: #991B1B; }
.badge-showed     { background: #F3F4F6; color: #374151; }
.badge-no-show    { background: #FEF3C7; color: #92400E; }
.badge-admin      { background: rgba(184,151,90,.15); color: #8B6F2E; }
.badge-assistant  { background: rgba(59,130,196,.15);  color: #1D4E85; }
.badge-reception  { background: rgba(42,157,90,.15);   color: #145C38; }
.badge-urgent     { background: #FEE2E2; color: #991B1B; }
.badge-soon       { background: #FEF3C7; color: #92400E; }
.badge-normal     { background: #F3F4F6; color: #374151; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: 'Montserrat', sans-serif;
  background: #fff;
  color: var(--dark);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--gold); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }

/* ── Modals ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-lg { max-width: 760px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: 4px;
}
.modal-close:hover { background: var(--bg-alt); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Search bar ──────────────────────────────────────────────────────────── */

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  min-width: 260px;
}
.search-bar input {
  border: none;
  background: none;
  padding: 9px 0;
  font-size: 14px;
  font-family: 'Montserrat', sans-serif;
  color: var(--dark);
  width: 100%;
}
.search-bar input:focus { outline: none; }
.search-bar svg { color: var(--text-muted); flex-shrink: 0; }

/* ── Patient detail ──────────────────────────────────────────────────────── */

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.detail-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 600; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.detail-name { font-family: 'Cormorant Garamond', serif; font-size: 26px; font-weight: 600; }
.detail-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: 'Montserrat', sans-serif;
  transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--dark); border-bottom-color: var(--gold); }
.tab-btn.hidden { display: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Timeline (historial clínico) ────────────────────────────────────────── */

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 24px;
  position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child .timeline-line { display: none; }

.timeline-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  width: 20px;
}
.timeline-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg-alt);
  margin-top: 4px;
}
.timeline-dot.first { background: var(--dark); }
.timeline-line {
  width: 2px;
  background: var(--border);
  flex: 1;
  margin-top: 4px;
}
.timeline-body { flex: 1; }

.visit-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}
.visit-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}
.visit-title { font-weight: 700; font-size: 14px; }
.visit-date  { font-size: 12px; color: var(--text-muted); }

.visit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.visit-field-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin-bottom: 2px; }
.visit-field-value { font-size: 13px; }

.visit-notes {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--bg-alt);
  border-radius: 6px;
  font-size: 13px;
  color: var(--dark);
  font-style: italic;
}

/* ── Calendar / Agenda ───────────────────────────────────────────────────── */

.agenda-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-display-wrap {
  position: relative;
}
.date-display {
  font-family: 'Montserrat', sans-serif;   /* lleva fechas: nunca el serif */
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  min-width: 200px;
  text-align: center;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background .15s;
  user-select: none;
}
.date-display:hover { background: var(--bg-alt); }

.appointment-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.appointment-row:last-child { border-bottom: none; }
a.appointment-row { color: inherit; text-decoration: none; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.appointment-row:hover { background: var(--bg-alt); }

.appt-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--dark);
  min-width: 56px;
  flex-shrink: 0;
}
.appt-info { flex: 1; min-width: 0; }
.appt-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-patient { font-size: 12px; color: var(--text-muted); }
.appt-professional { font-size: 12px; color: var(--gold); font-weight: 600; }
.appt-actions { display: flex; gap: 6px; flex-shrink: 0; }

.agenda-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.agenda-empty svg { margin: 0 auto 12px; display: block; opacity: .3; }

/* ── Follow-ups ──────────────────────────────────────────────────────────── */

.followup-section { margin-bottom: 28px; }
.followup-section-title {
  font-family: 'Montserrat', sans-serif;   /* lleva cifras ("+80 días"): nunca el serif */
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.followup-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  cursor: pointer;
}
.followup-card:last-child { border-bottom: none; }
.followup-card:hover { background: var(--bg-alt); }

.followup-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.followup-info { flex: 1; min-width: 0; }
.followup-name { font-weight: 600; }
.followup-sub  { font-size: 12px; color: var(--text-muted); }

/* ── Alert / notification ────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }
.alert-success { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.alert-danger  { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }

/* ── Skeleton loaders ────────────────────────────────────────────────────── */

@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-alt) 50%, var(--border) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
.skel-line { height: 14px; margin-bottom: 8px; }
.skel-line.w-60  { width: 60%; }
.skel-line.w-80  { width: 80%; }
.skel-line.w-100 { width: 100%; }

/* ── Profile card (staff) ────────────────────────────────────────────────── */

.profile-card {
  max-width: 560px;
}
.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; font-weight: 600; color: #fff;
  overflow: hidden; flex-shrink: 0;
}
.profile-avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

/* ── Utility ─────────────────────────────────────────────────────────────── */

.text-muted  { color: var(--text-muted); }
.text-gold   { color: var(--gold); }
.text-danger { color: var(--danger); }
.text-sm     { font-size: 12px; }
.fw-600      { font-weight: 600; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.flex   { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 16px;
}

.divider { height: 1px; background: var(--border); margin: 20px 0; }

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* ── Barra de navegación inferior (solo móvil) ─────────────────────────────
   La pinta admin.js. En ordenador no se ve. */
.nav-movil { display: none; }

/* ══ MÓVIL ═══════════════════════════════════════════════════════════════════
   Revisión del 14/09/2026 (Franco: "tiene que ser más visual, fácil de ver y
   navegar"). Antes el panel se salía por los lados en casi todas las pantallas
   (agenda 1280 px en un móvil de 390) y se navegaba con un menú escondido. */
@media (max-width: 768px) {
  /* Nada se estira más que la pantalla. Un hijo de flex, por defecto, crece
     para abarcar su contenido: esa era la causa del desborde en casi todo. */
  html, body { max-width: 100%; overflow-x: hidden; }
  .main-content, .page-body { min-width: 0; max-width: 100vw; }
  .main-content { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  img, svg, video { max-width: 100%; }

  /* Legible y pulsable con el dedo */
  body { font-size: 15px; }
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 38px; padding: 8px 12px; font-size: 13px; }
  /* 16 px en los campos: con menos, el iPhone hace zoom al tocarlos. */
  input, select, textarea, .form-control { font-size: 16px !important; }
  .form-control { min-height: 44px; }

  /* Barra superior compacta y clara */
  .topbar { padding: 0 12px; height: 56px; gap: 10px; }
  .topbar-title { font-family: 'Montserrat', sans-serif; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; text-align: left; }
  .topbar-actions { gap: 8px; flex-shrink: 0; }
  #sidebar-toggle { display: none !important; }  /* el menú se abre desde "Más" en la barra inferior */

  .page-body { padding: 14px 12px 20px; }
  .card { padding: 14px; border-radius: 12px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-title { font-family: 'Montserrat', sans-serif; font-size: 16px; font-weight: 600; }

  /* Números en 2 columnas que SÍ caben */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 24px; }
  .stat-label { font-size: 10.5px; letter-spacing: .06em; }

  /* Tablas: si quedara alguna, que se deslice DENTRO de su tarjeta y no la página */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px; }

  /* Pestañas deslizables, sin cortar ninguna */
  .detail-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: -12px; margin-right: -12px; padding: 0 12px; }
  .detail-tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; padding: 12px 14px; font-size: 14px; }

  /* Ventanas emergentes a pantalla casi completa, desde abajo */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { width: 100% !important; max-width: 100% !important; max-height: 92vh; border-radius: 16px 16px 0 0; overflow-y: auto; margin: 0; }

  .sidebar { transform: translateX(-100%); transition: transform .25s; z-index: 120; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 115;  /* por encima de la barra inferior */
  }
  .sidebar-overlay.open { display: block; }
  .form-row { grid-template-columns: 1fr; }
  .visit-fields { grid-template-columns: 1fr; }
  .page-body { padding: 16px; }

  .nav-movil {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
    background: #fff; border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -2px 12px rgba(0,0,0,.05);
  }
  .nav-movil a, .nav-movil button {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border: none; background: none; border-radius: 10px;
    font-family: 'Montserrat', sans-serif; font-size: 11px; font-weight: 600; color: #8A8780; text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-movil svg { width: 23px; height: 23px; }
  .nav-movil .activo { color: var(--dark); }
  .nav-movil .activo svg { color: var(--gold); }
  .nav-movil a:active, .nav-movil button:active { background: var(--bg-alt); }

  /* ── Inicio ──────────────────────────────────────────────────────────── */
  .dash-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .appointment-row { padding: 12px 4px; gap: 10px; min-height: 56px; }
  .appointment-row .badge { flex-shrink: 0; font-size: 10px; padding: 3px 8px; }
  .appt-title { font-size: 14.5px; }

  /* ── Pacientes: tarjetas en vez de tabla ─────────────────────────────── */
  .pac-titulo, #btn-export, .pac-filtros { display: none !important; }  /* el buscador de arriba ya busca por nombre, email y teléfono */
  .topbar .search-bar { flex: 1; min-width: 0; }
  .topbar .search-bar input { width: 100%; }
  .topbar-actions:has(.search-bar) { flex: 1; min-width: 0; }
  #patients-table { display: block; }
  .card:has(#patients-table) { padding: 0; background: none; border: none; }
  .card:has(#patients-table) .table-wrap { margin: 0; padding: 0; overflow: visible; }
  .card:has(#patients-table) table, .card:has(#patients-table) thead { display: block; }
  .card:has(#patients-table) thead { display: none; }
  #patients-table tr.patient-row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center;
    background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
  }
  #patients-table tr.patient-row td { display: block; padding: 0; border: none; min-width: 0; }
  #patients-table tr.patient-row td:first-child { grid-column: 1 / -1; }
  #patients-table .patient-name { font-size: 15px; font-weight: 600; }
  #patients-table .patient-email { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #patients-table .pac-tel a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--bg-alt); color: var(--dark); font-size: 13.5px; font-weight: 600; text-decoration: none; }
  #patients-table .pac-tags { grid-column: 1 / 2; grid-row: 2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 0; }
  #patients-table .pac-tags .badge { font-size: 11px; }
  #patients-table .pac-tel { grid-column: 2; grid-row: 2; justify-self: end; }
  #patients-table tr.patient-row td.pac-alta, #patients-table tr.patient-row td:last-child:not(.pac-tel) { display: none; }

  /* Zonas táctiles mínimas en lo que quedaba chico: la "×" de las etiquetas,
     los chips del filtro y las acciones de las tarjetas del equipo. */
  #tag-filtros button { min-height: 36px; }
  #tag-filtros button:not([data-tag]) { min-width: 36px; }
  .main-content .card button, .main-content .card .btn { min-height: 40px; }
  #tag-pills button, .tag-pill button { min-width: 32px; min-height: 32px; }

  /* ── Seguimientos ────────────────────────────────────────────────────── */
  .followup-section-title { flex-wrap: wrap; }
  .followup-section-title > div[style*="margin-left:auto"] { margin-left: 0 !important; width: 100%; }
  .horizonte { flex: 1; min-height: 40px; }

  /* ── Facturación y perfil ────────────────────────────────────────────── */
  .billing-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: -12px !important; margin-right: -12px !important; padding: 0 12px; }
  .billing-tabs::-webkit-scrollbar { display: none; }
  .billing-tab { white-space: nowrap; flex-shrink: 0; padding: 12px 14px !important; font-size: 14px !important; }
  .card table { min-width: 0; }
  .card:has(> table), .card:has(> div > table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .perfil-datos { grid-template-columns: minmax(0, 1fr) !important; }
  .perfil-datos * { overflow-wrap: anywhere; }

  /* ── Agenda en el móvil: lista del día ──────────────────────────────── */
  .agenda-controls { flex-wrap: wrap; gap: 8px; }
  .agenda-controls > div:first-child { display: none !important; }   /* Día/Semana: en el móvil, siempre Día */
  #filter-calendar { display: none !important; }                        /* se filtra con las etiquetas de color */
  .date-nav { flex: 1; min-width: 0; justify-content: space-between; }
  .date-nav .btn-icon { width: 44px; height: 44px; }
  .date-display { font-size: 15px !important; text-align: center; min-width: 0 !important; }
  #agenda-count { margin-left: 0 !important; width: 100%; text-align: center; }
  #prof-chips { flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin: 0 -12px 12px !important; padding: 2px 12px; }
  #prof-chips::-webkit-scrollbar { display: none; }
  #prof-chips > * { flex-shrink: 0; min-height: 38px; }

  /* botones de la barra superior: solo iconos, salvo "Nueva cita" */
  #btn-block-agenda, #btn-walkin { font-size: 0 !important; gap: 0 !important; padding: 0 !important; width: 44px; justify-content: center; }
  #btn-block-agenda svg, #btn-walkin svg { width: 18px; height: 18px; }
  #btn-new-appt { padding: 10px 14px !important; }

  #day-view-card { background: none; border: none; padding: 0; }
  #agenda-list { display: block !important; padding: 0 !important; }
  .am-cita {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    background: #fff; border: 1px solid var(--border); border-left: 5px solid var(--am-color, var(--gold));
    border-radius: 12px; padding: 12px 12px 12px 10px; margin-bottom: 8px; min-height: 68px;
    font-family: 'Montserrat', sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .am-cita:active { background: var(--bg-alt); }
  .am-hora { display: flex; flex-direction: column; align-items: center; min-width: 50px; font-variant-numeric: tabular-nums; }
  .am-hora strong { font-size: 16px; font-weight: 700; color: var(--dark); }
  .am-hora span { font-size: 12px; color: var(--text-muted); }
  .am-info { flex: 1; min-width: 0; }
  .am-nombre { font-size: 15px; font-weight: 600; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .am-prof { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .am-prof i { width: 8px; height: 8px; border-radius: 50%; background: var(--am-color, var(--gold)); flex-shrink: 0; }
  .am-llegada { flex-shrink: 0; font-size: 11px !important; padding: 5px 9px !important; border-radius: 20px !important; white-space: nowrap; }
  .am-bloqueo { background: repeating-linear-gradient(45deg,#EDEDEA,#EDEDEA 6px,#E4E4E0 6px,#E4E4E0 12px); border: 1px solid #D8D8D3; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; font-size: 12.5px; font-weight: 600; color: #6B6B68; font-variant-numeric: tabular-nums; }
  .am-ahora { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; color: #E0463A; font-size: 12px; font-weight: 700; }
  .am-ahora::before, .am-ahora::after { content: ''; height: 2px; background: #E0463A; flex: 1; border-radius: 2px; }
  .am-ahora::before { flex: 0 0 10px; }

  /* Ficha de la cita a pantalla completa */
  #appt-drawer { width: 100% !important; max-width: 100% !important; }
}
