/* =========================================================
   style-formularios.css
   Estilos por modal — sin unificación entre modales
   ========================================================= */

/* ─── Utilidades globales ─── */

label {
  font-weight: bold;
  margin-top: 1rem;
  display: block;
}

input {
  margin: 0.5rem 0;
  padding: 0.5rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  text-align: center;
  background: var(--bg-soft);
  color: var(--text);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.row input[type="number"],
.row input[type="text"],
.row input[type="date"],
.row input[type="tel"],
.row input[type="email"],
.row input[type="password"],
.row textarea {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--text);
}

.hint {
  font-size: 12.5px;
  color: color-mix(in oklab, var(--text) 65%, transparent);
}

fieldset {
  border: none;
}

/* Contenido scrollable compartido */
.contenido-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: none;
}

/* ─── Badges ─── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--text) 20%, transparent);
}

.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.badge.ok      { color: #0f9d58; background: color-mix(in oklab, #0f9d58 16%, transparent); border-color: color-mix(in oklab, #0f9d58 50%, transparent); }
.badge.warn    { color: #b7791f; background: color-mix(in oklab, #b7791f 18%, transparent); border-color: color-mix(in oklab, #b7791f 50%, transparent); }
.badge.danger  { color: #c0392b; background: color-mix(in oklab, #c0392b 20%, transparent); border-color: color-mix(in oklab, #c0392b 55%, transparent); }
.badge.critical{ color: #a11427; background: color-mix(in oklab, #a11427 22%, transparent); border-color: color-mix(in oklab, #a11427 55%, transparent); }
.badge.off     { color: var(--muted); background: rgba(255,120,0,0.12); border-color: var(--border); }

/* Contador de notas (fondo acento) */
#notaCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-contrast, #fff);
  background: var(--accent, #6c5ce7);
  border: none;
}

/* ─── Spinner ─── */

.spin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--text);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Ghost placeholder ─── */
.ghost-solid { color: #9aa4b2; }

/* ─── No-select helper ─── */
.no-select,
.no-select * {
  user-select: none;
  -webkit-user-select: none;
}

/* ─── data-raise: z-index al hacer click ─── */
[data-raise] {
  transition: box-shadow 0.15s ease;
}
[data-raise].is-front {
  box-shadow: 0 12px 30px rgba(0,0,0,.28), 0 0 0 1px var(--border);
}

/* ─── Animación de entrada (usada por todos los modales) ─── */
@keyframes fadeInScale {
  from { opacity: 0; transform: translate(-50%, -45%) scale(0.95); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}


/* =========================================================
   MODAL PACIENTE
   ========================================================= */

#modalPaciente {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(95vw, 900px);
  height: 88vh;
  max-height: 95dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 110;
  animation: fadeInScale 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

#barraArrastre {
  position: sticky;
  top: 0;
  padding: 12px 20px;
  background-color: var(--card);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
#barraArrastre:active { cursor: grabbing; }

/* Label + input de fecha dentro de la barra */
#barraArrastre .fecha-campo {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#barraArrastre .fecha-campo label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  cursor: default;
}
#barraArrastre .fecha-campo input {
  margin: 0;
  padding: 4px 8px;
  font-size: 13px;
  text-align: left;
}

#barraArrastre button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}
#barraArrastre button:hover {
  background: color-mix(in oklab, var(--text) 8%, transparent);
}

/* Wrapper label + input dentro de .row */
.field-group {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 3px;
  min-width: 0;
}
.field-group > label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
  cursor: default;
  white-space: nowrap;
}
.field-group > input,
.field-group > textarea {
  width: 100%;
  margin: 0;
}

/* Tabs */
.tabs {
  display: flex;
}

.tab-link {
  flex: 1;
  padding: 0.5rem;
  background: var(--card-2);
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: bold;
  text-align: center;
  color: var(--text);
}
.tab-link.active {
  background: var(--accent);
  color: #fff;
}

.tab-content {
  display: none;
  margin: 1rem 10px 0;
}
.tab-content.active {
  display: block;
}

/* Género */
.genero-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.genero-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: normal;
}

