/* ==========================================================
   Jornadas de Salud — sistema visual
   Sobrio, legible en celular, jerarquía clara.
   ========================================================== */
:root {
  --tinta: #14212b;
  --tinta-2: #3d4b57;
  --tinta-3: #6b7884;
  --linea: #e3e8ec;
  --linea-2: #eef2f5;
  --fondo: #f5f7f8;
  --papel: #ffffff;
  --primario: #1d4e63;
  --primario-2: #2c6a84;
  --primario-suave: #e6f0f4;
  --acento: #0f7b6c;
  --acento-suave: #e3f3f0;
  --eco: #2f6f8f;
  --eco-suave: #e5f0f5;
  --vph: #8a4f7d;
  --vph-suave: #f4eaf2;
  --ok: #157a4a;
  --ok-suave: #e5f4ec;
  --alerta: #a86400;
  --alerta-suave: #fdf3e2;
  --error: #b42318;
  --error-suave: #fdeceb;
  --info: #2b5c9e;
  --info-suave: #e9f0fa;
  --radio: 12px;
  --radio-s: 8px;
  --sombra: 0 1px 2px rgba(20, 33, 43, .06), 0 2px 8px rgba(20, 33, 43, .05);
  --sombra-alta: 0 8px 30px rgba(20, 33, 43, .14);
  --fuente: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--fuente); color: var(--tinta); background: var(--fondo);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .6em; }
