:root {
  /* Paleta MEDIBASE (rebranding v0.23.0): azul petróleo como color de
     marca principal, verde sanitario como acento — ver el documento
     de análisis MEDIBASE para el porqué de cada tono. */
  --primary: #0b6b5f;
  --primary-dark: #084f46;
  --accent: #12897a;
  --accent-dark: #0b6b5f;
  --bg: #f3f5f4;
  --card: #ffffff;
  --border: #dce3e1;
  --text: #14201e;
  --text-muted: #51615e;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --sidebar-bg: #14201e;
  --sidebar-text: #e6ecea;
  --sidebar-active: #1d2c29;
  /* Fondos "sutiles" (hovers, tarjetas anidadas, filas resaltadas) —
     antes eran colores fijos (#f1f5f9, #f8fafc, #eff6ff, #dbeafe,
     #fef2f2) repetidos por todo el CSS, combinados con texto que SÍ
     hereda var(--text) — en modo oscuro eso daba texto claro sobre
     fondo claro, casi ilegible (confirmado como fallo real). Con esto
     como variable, el texto (ya correctamente temático) sigue
     contrastando bien sin tener que fijar su color en cada sitio. */
  --surface-hover: #eef1f0;
  --surface-info: #ddf0ec;
  --surface-info-strong: #bfe3db;
  --surface-danger-subtle: #fef2f2;
}

/* Modo oscuro — activado poniendo data-theme="dark" en <html> (ver
   theme.js). Se tocan solo las variables base (fondo, tarjetas, texto,
   bordes, sidebar), que cubren la mayor parte de la superficie de la
   app. Los colores de estado (badges de éxito/aviso/error) se dejan
   igual a propósito — son fondos pastel con buen contraste en ambos
   modos, cambiarlos sin poder revisar cada pantalla una a una sería
   más arriesgado que dejarlos como "acento" reconocible sobre el fondo
   oscuro. primary/danger se aclaran un punto para que sigan
   destacando bien sobre un fondo oscuro (el tono original se pensó
   para contrastar sobre blanco).
*/
[data-theme="dark"] {
  --primary: #0f8576;
  --primary-dark: #0b6b5f;
  --accent: #5fd3b6;
  --accent-dark: #46b89c;
  --bg: #0e1716;
  --card: #162321;
  --border: #2a3b38;
  --text: #e6ecea;
  --text-muted: #a9b8b4;
  --danger: #f87171;
  --danger-dark: #ef4444;
  --sidebar-bg: #0a1211;
  --sidebar-text: #d5dfdc;
  --sidebar-active: #1d2c29;
  --surface-hover: #1d2c29;
  --surface-info: #123a34;
  --surface-info-strong: #1f5a50;
  --surface-danger-subtle: #4c1d1d;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.full-loading {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* --- Login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-logo { max-width: 220px; width: 100%; height: auto; display: block; margin: 0 auto 4px; }
.login-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; text-align: center; }

/* --- Layout general --- */
/* Contenedor de más afuera: apila avisos (sin conexión, licencia) a
   ancho completo ENCIMA de barra lateral + contenido, en vez de dejarlos
   como hermanos sueltos dentro de .app-shell — que es flex en fila, así
   que sin este envoltorio, cada aviso se colaba como una columna más
   junto a la barra lateral, empujando el contenido casi fuera de la
   pantalla (visto de verdad renderizándolo, no una suposición). */
.app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.app-shell {
  display: flex;
  flex: 1;
  min-height: 0; /* mismo motivo de siempre: un hijo flex no se encoge
                    por debajo de su contenido sin esto — aquí haría que
                    .app-shell empujara a .app-root más alto que 100vh */
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  height: 100vh;
  /* Sin overflow-y aquí a propósito: el menú de Ajustes y el de
     notificaciones se despliegan hacia fuera del sidebar (left: 100%) —
     poner overflow en un eje recorta los dos ejes en CSS, y eso cortaría
     esos menús. El contenido del propio sidebar (unos pocos botones) no
     va a desbordar 100vh en ningún caso realista. */
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: white;
  padding: 0 10px 20px;
}
.sidebar-brand-link {
  /* Se pincha para volver al Dashboard — sin añadir ningún icono nuevo a
     la barra, reutilizando la propia marca. Reseteo de <button>: por
     defecto trae borde, fondo y tipografía distintos a un <div>. */
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.sidebar-brand-link:hover .sidebar-brand-text { text-decoration: underline; }
.sidebar-brand-link.active { background: var(--sidebar-active); border-radius: 8px; }
.sidebar-brand-icon { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; }
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--sidebar-active); }
.sidebar-link.active { background: var(--primary); color: white; }
.sidebar-link .icon { font-size: 16px; }