/* Textareas del formulario */
textarea#historial,
textarea#historial_nutricional {
  width: 100%;
  min-height: 600px;
  height: auto;
  resize: vertical;
  border: 1px solid var(--border);
  padding: 0.5rem;
  border-radius: 6px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  background: var(--bg-soft);
  color: var(--text);
}

/* Botonera sticky */
.container-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: sticky;
  bottom: 0;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 1rem;
  justify-content: end;
  z-index: 999;
}
.container-buttons button {
  min-width: 100px;
  padding: 0.6rem;
  border: none;
  border-radius: 6px;
  background-color: var(--muted);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s ease;
}
.container-buttons button:hover {
  background-color: var(--accent);
}

/* ── Chips fields ────────────────────────────────────────────────── */
.chips-field {
  position: relative;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--input-bg, var(--surface));
  min-height: 36px;
  cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
.chips-field:focus-within {
  border-color: var(--primary, #6366f1);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary,#6366f1) 12%, transparent);
}

.chips-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 3px;
}

/* Chips tag */
.chip--tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
    background: color-mix(in oklab, #f59e0b 10%, transparent);
}
.chip-cond {
  background: color-mix(in oklab, #f59e0b 10%, transparent);
  color:      color-mix(in oklab, #f59e0b 80%, var(--text));
  border: 1px solid color-mix(in oklab, #f59e0b 25%, transparent);
}
.chip-med {
  background: color-mix(in oklab, #3b82f6 10%, transparent);
  color: var(--info, #3b82f6);
  border: 1px solid color-mix(in oklab, #3b82f6 22%, transparent);
}

.chip-remove {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.55; padding: 0 1px;
  line-height: 1; font-size: 1rem;
}
.chip-remove:hover { opacity: 1; }

/* Chip toggle (flags situacionales) */
.chip--toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--surface);
  color: var(--text-muted, #888);
  transition: background .15s, color .15s, border-color .15s;
  user-select: none;
}
.chip--toggle input { display: none; }
.chip--toggle:has(input:checked) {
  background: color-mix(in oklab, var(--primary,#6366f1) 10%, transparent);
  color: var(--primary, #6366f1);
  border-color: color-mix(in oklab, var(--primary,#6366f1) 28%, transparent);
}

/* Búsqueda */
.chips-search {
  border: none; outline: none; background: transparent;
  font-size: 0.80rem; width: 160px; color: var(--text);
  padding: 1px 0;
}

/* Dropdown */
.chips-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface-raised, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.10);
  z-index: 300;
  max-height: 210px;
  overflow-y: auto;
}

.chips-group-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted, #888);
  padding: 8px 12px 3px;
}

.chips-option {
  display: flex; align-items: center; gap: 7px;
  width: 100%; text-align: left;
  padding: 7px 12px;
  background: none; border: none; cursor: pointer;
  font-size: 0.80rem; color: var(--text);
}
.chips-option:hover { background: var(--hover-bg, #f1f5f9); }

.chips-opt-meta {
  font-size: 0.66rem; padding: 1px 6px; border-radius: 100px;
  background: var(--border, #e2e8f0); color: var(--text-muted, #888);
  white-space: nowrap;
}


/* =========================================================
   MODAL VITALES
   ========================================================= */

#modalVitales {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 700px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  z-index: 1000;
  animation: fadeInScale 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

#barraArrastreVitales {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,0));
  border-bottom: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(10px);
  cursor: grab;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.light-theme #barraArrastreVitales {
  background: linear-gradient(180deg, rgba(0,0,0,.04), rgba(0,0,0,0));
  border-bottom: 1px solid rgba(0,0,0,.10);
}
#barraArrastreVitales:active { cursor: grabbing; }

#barraArrastreVitales h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
}
#barraArrastreVitales .mh { display: flex; flex-direction: column; gap: 2px; }
#barraArrastreVitales .sub { color: var(--muted); font-size: 12px; }

#barraArrastreVitales .button-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
}
.light-theme #barraArrastreVitales .button-close {
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(0,0,0,.04);
}
#barraArrastreVitales .button-close:hover { background: rgba(255,255,255,.12); }
.light-theme #barraArrastreVitales .button-close:hover { background: rgba(0,0,0,.06); }

/* Lista de vitales */
#modalVitales .vlist { display: flex; flex-direction: column; gap: 12px; }

#modalVitales .vgroup {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.04);
  border-radius: 16px;
  overflow: hidden;
}
.light-theme #modalVitales .vgroup {
  border: 1px solid rgba(0,0,0,.12);
  background: rgba(0,0,0,.02);
}

#modalVitales .vgroup-title {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.light-theme #modalVitales .vgroup-title { border-bottom: 1px solid rgba(0,0,0,.10); }

#modalVitales .vrow {
  display: flex;
  gap: 12px;
  padding: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.light-theme #modalVitales .vrow { border-bottom: 1px solid rgba(0,0,0,.08); }
#modalVitales .vrow:last-child { border-bottom: none; }

#modalVitales .vleft { flex: 0 0 48%; min-width: 160px; }
#modalVitales .vlabel { font-weight: 800; font-size: 13px; color: var(--text); }
#modalVitales .vmeta  { font-size: 12px; color: var(--muted); margin-top: 2px; }
#modalVitales .vright { flex: 1; display: flex; flex-direction: column; gap: 6px; }

#modalVitales input,
#modalVitales select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}
.light-theme #modalVitales input,
.light-theme #modalVitales select {
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.03);
}
#modalVitales input:focus,
#modalVitales select:focus {
  border-color: rgba(99,102,241,.55);
  box-shadow: 0 0 0 4px rgba(99,102,241,.18);
}

#modalVitales .inline { display: flex; gap: 8px; align-items: center; }
#modalVitales .inline select { width: 44%; min-width: 140px; }
#modalVitales .inline input  { width: 56%; }

#modalVitales .vright--split .split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
#modalVitales .mini { display: flex; flex-direction: column; gap: 6px; }

#modalVitales .tag {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  padding: 3px 8px;
  border-radius: 999px;
  width: fit-content;
}
.light-theme #modalVitales .tag {
  border: 1px solid rgba(0,0,0,.14);
  background: rgba(0,0,0,.04);
}