a { color: var(--primario-2); }
small, .peq { font-size: .85rem; }
.muted { color: var(--tinta-3); }
.oculto { display: none !important; }
.fila { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.fila.entre { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: .6rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.mt { margin-top: 1rem; } .mt2 { margin-top: 1.6rem; } .mb { margin-bottom: 1rem; }
.num { font-variant-numeric: tabular-nums; }

/* Tarjetas */
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1.1rem 1.2rem; }
.tarjeta.plana { box-shadow: none; }
.tarjeta h2 + *, .tarjeta h3 + * { margin-top: .6rem; }
.titulo-seccion { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.titulo-seccion p { margin: .2rem 0 0; color: var(--tinta-3); }

/* Botones */
.btn {
  appearance: none; border: 1px solid var(--linea); background: var(--papel); color: var(--tinta);
  border-radius: var(--radio-s); padding: .6rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px;
  transition: background .15s, border-color .15s, transform .05s; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--linea-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primario { background: var(--primario); border-color: var(--primario); color: #fff; }
.btn.primario:hover { background: var(--primario-2); }
.btn.acento { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.peligro { color: var(--error); border-color: #f0c6c2; }
.btn.peligro:hover { background: var(--error-suave); }
.btn.fantasma { background: transparent; border-color: transparent; }
.btn.fantasma:hover { background: var(--linea-2); }
.btn.wa { background: #1f8f4e; border-color: #1f8f4e; color: #fff; }
.btn.ancho { width: 100%; }
.btn.chico { min-height: 32px; padding: .3rem .65rem; font-size: .85rem; }
.ico { width: 18px; height: 18px; flex: none; }
.aviso > .ico { margin-top: 1px; }
.vacio > .ico { width: 32px; height: 32px; color: var(--ok); }

/* Formularios */
label.campo { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; color: var(--tinta-2); }
label.campo .ayuda { font-weight: 400; color: var(--tinta-3); font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--tinta); background: var(--papel); border: 1px solid #cfd7dd; border-radius: var(--radio-s);
  padding: .65rem .75rem; min-height: 44px; width: 100%;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primario-2); outline-offset: 0; border-color: var(--primario-2); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primario); flex: none; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; font-size: .9rem; color: var(--tinta-2); }
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--linea-2); color: var(--tinta-2); white-space: nowrap; }
.chip.ok { background: var(--ok-suave); color: var(--ok); }
.chip.alerta { background: var(--alerta-suave); color: var(--alerta); }
.chip.error { background: var(--error-suave); color: var(--error); }
.chip.info { background: var(--info-suave); color: var(--info); }
.chip.eco { background: var(--eco-suave); color: var(--eco); }
.chip.vph { background: var(--vph-suave); color: var(--vph); }
.chip.neutro { background: #eef0f2; color: var(--tinta-3); }
.punto { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* Avisos */
.aviso { border-radius: var(--radio-s); padding: .75rem .9rem; font-size: .9rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.aviso.info { background: var(--info-suave); border-color: #cddcf1; color: #22497d; }
.aviso.ok { background: var(--ok-suave); border-color: #c4e6d3; color: #12603b; }
.aviso.alerta { background: var(--alerta-suave); border-color: #f2dcb3; color: #7a4a00; }
.aviso.error { background: var(--error-suave); border-color: #f4c7c3; color: #8f1c13; }

/* Barras de capacidad */
.barra { height: 10px; background: var(--linea-2); border-radius: 99px; overflow: hidden; display: flex; }
.barra > span { height: 100%; display: block; }
.barra .b-res { background: var(--primario); }
.barra .b-proc { background: #9fb8c6; }
.barra .b-bloq { background: repeating-linear-gradient(45deg, #d5dbe0, #d5dbe0 4px, #e9edf0 4px, #e9edf0 8px); }

/* Toast */
#toasts { position: fixed; z-index: 90; left: 50%; bottom: 1rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; width: min(440px, calc(100% - 2rem)); }
.toast { background: var(--tinta); color: #fff; padding: .75rem 1rem; border-radius: 10px; box-shadow: var(--sombra-alta); font-size: .92rem; animation: entra .2s ease-out; }
.toast.error { background: var(--error); }
.toast.ok { background: var(--ok); }
@keyframes entra { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Modal / panel lateral */
.velo { position: fixed; inset: 0; background: rgba(20, 33, 43, .42); z-index: 70; display: flex; align-items: flex-end; justify-content: center; animation: aparece .15s; }
@keyframes aparece { from { opacity: 0; } }
.modal { background: var(--papel); border-radius: 16px 16px 0 0; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; padding: 1.2rem 1.2rem 1.6rem; box-shadow: var(--sombra-alta); }
.modal .cab-modal { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; position: sticky; top: -1.2rem; background: var(--papel); padding: .4rem 0; z-index: 1; }
@media (min-width: 760px) {
  .velo { align-items: center; }
  .modal { border-radius: 16px; }
  .velo.lateral { justify-content: flex-end; align-items: stretch; }
  .velo.lateral .modal { border-radius: 0; max-height: none; height: 100%; max-width: 560px; }
}

/* Tablas */
.tabla-wrap { overflow-x: auto; border: 1px solid var(--linea); border-radius: var(--radio); background: var(--papel); }
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabla th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tinta-3); font-weight: 650; background: #fafbfc; padding: .65rem .8rem; border-bottom: 1px solid var(--linea); white-space: nowrap; position: sticky; top: 0; }
.tabla td { padding: .6rem .8rem; border-bottom: 1px solid var(--linea-2); vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: #f8fafb; }

.vacio { text-align: center; padding: 2rem 1rem; color: var(--tinta-3); }
.cargando { display: inline-block; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: gira .7s linear infinite; vertical-align: -3px; }
@keyframes gira { to { transform: rotate(360deg); } }
.esqueleto { background: linear-gradient(90deg, #eef2f5, #f7f9fa, #eef2f5); background-size: 200% 100%; animation: brillo 1.2s infinite; border-radius: 8px; min-height: 60px; }
@keyframes brillo { to { background-position: -200% 0; } }

/* ============== PACIENTE ============== */
.pac-cab { background: var(--primario); color: #fff; padding: 1.1rem 1.1rem 3.6rem; }
.pac-cab .marca { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; opacity: .8; font-weight: 600; }
.pac-cab h1 { font-size: 1.35rem; margin-top: .35rem; }
.pac-cab .meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .6rem; font-size: .9rem; opacity: .92; }
.pac-cuerpo { max-width: 620px; margin: -2.6rem auto 2rem; padding: 0 .9rem; }
.pac-cuerpo .tarjeta { padding: 1.2rem; }
.pasos { display: flex; gap: .35rem; margin-bottom: 1rem; }
.pasos span { flex: 1; height: 4px; border-radius: 4px; background: var(--linea); }
.pasos span.hecho { background: var(--acento); }
.opcion-cat { display: flex; gap: .8rem; align-items: center; border: 1.5px solid var(--linea); border-radius: var(--radio); padding: .85rem; cursor: pointer; background: var(--papel); }
.opcion-cat:has(input:checked) { border-color: var(--primario); background: var(--primario-suave); }
.opcion-cat strong { display: block; }
.combo { border: 1.5px solid var(--linea); border-radius: var(--radio); padding: .8rem .9rem; background: var(--papel); cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; display: flex; gap: .8rem; align-items: center; justify-content: space-between; transition: border-color .15s, background .15s; }
.combo:hover { border-color: var(--primario-2); background: #fbfdfe; }
.combo .pasos-combo { display: flex; flex-direction: column; gap: .3rem; }
.combo .linea-examen { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.combo .hora { font-variant-numeric: tabular-nums; min-width: 5.4rem; display: inline-block; white-space: nowrap; }
.combo > .peq { flex: none; white-space: nowrap; }
.combo .linea-examen { flex-wrap: nowrap; }
.combo .flecha { color: var(--tinta-3); }
.combo.recomendada { border-color: #b9d6cf; background: #f7fcfb; }
.etiqueta-rec { font-size: .72rem; font-weight: 700; color: var(--acento); text-transform: uppercase; letter-spacing: .05em; }
.horas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.hora-btn { border: 1.5px solid var(--linea); background: var(--papel); border-radius: 10px; padding: .6rem .3rem; font: inherit; font-weight: 650; cursor: pointer; font-variant-numeric: tabular-nums; position: relative; color: var(--tinta); }
.hora-btn:hover { border-color: var(--primario-2); }
.hora-btn.rec { border-color: #b9d6cf; background: #f4fbf9; }
.hora-btn.rec::after { content: "Sugerido"; display: block; font-size: .65rem; color: var(--acento); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.franja { margin-top: 1rem; }
.franja > h3 { font-size: .8rem; color: var(--tinta-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.reloj { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.6rem; color: var(--primario); }
.reloj.urgente { color: var(--error); }
.cita-linea { display: flex; gap: .9rem; align-items: center; padding: .8rem 0; border-bottom: 1px solid var(--linea-2); }
.cita-linea:last-child { border-bottom: 0; }
.cita-linea .hora-grande { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 6.2rem; }
.icono-ok { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-suave); color: var(--ok); display: grid; place-items: center; margin: 0 auto .6rem; }
.aviso-legal { max-height: 220px; overflow: auto; font-size: .82rem; color: var(--tinta-2); background: #fafbfc; border: 1px solid var(--linea); border-radius: var(--radio-s); padding: .7rem .8rem; }
.pie { text-align: center; color: var(--tinta-3); font-size: .78rem; padding: 1rem; }
.en-vivo { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; color: var(--acento); font-weight: 600; }
.en-vivo .punto { animation: pulso 2s infinite; }
@keyframes pulso { 50% { opacity: .35; } }

/* ============== ADMINISTRACIÓN ============== */
.adm { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.adm-lateral { background: #102a36; color: #cfdee5; padding: 1rem .7rem; position: sticky; top: 0; height: 100vh; overflow: auto; display: flex; flex-direction: column; gap: .2rem; }
.adm-lateral .logo { color: #fff; font-weight: 700; padding: .3rem .6rem 1rem; font-size: 1rem; line-height: 1.2; }
.adm-lateral .logo small { display: block; color: #8fb0bf; font-weight: 500; font-size: .75rem; margin-top: .2rem; }
.nav-item { display: flex; align-items: center; gap: .65rem; padding: .55rem .65rem; border-radius: 8px; color: #cfdee5; text-decoration: none; font-weight: 550; font-size: .92rem; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font-family: inherit; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.activo { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item .contador { margin-left: auto; background: #e9a23b; color: #2b1a00; border-radius: 99px; font-size: .7rem; padding: 0 .45rem; font-weight: 700; }
.adm-principal { min-width: 0; }
.adm-barra { background: var(--papel); border-bottom: 1px solid var(--linea); padding: .6rem 1.2rem; display: flex; align-items: center; gap: .8rem; position: sticky; top: 0; z-index: 20; }
.adm-barra select { max-width: 360px; font-weight: 600; }
.adm-contenido { padding: 1.3rem 1.4rem 5rem; max-width: 1280px; }
.adm-movil-nav { display: none; }
@media (max-width: 900px) {
  .adm { grid-template-columns: 1fr; }
  .adm-lateral { display: none; }
  .adm-contenido { padding: 1rem .8rem 6rem; }
  .adm-barra { padding: .5rem .8rem; }
  .adm-movil-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--papel); border-top: 1px solid var(--linea); z-index: 40; padding: .25rem .2rem calc(.25rem + env(safe-area-inset-bottom)); }
  .adm-movil-nav button { flex: 1; border: 0; background: none; font: inherit; font-size: .68rem; color: var(--tinta-3); display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .35rem 0; cursor: pointer; font-weight: 600; position: relative; }
  .adm-movil-nav button.activo { color: var(--primario); }
  .adm-movil-nav svg { width: 22px; height: 22px; }
}
.kpi { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: .9rem 1rem; }
.kpi .et { font-size: .78rem; color: var(--tinta-3); font-weight: 600; }
.kpi .val { font-size: 1.7rem; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin-top: .15rem; }
.kpi .val small { font-size: .95rem; color: var(--tinta-3); font-weight: 600; }
.kpi .sub { font-size: .8rem; color: var(--tinta-3); }
.kpi.destacado { border-color: #c9dbe3; background: linear-gradient(180deg, #fff, #f6fafb); }
.servicio-cap { display: flex; flex-direction: column; gap: .45rem; }
.leyenda { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .78rem; color: var(--tinta-3); }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }

/* Agenda */
.agendas { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.agenda-col h3 { display: flex; align-items: center; gap: .5rem; }
.slot { display: grid; grid-template-columns: 5.6rem 1fr auto; gap: .6rem; align-items: center; padding: .5rem .7rem; border-bottom: 1px solid var(--linea-2); font-size: .88rem; }
.slot:last-child { border-bottom: 0; }
.slot .h { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot.disponible .quien { color: var(--ok); }
.slot.bloqueado { background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 6px, #f2f4f6 6px, #f2f4f6 12px); color: var(--tinta-3); }
.slot.en_proceso .quien { color: var(--alerta); }
.slot.fuera_de_horario { background: var(--alerta-suave); }
.slot .quien { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .prof { font-size: .75rem; color: var(--tinta-3); }

/* Tablero operativo */
.tablero-hora { margin-bottom: 1.2rem; }
.tablero-hora > .cab-hora { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .5rem; }
.tablero-hora > .cab-hora strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.tarjetas-pac { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tpac { background: var(--papel); border: 1px solid var(--linea); border-left: 4px solid var(--linea); border-radius: var(--radio); padding: .75rem .85rem; display: flex; flex-direction: column; gap: .5rem; }
.tpac.M { border-left-color: var(--vph); }
.tpac.H { border-left-color: var(--eco); }
.tpac.atendido { opacity: .7; }
.tpac .nombre { font-weight: 700; }
.tpac .examen { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-size: .87rem; padding: .35rem .45rem; border-radius: 8px; background: #fafbfc; }
.tpac .examen .hora { font-weight: 700; font-variant-numeric: tabular-nums; }
.acciones-mini { display: flex; gap: .3rem; flex-wrap: wrap; margin-left: auto; }

.lista-seg { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.lista-seg li { display: flex; gap: .55rem; align-items: center; font-size: .9rem; }
.lista-seg .si { color: var(--ok); } .lista-seg .no { color: #b8c2ca; }
.linea-tiempo { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--linea); }
.linea-tiempo li { position: relative; padding: 0 0 .8rem .4rem; font-size: .85rem; }
.linea-tiempo li::before { content: ""; position: absolute; left: -1.38rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--primario-2); border: 2px solid #fff; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--linea); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--tinta-3); padding: .6rem .8rem; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.activo { color: var(--primario); border-bottom-color: var(--primario); }
.msg-prev { white-space: pre-wrap; font-size: .87rem; background: #f6f8f9; border-radius: 8px; padding: .7rem .8rem; border: 1px solid var(--linea); max-height: 260px; overflow: auto; }
.qr-caja { background: #fff; padding: 12px; border: 1px solid var(--linea); border-radius: 12px; display: inline-block; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, #102a36, #1d4e63); }
.login .tarjeta { width: min(400px, 100%); }
.grafico-horas { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: .5rem; }
.grafico-horas .gh { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.grafico-horas .barras { display: flex; gap: 2px; align-items: flex-end; height: 92px; width: 100%; justify-content: center; }
.grafico-horas .barras span { width: 40%; max-width: 16px; border-radius: 3px 3px 0 0; background: var(--linea); position: relative; }
.grafico-horas .barras span i { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 3px 3px 0 0; }
.grafico-horas .et { font-size: .7rem; color: var(--tinta-3); font-variant-numeric: tabular-nums; }

@media print {
  body { background: #fff; }
  .no-imprimir { display: none !important; }
}
@media (max-width: 600px) { #b-nueva span { display: none; } .adm-barra select { max-width: none; flex: 1; } }
