/* odontOS · «Pendientes y seguimiento» estilo Nueva atención (ficha del paciente + Planificación).
   Medidas en px (la app usa rem de 20 px; la maqueta, 16 px). Maqueta aprobada: ~/Desktop/CODIGO/maqueta_pendientes.html. Todo con prefijo .pn-; usa los tokens de 02-bloque.css.
   Lo que no existe como token (rojo/ámbar de texto) se define aquí con su versión oscura. */
:root { --pn-red-ink: #B91C1C; --pn-warn-ink: #B45309; --pn-fld: #F6F8FB; --pn-pri-ink: #fff; }
:root[data-theme="dark"] { --pn-red-ink: var(--red); --pn-warn-ink: var(--warn); --pn-fld: #252528; --pn-pri-ink: #04202e; }

/* ---------- botones e iconos ---------- */
html body .pn-btn, html body .pn-ib, html body .pn-mi { box-sizing: border-box; margin: 0; cursor: pointer; font-family: inherit; box-shadow: none; }
html body .pn-btn { width: auto; height: 38px; min-height: 0; padding: 0 14px; border-radius: 11px; border: 1px solid var(--line); background: var(--card); font-weight: 700; font-size: 13.44px; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; flex: none; }
html body .pn-btn:hover { background: var(--card-2); }
html body .pn-btn.pri { background: var(--blue-2); border-color: var(--blue-2); color: var(--pn-pri-ink); }
html body .pn-btn.pri:hover { filter: brightness(1.08); background: var(--blue-2); }
html body .pn-btn svg { width: 15px; height: 15px; flex: none; }
html body .pn-ib { width: 38px; height: 38px; min-height: 0; min-width: 0; padding: 0; border-radius: 11px; border: 1px solid var(--line); background: var(--card); display: inline-grid; place-items: center; color: var(--muted); flex: none; }
html body .pn-ib:hover { background: var(--card-2); color: var(--ink); }
html body .pn-ib.x2 { color: var(--pn-red-ink); }
html body .pn-ib svg { width: 16px; height: 16px; }
.pn-link { margin: 0; padding: 0 4px; min-height: 0; height: auto; border: 0; background: transparent; box-shadow: none; color: var(--blue-2); font-weight: 800; font-size: 13.76px; cursor: pointer; font-family: inherit; white-space: nowrap; }
.pn-link:hover { text-decoration: underline; }
.pn-ib svg, .pn-btn svg, .pn-dot svg, .pn-mi svg, .pn-hic svg, .pn-search svg, .pn-av svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pn-btn.pri svg { stroke-width: 2.4; }
svg.pn-fill { fill: currentColor; stroke: none; }
.pn-fill circle { fill: currentColor; stroke: none; }

/* ---------- menú «···» ---------- */
.pn-mw { position: relative; display: inline-flex; }
.pn-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 1000; width: 220px; max-width: calc(100vw - 16px); background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(15, 23, 42, .14); padding: 6px; display: block; }
.pn-pop.up { top: auto; bottom: calc(100% + 6px); }
.pn-pop.lf { right: auto; left: 0; }
.pn-pop[hidden] { display: none !important; }
html body .pn-mi { width: 100%; min-height: 0; height: auto; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; font-size: 13.76px; font-weight: 600; color: var(--ink-2); display: flex; gap: 9px; align-items: center; justify-content: flex-start; text-align: left; white-space: nowrap; }
html body .pn-mi svg { width: 15px; height: 15px; color: var(--muted); flex: none; }
html body .pn-mi:first-child, html body .pn-mi:hover { background: var(--blue-soft); color: var(--blue-2); }
html body .pn-mi:first-child svg, html body .pn-mi:hover svg { color: var(--blue-2); }
html body .pn-mi.dg { color: var(--pn-red-ink); }
html body .pn-mi.dg svg { color: var(--pn-red-ink); }
html body .pn-mi.dg:hover { background: var(--red-soft); color: var(--pn-red-ink); }

/* ---------- pendiente (ficha y móvil) ---------- */
.pn-list, #planPaneFollow #plList { container-type: inline-size; }
.pn-pd { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.pn-pd:last-child { border-bottom: 0; }
.pn-dot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--blue-soft); color: var(--blue-2); }
.pn-dot svg { width: 17px; height: 17px; }
.pn-dot.r { background: var(--red-soft); color: var(--pn-red-ink); }
.pn-dot.w { background: var(--warn-soft); color: var(--pn-warn-ink); }
.pn-dot.g { background: var(--good-soft); color: var(--good); }
.pn-tx { display: block; min-width: 0; overflow-wrap: anywhere; }
.pn-tx > b { display: block; font-size: 15.2px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.pn-tx > small { display: block; color: var(--muted); font-size: 13.44px; margin-top: 2px; line-height: 1.35; }
.pn-tx > small em { font-style: normal; font-weight: 800; color: var(--ink-2); }
.pn-tx > small em.r { color: var(--pn-red-ink); }
.pn-tx > small em.w { color: var(--pn-warn-ink); }
.pn-tx > small em.b { color: var(--blue-2); }
.pn-who { display: block; font-size: 12.48px; font-weight: 800; color: var(--blue-2); margin-bottom: 2px; }
.pn-tag { display: inline-block; font-size: 12.16px; font-weight: 800; padding: 5px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-2); margin-top: 8px; white-space: nowrap; line-height: 1.2; }
.pn-tx > small .pn-tag { margin: 0 0 0 2px; }
.pn-acts { display: flex; gap: 6px; align-items: center; flex: none; }
@container (max-width: 640px) {
  .pn-pd { grid-template-columns: 34px minmax(0, 1fr); align-items: start; }
  .pn-pd .pn-acts { grid-column: 1 / -1; flex-wrap: wrap; }
  .pn-pd .pn-acts .pn-btn { flex: 1 1 auto; }
  .pn-pd .pn-acts .x2 { margin-left: auto; }
}