#modalVitales .hint { font-size: 12px; color: var(--muted); min-height: 14px; }

#modalVitales .vactions {
  position: sticky;
  bottom: 0;
  padding: 12px 0 0;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.22));
  border-top: 1px solid rgba(255,255,255,.10);
}
.light-theme #modalVitales .vactions {
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,.92));
  border-top: 1px solid rgba(0,0,0,.10);
}

#modalVitales .vbtn {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(99,102,241,.95);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background .15s ease, transform .08s ease, box-shadow .15s ease, opacity .15s ease;
}
#modalVitales .vbtn:hover:not(:disabled) {
  background: rgba(99,102,241,1);
  box-shadow: 0 6px 16px rgba(99,102,241,.35);
}
#modalVitales .vbtn:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
#modalVitales .vbtn:disabled {
  opacity: .7;
  cursor: not-allowed;
  box-shadow: none;
}
#modalVitales .vbtn.is-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: vbtn-spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes vbtn-spin { to { transform: rotate(360deg); } }

/* Referencias NOM */
#modalVitales .ref-nom {
  margin-top: 12px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.light-theme #modalVitales .ref-nom { border-color: rgba(0,0,0,.10); }
#modalVitales .ref-nom summary { cursor: pointer; color: var(--muted); }

@media (max-width: 640px) {
  #modalVitales .vrow { flex-direction: column; align-items: stretch; }
  #modalVitales .vleft { flex: none; min-width: 0; }
  #modalVitales .inline { flex-direction: column; align-items: stretch; }
  #modalVitales .inline select,
  #modalVitales .inline input { width: 100%; }
  #modalVitales .vright--split .split { grid-template-columns: 1fr; }
}


/* =========================================================
   MODAL BIOQUÍMICOS
   ========================================================= */

#modalBioquimicos {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(320px, 56vw, 700px);
  height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  animation: fadeInScale 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

#barraArrastreBio {
  position: sticky;
  top: 0;
  padding: 12px 20px;
  background-color: var(--card);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
#barraArrastreBio:active { cursor: grabbing; }

#barraArrastreBio button {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}
#barraArrastreBio button:hover {
  background: color-mix(in oklab, var(--text) 8%, transparent);
}

