/* Diseño replicado de la interfaz de PrecisePK (medidas y colores tomados de la aplicación). */
:root {
  --primary: #0C5AA2;      /* botones de contorno */
  --header: #B3261E;       /* franja superior (rojo) */
  --blue: #1774CF;         /* individuo, enlaces, botón principal */
  --pop: #E52D02;          /* población */
  --text: #23262B;
  --title: #323130;
  --label: #56585C;
  --muted: #6F7176;
  --sub: #3E3F43;
  --border: #BCBFC2;
  --line: #EAEEEF;
  --grey: #EAEEEF;
  --alt: #EDEDF1;
  --hover: #EDEDF7;
  --tabbg: #DFF3FF;
  --soft: #F9F9FA;
  --disabled: #898B8F;
  --switch-off: #A3A5A9;
  --tox: #FFA726;
  --band: #E4EEFD;
  --serum: #3A539B;
  --shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px 0 rgba(0,0,0,.06);
  --font: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 16px; color: var(--text); background: #fff; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
.hidden { display: none !important; }
hr { border: 0; border-bottom: 1px solid var(--border); margin: 12px 0; }

/* ---------------- Encabezado ---------------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 70px; z-index: 20;
  display: flex; align-items: center; gap: 16px; padding: 0 22px;
  background: var(--header);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; }
.brand p { font-size: 24px; font-weight: 500; white-space: nowrap; }
.logo { width: 28px; height: 28px; border-radius: 50%; background: #fff; color: var(--header); display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.mainnav { display: flex; gap: 1px; }
.navbtn { height: 40px; padding: 0 16px; border: 0; border-radius: 6px; background: transparent; color: #fff; font-size: 18px; font-weight: 500; white-space: nowrap; }
.navbtn:hover { background: rgba(255,255,255,.08); }
.navbtn.active { background: rgba(255,255,255,.16); }
.hdr-icons { margin-left: auto; display: flex; gap: 12px; }
.iconbtn { width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; }
.iconbtn:hover { background: rgba(255,255,255,.1); }
.iconbtn svg { width: 26px; height: 26px; }

/* ---------------- Estructura ---------------- */
.shell { display: flex; padding-top: 70px; min-height: 100vh; }
.sidebar { width: 200px; flex: 0 0 200px; padding: 12px 4px 0 12px; position: sticky; top: 70px; height: calc(100vh - 70px); overflow-y: auto; }
.shell.nosidebar .sidebar { display: none; }
.content { flex: 1; min-width: 0; padding: 12px 12px 40px; }
.page { display: none; }
.page.active { display: block; }
.grid2 { display: grid; grid-template-columns: 515px 515px; gap: 12px; justify-content: center; align-items: start; }
.grid2 > .col { display: flex; flex-direction: column; gap: 12px; }
.span2 { grid-column: 1 / -1; }
.home-grid { max-width: 1154px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }

/* ---------------- Tarjetas ---------------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 16px 12px; min-width: 0; }
.card.h601 { min-height: 601px; }
.card.h470 { height: 470px; display: flex; flex-direction: column; }
.card.h733 { min-height: 733px; }
.card-title { font-size: 18px; font-weight: 800; color: var(--title); line-height: 27px; margin-bottom: 4px; }
.card-title.mt { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head.left { justify-content: flex-start; }
.card-foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: flex-end; gap: 8px; }
.sub16 { font-size: 16px; font-weight: 500; color: var(--sub); line-height: 24px; }
.sub14 { font-size: 14px; font-weight: 500; color: var(--sub); margin: 6px 0 8px; }
.muted { font-size: 14px; color: var(--label); }
.muted-s { font-size: 12px; color: var(--label); margin-top: 6px; }
.unit { font-size: 14px; color: var(--muted); font-weight: 400; }
.lbl { font-size: 14px; font-weight: 500; color: var(--title); line-height: 21px; }
.row-between { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

/* ---------------- Controles ---------------- */
input[type=text], input[type=number], select {
  height: 35px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font-size: 14px; color: var(--text);
  background: #fff; width: 100%; outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
input.grey, input:disabled { background: var(--grey); color: var(--text); }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.selwrap { position: relative; }
.selwrap select { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer; }
.selwrap::after { content: ""; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; border-right: 2px solid var(--text); border-bottom: 2px solid var(--text); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.selwrap.w200 { width: 200px; }
.selwrap.w120 { width: 120px; }
.selwrap.w120 select { height: 25px; font-size: 14px; }
select:disabled { background: #fff; color: var(--text); opacity: 1; cursor: default; }

.btn-primary { height: 40px; padding: 0 16px; border: 0; border-radius: 6px; background: var(--blue); color: #fff; font-size: 14px; font-weight: 500; white-space: nowrap; }
.btn-primary:hover { filter: brightness(.95); }
.btn-primary.sm { height: 32px; font-weight: 600; }
.btn-primary.lg { font-size: 16px; font-weight: 600; }
.btn-primary.block { width: 100%; }
.btn-outline { height: 32px; padding: 0 16px; border: 1px solid var(--primary); border-radius: 6px; background: #fff; color: var(--primary); font-size: 14px; font-weight: 600; white-space: nowrap; }
.btn-outline:hover { background: #F2F7FC; }
.btn-outline.wide { width: 184px; height: 40px; font-size: 14px; padding: 0 8px; }
.btn-outline.xs { height: 24px; font-size: 12px; padding: 0 8px; }
.btn-outline.lg { height: 40px; font-size: 16px; }
.linkbtn { border: 0; background: none; color: var(--blue); font-size: 16px; padding: 0; white-space: nowrap; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn.sm { font-size: 12px; }

.segctl { display: inline-flex; gap: 4px; padding: 2px 4px; border-radius: 7px; background: var(--grey); align-items: center; height: 42px; }
.segctl button { height: 30px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--title); font-size: 14px; font-weight: 500; }
.segctl button.on { background: #fff; border-color: var(--border); box-shadow: var(--shadow); }
.unit-row .segctl { height: 35px; }
.unit-row .segctl button { width: 32px; padding: 0; }

.tabs2 { display: flex; border-bottom: 2px solid var(--border); margin: 0 0 16px; }
.tabs2 button { flex: 1; height: 31px; margin-bottom: -2px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--disabled); font-size: 14px; font-weight: 500; }
.tabs2 button.on { color: var(--blue); background: var(--tabbg); border-bottom-color: var(--blue); }

.radio { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--title); cursor: pointer; }
.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.radio span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border); flex: 0 0 12px; }
.radio input:checked + span { background: var(--blue); border-color: var(--blue); }

.switch-l { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; color: var(--label); }
.switch-l.n { font-size: 14px; color: var(--title); }
.switch { position: relative; width: 34px; height: 20px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 9999px; background: var(--switch-off); transition: background .15s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { transform: translateX(14px); }

.chk { position: relative; display: inline-block; width: 16px; height: 16px; vertical-align: middle; }
.chk input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.chk i { position: absolute; inset: 0; border: 2px solid var(--border); border-radius: 2px; background: #fff; }
.chk input:checked + i { background: var(--blue); border-color: var(--blue); }
.chk input:checked + i::after { content: ""; position: absolute; left: 3px; top: 0; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.badge { display: inline-block; padding: 0 4px; border-radius: 5px; font-size: 12px; font-weight: 600; color: #fff; line-height: 18px; white-space: nowrap; background: var(--disabled); }
.badge.stage { background: #F2C94C; }

/* Fecha y hora segmentadas (mm/dd/yyyy y hh:mm) */
.dtseg { display: inline-flex; align-items: center; height: 35px; border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 0 6px; font-size: 14px; }
.dtseg:focus-within { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.dtseg input { border: 0 !important; box-shadow: none !important; padding: 0 !important; height: 28px; width: 17px; text-align: center; font-size: 14px; background: transparent !important; }
.dtseg input.y { width: 34px; }
.dtseg b { font-weight: 400; color: var(--title); padding: 0 1px; }

/* ---------------- Barra lateral ---------------- */
.side-sec { border-top: 1px solid var(--border); margin-top: 12px; }
.side-sec + .side-sec { margin-top: 0; }
.side-head { width: 100%; min-height: 40px; padding: 8px; display: flex; align-items: center; justify-content: space-between; border: 0; background: transparent; font-size: 16px; font-weight: 500; color: var(--text); text-align: left; }
.side-head i { display: grid; }
.side-head i svg { width: 20px; height: 20px; transition: transform .15s; }
.side-sec.closed .side-head i svg { transform: rotate(180deg); }
.side-sec.closed .side-body { display: none; }
.side-body { padding: 0 8px 12px; }
.kv { display: grid; grid-template-columns: 50px 1fr; column-gap: 8px; row-gap: 8px; font-size: 14px; align-items: center; }
.kv p:nth-child(odd) { font-weight: 500; }
.kv p { word-break: break-word; }
.pkside { display: grid; grid-template-columns: 56px 56px 56px; row-gap: 8px; font-size: 14px; }
.pkside .n { font-weight: 500; }
.pkside .p { color: var(--pop); }
.pkside .i { color: var(--blue); }
.pkside + .btn-outline { margin-top: 10px; }

/* ---------------- Formularios del paciente ---------------- */
.pform { display: grid; grid-template-columns: 78px 156px 78px 156px; column-gap: 12px; row-gap: 12px; align-items: center; margin-top: 8px; }
.pform .lbl { line-height: 1.5; }
.pform .dtseg { width: 156px; justify-content: center; }
.unit-row { display: flex; gap: 4px; align-items: center; }
.unit-row input { width: 77px; }
.drug-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.drug-row .lbl { width: 68px; }
.lab-row { display: grid; grid-template-columns: 150px 93px 50px 1fr; align-items: center; gap: 8px; margin: 12px 0; }
.lab-row .linkbtn { justify-self: end; }
.lab-row .unit { font-weight: 500; }

/* ---------------- Tablas ---------------- */
.tablewrap { overflow: auto; }
.scroll346 { max-height: 346px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th { font-size: 12px; font-weight: 500; color: var(--label); text-align: left; padding: 2px 2px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: #fff; z-index: 1; }
th.c { text-align: center; }
table.info th { border-bottom-color: var(--border); padding: 2px 8px; }
table.info td { height: 38px; padding: 0 8px; font-size: 14px; }
table.info tbody tr:nth-child(even) td { background: var(--alt); }
table.info tbody tr:nth-child(even) td:first-child { border-radius: 5px 0 0 5px; }
table.info tbody tr:nth-child(even) td:last-child { border-radius: 0 5px 5px 0; }
table.info td.name { font-weight: 500; color: var(--title); }
table.info td.u { color: var(--muted); }
table.info .pm { display: flex; align-items: center; gap: 4px; justify-content: center; }
table.info .pm input { width: 75px; height: 30px; border-color: transparent; background: transparent; }
table.info .pm input:not(:disabled):hover { border-color: var(--border); background: #fff; }
table.info .pm input:disabled { background: transparent; }
table.edit td { height: 36px; padding: 2px; font-size: 14px; vertical-align: middle; background: #fff; }
table.edit tbody tr:hover td { background: var(--hover); }
table.edit td.num { font-weight: 500; text-align: center; min-width: 24px; }
table.edit input[type=number], table.edit input[type=text], table.edit select { height: 30px; padding: 0 6px; }
table.edit .selwrap select { padding-right: 22px; font-size: 14px; }
table.edit .dtseg { height: 30px; padding: 0 3px; }
table.edit .dtseg input { width: 16px; }
table.edit .dtseg input.y { width: 31px; }
.predbox { display: flex; height: 30px; border: 1px solid var(--border); border-radius: 5px; background: var(--grey); align-items: center; font-size: 14px; min-width: 110px; }
.predbox p { flex: 1; text-align: center; }
.pop { color: var(--pop); }
.ind { color: var(--blue); }
.circbtn { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--switch-off); background: #fff; display: grid; place-items: center; padding: 0; color: var(--text); }
.circbtn svg { width: 16px; height: 16px; }
.circbtn:hover { background: #F2F2F4; }
.infobtn { width: 22px; height: 22px; border: 1px solid transparent; border-radius: 5px; background: transparent; padding: 0; display: grid; place-items: center; color: var(--label); }
.infobtn:hover { background: var(--grey); }
.infobtn svg { width: 14px; height: 14px; }
.clock { color: var(--label); display: grid; place-items: center; cursor: help; }
.clock svg { width: 19px; height: 19px; }
.formula-btn { white-space: nowrap; border: 0; background: none; font-size: 14px; font-weight: 500; color: var(--sub); }
.formula-btn:hover { text-decoration: underline; }
.hint-row td { color: var(--muted); font-size: 14px; padding: 12px 4px !important; }

/* Lista de casos (Inicio) */
table.list th { font-size: 12px; font-weight: 400; color: var(--sub); padding: 14px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 8px; font-size: 14px; border-bottom: 1px solid var(--line); }
table.list tbody tr:hover td { background: var(--hover); }
.search-row { display: flex; gap: 8px; align-items: center; margin: 8px 0 16px; }
.search { max-width: 560px; height: 40px !important; }
.recent { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 12px; }
.case-card { display: flex; flex-direction: column; gap: 4px; min-height: 150px; }
.case-card .nm { font-size: 16px; font-weight: 500; color: var(--title); }
.case-card .meta { font-size: 14px; color: var(--muted); }
.case-card .btn-outline { margin-top: auto; width: 211px; }
.empty { color: var(--muted); font-size: 16px; text-align: center; padding: 30px 0; }

/* ---------------- Objetivo terapéutico ---------------- */
.target { display: grid; grid-template-columns: 149px 1fr; gap: 16px; }
.t-in-head { display: flex; align-items: center; justify-content: space-between; height: 24px; margin-bottom: 4px; }
.grey-panel { background: var(--grey); border-radius: 5px; padding: 10px; display: flex; flex-direction: column; }
.grey-panel .lbl { margin-top: 16px; }
.grey-panel > .lbl:first-child { margin-top: 0; }
.grey-panel select, .grey-panel input { height: 32px; }
.grey-panel .dtseg { height: 32px; width: 100%; }
.sfx { position: relative; }
.sfx input { padding-right: 58px; }
.sfx span { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--muted); pointer-events: none; }
.t-out { min-width: 0; }
.recrow { display: grid; grid-template-columns: 136px 97px 1fr; align-items: center; gap: 0 8px; margin: 12px 0; font-size: 14px; }
.recrow .k { font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 4px; }
.recrow .v { font-weight: 500; color: var(--blue); text-align: center; }
.recrow .u { color: var(--muted); }
.recrow .sub { grid-column: 1 / -1; color: var(--muted); font-weight: 400; }
.recrow input { height: 32px; }
.stepper { display: flex; align-items: center; justify-content: space-between; }
.stepper button { width: 24px; height: 24px; border: 0; background: transparent; padding: 0; border-radius: 6px; color: var(--text); display: grid; place-items: center; }
.stepper button:hover { background: var(--grey); }
.stepper button svg { width: 22px; height: 22px; }
.stepper p { color: var(--blue); font-weight: 500; }
.md-line { font-weight: 500; }
.md-line .b { color: var(--blue); }
.md-line .g { color: var(--muted); }
.export-box { margin-top: 24px; background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 8px 17px; font-size: 14px; text-align: center; line-height: 1.5; }
.export-box u { cursor: pointer; }
.alert { border-radius: 6px; padding: 10px 12px; font-size: 14px; margin: 8px 0; background: #FFF4E5; color: #663C00; border: 1px solid #FFD8A8; }
.warnicon { color: #E67E22; display: inline-grid; place-items: center; cursor: help; }
.warnicon svg { width: 16px; height: 16px; }

/* ---------------- Gráfica ---------------- */
.readout { border: 1px solid var(--border); border-radius: 5px; min-height: 33px; display: flex; align-items: center; justify-content: center; padding: 4px 11px; }
.readout .ro { display: grid; grid-template-columns: 1fr 65px 65px 45px; width: 100%; font-size: 14px; align-items: center; }
.readout .ro p:first-child { color: var(--label); }
.readout .ro p:last-child { color: var(--sub); text-align: right; }
.readout .ro .pop, .readout .ro .ind { text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; font-size: 14px; color: var(--label); }
.legend span { display: inline-flex; align-items: center; gap: 3px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.range-row { display: flex; justify-content: flex-end; margin: 3px 0 0; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; user-select: none; }
svg .ther-range { fill: var(--band); fill-opacity: .5; }
svg .tox-line { stroke: var(--tox); stroke-width: 2; }
svg .serum-pt { fill: var(--serum); stroke: var(--serum); stroke-width: 2; }
svg .serum-pt.off { fill: #fff; }
svg .domain { stroke: var(--text); stroke-width: 1; }
svg .ax-t { font-size: 10px; fill: var(--text); font-family: var(--font); }
svg .svg-text { font-size: 14px; fill: #000; }
svg .ax-label { font-size: 12px; }
svg .y-crosshair { stroke: #ccc; stroke-width: 1; }
svg .marker-line { stroke: #CCCCCC; stroke-width: 2; stroke-dasharray: 3 3; }
svg .brush-sel { fill: #777; fill-opacity: .3; stroke: #fff; cursor: move; }
svg .brush-handle { fill: transparent; cursor: ew-resize; }
svg .aux-bottom { stroke: #000; }
.readrow { display: grid; grid-template-columns: 44px 109px 56px 1fr 1fr 40px; gap: 8px; align-items: center; margin: 8px 6px; font-size: 14px; }
.readrow .tbtn { color: var(--muted); }
.readrow .dtseg { height: 30px; padding: 0 4px; }
.readrow p { text-align: center; }
.readrow .u { color: var(--sub); }
.readrow.auc { grid-template-columns: 1fr 85px 85px 60px; margin-left: 110px; color: var(--sub); }

/* ---------------- Estado estable ---------------- */
.ss-body { display: grid; grid-template-columns: 191px 1fr; gap: 16px; margin-top: 8px; }
.ss-in .lbl { margin-top: 8px; }
.ss-in input, .ss-in select { margin-top: 4px; }
.ss-in .sub16 { margin-bottom: 4px; }
.rec-head, .pred-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pred-head .ph { width: 72px; text-align: center; font-size: 16px; }
.pred-head .sub16 { flex: 1; }
.ld-row { display: flex; align-items: center; justify-content: space-between; margin: 12px 0; }
.ld-box { width: 117px; min-height: 21px; border-radius: 5px; background: rgba(23,116,207,.25); text-align: right; padding: 0 6px; font-size: 14px; font-weight: 500; color: var(--blue); }
.ld-box.pop { background: rgba(229,45,2,.2); color: var(--pop); }
.nomo-wrap { position: relative; padding: 24px 0 0 20px; }
.nomo-inf { position: absolute; top: 0; left: 20px; font-size: 14px; font-weight: 500; }
.nomo-int { position: absolute; left: -2px; top: 60px; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 14px; font-weight: 500; }
table.nomo { border: 1px solid var(--border); border-radius: 5px; border-spacing: 0; }
table.nomo td { height: 39px; border-left: 1px solid var(--border); border-top: 1px solid var(--border); text-align: center; padding: 0 4px; font-size: 14px; font-weight: 500; }
table.nomo tr:first-child td { border-top: 0; }
table.nomo td:first-child { border-left: 0; width: 37px; }
table.nomo input { height: 20px; width: 64px; border: 0; border-radius: 5px; background: rgba(137,139,143,.15); text-align: center; font-size: 14px; padding: 0; }
table.nomo td:first-child input { width: 28px; }
table.nomo td.cell { cursor: pointer; width: 74px; }
table.nomo td.cell.pop { color: var(--pop); }
table.nomo td.cell.ind { color: var(--blue); }
table.nomo td.cell:hover { background: var(--hover); }
table.nomo td.cell.sel.pop { background: var(--pop); color: #fff; }
table.nomo td.cell.sel.ind { background: var(--blue); color: #fff; }
.predgrid { display: grid; grid-template-columns: 1fr 72px 72px; row-gap: 12px; align-items: center; font-size: 14px; }
.predgrid .k { font-weight: 500; color: var(--title); }
.predgrid .k small { display: block; font-weight: 400; color: var(--muted); font-size: 14px; }
.predgrid .v { text-align: center; font-weight: 500; }

/* ---------------- Diálogos ---------------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.48); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding-top: 64px; }
.modal-box { background: #fff; border-radius: 6px; box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05); padding: 16px 24px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.modal-box.w700 { width: 700px; }
.modal-box.w560 { width: 560px; }
.modal-box.w448 { width: 448px; }
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.modal-title { font-size: 20px; font-weight: 600; color: var(--text); }
.closebtn { margin-left: auto; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 6px; display: grid; place-items: center; color: var(--text); }
.closebtn:hover { background: var(--grey); }
.closebtn svg { width: 14px; height: 14px; }
.mscroll { overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.reg-form { display: grid; grid-template-columns: 133px 200px; row-gap: 8px; align-items: center; }
.reg-form > input { width: 125px; }
#rgEnd { display: flex; flex-direction: column; gap: 4px; }
.reg-form .dtseg { width: 125px; justify-content: center; }
.popover { position: fixed; z-index: 60; max-width: 560px; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 10px 15px -3px rgba(0,0,0,.1); padding: 12px 16px; font-size: 14px; line-height: 1.5; }
.popover h4 { margin: 0 0 6px; font-size: 14px; }
.popover ul { margin: 4px 0; padding-left: 18px; }
.popover .src { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------------- Impresión ---------------- */
@media print {
  .topbar, .sidebar, .card-foot, .linkbtn, .btn-outline, .btn-primary, .range-row, .modal, .readrow, .popover { display: none !important; }
  .shell { padding-top: 0; }
  .page { display: block !important; }
  #page-home { display: none !important; }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .card { break-inside: avoid; box-shadow: none; }
  .card.h470 { height: auto; }
  .scroll346 { max-height: none; }
}

/* ---------------- Ancho < 1280 px: una columna de 660 px y barra lateral de 240 px (como PrecisePK) ---------------- */
@media (max-width: 1279px) {
  .grid2 { grid-template-columns: 660px; }
  .sidebar { width: 240px; flex-basis: 240px; }
  .content { overflow-x: auto; }
}
.recrow .k svg { width: 16px; height: 16px; flex: 0 0 16px; color: var(--label); }
.export-box svg { vertical-align: -1px; }
.range-row { align-items: center; gap: 8px; }
.zoombtns { display: flex; gap: 4px; margin-right: auto; }
.zoombtns button { height: 25px; min-width: 25px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); font-size: 14px; line-height: 1; }
.zoombtns button:hover { background: var(--grey); }
.zoom-hint { font-size: 12px; color: var(--muted); }

/* ---------------- Ajustes de encuadre de textos ---------------- */
.btn-outline.wide { white-space: normal; height: auto; min-height: 40px; line-height: 1.25; padding: 4px 8px; }
.kv { grid-template-columns: max-content minmax(0, 1fr); column-gap: 10px; }
.kv p { word-break: normal; overflow-wrap: anywhere; }
.kv p:nth-child(odd) { overflow-wrap: normal; white-space: nowrap; }
.pkside { grid-template-columns: max-content 1fr 1fr; column-gap: 12px; }
.side-head span { padding-right: 6px; }
/* Tablas editables: anchos mínimos para que ningún valor quede cortado */
table.edit select { min-width: 96px; }
table.edit input[type=number] { min-width: 64px; }
table.edit td.num { width: 28px; }
table.edit .dtseg { white-space: nowrap; }
#doseTable td:nth-child(8), #levelTable td:nth-child(7), #levelTable td:nth-child(8) { width: 28px; }
#levelTable input[type=number] { min-width: 70px; }
#dialTable select { min-width: 150px; }
.predbox { min-width: 118px; }
.lab-row { grid-template-columns: max-content 93px max-content 1fr; }
.lab-row .radio { white-space: nowrap; }
.pform .lbl { overflow-wrap: normal; }
.readrow { grid-template-columns: 48px max-content max-content 1fr 1fr 44px; }
.legend { gap: 4px 14px; }
.range-row .selwrap.w120 { width: 140px; }
table.edit td { padding: 2px 1px; }
#doseTable td:nth-child(6) input, #doseTable td:nth-child(7) input { min-width: 50px; }
#doseTable select { min-width: 86px; }
#doseTable td:nth-child(5) input { min-width: 58px; }
#doseTable td:nth-child(6) input, #doseTable td:nth-child(7) input { min-width: 44px; }
#doseTable td:nth-child(5) input { min-width: 54px; }
#doseTable td:nth-child(6) input, #doseTable td:nth-child(7) input { min-width: 40px; }
#doseTable .dtseg { padding: 0 2px; }
.drug-row .lbl { width: 90px; white-space: nowrap; }
/* Tarjetas de una misma fila con la misma altura */
.grid2 { align-items: stretch; }
.grid2 > .card { display: flex; flex-direction: column; }
.readrow .dtseg input { width: 21px; }
.readrow .dtseg input.y { width: 36px; }
.readrow { grid-template-columns: 48px max-content max-content 1fr 1fr 44px; }
/* Barra lateral más ancha para que los valores quepan completos */
.sidebar { width: 270px; flex: 0 0 270px; }
.btn-outline.wide { width: 100%; }
.kv p, .kv p:nth-child(even) { overflow-wrap: normal; word-break: keep-all; }
.pkside { grid-template-columns: 70px 1fr 1fr; }
@media (max-width: 1359px) {
  .grid2 { grid-template-columns: 660px; }
  .sidebar { width: 270px; flex-basis: 270px; }
  .content { overflow-x: auto; }
}
/* Tarjeta «Paciente»: columnas flexibles dentro del ancho de la tarjeta */
.pform { grid-template-columns: 82px minmax(0, 1fr) 60px minmax(0, 1fr); column-gap: 8px; }
.pform > input, .pform .dt-host, .pform .dtseg { width: 100%; min-width: 0; }
.pform .segctl { width: 100%; justify-content: space-between; padding: 2px 3px; gap: 2px; }
.pform #pSex button { flex: 1; padding: 0 2px; }
.unit-row { min-width: 0; }
.unit-row input { flex: 1 1 auto; width: auto; min-width: 0; }
.unit-row .segctl { width: auto; flex: 0 0 auto; }
.unit-row .segctl button { width: 30px; }
/* Tablas informativas: valores con espacio suficiente */
#renalTable td:nth-child(2), #bodyTable td:nth-child(2) { white-space: nowrap; }
.lab-row { grid-template-columns: max-content 80px max-content minmax(0, 1fr); }
.lab-row .linkbtn { white-space: normal; text-align: right; }
/* Logo del Hospital Santa Isabel en la franja roja */
.logo { width: 52px; height: 52px; flex: 0 0 52px; background: #fff; overflow: hidden; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 2px 6px rgba(0,0,0,.25); }
.logo img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.09); display: block; }
.brand { gap: 12px; }
/* Información del paciente: filas alineadas (arriba y abajo) */
.grid2 > .col.stack { display: flex; flex-direction: column; gap: 12px; }
.grid2 > .col.stack > .card:last-child { flex: 1 1 auto; }
#page-patient .grid2 > .card .row-between { margin-top: auto; padding-top: 8px; }

/* ---------------- Inicio de sesión (versión publicada) ---------------- */
html.auth-locked .topbar, html.auth-locked .shell { visibility: hidden; }
#login-back { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #8f1d17 0%, var(--header) 55%, #7a1712 100%); font-family: var(--font); }
.login-card { background: #fff; border-radius: 12px; padding: 28px; width: min(360px, 92vw); box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.login-logo { display: block; width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; object-fit: cover; }
.login-card h2 { text-align: center; margin: 10px 0 2px; font-size: 20px; color: var(--title); }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-card label { display: block; font-size: 12px; color: var(--label); margin-bottom: 3px; }
.login-card input { margin-bottom: 12px; }
#lg-btn { width: 100%; height: 40px; border: 0; border-radius: 6px; background: var(--header); color: #fff; font-size: 14px; font-weight: 600; margin-top: 4px; }
#lg-btn:disabled { opacity: .7; }
#lg-err { color: #b32424; font-size: 13px; text-align: center; margin-top: 10px; min-height: 16px; }
.login-msg { background: #fde8e8; color: #b32424; padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px; }
.logout { height: 32px; align-self: center; padding: 0 12px; border: 1px solid rgba(255,255,255,.5); border-radius: 6px; background: transparent; color: #fff; font-size: 13px; white-space: nowrap; }
.logout:hover { background: rgba(255,255,255,.12); }
input[type=password] { height: 35px; border: 1px solid var(--border); border-radius: 6px; padding: 0 10px; font-size: 14px; color: var(--text); background: #fff; width: 100%; outline: none; }
input[type=password]:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