/* ---------- ficha del paciente ---------- */
#patientDetail #plPatientCard.pd-card { padding: 0; overflow: visible; }
#plPatientCard .pn-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.pn-hic { width: 38px; height: 38px; border-radius: 12px; background: var(--blue-soft); color: var(--blue-2); display: grid; place-items: center; flex: none; }
.pn-hic svg { width: 20px; height: 20px; }
#plPatientCard .pn-ht { flex: 1 1 200px; min-width: 0; }
html body #patientDetail #plPatientCard .pn-ht h4 { margin: 0; padding: 0; font-size: 17.6px; font-weight: 800; color: var(--ink); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; line-height: 1.25; letter-spacing: 0; text-transform: none; }
.pn-ht small { display: block; color: var(--muted); font-size: 13.6px; margin-top: 2px; overflow-wrap: anywhere; }
.pn-cnt { font-size: 12.8px; font-weight: 800; padding: 4px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-2); line-height: 1.2; }
.pn-hact { display: flex; align-items: center; gap: 12px; margin-left: auto; flex-wrap: wrap; }
#plPatientCard .pn-list { padding: 6px 16px; }
.pn-vacio { margin: 0; padding: 14px 0; color: var(--muted); font-size: 13.76px; line-height: 1.45; }
.pn-vacio.pn-hechos { padding-top: 8px; border-top: 1px solid var(--line); font-size: 12.8px; }
.pn-pd + .pn-vacio.pn-hechos { margin-top: 0; }