/* Banner de alertas */
#modalBioquimicos .banner {
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--text) 22%, transparent);
  background: color-mix(in oklab, var(--text) 8%, transparent);
  color: var(--text);
  display: none;
}
#modalBioquimicos .banner.warn    { background: color-mix(in oklab, #b7791f 16%, transparent); color: #fff; border-color: color-mix(in oklab, #b7791f 55%, transparent); }
#modalBioquimicos .banner.danger  { background: color-mix(in oklab, #c0392b 18%, transparent); color: #fff; border-color: color-mix(in oklab, #c0392b 55%, transparent); }
#modalBioquimicos .banner.critical{ background: color-mix(in oklab, #a11427 20%, transparent); color: #fff; border-color: color-mix(in oklab, #a11427 55%, transparent); }

/* Campo fecha */
#form-bioquimicos > input[type="datetime-local"] {
  width: 100%;
  height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}
#form-bioquimicos > input[type="datetime-local"]:focus {
  border-color: color-mix(in oklab, var(--text) 35%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--text) 18%, transparent);
}

/* Fieldsets: 3 columnas — label | input | hint */
#form-bioquimicos fieldset {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg-soft) 92%, transparent);
  display: grid;
  grid-template-columns: 200px minmax(180px, 1fr) minmax(200px, 320px);
  align-items: center;
  column-gap: 12px;
  row-gap: 10px;
}

#form-bioquimicos legend {
  font-weight: 600;
  font-size: 13.5px;
  padding: 0 6px;
  color: var(--text);
}

#form-bioquimicos fieldset label {
  grid-column: 1;
  justify-self: end;
  padding-right: 6px;
  font-size: 13px;
  opacity: .95;
}

#form-bioquimicos fieldset input {
  grid-column: 2;
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in oklab, var(--text) 18%, transparent);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
}
#form-bioquimicos fieldset input:focus {
  border-color: color-mix(in oklab, var(--text) 35%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--text) 18%, transparent);
}

#form-bioquimicos fieldset .hint {
  grid-column: 3;
  margin: 0;
  align-self: center;
  white-space: normal;
}
#form-bioquimicos .hint .badge           { display: inline-flex; vertical-align: middle; }
#form-bioquimicos .hint .badge + .badge  { margin-left: 6px; }

#form-bioquimicos > input[type="datetime-local"].full { grid-column: 1 / -1; }

/* Botón guardar */
#form-bioquimicos button[type="submit"] {
  justify-self: end;
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid color-mix(in oklab, var(--accent, #0b6bcb) 55%, #000);
  background: var(--accent, #0b6bcb);
  color: #fff;
  cursor: pointer;
}
#form-bioquimicos button[type="submit"]:hover { filter: brightness(.96); }

@media (max-width: 720px) {
  #form-bioquimicos fieldset {
    grid-template-columns: 1fr;
  }
  #form-bioquimicos fieldset label,
  #form-bioquimicos fieldset input,
  #form-bioquimicos fieldset .hint {
    grid-column: 1;
    justify-self: start;
  }
  #form-bioquimicos fieldset .hint { margin-top: 2px; }
}


/* =========================================================
   MODAL NOTA
   ========================================================= */

#modalNota {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 680px);
  height: 85vh;
  max-height: 95dvh;
  resize: both;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 100;
  animation: fadeInScale 0.4s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Cuando la lista está expandida se necesita más ancho */
#modalNota:has(.modal-body:not(.is-list-collapsed)) {
  width: min(96vw, 1000px);
}

#barraArrastreNota {
  position: sticky;
  top: 0;
  padding: 12px 16px;
  background-color: var(--card);
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
#barraArrastreNota:active { cursor: grabbing; }

#barraArrastreNota .titulo-modal {
  font-weight: 600;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

#barraArrastreNota .controles {
  display: flex;
  gap: 6px;
  align-items: center;
}

#barraArrastreNota .button-close,
#barraArrastreNota .button-icon {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  transition: background-color 0.2s ease, transform 0.05s ease;
}
#barraArrastreNota .button-close:hover,
#barraArrastreNota .button-icon:hover {
  background-color: color-mix(in oklab, var(--text) 8%, transparent);
}
#barraArrastreNota .button-icon:active { transform: translateY(1px); }