/* Menú flotante de Ajustes */
.sidebar-settings { position: relative; margin-top: auto; }
.settings-dropdown {
  position: absolute;
  left: 100%;
  bottom: 0;
  margin-left: 8px;
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 210px;
  z-index: 50;
}
.settings-dropdown button {
  background: transparent;
  border: none;
  text-align: left;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.settings-dropdown button:hover { background: var(--surface-hover); }
.settings-dropdown button.danger { color: var(--danger-dark); }
.settings-dropdown-divider { height: 1px; background: var(--border); margin: 4px 6px; }

.app-main {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
  height: 100vh; /* junto con .app-shell height fijo, esto es lo que hace
                    que SOLO el contenido (la agenda, etc.) haga scroll,
                    mientras la barra lateral (con Ajustes) se queda fija */
}

.view { max-width: 1100px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; margin: 0; }
.lang-select {
  width: auto;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
}

/* --- Formularios / botones genéricos --- */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  margin-top: 12px;
}
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}
textarea { resize: vertical; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-ghost.small { padding: 5px 9px; font-size: 12px; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-block { width: 100%; }

.error-message { color: var(--danger); font-size: 13px; margin-top: 10px; }
.empty-state { color: var(--text-muted); font-size: 14px; padding: 10px 0; }
.empty-state.small { font-size: 13px; padding: 4px 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

/* --- Dashboard / pantalla principal --- */
.dashboard-view { max-width: 900px; }
.dashboard-greeting { font-size: 24px; margin: 0 0 20px; }
.dashboard-section-title { font-size: 17px; margin: 0 0 12px; }
.dashboard-banner {
  background: #fef3c7; color: #92400e; border-radius: 10px;
  padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
/* Un color de acento por tarjeta (borde superior + color del icono), para
   que las tres no se vean todas idénticas una al lado de otra. */
.dashboard-card { border-top: 3px solid transparent; }
.dashboard-card.accent-blue { border-top-color: #2563eb; }
.dashboard-card.accent-amber { border-top-color: #d97706; }
.dashboard-card.accent-violet { border-top-color: #7c3aed; margin-bottom: 14px; }
.dashboard-card h3 { margin: 0 0 10px; font-size: 14px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.dashboard-card-icon { font-size: 16px; }
.dashboard-big-number { font-size: 34px; font-weight: 700; margin: 0; line-height: 1; }
.dashboard-next-appt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: none; padding: 0; text-align: left; cursor: pointer;
}
.dashboard-next-appt-patient { font-weight: 600; }
.dashboard-next-appt-secondary { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); opacity: 0.75; }
.dashboard-waitlist-detail { margin: 8px 0 0; font-size: 14px; }
.dashboard-quick-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* Círculo con las iniciales del paciente/fisio, color fijo por persona
   (calculado en JS a partir del nombre) — un ancla visual rápida en vez
   de solo texto suelto. */
.dashboard-patient-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
}
.dashboard-patient-avatar.small { width: 26px; height: 26px; font-size: 11px; margin-right: 8px; }

.dashboard-team-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.dashboard-team-row:last-child { border-bottom: none; }
.dashboard-team-row-name { display: flex; align-items: center; }
.dashboard-team-status { font-size: 13px; }
.dashboard-team-status.cabinet { color: #15803d; }
.dashboard-team-status.home { color: #0369a1; }
.dashboard-team-status.mixed { color: #b45309; }
.dashboard-license-warning { border-color: #fbbf24; background: #fffbeb; color: #92400e; }
.dashboard-license-warning .meta { color: #92400e; }

/* Franja de días para saltar directo a la agenda de ese día desde el
   propio Dashboard — deslizable en pantallas estrechas, igual que otras
   filas de botones de la app, para no arriesgarse al mismo desbordamiento
   que ya se corrigió en otros sitios. */
.dashboard-day-strip {
  display: flex; gap: 8px; margin: 4px 0 20px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.dashboard-day-chip {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--card); cursor: pointer;
  min-width: 52px;
}
.dashboard-day-chip-weekday { font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.dashboard-day-chip-num { font-size: 16px; font-weight: 700; color: var(--text); }
.dashboard-day-chip.today { background: var(--primary); border-color: var(--primary); }
.dashboard-day-chip.today .dashboard-day-chip-weekday,
.dashboard-day-chip.today .dashboard-day-chip-num { color: white; }

/* --- Fila de dos columnas (cumpleaños + lista de espera, lado a lado) ---
   En móvil se apilan como el resto de tarjetas del Dashboard. */
.dashboard-row-2col { display: flex; gap: 14px; margin-bottom: 14px; align-items: flex-start; }
.dashboard-row-2col > * { flex: 1 1 0; min-width: 0; margin-bottom: 0 !important; }
@media (max-width: 800px) {
  .dashboard-row-2col { flex-direction: column; }
}

/* --- Aviso de cumpleaños --- */
/* Rediseñado a una tira plegada, no una tarjeta a todo lo ancho — pedido
   directo: "algo curioso, un añadido, pero no algo principal". Sin
   .card/border-top de acento (eso es lenguaje visual de tarjeta
   importante); un fondo sutil y una sola línea bastan para que se note
   sin competir con lista de espera / próxima cita. */
.dashboard-birthday-strip { margin-bottom: 12px; }
.dashboard-birthday-strip-toggle {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: var(--bg-subtle, rgba(219, 39, 119, 0.06)); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; color: var(--text-muted);
  cursor: pointer; text-align: left;
}
.dashboard-birthday-strip-toggle:hover { background: rgba(219, 39, 119, 0.12); }
.dashboard-birthday-strip-caret { font-size: 10px; margin-left: 8px; flex-shrink: 0; }
.dashboard-birthday-strip-list {
  border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px;
  padding: 4px 12px; margin-top: -1px;
}
.dashboard-birthday-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px;
}
.dashboard-birthday-row:last-child { border-bottom: none; }
.dashboard-birthday-when { color: #9d174d; font-size: 13px; font-weight: 600; }

/* --- Aviso de ordonnances con pocas sesiones --- */
.dashboard-lowsessions-card { border-top: 3px solid #d97706; margin-bottom: 14px; }
.dashboard-lowsessions-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; cursor: pointer;
}
.dashboard-lowsessions-row:last-child { border-bottom: none; }
.dashboard-lowsessions-count { color: #b45309; font-size: 13px; font-weight: 600; }

/* --- Gráfico pequeño de citas por día de la semana --- */
.dashboard-card.accent-teal { border-top-color: #0d9488; }
.dashboard-week-chart { display: flex; justify-content: space-between; align-items: flex-end; height: 90px; gap: 6px; margin-top: 4px; }
.dashboard-week-chart-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; height: 100%; }
.dashboard-week-chart-bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.dashboard-week-chart-bar { width: 100%; background: var(--border); border-radius: 4px 4px 0 0; min-height: 4px; }
.dashboard-week-chart-bar.today { background: var(--primary); }

/* --- Reparto cabinet / domicilio --- */
.dashboard-split-bar { height: 10px; border-radius: 5px; background: #ccfbf1; overflow: hidden; margin: 6px 0 8px; }
.dashboard-split-bar-fill { height: 100%; background: #0d9488; }
.dashboard-split-legend { display: flex; justify-content: space-between; font-size: 13px; }


.section-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.section-header h3 { margin: 0; font-size: 15px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  margin-right: 6px;
}
.badge-collab { background: #dcfce7; color: #15803d; }
.badge-sub { background: #fef3c7; color: #92400e; }

/* --- Retrocesión: lista agrupada por mes, colapsable --- */
.retrocession-month-group { margin-bottom: 6px; }
.retrocession-month-header {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  background: var(--surface-hover); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-weight: 600; font-size: 13px; cursor: pointer; margin-bottom: 4px;
}
.retrocession-row {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.retrocession-row:last-child { border-bottom: none; }
.retrocession-row.archived { opacity: 0.55; }
.retrocession-row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.retrocession-row-actions { display: flex; gap: 6px; }
.badge.muted { background: #f1f5f9; color: #64748b; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-off { background: #fee2e2; color: #b91c1c; }
.cliente-codigo-like {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  background: var(--surface-hover);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}
.badge-admin { background: #ede9fe; color: #6d28d9; }
.badge-admin { background: #ede9fe; color: #6d28d9; }

/* --- Agenda --- */
.agenda-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-label { font-size: 14px; font-weight: 600; margin-left: 8px; }
.agenda-toolbar-right { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.agenda-toolbar-right select { width: auto; }
.agenda-toolbar-right .btn-primary,
.agenda-toolbar-right .btn-ghost { white-space: nowrap; }

.agenda-week {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.agenda-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  min-height: 120px;
}
.agenda-day-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.appointment-item {
  background: var(--surface-info);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  cursor: pointer;
}
.appointment-item:hover { filter: brightness(0.95); }
.appt-time { font-size: 12px; font-weight: 700; color: var(--primary-dark); }
.appt-patient .name { font-size: 13px; font-weight: 600; }
.appt-note-icon { margin-left: 4px; font-size: 11px; }

.appointment-item.cancelled { opacity: 0.7; }
.appointment-item.cancelled .name { text-decoration: line-through; }
.cancelled-label { color: var(--danger-dark) !important; font-weight: 600; }
.appt-patient .title { font-size: 12px; color: var(--text-muted); }

/* Cuando la cita tiene un tipo de sesión con color propio, el color se aplica
   como fondo real de la tarjeta (via style inline) y el texto interno debe
   heredarlo en vez de usar los colores fijos de arriba, para mantener contraste. */
.appointment-item.has-type .appt-time,
.appointment-item.has-type .appt-patient .title {
  color: inherit;
  opacity: 0.85;
}
.appointment-item.has-type .appt-patient .name { color: inherit; }

/* --- Pacientes --- */
.patients-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}
.patients-list-panel {
  min-width: 0; /* mismo motivo de siempre, pero en CSS Grid en vez de
    flexbox: un item de grid tampoco se encoge por debajo del ancho
    mínimo de su contenido sin esto — confirmado renderizando de
    verdad: sin min-width:0 aquí y en el panel de al lado, la columna
    (tras colapsar a una sola en móvil) se resolvía a 515px de ancho
    en vez de a los 390px disponibles, y arrastraba a TODA LA PÁGINA
    a desbordarse horizontalmente con ella. */
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.search-row { margin-bottom: 10px; }
.patients-list { margin-top: 12px; max-height: 60vh; overflow-y: auto; }
.patient-item {
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.patient-item:hover { background: var(--surface-hover); }
.patient-item.active { background: var(--surface-info-strong); }
.patient-item .name { font-weight: 600; }
.patient-item .meta { color: var(--text-muted); font-size: 12px; }

.patient-detail-panel { min-height: 300px; min-width: 0; /* ver comentario en .patients-list-panel — mismo motivo */ }
.form-grid { display: flex; flex-direction: column; }
.form-row-split { display: flex; gap: 12px; }
.form-row-split .form-row { flex: 1; }

.patient-problems { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.problem-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.problem-item:last-child { border-bottom: none; }
.problem-title { font-size: 13px; font-weight: 600; }
.meta { color: var(--text-muted); font-size: 12px; }

/* --- Patient picker (autocompletar) --- */
.patient-picker { position: relative; }
.patient-picker-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.patient-picker-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.patient-picker-item:hover { background: var(--surface-hover); }

/* --- Usuarios --- */
.users-table {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-row-main { flex: 1 1 140px; min-width: 140px; }
.user-row-main .name { font-size: 14px; font-weight: 600; }
.user-row-main .meta { font-size: 12px; }
.user-row-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

/* --- Modales --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-box {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box.modal-wide { max-width: 620px; }

/* --- Vista previa de archivos (imagen/PDF) sin descargar --- */
.file-preview-modal {
  background: var(--card); border-radius: 12px; width: 100%; max-width: 720px;
  /* height (no max-height): un contenedor flex sin altura EXPLÍCITA se
     encoge a su contenido en vez de crecer hasta el máximo disponible
     — confirmado renderizando de verdad (con max-height en vez de
     height, el modal se colapsaba a solo la altura del título, 75px).
     dvh (altura dinámica real del viewport) se usa como mejora en los
     navegadores que ya la admiten, sobrescribiendo el valor en vh de
     reserva — más fiable en móviles, donde la barra de direcciones del
     navegador puede aparecer/desaparecer y hacer que un vh fijo no
     coincida con el espacio realmente disponible. */
  height: 88vh;
  height: 88dvh;
  display: flex; flex-direction: column; overflow: hidden;
  min-height: 0; /* sin esto, un contenedor flex puede seguir creciendo
    hasta el tamaño natural de su contenido en algunos navegadores —
    no es solo cosa del "height" de arriba. */
}
.file-preview-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.file-preview-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-body {
  flex: 1 1 0; min-height: 0; /* la clave del arreglo: sin min-height:0 aquí,
    una imagen grande (foto de móvil real, varios miles de píxeles) puede
    empujar este contenedor a crecer por encima de la altura disponible
    en vez de encogerse y dejar que la imagen se ajuste dentro — el
    modal entero se ve entonces "descuadrado", extendiéndose más allá
    de la pantalla en vez de quedarse contenido y con scroll interno. */
  display: flex; align-items: center; justify-content: center;
  overflow: auto; background: #0f172a10; padding: 12px;
}
.file-preview-image { display: block; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }

/* --- Estado del paciente (activo/inactivo/fallecido) --- */
.patient-detail-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.patient-detail-name { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.patient-detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.patient-status-badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 10px; text-transform: uppercase; }
.patient-status-badge.small { font-size: 10px; padding: 1px 7px; margin-left: 6px; }
.patient-status-badge.inactive { background: #e5e7eb; color: #4b5563; }
.patient-status-badge.deceased { background: #f3e8ff; color: #6b21a8; }

/* --- Registro de auditoría --- */
.audit-row { padding: 8px 0; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.audit-row-main { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-action-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; text-transform: uppercase; }
.audit-action-badge.create { background: #dcfce7; color: #15803d; }
.audit-action-badge.update { background: #dbeafe; color: #1d4ed8; }
.audit-action-badge.delete { background: #fee2e2; color: #b91c1c; }
.audit-entity { font-weight: 600; }
.audit-changes { background: var(--surface-hover); border-radius: 6px; padding: 8px; margin-top: 6px; font-size: 11px; overflow-x: auto; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  color: var(--text-muted);
}
.modal-body { padding: 18px 20px; }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}
.modal-actions .spacer { flex: 1; }

/* --- Responsive --- */
@media (max-width: 800px) {
  .app-root { height: auto; min-height: 100vh; }
  .app-shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 8px 8px; height: auto; overflow-y: visible; box-sizing: border-box; }
  .sidebar-brand { padding: 0 8px 0 0; }
  .sidebar-brand-text { display: none; }
  /* Sin esto, el botón se queda con el width:100% pensado para la barra
     lateral vertical (donde ocupa todo el ancho del sidebar a propósito)
     — en la barra horizontal de móvil eso lo infla a un rectángulo vacío
     enorme en vez de encogerse al tamaño del icono, que es lo único que
     queda visible una vez se oculta el texto de arriba. Visto en una
     captura real de Android: un bloque azul oscuro sin nada dentro,
     mucho más ancho que el propio icono. */
  .sidebar-brand-link { width: auto; }
  .sidebar-nav { flex-direction: row; flex: 1; align-items: center; gap: 0; min-width: 0; }
  .sidebar-link, .notification-bell-btn { padding: 8px 7px; gap: 6px; font-size: 13px; }
  .sidebar-brand { padding: 0 4px 0 0; }
  .sidebar-settings { margin-top: 0; margin-left: auto; }
  .app-main { padding: 16px; height: auto; overflow-y: visible; }
  .patients-layout { grid-template-columns: 1fr; }
  .form-row-split { flex-direction: column; }
  .agenda-week { grid-template-columns: 1fr; }

  /* Ahorra espacio: en móvil solo se ve el texto de la pestaña activa,
     el resto queda solo con su icono. Así no hace falta hacer scroll
     horizontal para encontrar los botones. */
  .sidebar-link .label { display: none; }
  .sidebar-link.active .label { display: inline; }
  /* La campanita nunca tiene un "view" activo que la marque (no es una
     pestaña, es un desplegable) — se queda siempre solo con el icono en
     móvil, igual que el resto salvo el activo. En escritorio SÍ lleva
     su etiqueta, para no ser el único botón de la barra sin texto. */
  .notification-bell-btn .label { display: none; }
}

/* --- Pestañas genéricas (usuarios, pacientes, ajustes, agenda) --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  /* Con 5 pestañas (Datos/Administrativo/Bilan/Ordonnances/Documentos),
     en una pantalla estrecha no cabían todas — confirmado renderizando
     de verdad: la fila se desbordaba y arrastraba a TODA LA PÁGINA con
     ella (scroll horizontal de la página entera, contenido cortado por
     la izquierda), en vez de quedarse contenida y deslizable ella sola.
     Mismo arreglo que ya se aplicó en su día a las subpestañas de
     Ajustes del panel de licencias. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tabs .tab { flex-shrink: 0; white-space: nowrap; }
.tabs.compact { border-bottom: none; margin-bottom: 0; gap: 2px; }
.tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 0;
}
.tabs.compact .tab {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs.compact .tab.active { background: var(--primary); color: white; border-color: var(--primary); }

/* --- Tarjeta rápida de paciente dentro del modal de cita --- */
.patient-quick-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-hover);
  border-radius: 8px;
  font-size: 13px;
}
.phone-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.phone-link:hover { text-decoration: underline; }
.contact-links {
  display: flex;
  gap: 6px;
}
.contact-links .phone-link {
  font-size: 20px;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.contact-links .phone-link:hover { text-decoration: none; background: var(--border); }

/* --- Botón de llamada junto a un campo de teléfono editable --- */
.phone-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.phone-input-row input { flex: 1; }
.call-btn {
  flex-shrink: 0;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
}

/* --- Documentos del paciente --- */
.documents-list { display: flex; flex-direction: column; gap: 6px; }
.document-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.document-item:hover { background: var(--surface-hover); }
.document-icon { font-size: 22px; }
.document-info { flex: 1; }
.document-info .name { font-size: 13px; font-weight: 600; }
.expired-warning { color: var(--danger-dark); font-weight: 600; }

.substitution-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
/* El fondo de este aviso es un ámbar fijo, igual en claro y oscuro (ver
   comentario sobre los colores de estado más arriba) — pero el botón
   "Transmisión" que vive dentro heredaba los colores temáticos genéricos
   de .btn-ghost (var(--text)/var(--border)), que en modo oscuro son casi
   blancos: prácticamente invisibles sobre este amarillo pálido. Se fija
   aquí al mismo tono ámbar que el resto del aviso, para que quede legible
   sin importar el tema. */
.substitution-banner .btn-ghost {
  color: #92400e;
  border-color: #b45309;
  background: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  padding: 2px 8px;
}
.substitution-banner .btn-ghost:hover {
  background: rgba(146, 64, 14, 0.15);
}

.substitution-row {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}
.substitution-row.archived { opacity: 0.55; }
.substitution-row:last-child { border-bottom: none; }
.substitution-row-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.substitution-row-info { cursor: pointer; flex: 1 1 200px; }
.substitution-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.substitution-contracts {
  margin-top: 10px;
  padding: 10px;
  background: var(--surface-hover);
  border-radius: 8px;
}

/* --- Prescripciones (ordonnances) --- */
.prescriptions-section {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.prescription-item {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.prescription-item:last-child { border-bottom: none; }
.prescription-item-main { flex: 1 1 200px; }
.prescription-item-main .name { font-size: 13px; font-weight: 600; }
.prescription-item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.quick-add-physician {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  background: var(--surface-hover);
  border-radius: 8px;
}
.quick-add-physician input { flex: 1 1 120px; }

/* --- Ficha de médico (Ajustes > Médicos) --- */
.physician-card {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-hover);
  border-radius: 8px;
}
.physician-card .form-row { margin-top: 8px; }
.physician-card .form-row:first-child { margin-top: 0; }
.physician-patients-list {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
}
.physician-patients-list li { margin-bottom: 2px; }

/* --- Tipos de cita (Ajustes) --- */
.type-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.type-row:last-child { border-bottom: none; }
.type-row input[type="color"] { width: 36px; height: 32px; padding: 2px; flex-shrink: 0; }
.type-row-label { flex: 1 1 120px; min-width: 120px; }
.type-row-active { display: flex; align-items: center; gap: 4px; font-size: 12px; white-space: nowrap; }

.checkbox-row {
  display: flex;
  align-items: flex-start; /* antes "center" — con una etiqueta larga que se
    parte en dos líneas (pantallas estrechas), dejaba la casilla flotando
    centrada entre ambas líneas en vez de alineada con la primera. Con
    una etiqueta corta de una sola línea no cambia nada visualmente. */
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"] {
  /* Sin "width: auto" aquí, heredaba el width:100% de la regla genérica
     de más arriba (pensada para campos de texto) — con flex-shrink:0
     impidiéndole encogerse, el checkbox reclamaba casi todo el ancho de
     la fila y dejaba el texto sin espacio real (confirmado midiendo con
     Playwright: el span quedaba con 0px de ancho, empujado fuera de la
     tarjeta). Nunca se había notado porque los usos anteriores de esta
     clase tenían tan poco texto que sobraba espacio de sobra incluso así. */
  width: auto;
  flex-shrink: 0;
  margin-top: 2px;
}
.checkbox-row span {
  /* Sin esto, el texto (como nodo de flex suelto, sin flex-basis propio)
     se salía por fuera de la tarjeta entera en vez de partirse en líneas
     dentro del espacio que le quedaba — nunca se había visto porque los
     usos anteriores de esta clase siempre tenían etiquetas cortas de una
     sola línea (AME, C2S...), esta es la primera vez que hace falta que
     el texto sea largo y necesite envolverse de verdad. Confirmado
     renderizando de verdad con Chromium, antes y después del arreglo. */
  flex: 1;
  min-width: 0;
}
.mini-label { display: block; font-size: 12px; color: var(--text-muted); margin: 10px 0 3px; }
.backup-history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; flex-wrap: wrap;
}
.backup-history-row:last-child { border-bottom: none; }
.btn-ghost.danger { color: var(--danger); border-color: var(--danger); }

/* --- Agenda: vista día y mes --- */
.agenda-day-single { max-width: 480px; }

.agenda-month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.agenda-month-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.agenda-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.agenda-month-cell {
  aspect-ratio: 1;
  min-width: 0; /* sin esto, una rejilla CSS nunca encoge una columna por
                   debajo del contenido mínimo de su celda — con varias
                   insignias apiladas (varios tipos de cita el mismo día),
                   la rejilla entera se ensanchaba más que la pantalla en
                   móvil, dejando una franja vacía a la derecha */
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  background: var(--card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.agenda-month-cell:hover { background: var(--surface-hover); }
.agenda-month-cell.muted { opacity: 0.4; }
.agenda-month-cell.today { border-color: var(--primary); border-width: 2px; }
.agenda-month-cell.has-exception { background: var(--surface-danger-subtle); }
.agenda-month-daynum { font-size: 12px; font-weight: 600; }

.agenda-month-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-self: flex-end;
  justify-content: flex-end;
}
.agenda-month-dot {
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: white;
  border-radius: 999px;
  padding: 2px 5px;
  min-width: 14px;
  text-align: center;
}
.agenda-month-dot-more { background: var(--text-muted); }

/* Ausencia: tacha el día con una línea en vez de mostrar puntos de citas,
   con un icono pequeño para saber el motivo sin que ocupe espacio. */
.agenda-month-exception {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 2px;
}
.agenda-month-exception::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -6px;
  right: -6px;
  height: 2px;
  background: #ef4444;
  transform: rotate(-8deg);
}
.agenda-month-exception-icon { font-size: 14px; z-index: 1; }
.agenda-month-exception-label {
  font-size: 8px;
  font-weight: 700;
  color: #b91c1c;
  text-transform: uppercase;
  z-index: 1;
  text-align: center;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.version-card { margin-top: 20px; }
.version-card h3 { margin-bottom: 6px; }
.version-card .meta { margin: 2px 0; }
.adventurebase-logo { max-width: 220px; width: 100%; height: auto; display: block; margin: 14px 0 6px; }

.weekday-picker { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.weekday-chip {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.weekday-chip.active { background: var(--primary); border-color: var(--primary); color: white; }

.timeline-free {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 4px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
}
.timeline-free:hover { background: #f8fafc; border-color: #2563eb; color: #2563eb; }
.timeline-free-plus { margin-left: auto; font-weight: 700; }

.timeline-exception {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 4px;
  background: repeating-linear-gradient(45deg, #fee2e2, #fee2e2 8px, #fecaca 8px, #fecaca 16px);
  border: 1px solid #fca5a5;
  border-radius: 8px;
  font-size: 12px;
  color: #991b1b;
  font-weight: 600;
}

.warning-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin: 0 0 4px;
}
.warning-banner.exception-warning {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.recurrence-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 4px;
}
.recurrence-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  cursor: pointer;
}
.recurrence-fields {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.recurrence-end-mode {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.recurrence-end-mode label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-weight: 500;
  white-space: nowrap;
}
.recurrence-end-mode input[type="number"],
.recurrence-end-mode input[type="date"] {
  width: 140px;
}

.type-row-duration { width: 70px; flex-shrink: 0; }

/* --- Aviso de sin conexión --- */
.offline-banner {
  background: #7c2d12;
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
}
.version-banner {
  background: #1e40af;
  color: white;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
.version-banner .btn-ghost {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
}
.version-banner .btn-ghost:hover { background: rgba(255, 255, 255, 0.25); }

/* --- Aviso de licencia requerida --- */
.license-required-banner {
  background: #7c2d12;
  color: white;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
}
.license-required-banner button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

/* --- Avisos del panel de licencias (mantenimiento, caducidad, general) --- */
.avisos-banner-stack { display: flex; flex-direction: column; }
.avisos-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.avisos-banner-mantenimiento { background: #FEF3C7; color: #92400E; }
.avisos-banner-caducidad { background: #FEE2E2; color: #991B1B; }
.avisos-banner-general { background: #E0F2FE; color: #075985; }
.avisos-banner-icon { flex-shrink: 0; font-size: 15px; }
.avisos-banner-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.avisos-banner-text strong { font-weight: 700; }
.avisos-banner-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
  flex-shrink: 0;
}
.avisos-banner-close:hover { opacity: 1; }

/* --- Rueda de carga --- */
.loading-spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 0;
}
.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: medibase-spin 0.8s linear infinite;
}
.loading-spinner.small { width: 18px; height: 18px; border-width: 2px; }
.loading-spinner-label { font-size: 13px; color: var(--text-muted); }
@keyframes medibase-spin {
  to { transform: rotate(360deg); }
}

/* --- Campanita de notificaciones --- */
.notification-bell { position: relative; }
.notification-bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  cursor: pointer;
}
.notification-bell-btn .icon { font-size: 16px; }
.notification-bell-btn:hover { background: var(--sidebar-active); }
.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}
.notification-dropdown {
  position: absolute;
  left: 100%;
  bottom: 0; /* se abre hacia arriba, como el menú de Ajustes — la
                campanita está abajo del todo del sidebar, y con "top: 0"
                (hacia abajo) se salía de la pantalla */
  margin-left: 8px;
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  width: 300px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.notification-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.notification-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0; /* sin esto, un hijo flex no se encoge por debajo de su
                    contenido — el scroll nunca llegaba a activarse y el
                    resto de avisos quedaba recortado sin más */
}
.notification-item {
  padding: 10px 30px 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--surface-hover); }
.notification-item.unread { background: var(--surface-info); }
.notification-item.unread .notification-item-title::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 6px;
}
.notification-item-title { font-size: 13px; font-weight: 600; }
.notification-item-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notification-item-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notification-item-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}
.notification-item-close:hover { background: #e2e8f0; color: #1e293b; }

/* En móvil la barra es horizontal y los botones (campanita, ajustes) no
   están pegados al borde de la pantalla, sino en medio de la fila — un
   menú anclado con "right: 0" se posiciona respecto al propio botón (muy
   estrecho), no respecto a la pantalla, y se sale por el borde izquierdo
   si el botón no está ya cerca del borde derecho (justo lo que se veía en
   la campanita). Con "position: fixed" y coordenadas de viewport en vez
   de "absolute" respecto al botón, el menú queda siempre dentro de la
   pantalla sin importar dónde esté el botón que lo abre. Esta regla va
   DESPUÉS de las reglas base de .settings-dropdown y .notification-dropdown
   a propósito: con la misma especificidad, en CSS gana la que aparece más
   tarde en el archivo — si esta regla fuera antes, la base (sin media
   query, aplica siempre) la pisaría también en móvil.
   */
/* Fondo semitransparente detrás de los menús de Ajustes/Notificaciones en
   móvil — sin esto, el menú (con position:fixed) parece "mezclado" con el
   contenido de la página que queda justo debajo, sin separación visual
   clara. En escritorio no hace falta (los menús se abren pegados a su
   botón, ya se distinguen bien) — display:none por defecto, solo se
   activa dentro de la media query de móvil. */
.mobile-dropdown-backdrop { display: none; }

@media (max-width: 800px) {
  .mobile-dropdown-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 49; /* justo debajo del propio menú (z-index: 50) */
  }

  .settings-dropdown,
  .notification-dropdown {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 60px;
    bottom: auto;
    margin: 0;
    width: auto;
    max-width: none;
    max-height: 70vh;
    overflow-y: auto;
  }
}


/* La regla móvil de .notification-dropdown ya está unificada junto a
   .settings-dropdown más arriba (position: fixed, misma media query) —
   evita tener dos reglas @media compitiendo por el mismo selector. */

/* --- Lista de espera --- */
.waitlist-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.waitlist-column h3 { margin-bottom: 10px; font-size: 15px; }
@media (max-width: 800px) {
  .waitlist-columns { grid-template-columns: 1fr; }
}

/* --- Bilan estructurado (0.34.0) --- */
.bilan-panel { margin-bottom: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.bilan-list-item .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 3px; }
.bilan-wizard { min-width: 0; }
.bilan-wizard-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.bilan-wizard-title { flex: 1 1 200px; min-width: 0; }
.bilan-banner { margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-info); }
.bilan-banner-warn { background: var(--surface-danger-subtle); font-size: 13px; }
.bilan-banner-warn ul { margin: 6px 0 0 18px; padding: 0; }
.bilan-meta { display: flex; flex-wrap: wrap; gap: 0 16px; }
.bilan-meta .form-row { flex: 1 1 200px; min-width: 0; }
.bilan-steps { margin-top: 12px; }
.bilan-step { min-width: 0; }
.bilan-step h3 { margin: 6px 0 4px; }
.bilan-textlang { max-width: 260px; }
.bilan-field { min-width: 0; }
.bilan-multichoice { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.bilan-alert-note { color: #b45309; margin-top: 4px; }
.bilan-group { margin-top: 18px; min-width: 0; }
.bilan-group-title { margin: 0 0 6px; font-size: 14px; color: var(--primary); padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.bilan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.bilan-row-label { flex: 1 1 220px; min-width: 0; font-size: 13px; font-weight: 500; }
.bilan-side { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--surface-info-strong); color: var(--text); }
.bilan-row-input { flex: 0 1 200px; min-width: 0; }
.bilan-num-input { display: flex; align-items: center; gap: 6px; }
.bilan-unit { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.bilan-row-prev { flex: 1 1 100%; }
.bilan-diff { font-weight: 600; color: var(--text); }
.bilan-details-toggle { flex: 0 0 auto; }
.bilan-row-error { flex: 1 1 100%; margin: 0; }
.bilan-row-details { flex: 1 1 100%; min-width: 0; padding: 4px 0 8px; }
.bilan-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); }
.bilan-footer-nav, .bilan-footer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bilan-savestate.error { color: var(--danger); }
@media (max-width: 800px) {
  .bilan-row-input { flex: 1 1 100%; }
  .bilan-footer-nav, .bilan-footer-actions { width: 100%; }
}

/* Próximas sesiones del paciente */
.upcoming-appointments-list { display: flex; flex-direction: column; gap: 8px; }
.upcoming-appointment-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 8px 12px; border-left: 3px solid #2563eb; background: var(--surface-2, rgba(127,127,127,.07)); border-radius: 0 8px 8px 0; }
.upcoming-when { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.upcoming-day { color: var(--text-muted, #6b7280); font-size: .9em; }
.upcoming-time { font-size: 1.05em; }
.upcoming-provider { font-size: .95em; overflow-wrap: anywhere; }
.badge-home { background: #ede9fe; color: #5b21b6; }
.badge-clinic { background: #e0f2fe; color: #075985; }
@media (min-width: 720px) {
  .upcoming-appointment-item { flex-direction: row; align-items: center; gap: 16px; }
  .upcoming-when { min-width: 190px; }
  .upcoming-provider { flex: 1; }
}

/* Bilan: modo simplificado / extenso */
.bilan-step-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.bilan-step-head h3 { margin: 0; min-width: 0; }
.bilan-mode { display: inline-flex; border: 1px solid var(--border, #d5dee2); border-radius: 999px; overflow: hidden; }
.bilan-mode-btn { background: transparent; border: 0; padding: 6px 14px; cursor: pointer; font: inherit; font-size: .9em; color: inherit; }
.bilan-mode-btn.active { background: var(--primary, #1e3a5f); color: #fff; }
.bilan-hidden-note { margin-top: 12px; }

/* --- Ejercicios (0.36.0) --- */
.ex-view { max-width: 1000px; }
.ex-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.ex-header h2, .ex-header h3 { margin: 0; }
.ex-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.ex-filters input[type="search"] { flex: 1 1 180px; min-width: 0; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 10px; }
.ex-card { display: flex; flex-direction: column; text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 0; overflow: hidden; cursor: pointer; font: inherit; color: inherit; }
.ex-card:hover { border-color: var(--primary); }
.ex-card.archived { opacity: 0.6; }
.ex-card-body { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 12px; }
.ex-status { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ex-img { background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: center; min-height: 120px; }
.ex-img img { display: block; width: 100%; height: auto; max-height: 300px; object-fit: contain; }
.ex-img-sm { min-height: 90px; }
.ex-img-sm img { max-height: 150px; }
.ex-img-empty { color: var(--text-muted); font-size: 22px; }
.ex-detail h4 { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.ex-detail p, .ex-detail ol { margin: 0 0 4px; font-size: 14px; }
.ex-detail ol { padding-left: 20px; }
.ex-warn { background: #fef3c7; color: #92400e; border-radius: 8px; padding: 8px 10px; font-size: 13px; margin: 8px 0; }
.ex-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.ex-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.ex-check input { width: auto; }
.ex-image-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ex-picklist { max-height: 55vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.ex-pick { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: none; border-bottom: 1px solid var(--border); background: transparent; font: inherit; color: inherit; cursor: pointer; }
.ex-pick:last-child { border-bottom: none; }
.ex-pick.disabled { opacity: 0.5; cursor: default; }
.ex-pick input { width: auto; flex-shrink: 0; }
.ex-pick .meta { margin-left: auto; }
.ex-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: var(--card); }
.ex-item-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.ex-item-head strong { min-width: 0; overflow-wrap: anywhere; }
.ex-dose-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.ex-dose-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-muted); }
.ex-dose-field input, .ex-dose-field select { width: 84px; padding: 6px 8px; }
.ex-item-note { width: 100%; margin-bottom: 4px; }
.ex-template, .ex-program { margin-bottom: 10px; }
.ex-template { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ex-program-head { display: flex; gap: 8px; }
.ex-program-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ex-history { margin: 10px 0 0; padding-left: 18px; }
.btn-primary.small { padding: 5px 9px; font-size: 12px; }
@media (max-width: 640px) {
  .ex-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .ex-dose-field input, .ex-dose-field select { width: 70px; }
}
.ex-filters select { width: auto; flex: 1 1 150px; min-width: 0; }
.ex-filters .ex-check { flex: 0 0 auto; }
.ex-dose-field select { width: 118px; }

/* Panel KPI (0.37.0) */
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.kpi-ranges { display: flex; gap: 4px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.kpi-tile { border: 1px solid var(--border, #e2e8f0); border-radius: 8px; padding: 10px; }
.kpi-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.kpi-delta { font-size: 0.8rem; margin-top: 2px; }
.kpi-delta.up { color: #15803d; }
.kpi-delta.down { color: #b91c1c; }
.kpi-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 0.9rem; }
.kpi-table th, .kpi-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border, #e2e8f0); }
.kpi-subs { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; margin: 6px 0; cursor: pointer; }

/* Festivos y vacaciones escolares (0.38.0) */
.holiday-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 2px 0 6px; }
.holiday-tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; line-height: 1.3; }
.holiday-tag.public { background: #fee2e2; color: #991b1b; }
.holiday-tag.school { background: #dbeafe; color: #1e40af; }
.agenda-month-cell.has-school { background-image: linear-gradient(rgba(59,130,246,0.10), rgba(59,130,246,0.10)); }
.agenda-month-cell.has-public { box-shadow: inset 0 -3px 0 #dc2626; }
.agenda-month-holiday { font-size: 0.68rem; color: #991b1b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-month-school { font-size: 0.8rem; }
:root[data-theme="dark"] .holiday-tag.public { background: #7f1d1d; color: #fecaca; }
:root[data-theme="dark"] .holiday-tag.school { background: #1e3a8a; color: #bfdbfe; }

/* ---------- Módulo Web (0.39.0): Ajustes → Web y citas ---------- */
.web-locked { border-left: 4px solid var(--accent); }
.web-locked ul { margin: 8px 0 12px 18px; padding: 0; }
.web-locked li { margin: 4px 0; }
.web-request { display: flex; gap: 14px; justify-content: space-between; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.web-request:first-of-type { border-top: 0; }
.web-request-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.web-request-main > strong { font-size: 0.98rem; }
.web-request-main .badge { align-self: flex-start; }
.web-request-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.web-warn { color: #92400e; }
.web-freetext { margin: 4px 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--surface-info); border-radius: 6px; white-space: pre-wrap; font-size: 0.9rem; }
.web-savebar { margin-top: 12px; align-items: center; }
.web-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.web-table-wrap { overflow-x: auto; margin: 6px 0 12px; }
.web-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.web-table th, .web-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.web-table th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; }
.web-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--border); }
.web-checks { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.web-checks li { font-size: 0.9rem; display: flex; gap: 8px; align-items: baseline; }
.web-checks li span { font-weight: 700; width: 1em; text-align: center; }
.web-check-ok span { color: #15803d; }
.web-check-warn span { color: #b45309; }
.web-check-error { color: var(--danger); }
.web-check-error span { color: var(--danger); }
.web-themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.web-theme { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 8px; border: 2px solid var(--border); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; font: inherit; }
.web-theme:hover { border-color: var(--text-muted); }
.web-theme.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--surface-info-strong); }
.web-theme .meta { font-size: 0.78rem; line-height: 1.3; }
.web-theme-sample { position: relative; display: flex; flex-direction: column; gap: 6px; height: 86px; padding: 10px; border: 1px solid; border-radius: 6px; overflow: hidden; }
.web-theme-sample > span { display: block; border-radius: 2px; }
.web-theme-sample .web-theme-second { position: absolute; right: -14px; top: -14px; width: 46px !important; height: 46px !important; border-radius: 50% !important; opacity: 0.85; }
.web-window { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 0; }
.web-window .web-chips { margin: 0; }
.web-window input[type="time"] { width: auto; }
.web-portal-box { margin-bottom: 16px; }
.web-share { font-size: 0.82rem; margin: 0 8px 0 0; white-space: nowrap; }
.appointment-item.web-pending { outline: 2px dashed #d97706; outline-offset: -2px; }
.appt-web-badge { margin-left: 6px; font-size: 0.68rem; padding: 1px 6px; }
.appt-web-icon { margin-left: 4px; font-size: 0.8rem; }
@media (max-width: 640px) {
  .web-request { flex-direction: column; }
  .web-request-actions { justify-content: flex-start; }
}
:root[data-theme="dark"] .web-warn { color: #fcd34d; }
.web-stack .card + .card, .web-stack > div > .card + .card { margin-top: 16px; }
.web-color { width: 52px; height: 36px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; }
a.web-linkbtn { display: inline-flex; align-items: center; text-decoration: none; }

/* ============================================================
   0.40.0 — Nueva estructura (docs/PLAN-INTERFAZ-MULTIPROFESION.md)
   Ordenador: panel lateral. Móvil: barra superior mínima + barra
   inferior con «+» central.
   ============================================================ */
.nav-icon { flex: none; }
.sidebar { width: 236px; padding: 18px 12px; gap: 14px; }
.sidebar-brand-text { font-weight: 700; font-size: 18px; letter-spacing: -0.2px; }
.sidebar-profile { display: flex; flex-direction: column; border: 1px solid rgba(255,255,255,0.14); background: var(--sidebar-active); border-radius: 10px; padding: 8px 12px; }
.sidebar-profile-label { font-size: 11px; opacity: 0.75; }
.sidebar-profile-value { font-weight: 600; font-size: 14px; color: #fff; }
.sidebar-link { min-height: 44px; border-radius: 10px; font-weight: 500; }
.sidebar-link.active { background: var(--primary); color: #fff; font-weight: 700; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar-settings { margin-top: 0; }
.sidebar-data { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; width: 100%; background: transparent; color: inherit; font-family: inherit; text-align: left; cursor: pointer; min-height: 40px; }
.sidebar-data:hover { background: rgba(255,255,255,0.06); }
.sidebar-data-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd3b6; flex: none; }
.sidebar-data.offline .sidebar-data-dot { background: #f2c078; }
.sidebar-user { width: 100%; }
.sidebar-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex: none; }
.sidebar-link.active .sidebar-avatar { background: rgba(255,255,255,0.22); }
.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-sub { font-size: 12px; opacity: 0.75; }
.settings-dropdown button { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.notification-bell-btn { min-height: 44px; border-radius: 10px; }
.bottomnav, .quickadd-sheet, .quickadd-backdrop { display: none; }

.profession-setting { margin-bottom: 16px; }
.profession-options { display: flex; flex-wrap: wrap; gap: 8px; }
.profession-option { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.profession-option:hover { border-color: var(--text-muted); }
.profession-option.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.profession-option:disabled { opacity: 0.6; cursor: default; }

@media (max-width: 800px) {
  /* Barra superior: marca a la izquierda; avisos, tema y ajustes a la derecha. */
  .sidebar { width: 100%; padding: 8px 12px; gap: 8px; position: sticky; top: 0; z-index: 40; }
  .sidebar-brand-text { display: inline; font-size: 17px; }
  .sidebar-profile, .sidebar-data, .sidebar .nav-primary { display: none; }
  .sidebar-nav { justify-content: flex-end; gap: 2px; }
  .sidebar-foot { margin-top: 0; flex-direction: row; align-items: center; gap: 2px; }
  .sidebar-link, .notification-bell-btn { min-width: 44px; min-height: 44px; justify-content: center; padding: 0 8px; }
  .sidebar-link .label, .sidebar-link.active .label, .sidebar-user-text { display: none; }
  .sidebar-settings { margin-left: 0; }
  .sidebar-avatar { width: 34px; height: 34px; }

  /* El contenido deja sitio a la barra inferior fija. */
  .app-main { padding: 16px 16px calc(96px + env(safe-area-inset-bottom, 0px)); }

  .bottomnav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--card); border-top: 1px solid var(--border); padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .bottomnav.bottomnav-4 { grid-template-columns: 1fr 1fr 72px 1fr; }
  .bottomnav-link { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 11.5px; font-weight: 500; cursor: pointer; border-radius: 10px; }
  .bottomnav-link.active { color: var(--primary); font-weight: 700; }
  [data-theme="dark"] .bottomnav-link.active { color: var(--accent); }
  .bottomnav-add { justify-self: center; width: 58px; height: 58px; margin-top: -26px; border-radius: 50%; border: 4px solid var(--card); background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 6px 16px rgba(11,107,95,0.35); }
  .quickadd-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,18,17,0.45); z-index: 46; }
  .quickadd-sheet { display: flex; flex-direction: column; gap: 4px; position: fixed; left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 47; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 8px; box-shadow: 0 12px 32px rgba(0,0,0,0.25); }
  .quickadd-sheet button { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--text); font: inherit; font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; }
  .quickadd-sheet button:hover { background: var(--surface-hover); }
}

/* ============================================================
   0.41.0 — Agenda de la maqueta, «Hoy» y «Por hacer»
   ============================================================ */
.agenda-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.agenda-head-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -0.4px; }
.agenda-head-title::first-letter { text-transform: uppercase; }
.agenda-head-summary { margin: 0 0 8px; color: var(--text-muted); font-size: 14px; }
.agenda-toolbar { align-items: flex-end; }
.agenda-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.agenda-main { min-width: 0; }
.agenda-aside { display: none; }
@media (min-width: 1280px) {
  .agenda-layout:not(.no-aside) { grid-template-columns: minmax(0, 1fr) 320px; }
  .agenda-aside { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; }
}
.agenda-team { display: grid; gap: 14px; align-items: start; }
.agenda-team-col { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.agenda-team-col > header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.agenda-team-col h3 { margin: 0; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-team-add { min-height: 44px; border: 1px dashed var(--border); border-radius: 10px; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; }
.agenda-team-add:hover { border-color: var(--primary); color: var(--primary); }
.agenda-chip { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 8px 12px; border: 1px solid transparent; border-radius: 10px; background: var(--surface-info); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.agenda-chip:hover { filter: brightness(0.97); }
.agenda-chip-time { font-weight: 700; font-variant-numeric: tabular-nums; width: 46px; flex: none; }
.agenda-chip-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.agenda-chip-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-chip-sub { font-size: 12px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-chip-tag { flex: none; font-size: 11px; font-weight: 700; border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px; }
.agenda-chip.pending { background: var(--card); border: 2px dashed #6d4aa8; color: #5b3a8c; }
[data-theme="dark"] .agenda-chip.pending { color: #cdb8f0; border-color: #a98ee0; }
.agenda-chip.cancelled { background: var(--surface-hover); color: var(--text-muted); }
.agenda-chip.cancelled .agenda-chip-name { text-decoration: line-through; }

.agenda-next { background: var(--sidebar-bg); color: var(--sidebar-text); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.agenda-next-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; opacity: 0.75; }
.agenda-next-name { font-size: 19px; font-weight: 700; color: #fff; }
.agenda-next-sub { font-size: 13px; opacity: 0.8; margin: 0; }
.agenda-next-tracker { background: var(--sidebar-active); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.agenda-next-tracker-row { display: flex; justify-content: space-between; font-size: 13px; }
.agenda-next-bar { height: 8px; border-radius: 999px; background: rgba(255,255,255,0.16); overflow: hidden; }
.agenda-next-bar > div { height: 100%; background: #f2c078; }
.agenda-next-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.agenda-next-btn { flex: 1; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.3); background: transparent; color: #fff; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.agenda-next-btn.primary { background: #5fd3b6; border-color: #5fd3b6; color: #06241f; font-weight: 700; }
.agenda-next-pill { background: #f2c078; color: #2a1a02; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 10px; }
.agenda-todo { padding: 16px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.agenda-todo h3 { margin: 0 0 2px; font-size: 15px; }
.agenda-todo-item { display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 10px; border: 0; border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; text-align: left; cursor: pointer; min-height: 44px; }
.agenda-todo-item:hover { background: var(--surface-hover); }
.agenda-todo-kind { flex: none; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 3px 7px; }
.agenda-todo-kind.tone-violet { background: #ebe4f6; color: #4a2e78; }
.agenda-todo-kind.tone-blue { background: #dfeaf7; color: #173f70; }
.agenda-todo-kind.tone-amber { background: #fbebd3; color: #6b3a05; }
.agenda-todo-kind.tone-green { background: #ddf0ec; color: #084f46; }
.agenda-todo-text { display: flex; flex-direction: column; min-width: 0; }
.agenda-todo-text span { font-size: 12px; color: var(--text-muted); }

/* «Hoy»: tarjeta del próximo paciente arriba del todo. */
.today-hero { margin-bottom: 16px; max-width: 720px; }
.today-hero .agenda-next { padding: 18px; border-radius: 18px; }
.today-hero .agenda-next-name { font-size: 22px; }
.today-hero .agenda-next-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.today-then { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.today-then h3 { margin: 0; font-size: 15px; }
/* «Por hacer» como página. */
.todo-page { max-width: 720px; }
.todo-page .agenda-todo-item { padding: 14px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; min-height: 60px; align-items: center; }
.todo-page .agenda-todo-text strong { font-size: 15px; }
.todo-page .agenda-todo-text span { font-size: 13px; }
.bottomnav-badge { position: absolute; top: 2px; right: calc(50% - 22px); background: #f2c078; color: #2a1a02; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 6px; }
.sidebar-badge { margin-left: auto; background: #f2c078; color: #2a1a02; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
@media (max-width: 800px) {
  .agenda-team { grid-template-columns: minmax(0, 1fr) !important; }
  .agenda-head-title { font-size: 20px; }
  .agenda-team-tab { display: none; }
  .bottomnav-link { position: relative; }
}

.settings-dropdown .only-mobile { display: none; }
@media (max-width: 800px) { .settings-dropdown .only-mobile { display: flex; } }

/* ============================================================
   0.42.0 — Ficha, sesión en curso, ruta, buscador y «Mis datos»
   ============================================================ */
/* Ficha */
.ficha-sub { margin: 2px 0 8px; color: var(--text-muted); font-size: 14px; }
.ficha-alerts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ficha-alert { display: inline-flex; align-items: center; gap: 4px; background: #fbebd3; color: #6b3a05; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 4px 3px 10px; }
.ficha-alert button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 15px; line-height: 1; cursor: pointer; }
.ficha-alert button:hover { background: rgba(0,0,0,0.1); }
.route-current .ficha-alert { padding-right: 10px; }
.ficha-alert-add { min-height: 28px; padding: 0 10px; border: 1px dashed var(--border); border-radius: 999px; background: transparent; color: var(--text-muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.ficha-alert-add:hover { border-color: var(--primary); color: var(--primary); }
.ficha-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ficha-actions a { text-decoration: none; display: inline-flex; align-items: center; min-height: 40px; }
.ficha-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.ficha-card { margin: 0; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.ficha-card h3 { margin: 0; font-size: 15px; }
.ficha-prescription { gap: 8px; }
.ficha-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; border-top: 1px solid var(--border); padding-top: 8px; }
.ficha-row:first-of-type { border-top: 0; padding-top: 0; }
.ficha-row-main { display: flex; flex-direction: column; min-width: 0; }
.ficha-stats { flex-direction: row; gap: 24px; }
.ficha-stats div { display: flex; flex-direction: column; }
.ficha-stats strong { font-size: 24px; line-height: 1.1; }
.ficha-recent { grid-column: 1 / -1; }
.ficha-note { display: flex; gap: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
.ficha-note:first-of-type { border-top: 0; padding-top: 0; }
.ficha-note-date { width: 62px; flex: none; color: var(--text-muted); font-size: 13px; }
.ficha-note-text { white-space: pre-wrap; font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.ficha-note-text.empty { color: var(--text-muted); font-style: italic; }

/* Sesión en curso */
.session-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10,18,17,0.55); display: flex; justify-content: center; align-items: stretch; }
.session-panel { width: 100%; max-width: 560px; background: var(--bg); display: flex; flex-direction: column; height: 100%; }
@media (min-width: 801px) { .session-overlay { padding: 24px; align-items: center; } .session-panel { height: auto; max-height: 100%; border-radius: 18px; overflow: hidden; } }
.session-head { background: var(--sidebar-bg); color: var(--sidebar-text); padding: 14px 18px; display: flex; flex-direction: column; gap: 6px; }
.session-head-top { display: flex; align-items: center; justify-content: space-between; }
.session-back { width: 44px; height: 44px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.3); background: transparent; color: #fff; font-size: 22px; cursor: pointer; }
.session-timer { display: inline-flex; align-items: center; gap: 8px; background: var(--sidebar-active); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.session-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd3b6; }
.session-name { font-size: 21px; font-weight: 700; color: #fff; }
.session-sub { font-size: 14px; opacity: 0.8; }
.session-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.session-card { margin: 0; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.session-card h3, .session-label { margin: 0; font-size: 15px; font-weight: 700; }
.session-last { margin: 0; white-space: pre-wrap; font-size: 14px; color: var(--text-muted); max-height: 96px; overflow: auto; }
.session-card textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.session-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.session-chip { min-height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.session-chip.active { background: var(--surface-info); border-color: var(--primary); color: var(--primary-dark); }
[data-theme="dark"] .session-chip.active { color: #fff; }
.session-tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.session-tool { min-height: 48px; border-radius: 12px; border: 0; background: var(--sidebar-bg); color: #fff; font: inherit; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; padding: 0 10px; }
.session-tool.ghost { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.session-tool.on { background: #b3261e; }
.session-measures { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.session-measures label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.session-measures input { height: 44px; font-weight: 700; width: 100%; box-sizing: border-box; }
.session-foot { background: var(--card); border-top: 1px solid var(--border); padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
.session-finish { width: 100%; min-height: 52px; border-radius: 14px; font-size: 15px; }

/* Ruta a domicilio */
.route-page { max-width: 640px; display: flex; flex-direction: column; gap: 10px; }
.route-stats { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin-bottom: 4px; }
.route-stats .card { margin: 0; padding: 10px 14px; display: flex; flex-direction: column; }
.route-stats strong { font-size: 20px; }
.route-full { display: inline-flex; align-items: center; text-decoration: none; min-height: 44px; }
.route-stop { display: flex; gap: 12px; }
.route-rail { display: flex; flex-direction: column; align-items: center; width: 28px; flex: none; }
.route-num { width: 28px; height: 28px; border-radius: 50%; background: var(--card); border: 2px solid var(--border); box-sizing: border-box; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.route-num.done { background: var(--primary); border-color: var(--primary); color: #fff; }
.route-num.current { background: var(--sidebar-bg); border-color: var(--sidebar-bg); color: #fff; }
.route-line { flex: 1; width: 2px; background: var(--border); min-height: 12px; }
.route-line.done { background: var(--primary); }
.route-current { flex: 1; min-width: 0; margin-bottom: 4px; }
.route-card { flex: 1; min-width: 0; min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; color: var(--text); font: inherit; text-align: left; cursor: pointer; margin-bottom: 4px; }
.route-card.done { background: var(--surface-hover); color: var(--text-muted); }
.route-card.done svg { color: var(--primary); flex: none; }
.route-card-main { display: flex; flex-direction: column; min-width: 0; }
.route-late { min-height: 48px; border-radius: 12px; border: 1px dashed var(--text-muted); background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; padding: 0 12px; }
.route-link { align-self: flex-start; margin-top: 10px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--primary); font: inherit; font-weight: 700; cursor: pointer; }
[data-theme="dark"] .route-link { color: var(--accent); }

/* Buscador global */
.sidebar-search { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14); background: transparent; color: var(--sidebar-text); font: inherit; font-size: 13px; cursor: pointer; }
.sidebar-search .label { flex: 1; text-align: left; opacity: 0.8; }
.sidebar-search kbd { font: inherit; font-size: 11px; border: 1px solid rgba(255,255,255,0.2); border-radius: 5px; padding: 1px 5px; opacity: 0.8; }
.palette-overlay { position: fixed; inset: 0; z-index: 210; background: rgba(10,18,17,0.5); display: flex; justify-content: center; align-items: flex-start; padding: 10vh 16px 16px; }
.palette { width: 100%; max-width: 560px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,0.3); overflow: hidden; display: flex; flex-direction: column; max-height: 70vh; }
.palette input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; height: 54px; padding: 0 18px; font-size: 16px; background: transparent; color: var(--text); outline: none; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); padding: 8px 12px 4px; }
.palette-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-weight: 600; text-align: left; cursor: pointer; }
.palette-row .meta { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-row.active { background: var(--surface-info); }

/* Mis datos */
.data-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.data-card { margin: 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.data-card h3 { margin: 0; font-size: 15px; }
.data-wide { grid-column: 1 / -1; }
.data-rows { display: flex; flex-direction: column; gap: 6px; }
.data-rows div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.data-ok { color: #15803d; } .data-warn { color: #b45309; }
[data-theme="dark"] .data-ok { color: #6fd9a0; } [data-theme="dark"] .data-warn { color: #f2c078; }
.data-alert { margin: 0; background: #fbebd3; color: #6b3a05; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.data-login { display: flex; gap: 12px; align-items: center; min-height: 36px; border-top: 1px solid var(--border); font-size: 14px; }
.data-login-when { width: 120px; flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.data-login-who { flex: 1; }

.app-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(104px + env(safe-area-inset-bottom, 0px)); z-index: 220; background: var(--sidebar-bg); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
@media (min-width: 801px) { .app-toast { bottom: 24px; } }
@media (max-width: 800px) {
  .ficha-summary, .data-grid { grid-template-columns: minmax(0, 1fr); }
  .sidebar-search { min-width: 44px; min-height: 44px; justify-content: center; border: 0; padding: 0 8px; margin-left: auto; }
  .sidebar-search .label, .sidebar-search kbd { display: none; }
  .sidebar-nav { flex: none; }
  .palette-overlay { padding-top: 16px; }
}

.patient-detail-header { flex-wrap: wrap; }
.patient-detail-header > .ficha-sub, .patient-detail-header > .ficha-alerts, .patient-detail-header > .ficha-actions { flex-basis: 100%; }
.ficha-actions a { padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; font-weight: 600; color: var(--text); background: var(--card); }

/* 0.43.0 — contenido de la licencia (Ajustes › Licencia) */
.license-includes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; line-height: 1.4; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.chip-strong { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* 0.44.0 — Facturación */
.billing-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.billing-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.billing-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; position: relative; min-width: 0; }
.billing-kpi span { font-size: 12px; color: var(--text-muted); }
.billing-kpi strong { font-size: 20px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.billing-kpi em { position: absolute; top: 10px; right: 12px; font-style: normal; font-size: 12px; font-weight: 700; background: #fee2e2; color: #b91c1c; border-radius: 999px; padding: 1px 8px; }
.billing-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.billing-filters input[type="search"] { flex: 1 1 180px; min-width: 0; }
.billing-filters select, .billing-filters input, .billing-issuer-pick { min-height: 40px; }
.billing-list { list-style: none; margin: 0 0 14px; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.billing-list li + li { border-top: 1px solid var(--border); }
.billing-list li.is-off { opacity: 0.55; }
.billing-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 56px; background: none; border: 0; text-align: left; color: var(--text); cursor: pointer; font: inherit; }
.billing-row:hover { background: var(--surface-hover); }
.billing-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.billing-row-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.billing-row-main .meta { font-size: 12.5px; color: var(--text-muted); }
.billing-row-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.billing-warn { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; margin: 0 0 12px; }
.billing-ok { color: #15803d; font-size: 13.5px; margin: 8px 0 0; }
.billing-note { background: var(--bg); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; margin: 0 0 12px; }
.link-btn { background: none; border: 0; padding: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.billing-check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 6px 0 10px; min-height: 32px; }
.billing-check input { width: 18px; height: 18px; flex-shrink: 0; }
.billing-section { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.billing-section h4 { margin: 0 0 8px; font-size: 14px; }
.billing-picked { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.billing-results { list-style: none; margin: 4px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.billing-results button { width: 100%; text-align: left; padding: 10px 12px; min-height: 44px; background: var(--surface); border: 0; color: var(--text); font: inherit; cursor: pointer; }
.billing-results li + li button { border-top: 1px solid var(--border); }
.billing-results button:hover { background: var(--surface-hover); }
.billing-recipient { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 4px; }
.billing-pending { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.billing-pending-item { border: 1px dashed var(--primary); color: var(--primary); background: transparent; border-radius: 999px; padding: 7px 12px; min-height: 36px; font: inherit; font-size: 13px; cursor: pointer; }
.billing-pending-item:hover { background: var(--surface-hover); }
.billing-line { display: grid; grid-template-columns: minmax(0, 1fr) 140px 60px 90px 36px; gap: 6px; margin-bottom: 6px; align-items: center; }
.billing-line input { min-width: 0; width: 100%; }
.billing-line-qty, .billing-line-price { text-align: right; font-variant-numeric: tabular-nums; }
.billing-add { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.billing-add select { flex: 1 1 200px; min-width: 0; }
.billing-total { text-align: right; font-size: 16px; margin: 12px 0 4px; }
.billing-total strong { font-size: 20px; font-variant-numeric: tabular-nums; margin-left: 6px; }
.billing-detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.billing-detail-name { font-size: 17px; font-weight: 700; }
.billing-detail-total { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.billing-detail-total strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.billing-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 10px; }
.billing-table th { text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600; padding: 6px 6px; border-bottom: 1px solid var(--border); }
.billing-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.billing-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.billing-payments { list-style: none; margin: 0 0 8px; padding: 0; }
.billing-payments li { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; }
.billing-payments li span { flex: 1; }
.billing-balance { font-size: 14px; margin: 0 0 8px; }
.billing-pay { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 8px; align-items: end; }
.billing-pay .form-row { margin: 0; }
.billing-pay .error-message { grid-column: 1 / -1; margin: 0; }
.billing-issuer { margin-bottom: 14px; }
.billing-issuer h3 { margin-top: 0; }
.billing-issuer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.billing-settings .card { margin-bottom: 14px; }
.billing-tariffs > .meta, .billing-view > .meta { display: block; margin: 0 0 10px; color: var(--text-muted); font-size: 13.5px; }
.billing-session-fields { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.billing-session-fields select { flex: 1 1 180px; min-width: 0; min-height: 44px; }
[data-theme="dark"] .billing-warn { background: #3a2f0b; color: #fde68a; border-color: #7c5e10; }
[data-theme="dark"] .billing-kpi em { background: #4c1d1d; color: #fecaca; }
@media (max-width: 720px) {
  .billing-kpis { grid-template-columns: 1fr 1fr; }
  .billing-kpi:first-child { grid-column: 1 / -1; }
  .billing-line { grid-template-columns: minmax(0, 1fr) 56px 84px 36px; }
  .billing-line-label { grid-column: 1 / -1; }
  .billing-line-date { grid-column: 1; }
  .billing-pay { grid-template-columns: 1fr 1fr; }
  .billing-pay button { grid-column: 1 / -1; min-height: 44px; }
  .billing-issuer-grid { grid-template-columns: 1fr; }
  .billing-table th:first-child, .billing-table td:first-child { display: none; }
  .billing-toolbar .btn-primary { min-height: 44px; }
}

/* ============================================================
   0.45.0 — La agenda y el móvil, como en la maqueta
   ============================================================ */

/* Tipografía de la maqueta. Los ficheros no vienen en el paquete: si se
   copian a /assets/fonts/ se usan; si no, se queda la del sistema. Nunca se
   piden a un servidor de fuera. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: local("Inter"), url("/assets/fonts/inter-var.ttf") format("truetype"); }
@font-face { font-family: "Space Grotesk"; font-style: normal; font-weight: 500 700; font-display: swap; src: local("Space Grotesk"), url("/assets/fonts/space-grotesk-var.ttf") format("truetype"); }
:root {
  --font-display: "Space Grotesk", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --appt-office-bg: #DDF0EC; --appt-office-fg: #084F46;
  --appt-home-bg: #FBEBD3;   --appt-home-fg: #6B3A05;
}
[data-theme="dark"] {
  --appt-office-bg: #14342e; --appt-office-fg: #c4ece2;
  --appt-home-bg: #3a2b12;   --appt-home-fg: #f6d49b;
}
body { font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.topbar h1, .agenda-head-title, .billing-kpi strong, .billing-detail-total strong { font-family: var(--font-display); }

/* Cita: hora en su columna, nombre, y debajo el tipo (y la dirección si es a
   domicilio). El fondo dice dónde es; la franja, el color del tipo de cita. */
.appointment-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 8px 14px 8px 10px; margin-bottom: 8px;
  border-radius: 12px; border-left: 4px solid var(--type-color, transparent);
  background: var(--appt-office-bg); color: var(--appt-office-fg);
}
.appointment-item.is-home { background: var(--appt-home-bg); color: var(--appt-home-fg); }
.appointment-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.appointment-item .appt-time { flex: none; width: 46px; font-size: 15px; font-weight: 700; color: inherit; font-variant-numeric: tabular-nums; }
.appointment-item .appt-patient { flex: 1; min-width: 0; }
.appointment-item .appt-patient .name { font-size: 15px; font-weight: 600; color: inherit; overflow-wrap: anywhere; }
.appointment-item .appt-patient .title { font-size: 13px; color: inherit; opacity: 0.85; overflow-wrap: anywhere; }
/* En la semana las columnas son estrechas: hora encima del nombre. */
.agenda-week .appointment-item { flex-direction: column; align-items: flex-start; gap: 0; min-height: 0; padding: 6px 8px; margin-bottom: 6px; border-radius: 8px; }
.agenda-week .appointment-item .appt-time { width: auto; font-size: 12px; }
.agenda-week .appointment-item .appt-patient .name { font-size: 13px; }
.agenda-week .appointment-item .appt-patient .title { font-size: 12px; }

.timeline-free { width: 100%; min-height: 44px; margin-bottom: 8px; padding: 6px 14px; gap: 12px; border-radius: 12px; background: transparent; font: inherit; font-size: 13px; text-align: left; }
.timeline-free .appt-time { width: 46px; font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.timeline-free:hover { background: var(--surface-hover); border-color: var(--primary); color: var(--primary); }
.agenda-week .timeline-free { min-height: 0; padding: 4px 8px; margin-bottom: 4px; border-radius: 8px; gap: 6px; }
.agenda-week .timeline-free .appt-time { width: auto; font-size: 12px; }
.agenda-week .timeline-free-label { display: none; }
.agenda-pdf-btn { display: inline-flex; align-items: center; gap: 6px; }
/* El día ya está en el título de la página. */
.agenda-day-single:not(.agenda-day-offline) > .agenda-day-header { display: none; }

@media (max-width: 800px) {
  /* Cabecera clara: sin franja oscura ni nombre de la app; solo los botones. */
  .sidebar { background: var(--bg); color: var(--text); padding: 10px 16px 4px; position: static; }
  .sidebar-brand-text { display: none; }
  .sidebar-brand-icon { width: 36px; height: 36px; border-radius: 10px; }
  .sidebar-nav { gap: 8px; }
  .sidebar-foot { gap: 8px; }
  .sidebar .sidebar-link, .sidebar .notification-bell-btn, .sidebar .sidebar-search {
    width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; margin: 0;
    border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text);
  }
  .sidebar .sidebar-search { margin-left: auto; }
  .sidebar .sidebar-link:hover, .sidebar .notification-bell-btn:hover, .sidebar .sidebar-search:hover { background: var(--surface-hover); color: var(--text); }
  .sidebar .sidebar-user { border: 0; background: transparent; }
  .sidebar-avatar { width: 40px; height: 40px; }

  .app-main { padding-top: 8px; }
  .topbar { margin-bottom: 12px; }
  .topbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
  .topbar .lang-select { display: none; }   /* el idioma está en el menú del usuario */
  .agenda-view > .topbar { display: none; } /* en la agenda, el título es la fecha */

  /* Barra de la agenda: fecha y resumen; debajo, moverse por los días (y el
     PDF), la vista, y de quién es la agenda. */
  .agenda-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 8px; align-items: center; margin-bottom: 14px; }
  .agenda-head, .agenda-toolbar-right { display: contents; }
  .agenda-head-title { grid-area: 1 / 1 / 2 / -1; font-size: 26px; line-height: 1.15; }
  .agenda-head-summary { grid-area: 2 / 1 / 3 / -1; margin: -6px 0 2px; font-size: 14px; }
  .week-nav { grid-area: 3 / 1; gap: 6px; }
  .week-nav .btn-ghost { min-width: 44px; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--card); font-weight: 600; white-space: nowrap; }
  .agenda-pdf-btn { grid-area: 3 / 2; justify-self: end; width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 12px; background: var(--card); }
  .agenda-pdf-btn .label { display: none; }
  .agenda-toolbar .tabs.compact { grid-area: 4 / 1 / 5 / -1; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
  .agenda-toolbar .tabs.compact .tab { min-height: 44px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; }
  .agenda-toolbar .tabs.compact .tab.active { background: var(--primary); color: #fff; }
  .agenda-toolbar-right select { grid-area: 5 / 1 / 6 / -1; width: 100%; min-height: 44px; border-radius: 12px; }
  .agenda-new-btn { display: none; }        /* para eso está el «+» de abajo */

  /* En el móvil la semana es una sola columna: las citas, en fila como en el día. */
  .agenda-week .appointment-item { flex-direction: row; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px 8px 10px; margin-bottom: 8px; border-radius: 12px; }
  .agenda-week .appointment-item .appt-time { width: 46px; font-size: 15px; }
  .agenda-week .appointment-item .appt-patient .name { font-size: 15px; }
  .agenda-week .appointment-item .appt-patient .title { font-size: 13px; }
  .agenda-week .timeline-free { min-height: 44px; padding: 6px 14px; border-radius: 12px; gap: 12px; }
  .agenda-week .timeline-free .appt-time { width: 46px; font-size: 14px; }
  .agenda-week .timeline-free-label { display: inline; }
  .agenda-week .agenda-day { border-radius: 14px; padding: 12px; }
  .agenda-week .agenda-day-header { font-size: 14px; color: var(--text); }

  /* La lista va directamente sobre el fondo, sin caja alrededor. */
  .agenda-day-single { max-width: none; background: transparent; border: 0; padding: 0; min-height: 0; }
  .agenda-day-offline > .agenda-day-header { border: 0; margin: 14px 0 8px; padding: 0; font-size: 14px; color: var(--text); }
  .warning-banner { border-radius: 10px; }
}

/* 0.45.0 — «Mi día»: tres cifras, como en la maqueta. */
.day-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.day-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 76px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.day-tile:hover { background: var(--surface-hover); }
.day-tile-num { font-family: var(--font-display); font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.day-tile-label { font-size: 12.5px; color: var(--text-muted); }
.day-tile-sub { font-size: 12px; color: var(--primary); font-weight: 600; margin-top: 2px; }
[data-theme="dark"] .day-tile-sub { color: var(--accent); }
button.appointment-item { width: 100%; border-top: 0; border-right: 0; border-bottom: 0; font: inherit; text-align: left; cursor: pointer; }
button.appointment-item .name, button.appointment-item .title { display: block; }
.dashboard-greeting { font-family: var(--font-display); letter-spacing: -0.4px; }
@media (max-width: 800px) {
  .sidebar-brand-link.active { background: none; }
  .dashboard-greeting { font-size: 26px; }
}

/* ---- 0.46.0 · Ajustes con menú lateral (maqueta DesktopData) ---- */
.settings-view { padding: 0; }
.settings-layout { display: flex; min-height: calc(100vh - 64px); align-items: stretch; }
.settings-nav { width: 236px; flex: none; background: var(--card); border-right: 1px solid var(--border); padding: 20px 14px; box-sizing: border-box; }
.settings-nav-title { margin: 4px 10px 10px; font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.settings-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.settings-nav-item { width: 100%; min-height: 44px; font-size: 14px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 8px; font: inherit; cursor: pointer; }
.settings-nav-item:hover { background: var(--surface-hover); }
.settings-nav-item.active { background: var(--surface-info); color: var(--primary-dark); font-weight: 700; }
[data-theme="dark"] .settings-nav-item.active { color: var(--accent); }
.settings-nav-item .chev { display: none; opacity: .5; }
.settings-content { flex: 1; min-width: 0; padding: 24px 28px; box-sizing: border-box; display: flex; flex-direction: column; gap: 16px; }
.settings-content-head h2 { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
.settings-back { display: none; }
.settings-pills { margin: 0; }
@media (max-width: 800px) {
  .settings-layout { display: block; min-height: 0; }
  .settings-nav { width: auto; border-right: 0; background: transparent; padding: 12px 16px; }
  .settings-nav ul { background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; gap: 0; }
  .settings-nav li + li .settings-nav-item { border-top: 1px solid var(--border); }
  .settings-nav-item { border-radius: 0; min-height: 52px; }
  .settings-nav-item.active { background: transparent; color: var(--text); font-weight: 400; }
  .settings-nav-item .chev { display: block; }
  .settings-content { padding: 12px 16px 24px; }
  .settings-view:not(.has-section) .settings-content { display: none; }
  .settings-view.has-section .settings-nav { display: none; }
  .settings-back { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
  [data-theme="dark"] .settings-back { color: var(--accent); }
  .settings-content-head h2 { font-size: 22px; }
}

/* «Mis datos y mi seguridad» */
.ds-page { display: flex; flex-direction: column; gap: 14px; }
.ds-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.ds-head .meta { margin: 0; max-width: 640px; }
.ds-head .btn-ghost { flex: none; }
.ds-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.ds-grid > * { grid-column: span 2; }
.ds-grid > .ds-devices, .ds-grid > .ds-journal { grid-column: span 3; }
.ds-card { margin: 0; padding: 18px; border-radius: 14px; display: flex; flex-direction: column; gap: 10px; }
.ds-card h3 { margin: 0; font-size: 15px; font-weight: 700; }
.ds-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ds-card .meta { margin: 0; }
.ds-where { background: #14201e; color: #e6ecea; border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
[data-theme="dark"] .ds-where { background: #0b1513; border: 1px solid var(--border); }
.ds-eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: #a9b8b4; }
.ds-where-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; line-height: 1.2; }
.ds-where-status { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ds-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd3b6; flex: none; }
.ds-bar { height: 8px; border-radius: 999px; background: #33443f; overflow: hidden; display: block; }
.ds-bar > span { display: block; height: 100%; background: #5fd3b6; }
.ds-where-meta { font-size: 13px; color: #a9b8b4; }
.ds-rows { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; margin: 0; font-size: 14px; }
.ds-rows dt { margin: 0; }
.ds-rows dd { margin: 0; font-weight: 700; color: var(--primary-dark); text-align: right; }
[data-theme="dark"] .ds-rows dd { color: var(--accent); }
.ds-pill { display: inline-block; background: var(--surface-info); color: var(--primary-dark); font-weight: 700; font-size: 12px; border-radius: 999px; padding: 3px 10px; }
.ds-pill.warn { background: #fbebd3; color: #6b3a05; }
[data-theme="dark"] .ds-pill { color: var(--accent); }
[data-theme="dark"] .ds-pill.warn { background: #3a2f0b; color: #fde68a; }
.ds-warn, .ds-note, .ds-ok, .ds-ok-box { margin: 0; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.ds-warn { background: #fbebd3; color: #6b3a05; }
.ds-note { background: var(--surface-hover); color: var(--text-muted); }
.ds-ok, .ds-ok-box { background: var(--surface-info); color: var(--primary-dark); }
[data-theme="dark"] .ds-warn { background: #3a2f0b; color: #fde68a; }
[data-theme="dark"] .ds-ok, [data-theme="dark"] .ds-ok-box { color: var(--accent); }
.ds-ok-box ul, .ds-warn ul { margin: 6px 0 0; padding-left: 18px; }
.ds-external { display: flex; flex-direction: column; gap: 8px; }
.ds-candidates { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ds-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.ds-actions .btn-primary { flex: 1 1 160px; }
.ds-list { list-style: none; margin: 0; padding: 0; }
.ds-list > li { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border); }
.ds-list > li:last-child { border-bottom: 0; }
.ds-list > li.is-off { opacity: .6; }
.ds-list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ds-list-main strong { font-weight: 600; }
.ds-list-main .meta { font-size: 12px; }
.ds-danger { align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: none; color: var(--danger); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.ds-log > li { min-height: 40px; font-size: 14px; }
.ds-log-time { width: 96px; flex: none; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ds-log-text { flex: 1; min-width: 0; }
.ds-foot { margin: auto 0 0; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
@media (max-width: 1599px) {
  .ds-grid > *, .ds-grid > .ds-devices, .ds-grid > .ds-journal { grid-column: span 3; }
  .ds-grid > .ds-where { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 24px; align-items: center; }
  .ds-where > .ds-eyebrow, .ds-where > .ds-where-title { grid-column: 1; }
  .ds-where > .ds-where-status { grid-column: 1; }
  .ds-where > .ds-bar, .ds-where > .ds-where-meta { grid-column: 2; }
  .ds-where > .ds-eyebrow { grid-row: 1; } .ds-where > .ds-where-title { grid-row: 2; } .ds-where > .ds-where-status { grid-row: 3; }
  .ds-where > .ds-bar { grid-row: 1; } .ds-where > .ds-where-meta:nth-of-type(n) { grid-row: auto; }
}
@media (max-width: 800px) {
  .ds-grid { grid-template-columns: minmax(0, 1fr); }
  .ds-grid > *, .ds-grid > .ds-devices, .ds-grid > .ds-journal, .ds-grid > .ds-where { grid-column: auto; }
  .ds-grid > .ds-where { display: flex; }
  .ds-head { flex-direction: column; }
  .ds-log-time { width: 76px; }
}
.installation-country { padding: 18px; border-radius: 14px; display: flex; flex-direction: column; gap: 8px; }
.installation-country h3 { margin: 0; font-size: 15px; }
.installation-country-main { margin: 0; font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.installation-country-rules { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* ---- 0.46.0 · Ficha del paciente (maqueta DesktopPatient) ---- */
.pf-layout { grid-template-columns: 280px minmax(0, 1fr); gap: 0; background: var(--card); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; align-items: stretch; min-height: calc(100vh - 170px); }
.pf-list { min-width: 0; border-right: 1px solid var(--border); padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.pf-list-title { display: none; margin: 0; font-family: var(--font-display); font-size: 20px; }
.pf-search { width: 100%; box-sizing: border-box; height: 44px; }
.pf-scopes { display: flex; gap: 4px; background: var(--surface-hover); border-radius: 10px; padding: 3px; }
.pf-scope { flex: 1; min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.pf-scope.active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.pf-inactive { font-size: 13px; }
.pf-items { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 330px); }
.pf-item { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.pf-item:hover { background: var(--surface-hover); }
.pf-item.active { background: var(--surface-info); }
.pf-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--surface-info-strong); color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
[data-theme="dark"] .pf-avatar { color: #fff; }
.pf-item-text { min-width: 0; display: flex; flex-direction: column; }
.pf-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-item-sub { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-new { min-height: 44px; }
.pf-main { min-width: 0; padding: 22px 24px; }
.pf-empty { margin-top: 80px; }
.pf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.pf-head-main { min-width: 0; flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; }
.pf-name { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pf-sub { margin: 0; color: var(--text-muted); }
.pf-head .ficha-alerts { margin: 4px 0 0; }
.pf-back { display: none; }
.pf-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pf-actions > .btn-ghost, .pf-actions > .btn-primary, .pf-actions > a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }
.pf-notes .ficha-note-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pf-more { position: relative; }
.pf-more-btn { width: 44px; justify-content: center; font-size: 18px; }
.pf-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 220px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,0.14); padding: 6px; display: flex; flex-direction: column; }
.pf-more-menu > button, .pf-more-menu > a { min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font: inherit; text-decoration: none; display: flex; align-items: center; cursor: pointer; }
.pf-more-menu > button:hover, .pf-more-menu > a:hover { background: var(--surface-hover); }
.pf-more-status { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 4px; }
.pf-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 18px 0 16px; overflow-x: auto; scrollbar-width: none; }
.pf-tab { flex: none; min-height: 44px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pf-tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
[data-theme="dark"] .pf-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.pf-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.pf-summary > .agenda-next { margin: 0; }
.pf-card { margin: 0; padding: 16px; border-radius: 14px; display: flex; flex-direction: column; gap: 8px; }
.pf-card h3 { margin: 0; font-size: 15px; font-weight: 700; }
.pf-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pf-wide { grid-column: span 2; }
.pf-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; border-top: 1px solid var(--border); }
.pf-row:first-of-type { border-top: 0; }
.pf-row-main { display: flex; flex-direction: column; min-width: 0; }
.pf-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.pf-kv strong { text-align: right; overflow-wrap: anywhere; }
.pf-kv strong.warn { color: #9a4a06; }
[data-theme="dark"] .pf-kv strong.warn { color: #f2c078; }
.pf-card-cta { margin-top: auto; min-height: 44px; }
.pf-subtitle { margin-top: 10px !important; }
.pf-link { align-self: flex-start; }
.pf-doc { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.pf-doc-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-doc .web-share { margin: 0; font-size: 12px; }
.pf-stats { flex-direction: row; justify-content: space-around; align-items: center; }
.pf-stats > div { display: flex; flex-direction: column; align-items: center; }
.pf-stats strong { font-family: var(--font-display); font-size: 26px; }
.pf-evo { display: flex; flex-direction: column; gap: 8px; }
.pf-evo-pick { align-self: flex-start; max-width: 100%; }
.pf-evo-bars { display: flex; align-items: flex-end; gap: 10px; height: 110px; padding: 0 4px; border-bottom: 1px solid var(--border); }
.pf-evo-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.pf-evo-bar { display: block; width: 100%; border-radius: 6px 6px 0 0; background: var(--accent); opacity: .85; }
.pf-evo-col:last-child .pf-evo-bar { background: var(--primary); opacity: 1; }
.pf-evo-labels { display: flex; gap: 10px; padding: 0 4px; }
.pf-evo-labels > span { flex: 1; min-width: 0; font-size: 11px; color: var(--text-muted); text-align: center; }
.pf-evo-labels strong { color: var(--text); }
.pf-evo-empty { margin: 0; }
.pf-notes { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.pf-billing { display: flex; flex-direction: column; gap: 10px; }
.pf-billing .ds-list > li { gap: 12px; }
@media (max-width: 1280px) {
  .pf-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-wide { grid-column: 1 / -1; }
}
@media (max-width: 800px) {
  .patients-view .patients-topline { margin-bottom: 8px; }
  .pf-layout { display: block; border: 0; background: transparent; min-height: 0; }
  .pf-list { border-right: 0; padding: 0; }
  .pf-items { max-height: none; }
  .pf-item { background: var(--card); border: 1px solid var(--border); }
  .pf-items { gap: 6px; }
  .patients-view:not(.has-patient) .pf-main { display: none; }
  .patients-view.has-patient .pf-list, .patients-view.has-patient .patients-topline { display: none; }
  .pf-main { padding: 0; }
  .pf-back { display: inline-flex; align-self: flex-start; min-height: 44px; align-items: center; padding: 0; border: 0; background: none; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; }
  [data-theme="dark"] .pf-back { color: var(--accent); }
  .pf-name { font-size: 22px; }
  .pf-actions { width: 100%; }
  .pf-actions > .btn-primary { flex: 1; justify-content: center; }
  .pf-summary { grid-template-columns: minmax(0, 1fr); }
  .pf-wide { grid-column: auto; }
}

/* ---- 0.46.0 · Sesión en curso (maqueta MobileVisit) ---- */
.session-progress { height: 6px; border-radius: 999px; background: rgba(255,255,255,0.15); overflow: hidden; }
.session-progress > span { display: block; height: 100%; background: #5fd3b6; }
.session-alerts { display: flex; flex-wrap: wrap; gap: 6px; }
.session-alert { background: #fbebd3; color: #6b3a05; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.session-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.session-tag { font-size: 11px; font-weight: 700; color: var(--primary-dark); background: var(--surface-info); border-radius: 999px; padding: 3px 8px; }
[data-theme="dark"] .session-tag { color: var(--accent); }
.session-first { border-style: dashed; }
.session-first.on { border-style: solid; border-color: var(--primary); background: var(--surface-info); }
.session-first-toggle { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.session-first-toggle input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.session-first-toggle > span { display: flex; flex-direction: column; gap: 2px; }
.session-bilan-btn { min-height: 44px; }
.session-reeval { display: flex; flex-direction: column; gap: 6px; }
.session-reeval .meta { margin: 0; }
.session-mrows { display: flex; flex-direction: column; gap: 8px; }
.session-mrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.session-mrow > label { flex: 1; min-width: 0; font-size: 13px; }
.session-minput { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.session-minput input { width: 72px; height: 44px; font-weight: 700; text-align: right; box-sizing: border-box; }
.session-unit { min-width: 28px; font-size: 12px; color: var(--text-muted); }
.session-mremove { width: 32px; height: 44px; border: 0; background: none; color: var(--text-muted); font-size: 18px; cursor: pointer; }
.session-madd { display: flex; gap: 8px; flex-wrap: wrap; }
.session-madd select { flex: 1 1 160px; min-height: 44px; }
.session-foot { display: flex; gap: 8px; }
.session-foot .session-finish { flex: 1; width: auto; }
.session-next { min-height: 52px; border-radius: 14px; padding: 0 14px; }

/* Ruta: acceso y distintivos */
.route-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.route-badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: var(--surface-info); color: var(--primary-dark); }
.route-badge.warn { background: #fbebd3; color: #6b3a05; }
.route-access { font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.route-access strong { font-variant-numeric: tabular-nums; letter-spacing: .5px; }
.route-order { display: flex; flex-direction: column; gap: 2px; flex: none; }
.route-order button { width: 36px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer; font-size: 14px; }
.route-order button:disabled { opacity: .35; cursor: default; }
.route-card-row { display: flex; gap: 8px; align-items: stretch; flex: 1; min-width: 0; }

/* ---- 0.46.0 · Acceso (mismo lenguaje que las maquetas) ---- */
.login-screen { padding: 0; align-items: stretch; background: var(--bg); }
.login-brand { flex: 0 0 42%; max-width: 560px; background: var(--sidebar-bg); color: var(--sidebar-text); padding: 40px 44px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; box-sizing: border-box; }
.login-brand-logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: .3px; color: #fff; }
.login-brand-logo img { border-radius: 10px; }
.login-brand-body h2 { margin: 0 0 22px; font-family: var(--font-display); font-size: 34px; line-height: 1.15; letter-spacing: -0.6px; color: #fff; max-width: 420px; }
.login-brand-body ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.login-brand-body li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; color: #cfdad7; max-width: 420px; }
.login-brand-dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd3b6; flex: none; margin-top: 7px; }
.login-brand-foot { margin: 0; font-size: 13px; color: #a9b8b4; }
.login-screen > .login-card { margin: auto; border-radius: 16px; padding: 36px 32px; max-width: 400px; box-shadow: 0 10px 40px rgba(20,32,30,0.08); }
.login-screen > .login-card .login-logo { display: none; }
.login-title { margin: 0 0 4px; font-family: var(--font-display); font-size: 28px !important; font-weight: 700; letter-spacing: -0.4px; }
.login-screen > .login-card .subtitle { text-align: left; margin-bottom: 20px; }
.login-screen > .login-card input[type="email"], .login-screen > .login-card input[type="password"], .login-screen > .login-card input[type="text"] { height: 46px; }
.login-screen > .login-card .btn-primary.btn-block { min-height: 48px; border-radius: 12px; font-size: 15px; }
.login-device-note { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }
@media (max-width: 900px) {
  .login-screen { flex-direction: column; justify-content: flex-start; }
  .login-brand { flex: none; max-width: none; padding: 20px 20px 22px; gap: 14px; }
  .login-brand-body h2 { font-size: 22px; margin-bottom: 10px; }
  .login-brand-body ul { gap: 8px; }
  .login-brand-body li { font-size: 13px; }
  .login-brand-body li:nth-child(n+2), .login-brand-foot { display: none; }
  .login-screen > .login-card { margin: 16px; width: auto; max-width: none; padding: 24px 20px; box-shadow: none; }
}

/* 0.46.0 · bandeja sin conexión */
.offline-banner { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.offline-banner.syncing { background: var(--surface-info); color: var(--primary-dark); }
.offline-count { font-weight: 700; }
.offline-btn { min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid currentColor; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
.offline-failed { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.ds-path { font-size: 12px; font-family: ui-monospace, "SF Mono", Menlo, monospace; opacity: .85; overflow-wrap: anywhere; }

/* ---- 0.46.0 · Autorizaciones ---- */
.consents { display: flex; flex-direction: column; gap: 12px; }
.consents-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.consents-head .meta { margin: 0; max-width: 620px; }
.consent-badge { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 8px; margin-left: 6px; background: var(--surface-info); color: var(--primary-dark); }
.consent-badge.revoked, .consent-badge.expired { background: var(--surface-hover); color: var(--text-muted); }
.pf-consent-chip { align-self: flex-start; border: 0; border-radius: 999px; padding: 4px 10px; background: var(--surface-info); color: var(--primary-dark); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; min-height: 28px; }
[data-theme="dark"] .pf-consent-chip, [data-theme="dark"] .consent-badge { color: var(--accent); }
.consent-form { display: flex; flex-direction: column; gap: 10px; }
.consent-cats, .consent-methods { border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.consent-cats legend, .consent-methods legend { font-weight: 700; font-size: 13px; padding: 0 4px; }
.consent-methods { flex-direction: column; }
.consent-method { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 10px; cursor: pointer; }
.consent-method.on { background: var(--surface-info); }
.consent-method > span { display: flex; flex-direction: column; }
.consent-text { white-space: pre-wrap; font-family: inherit; font-size: 14px; line-height: 1.5; background: var(--surface-hover); border-radius: 12px; padding: 14px; margin: 0; max-height: 42vh; overflow: auto; }
.consent-check { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; }
.consent-check input { width: 20px; height: 20px; flex: none; }
.consent-sign { position: fixed; inset: 0; z-index: 300; background: var(--bg); overflow: auto; display: flex; justify-content: center; }
.consent-sign-panel { width: 100%; max-width: 760px; padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 12px; box-sizing: border-box; }
.consent-sign-hand { margin: 0; font-family: var(--font-display); font-size: 22px; font-weight: 700; }
.consent-sign .consent-text { max-height: none; }
.sig-wrap { position: relative; }
.sig-pad { width: 100%; height: 180px; border: 2px dashed var(--border); border-radius: 14px; background: #fff; touch-action: none; display: block; }
.sig-clear { position: absolute; top: 6px; right: 10px; }
.consent-sign-actions { display: flex; gap: 10px; justify-content: space-between; }
.consent-sign-actions .btn-primary { flex: 1; min-height: 52px; font-size: 16px; }
.consent-sign-actions .btn-ghost { min-height: 52px; }

/* Avatar del usuario con Ajustes abierto: visible en la barra oscura y en la cabecera clara del móvil */
.sidebar-link.sidebar-user.active .sidebar-avatar { background: #fff; color: var(--primary-dark); box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }
@media (max-width: 800px) {
  .sidebar .sidebar-link.sidebar-user.active .sidebar-avatar { background: var(--primary); color: #fff; box-shadow: 0 0 0 3px var(--surface-info-strong); }
}

/* ---- 0.46.3 · notas del equipo, bonos, sin conexión ---- */
.agenda-todo-kind.tone-red { background: #fde2e1; color: #8a1c14; }
.team-notes .tn-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.tn-list li { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; display: flex; flex-direction: column; gap: 2px; }
.tn-list li.unread { border-left-color: var(--primary); }
.tn-list li.urgent { border-left-color: #b3261e; }
.tn-meta { font-size: 12px; color: var(--text-muted); }
.tn-text { font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.tn-form { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.tn-form textarea { width: 100%; box-sizing: border-box; resize: vertical; }
.tn-form-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tn-form-row select { flex: 1 1 140px; }
.pf-bono-btn { align-self: flex-start; margin-top: 4px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.35); background: transparent; color: inherit; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.session-notes .session-note { margin: 0; font-size: 14px; }
.session-note.urgent { color: #8a1c14; }
[data-theme="dark"] .session-note.urgent { color: #fecaca; }
.offline-new { margin: 0 0 10px; min-height: 44px; }
.offline-pending { position: relative; opacity: .85; }
.offline-pending-tag { display: inline-block; font-size: 11px; font-weight: 700; background: #fbebd3; color: #6b3a05; border-radius: 999px; padding: 1px 8px; margin: 2px 0 2px 4px; }
.offline-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 250; background: var(--sidebar-bg); color: #fff; border-radius: 12px; padding: 10px 14px; max-width: 90vw; }

/* 0.47.0 — Ajustes › Web por pestañas (cabecera, puesta en marcha, vista previa) */
.web-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.web-head > .meta { flex: 1 1 260px; }
.web-head h2 { margin: 0 0 2px; font-size: 1.25rem; }
.web-head .meta { margin: 0; }
.web-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.web-chiptabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0 10px; margin-bottom: 4px; }
@media (max-width: 640px) { .web-chiptabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; margin-right: -16px; padding-right: 16px; } }
.web-chiptab { flex: none; border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 0.9rem; cursor: pointer; white-space: nowrap; }
.web-chiptab:hover { background: var(--surface-hover); }
.web-chiptab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.web-setup { padding: 0; overflow: hidden; }
.web-setup-head { display: flex; gap: 14px; align-items: center; width: 100%; padding: 14px 16px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.web-setup-title { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.web-setup-title .meta { margin: 0; }
.web-setup-ring { --p: 0; flex: none; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--border) 0); }
.web-setup-ring > span { width: 36px; height: 36px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; }
.web-setup-steps { list-style: none; margin: 0; padding: 0 16px 10px; }
.web-setup-steps li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.web-setup-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: #fff; }
.web-setup-steps li.ok .web-setup-mark { background: var(--accent); border-color: var(--accent); }
.web-setup-steps li.ok strong { color: var(--text-muted); font-weight: 500; }
.web-setup-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.web-setup-text .meta { margin: 0; font-size: 0.82rem; }
.web-domain { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-hover); }
.web-domain > div { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.web-domain a { text-decoration: none; color: var(--accent-dark); }
.web-domain .meta { margin: 4px 0 0; }
.web-toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 14px; }
.web-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.web-list-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.web-list-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.web-list-fields input, .web-list-fields textarea { width: 100%; }
.web-list-tools { display: flex; flex-direction: column; gap: 2px; }
.web-list-tools .icon-btn { width: 28px; height: 26px; border: 1px solid transparent; border-radius: 6px; background: none; color: var(--text-muted); cursor: pointer; font: inherit; line-height: 1; }
.web-list-tools .icon-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.web-list-tools .icon-btn:disabled { opacity: 0.3; cursor: default; }
.web-list > .btn-ghost { align-self: flex-start; }
.web-preview-overlay { align-items: stretch; }
.web-preview-sheet { margin: auto; width: min(1200px, 100%); height: min(94vh, 980px); background: var(--card); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.web-preview-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.web-preview-bar .spacer { flex: 1; }
.web-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 2px; }
.web-seg button { border: 0; background: none; font: inherit; font-size: 0.85rem; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--text-muted); }
.web-seg button.on { background: var(--accent); color: #fff; }
.web-preview-stage { flex: 1; min-height: 0; background: var(--surface-hover); display: flex; justify-content: center; padding: 16px; overflow: auto; }
.web-preview-stage iframe { border: 0; background: #fff; width: 100%; height: 100%; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.web-preview-stage.phone iframe { width: 390px; max-width: 100%; height: min(100%, 800px); border-radius: 28px; border: 10px solid #1d2624; }
.web-preview-note { margin: 0; padding: 8px 14px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .web-preview-sheet { height: 100vh; border-radius: 0; }
  .web-preview-stage { padding: 0; }
  .web-preview-stage.phone iframe { border: 0; border-radius: 0; height: 100%; }
}
.consent-requests { margin: 10px 0; padding: 10px 12px; border: 1px dashed var(--accent); border-radius: 10px; background: var(--surface-info); display: flex; flex-direction: column; gap: 6px; }
.consent-request { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.intake-banner { margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--accent); background: var(--surface-info); }
.intake-banner h4 { margin: 0 0 6px; }
.intake-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 14px; margin: 8px 0; }
.intake-grid label { display: flex; gap: 8px; align-items: flex-start; font-size: 0.9rem; }
.intake-grid label .meta { display: block; margin: 0; }
.intake-clinical { white-space: pre-wrap; font-size: 0.9rem; margin: 6px 0; padding: 8px 10px; background: var(--card); border-radius: 8px; border: 1px solid var(--border); }
.intake-grid label { justify-content: flex-start; text-align: left; font-weight: 400; }
.intake-grid input[type="checkbox"] { width: auto; flex: none; margin: 3px 0 0; }
.intake-grid label > span { flex: 1; min-width: 0; }
/* 0.47.2 — cita en curso / con retraso y citas de hoy sin registrar */
.agenda-next-pill.late { background: #ffd9a8; }
.agenda-pending { border-top: 1px solid rgba(255,255,255,0.18); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.agenda-pending-toggle { align-self: flex-start; background: none; border: 0; color: #fff; opacity: 0.85; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 0; min-height: 36px; }
.agenda-pending-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.agenda-pending-row .agenda-next-btn { flex: none; min-height: 36px; }
.pf-late { color: var(--warning-text, #8a5300); font-weight: 600; }
.agenda-next-btn.quiet { flex: 1 1 100%; min-height: 40px; border-style: dashed; font-weight: 500; opacity: 0.9; }
.agenda-next-btn:disabled { opacity: 0.5; cursor: default; }
.agenda-next-err { font-size: 12px; color: #ffd0c4; }
.agenda-pending-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* 0.48.0 — franjas semanales con lugar */
.sched-week { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sched-day { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--border); }
.sched-day:first-child { border-top: 0; }
.sched-day.off { background: var(--surface-hover); }
.sched-day-name { flex: none; width: 92px; font-weight: 600; padding-top: 8px; }
.sched-day-blocks { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.sched-day-blocks > .meta { margin: 0; padding: 8px 0; }
.sched-block { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 8px; border-radius: 10px; border: 1px solid var(--border); border-left-width: 4px; background: var(--card); flex-wrap: wrap; }
.sched-block input[type="time"] { width: 7.6em; min-width: 0; }
.sched-block select { width: auto; }
.sched-block.mode-clinic { border-left-color: var(--accent); }
.sched-block.mode-home { border-left-color: #c47a1c; }
.sched-block .icon-btn { width: 28px; height: 28px; border: 0; background: none; color: var(--text-muted); cursor: pointer; border-radius: 6px; }
.sched-block .icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.timeline-free.mode-home { background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(196,122,28,0.07) 8px 16px); }
.timeline-mode { margin-left: 8px; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 6px; vertical-align: 1px; }
.timeline-mode.mode-home { background: #fbebd3; color: #6b3a05; }
.timeline-mode.mode-clinic { background: #ddf0ec; color: #084f46; }
@media (max-width: 640px) {
  .sched-day { flex-direction: column; gap: 6px; }
  .sched-day-name { width: auto; padding-top: 0; }
}
/* 0.48.2 — Con ratón (PC) no hay forma cómoda de desplazar en horizontal: las pestañas de la ficha pasan a dos líneas si no caben. En móvil y tableta siguen deslizándose. */
@media (hover: hover) and (pointer: fine) {
  .pf-tabs { flex-wrap: wrap; overflow-x: visible; row-gap: 0; }
  .pf-tab { padding: 0 12px; }
}
/* 0.48.3 — «Verificar ahora» en el aviso de licencia */
.license-required-banner { flex-wrap: wrap; }
.license-required-banner > span:first-child { flex: 1 1 260px; }
.license-required-banner .license-verify-btn { border: 1px solid rgba(255,255,255,.7); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 700; min-height: 34px; }
.license-required-banner .license-verify-btn:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.license-required-banner .license-verify-msg { flex-basis: 100%; order: 10; font-weight: 500; opacity: .95; }

/* 0.48.3 — Semana completa en pantallas de ordenador: la agenda usa todo el ancho
   (antes .view la limitaba a 1100 px y quedaba un margen blanco a la derecha), una
   columna por día trabajado (el viernes ya no baja a otra fila) y el panel lateral
   solo aparece en la vista semana si queda sitio de verdad. */
.view.agenda-view { max-width: none; }
@media (min-width: 801px) {
  .agenda-week { grid-template-columns: repeat(var(--days, 5), minmax(112px, 1fr)); gap: 10px; }
}
@media (min-width: 1280px) and (max-width: 1599px) {
  .agenda-layout.mode-week:not(.no-aside) { grid-template-columns: minmax(0, 1fr); }
  .agenda-layout.mode-week .agenda-aside { display: none; }
}
@media (min-width: 801px) and (max-width: 1100px) {
  .agenda-week { overflow-x: auto; padding-bottom: 6px; }
}

/* 0.49.0 — Arrastrar citas (ratón y táctil) */
.appointment-item.is-draggable { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
@media (hover: hover) and (pointer: fine) { .appointment-item.is-draggable { cursor: grab; } }
.appointment-item.appt-press { transition: transform 0.35s ease 0.05s, box-shadow 0.35s ease 0.05s; transform: scale(0.98); box-shadow: 0 0 0 2px var(--primary, #2563eb) inset; }
.appointment-item.appt-drag-source { opacity: 0.35; transform: none; box-shadow: none; }
body.appt-dragging, body.appt-dragging * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }
.appt-drag-ghost { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; max-width: 260px; padding: 8px 12px; border-radius: 10px;
  background: var(--surface, #fff); color: var(--text, #111); border: 2px solid var(--primary, #2563eb); box-shadow: 0 10px 28px rgba(15, 23, 42, 0.25);
  font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; will-change: transform; }
.appt-drag-ghost.has-target { background: var(--primary, #2563eb); color: #fff; }
.agenda-main.is-drag-active .timeline-free { border-style: dashed; border-color: var(--primary, #2563eb); }
.timeline-free.drop-over, .agenda-main.is-drag-active .timeline-free.drop-over { background: var(--primary, #2563eb); color: #fff; border-style: solid; }
.timeline-free.drop-over .appt-time, .timeline-free.drop-over .timeline-mode { color: #fff; }
.move-confirm-name { margin: 0 0 10px; font-size: 16px; }
.move-confirm-times { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; border-radius: 12px; background: var(--surface-hover, #f1f5f9); margin-bottom: 10px; }
.move-confirm-old { text-decoration: line-through; color: var(--text-muted, #64748b); }
.move-confirm-new { font-weight: 700; color: var(--primary, #2563eb); }
.move-confirm-arrow { font-size: 20px; color: var(--text-muted, #64748b); }
.move-confirm-warn { margin: 6px 0; padding: 8px 12px; border-radius: 10px; background: rgba(234, 160, 40, 0.16); color: inherit; font-size: 14px; }
.move-toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 9000; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 16px; border-radius: 12px; background: #1f2937; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,0.25); font-size: 14px; max-width: calc(100vw - 32px); }
.move-toast .btn-ghost { color: #93c5fd; border-color: transparent; }
.move-toast-close { background: none; border: 0; color: #cbd5e1; font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
@media (max-width: 800px) { .move-toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 560px) { .move-confirm-times { flex-direction: column; align-items: flex-start; gap: 6px; } .move-confirm-arrow { transform: rotate(90deg); } }

/* 0.49.0 — Ficha personalizable */
.pf-customize-row { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.pf-clinical ul { margin: 2px 0 6px; padding-left: 18px; }
.pf-clinical li { margin: 2px 0; line-height: 1.35; }
.pf-clinical-label { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.pf-clinical-group.type-medication .pf-clinical-label { color: var(--primary); }
.pf-layout-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 10px; }
.pf-layout-cols h4 { margin: 0 0 8px; }
.pf-layout-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pf-layout-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface, #fff); }
.pf-layout-row.is-hidden { opacity: 0.55; }
.pf-layout-row.is-hidden .pf-layout-name { text-decoration: line-through; }
.pf-layout-pos { width: 20px; text-align: center; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pf-layout-name { flex: 1; min-width: 0; font-size: 14px; }
.pf-layout-row .btn-ghost.small { min-width: 34px; padding: 4px 8px; }
.pf-layout-show { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.pf-layout-fixed { font-size: 12px; white-space: nowrap; }
@media (max-width: 720px) { .pf-layout-cols { grid-template-columns: minmax(0, 1fr); } }
.pf-layout-cols h4 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pf-layout-showhead { font-size: 12px; font-weight: 500; padding-right: 6px; }
.pf-layout-name { overflow-wrap: anywhere; }
.pf-layout-show input { width: 18px; height: 18px; margin: 0 4px; }
.pf-layout-fixed { width: 26px; text-align: center; }

/* 0.49.0 — Demo */
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; padding: 6px 16px; background: #fde68a; color: #422006; font-size: 13px; text-align: center; }
.demo-banner strong { text-transform: uppercase; letter-spacing: 0.06em; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #422006; color: #fde68a; }
.demo-accounts { margin: 4px 0 14px; padding: 12px; border: 1px dashed var(--primary); border-radius: 12px; background: var(--surface-hover, #f1f5f9); }
.demo-accounts-title { margin: 0 0 2px; font-weight: 700; color: var(--primary); }
.demo-accounts .meta { margin: 0 0 8px; font-size: 13px; }
.demo-accounts-list { display: flex; flex-direction: column; gap: 6px; }
.demo-account { display: grid; grid-template-columns: 1fr; gap: 1px; text-align: left; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface, #fff); color: inherit; font: inherit; cursor: pointer; }
.demo-account:hover, .demo-account.is-picked { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.demo-account .meta { margin: 0; font-size: 12px; }

/* 0.50.0 — Podología */
.badge-warn { background: rgba(234, 160, 40, 0.18); color: #8a4b00; }
.seg-control { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-hover, #eef2f5); border: 1px solid var(--border); }
.seg-control button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font: inherit; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.seg-control button.is-on { background: var(--surface, #fff); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.podo-feet { display: flex; justify-content: center; gap: 18px; }
.podo-foot-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.podo-foot-fig figcaption { font-size: 12px; color: var(--text-muted); }
.podo-foot { width: 150px; height: auto; display: block; touch-action: manipulation; }
.podo-feet.is-small .podo-foot { width: 62px; }
.podo-feet.is-small figcaption { display: none; }
.podo-foot.is-editable { cursor: crosshair; }
.podo-foot-skin { fill: #f6dcc6; stroke: #9a6b4f; stroke-width: 1.6; }
.podo-foot-nail { fill: #fff7ef; stroke: #9a6b4f; stroke-width: 1; }
.podo-foot-arch { fill: none; stroke: #c99a7c; stroke-width: 1.2; stroke-dasharray: 3 3; }
.podo-mark { cursor: pointer; }
.podo-mark circle { stroke: #fff; stroke-width: 1.6; }
.podo-mark.is-selected circle { stroke: #111; stroke-width: 2.4; }
.podo-mark-txt { fill: #fff; font-weight: 700; font-family: system-ui, sans-serif; pointer-events: none; }
.podo-legend { display: flex; flex-direction: column; gap: 4px; }
.podo-legend-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid transparent; border-radius: 10px; background: transparent; font: inherit; font-size: 13px; color: inherit; text-align: left; cursor: pointer; }
.podo-legend-item:disabled { cursor: default; }
.podo-legend-item.is-active { border-color: var(--primary); background: var(--surface-hover, #eef2f5); font-weight: 600; }
.podo-legend-dot { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 3px; border-radius: 10px; color: #fff; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.podo-foot-modal { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.podo-foot-side { display: flex; flex-direction: column; gap: 10px; }
.podo-foot-side .meta { margin: 0; font-size: 13px; }
.podo-foot-main { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.podo-mark-edit { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-hover, #f1f5f9); }
.podo-mark-actions { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 720px) {
  .podo-foot-modal { grid-template-columns: minmax(0, 1fr); }
  .podo-legend { flex-direction: row; flex-wrap: wrap; }
  .podo-legend-item { padding: 4px 6px; font-size: 12px; }
  .podo-foot { width: 128px; }
}
.podo-foot-card .podo-foot-preview { display: flex; justify-content: center; gap: 14px; padding: 6px; border: 0; background: transparent; cursor: pointer; border-radius: 10px; }
.podo-foot-card .podo-foot-preview:hover { background: var(--surface-hover, #f1f5f9); }
.podo-mark-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.podo-mark-list li { display: flex; gap: 8px; align-items: flex-start; }
.podo-rx-row { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.podo-rx-row + .podo-rx-row { border-top: 1px solid rgba(255,255,255,0.12); }
.podo-rx-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.podo-rx .badge { font-size: 11px; }
.podo-steps { list-style: none; margin: 4px 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.podo-steps li { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); padding-right: 6px; }
.podo-steps li.is-current { color: var(--primary); font-weight: 700; }
.podo-steps li.is-done { color: var(--text); }
.podo-step-dot { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; font-size: 10px; }
.podo-steps li.is-done .podo-step-dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.podo-orth-item { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: transparent; font: inherit; color: inherit; cursor: pointer; }
.podo-orth-item:hover { border-color: var(--primary); }
.podo-orth-item .meta { font-size: 12px; }
.podo-rx-presets { display: flex; flex-direction: column; gap: 6px; }
.podo-report-text { font-family: inherit; line-height: 1.45; }
.podo-session-foot { padding: 10px 14px; }
.podo-foot-card .podo-foot-preview { flex-wrap: wrap; gap: 6px 10px; }
.podo-foot-card .podo-feet.is-small { gap: 4px; }
.podo-foot-card .podo-feet.is-small .podo-foot { width: 46px; }