/* ---------- Planificación › Pendientes y seguimientos ---------- */
#planPaneFollow .pn-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 6px 16px 10px; min-width: 0; }
.pn-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 14px 0; }
html body #planPaneFollow .pn-k { display: block; margin: 0; min-height: 0; height: auto; text-align: left; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; box-shadow: none; padding: 2px 16px; font-family: inherit; font-size: 12.8px; font-weight: 700; color: var(--muted); cursor: pointer; }
html body #planPaneFollow .pn-k:last-child { border-right: 0; }
html body #planPaneFollow .pn-k b { display: block; font-size: 20.8px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.25; margin: 0; }
html body #planPaneFollow .pn-k.r b { color: var(--pn-red-ink); }
html body #planPaneFollow .pn-k:hover { background: var(--card-2); }
html body #planPaneFollow .pn-k.on { background: var(--blue-soft); }
.pn-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.pn-search { position: relative; flex: 1 1 220px; min-width: 0; display: flex; align-items: center; }
.pn-search svg { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
html body #planPaneFollow .pn-search input { width: 100%; height: 40px; min-height: 0; margin: 0; padding: 0 12px 0 35px; border: 1px solid var(--line); border-radius: 12px; background: var(--pn-fld); color: var(--ink); font-family: inherit; font-size: 15.2px; box-shadow: none; box-sizing: border-box; }
html body #planPaneFollow .pn-search input:focus { border-color: var(--blue-2); outline: none; }
html body #planPaneFollow .pn-chip { height: auto; min-height: 0; margin: 0; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-family: inherit; font-size: 13.44px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; box-shadow: none; flex: none; }
html body #planPaneFollow .pn-chip:hover { background: var(--card-2); }
html body #planPaneFollow .pn-chip.on { background: var(--blue-2); border-color: var(--blue-2); color: var(--pn-pri-ink); }
#planPaneFollow .pn-bar .pla-fw { margin-left: 0; }

/* fila de Planificación */
.pn-pl { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.pn-pl:last-child { border-bottom: 0; }
.pn-av { width: 34px; height: 34px; border-radius: 50%; background: var(--card-2); color: var(--muted); display: grid; place-items: center; overflow: hidden; flex: none; }
.pn-av svg { width: 22px; height: 22px; }
.pn-av img, .pn-av > svg:not(:only-child) { width: 100%; height: 100%; object-fit: cover; display: block; }
.pn-av[data-av-ok] svg { width: 100%; height: 100%; }
.pn-pl .pn-tx > small .pn-tag { margin: 0 0 0 2px; padding: 4px 10px; vertical-align: 1px; }
.pn-pl .pn-tx > small.pn-nota { margin-top: 3px; }
.pn-when { text-align: right; font-size: 13.12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pn-when b { display: block; color: var(--ink-2); font-size: 13.76px; font-weight: 800; }
.pn-when b.r { color: var(--pn-red-ink); }
.pn-when b.w { color: var(--pn-warn-ink); }
@container (max-width: 760px) {
  .pn-pl { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .pn-pl .pn-acts { grid-column: 2 / -1; flex-wrap: wrap; }
}
/* urgencia: encabezado de grupo (reutiliza .pla-sec de plan-a.css) */
#planPaneFollow .pn-card .pla-sec { padding-left: 0; padding-right: 0; }

/* vista Tarjetas */
.pn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; padding: 8px 0 4px; }
.pn-tc { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--pn-fld); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pn-tc.vencido { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.pn-tct { display: flex; gap: 10px; align-items: center; min-width: 0; }
.pn-tct .pn-tx { flex: 1; }
.pn-tc .pn-tt { min-height: 38px; }
.pn-tc .pn-tag { margin-top: 6px; }
.pn-tc .pn-acts { margin-top: auto; flex-wrap: wrap; }

/* ---------- ventana Nuevo / Editar pendiente ---------- */
.pn-r2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.pn-r2 > .dn-fld { margin-bottom: 0; }
.dn-win .pn-quick.dn-fld { margin-bottom: 12px; }
.pn-r2 > .dn-fld:only-child { grid-column: 1 / -1; }
.pn-opc { font-weight: 600; color: var(--muted); }
.dn-win .pn-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.dn-win .pn-quick .dn-chip { padding: 6px 12px; font-size: .8rem; color: var(--ink-2); background: var(--card); cursor: pointer; }
.dn-win .pn-quick .dn-chip:hover { background: var(--blue-soft); color: var(--blue-2); }
@media (max-width: 480px) { .pn-r2 { grid-template-columns: 1fr; } }

/* ---------- móvil: toques de 44 px ---------- */
@media (max-width: 834px) {
  html body .pn-btn { height: 44px; }
  html body .pn-ib { width: 44px; height: 44px; }
  .pn-pd .pn-acts { gap: 8px; }
  #plPatientCard .pn-head { padding: 14px 16px; }
  #plPatientCard .pn-list { padding: 4px 14px; }
  #plPatientCard .pn-hact { width: 100%; justify-content: space-between; margin-left: 0; }
  .pn-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
  html body #planPaneFollow .pn-k:nth-child(2n) { border-right: 0; }
}

/* Check verde = Realizado / Hecha */
html body .pn-ib.ok { background: var(--good-soft, #E6F6EC); border: 1px solid var(--good, #0F9D58); color: #0B7A44; }
html body .pn-ib.ok:hover { background: var(--good, #0F9D58); color: #fff; }
html body .pn-ib.ok svg { stroke-width: 2.6; }
:root[data-theme="dark"] html body .pn-ib.ok, html[data-theme="dark"] body .pn-ib.ok { color: #86efac; background: rgba(15,157,88,.18); }

/* ---------- responsive real de la tarjeta de la ficha (se adapta al ancho del recuadro, no de la pantalla) ---------- */
#plPatientCard { container-type: inline-size; container-name: pcard; }
.pn-hact { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
html body .pn-hact .pn-link { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; padding: 0 6px; height: 38px; min-height: 0; cursor: pointer; color: var(--blue-2); font-weight: 800; font-size: 13.76px; }
.pn-hact .pn-link svg { display: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@container pcard (max-width: 560px) {
  #plPatientCard .pn-head { flex-wrap: nowrap; gap: 10px; padding: 14px 14px; }
  #plPatientCard .pn-ht { flex: 1 1 0; min-width: 0; }
  .pn-hact .pn-lbl { display: none; }
  html body .pn-hact .pn-link { width: 38px; padding: 0; justify-content: center; border: 1px solid var(--line); border-radius: 11px; background: var(--card); }
  .pn-hact .pn-link svg { display: block; }
  html body .pn-hact .pn-btn { width: 38px; padding: 0; justify-content: center; }
}
@container pcard (max-width: 440px) {
  .pn-pd .pn-acts .pn-btn .pn-lbl { display: none; }
  html body .pn-pd .pn-acts .pn-btn { flex: 0 0 38px; padding: 0; justify-content: center; }
  .pn-pd .pn-acts { gap: 8px; }
}

/* Ficha en escritorio: la lista de pendientes se desplaza dentro de su tarjeta para no empujar «Planificación» lejos del odontograma */
@media (min-width: 835px) {
  #patientDetail.fb #plPatientCard .pn-list { max-height: 9rem; overflow-y: auto; overscroll-behavior: contain; }
}