.nota-pos {
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--muted);
}

/* Layout del cuerpo */
.modal-body {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr 320px;
  min-height: 0;
}

/* Panel editor */
.panel-editor {
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 8px;
  min-width: 0;
}

.label-inline {
  font-size: 0.85rem;
  color: var(--muted);
}

#fecha-nota {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
}

.editor-form {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}

#nota_texto {
  width: 100%;
  min-height: 260px;
  height: 100%;
  resize: none;
  padding: 12px 14px;
  line-height: 1.45;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.03);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  scrollbar-width: none;
}

/* Botonera notas (sobreescribe .container-buttons para este contexto) */
#modalNota .container-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px dashed var(--border);
  position: static;
  background: transparent;
}

.btn-group-left,
.btn-group-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-nota {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color .15s ease, transform .05s ease;
}
.btn-nota:hover    { background: var(--card); }
.btn-nota:active   { transform: translateY(1px); }
.btn-nota:disabled { opacity: .6; cursor: not-allowed; }
.btn-nota.primary  { border-color: var(--accent, #6c5ce7); background: var(--accent, #6c5ce7); color: #fff; }

.char-count {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Panel lista */
.panel-list {
  display: flex;
  flex-direction: column;
  min-width: 260px;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  height: 100%;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.list-header h4 { margin: 0; font-size: 0.98rem; font-weight: 600; }

.nota-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.nota-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 6px 4px;
  background: var(--card);
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
}
.nota-item:hover  { background: rgba(0,0,0,0.03); }
.nota-item:active { transform: translateY(1px); }

.nota-item.active {
  border-color: var(--accent, #6c5ce7);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent, #6c5ce7) 25%, transparent);
}

.nota-item.empty {
  text-align: center;
  color: var(--muted);
  background: transparent;
  border-style: dashed;
  pointer-events: none;
}

.nota-fecha   { font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }
.nota-snippet {
  font-size: 0.92rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.list-footer { padding: 8px 12px; border-top: 1px solid var(--border); }
.list-footer small { color: var(--muted); font-size: 0.8rem; }

/* Toggle: panel-list colapsado */
.modal-body.is-list-collapsed { grid-template-columns: 1fr; }
.modal-body.is-list-collapsed .panel-list { display: none; }

/* Botón activo cuando la lista está visible */
#btnToggleNotaLista.is-active {
  background-color: color-mix(in oklab, var(--accent, #6c5ce7) 18%, transparent);
  color: var(--accent, #6c5ce7);
}

.nota-list::-webkit-scrollbar,
.editor-form::-webkit-scrollbar { width: 10px; }
.nota-list::-webkit-scrollbar-thumb,
.editor-form::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: content-box;
}

@media (max-width: 900px) {
  .modal-body { grid-template-columns: 1fr 280px; }
}
@media (max-width: 740px) {
  .modal-body { grid-template-columns: 1fr; }
  .panel-list {
    border-left: none;
    border-top: 1px solid var(--border);
    min-width: 0;
    max-height: 240px;
  }
}

/* Ajustes compactos para móvil — modal nota e historial clínico */
@media (max-width: 600px) {
  #modalPaciente,
  #modalNota {
    border-radius: 12px;
  }
  #barraArrastre,
  #barraArrastreNota {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  #barraArrastre h3,
  #barraArrastreNota .titulo-modal {
    font-size: 0.98rem;
  }
  #modalPaciente .contenido-scroll,
  #modalNota .panel-editor {
    padding: 10px;
  }
  #modalNota .container-buttons {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px;
  }
  .btn-group-left,
  .btn-group-right {
    flex-wrap: wrap;
    gap: 6px;
  }
  .btn-nota {
    padding: 7px 10px;
    font-size: 13px;
  }
  #nota_texto {
    min-height: 200px;
    font-size: 14px;
  }
}


/* =========================================================
   MODAL APP ACCESOS · Split Panel
   ========================================================= */

#modalApp {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: 860px;
  max-height: 90vh;
  z-index: 100;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: fadeInScale 0.35s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

.ybt-modal {
  display: grid;
  grid-template-columns: 270px 1fr;
  height: 100%;
  max-height: 90vh;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

/* ── Panel izquierdo ── */
.ybt-left {
  background: #062b20;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  user-select: none;
}
.ybt-left:active { cursor: grabbing; }

.ybt-left-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 25% 18%, rgba(29,158,117,.20) 0%, transparent 55%),
    radial-gradient(circle at 80% 85%, rgba(29,158,117,.12) 0%, transparent 50%);
  pointer-events: none;
}

.ybt-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}
.ybt-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: #1D9E75;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ybt-brand-name {
  font-size: 12px;
  font-weight: 600;
  color: #9FE1CB;
  letter-spacing: .02em;
}

/* Mini phone */
.ybt-phone-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}
.ybt-phone {
  width: 110px;
  border-radius: 20px;
  border: 1.5px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.ybt-ph-avatar-row { display: flex; gap: 6px; align-items: center; }
.ybt-ph-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(29,158,117,.3); flex-shrink: 0;
}
.ybt-ph-lines { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ybt-ph-bar {
  height: 4px; border-radius: 2px;
  background: rgba(255,255,255,.08);
}
.ybt-ph-bar.accent { background: #1D9E75; width: 70%; }
.ybt-ph-card {
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  padding: 7px;
  display: flex; flex-direction: column; gap: 4px;
}
.ybt-ph-row {
  height: 5px; border-radius: 2px;
  background: rgba(255,255,255,.08);
}
.ybt-ph-row.hi   { background: rgba(29,158,117,.5); width: 60%; }
.ybt-ph-row.short{ width: 45%; }
.ybt-ph-dots {
  display: flex; gap: 4px; justify-content: center; margin-top: 2px;
}
.ybt-ph-nav {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,.15);
}
.ybt-ph-nav.on { background: #1D9E75; }

/* Features */
.ybt-features {
  display: flex; flex-direction: column; gap: 12px;
  position: relative; z-index: 1;
}
.ybt-feat { display: flex; align-items: flex-start; gap: 9px; }
.ybt-feat-icon {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(29,158,117,.15);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.ybt-feat-text p { margin: 0; }
.ybt-feat-text .ft {
  font-size: 12px; font-weight: 600; color: #E1F5EE;
}
.ybt-feat-text .fd {
  font-size: 11px; color: rgba(255,255,255,.38);
  line-height: 1.4; margin-top: 2px;
}

.ybt-pill-wrap {
  margin-top: auto;
  padding-top: 20px;
  position: relative; z-index: 1;
}
.ybt-pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.06);
  border: 0.5px solid rgba(255,255,255,.12);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 11px; color: rgba(255,255,255,.45);
}
.ybt-pill-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #1D9E75; flex-shrink: 0;
}

/* ── Panel derecho ── */
.ybt-right {
  background: var(--card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ybt-right-head {
  padding: 20px 24px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
}
.ybt-right-title {
  margin: 0;
  font-size: 15px; font-weight: 600;
  color: var(--text);
}
.ybt-right-sub {
  margin: 2px 0 0;
  font-size: 12px; color: var(--text-muted, #888);
}
.ybt-head-controls { display: flex; gap: 6px; }
.ybt-ctrl-btn {
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s;
}
.ybt-ctrl-btn:hover { background: color-mix(in oklab, var(--text) 8%, transparent); }

/* Tabs */
.ybt-tabs {
  display: flex;
  gap: 0;
  margin: 14px 24px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ybt-tab {
  padding: 8px 14px;
  font-size: 12px; font-weight: 600;
  color: var(--text-muted, #888);
  cursor: pointer;
  border: none; background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex; align-items: center; gap: 6px;
  transition: color .15s;
}
.ybt-tab.on { color: #1D9E75; border-bottom-color: #1D9E75; }
.ybt-tab:hover:not(.on) { color: var(--text); }

.ybt-badge {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0 7px;
  font-size: 10px; font-weight: 600;
  color: var(--text-muted, #888);
  min-width: 18px; text-align: center;
}

/* Alerta */
.app-alert {
  border: 1px solid var(--border);
  background: rgba(0,180,90,.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  line-height: 1.4;
  font-size: 13px;
}
.app-alert.info  { background: rgba(0,120,255,.08); }
.app-alert.error { background: rgba(220,38,38,.08); border-color: rgba(220,38,38,.2); }

/* Body tabs */
.ybt-body {
  padding: 18px 24px 20px;
  overflow-y: auto;
  flex: 1;
}

/* Form */
.ybt-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 540px) {
  .ybt-modal { grid-template-columns: 1fr; }
  .ybt-left  { display: none; }
  .ybt-form-grid { grid-template-columns: 1fr; }
}
.ybt-field { display: flex; flex-direction: column; gap: 5px; }
.ybt-label { font-size: 11px; font-weight: 600; color: var(--text-muted, #888); letter-spacing: .02em; }
.ybt-input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 0 12px;
  font-size: 13px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color .15s;
}
.ybt-input:focus { outline: none; border-color: #1D9E75; }

.ybt-btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 0 16px;
  height: 36px;
  border: none; border-radius: 9px;
  background: #0F6E56; color: #E1F5EE;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: opacity .15s;
}
.ybt-btn-primary:hover   { opacity: .9; }
.ybt-btn-primary:disabled{ opacity: .6; cursor: not-allowed; }

.ybt-hint {
  margin: 9px 0 0;
  font-size: 11px; color: var(--text-muted, #999);
  display: flex; align-items: center; gap: 5px;
}

.ybt-sep {
  border: none; border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* Lista */
.ybt-list-head {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ybt-list-title {
  margin: 0; font-size: 12px; font-weight: 600;
  color: var(--text);
}

/* Toggle ver revocados */
.ybt-toggle-wrap {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-muted, #888);
  cursor: pointer;
}
.ybt-tog-track {
  width: 28px; height: 16px; border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  display: flex; align-items: center;
  padding: 2px; transition: background .2s;
  flex-shrink: 0;
}
.ybt-tog-track.on { background: #1D9E75; border-color: #0F6E56; }
.ybt-tog-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-muted, #bbb);
  transition: transform .2s, background .2s;
}
.ybt-tog-track.on .ybt-tog-thumb {
  transform: translateX(12px);
  background: #fff;
}

/* Tabla */
.ybt-table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.ybt-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.ybt-table thead th {
  background: var(--bg-soft);
  color: var(--text-muted, #888);
  font-size: 11px; font-weight: 600;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  letter-spacing: .02em;
}
.ybt-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.ybt-table tbody tr:last-child td { border-bottom: none; }
.ybt-table tbody tr.revocado { opacity: .5; }

/* Avatar initials */
.ybt-av {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.ybt-av-teal { background: #E1F5EE; color: #085041; }
.ybt-av-blue { background: #E6F1FB; color: #0C447C; }
.ybt-av-purple { background: #EEEDFE; color: #3C3489; }
.ybt-av-gray { background: var(--bg-soft); color: var(--text-muted, #888); }

.ybt-patient-cell { display: flex; align-items: center; gap: 8px; }
.ybt-patient-name { font-size: 13px; color: var(--text); }
.ybt-patient-email { font-size: 11px; color: var(--text-muted, #888); }

/* Status dot */
.ybt-status-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 99px;
}
.ybt-status-dot.on  { background: #E1F5EE; color: #085041; }
.ybt-status-dot.off { background: var(--bg-soft); color: var(--text-muted, #888); }
.ybt-status-dot::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
}
.ybt-status-dot.on::before  { background: #1D9E75; }
.ybt-status-dot.off::before { background: var(--text-muted, #bbb); }

/* Botones de fila */
.ybt-row-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.ybt-rbtn {
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 7px;
  padding: 4px 9px;
  font-size: 11px; font-weight: 500;
  color: var(--text); cursor: pointer;
  transition: background .12s;
}
.ybt-rbtn:hover:not(:disabled) { background: color-mix(in oklab, var(--text) 6%, transparent); }
.ybt-rbtn:disabled { opacity: .4; cursor: not-allowed; }
.ybt-rbtn.danger {
  border-color: #F0997B; background: #FAECE7; color: #993C1D;
}
.ybt-rbtn.danger:hover { background: #F5C4B3; }
.ybt-rbtn.safe {
  border-color: #9FE1CB; background: #E1F5EE; color: #085041;
}
.ybt-rbtn.safe:hover { background: #9FE1CB; }   
