/* Cabecera — estilo clínico: superficies claras, un acento verde azulado, tipografía grande y áreas táctiles amplias. */
:root {
  --bg: #f6f8f9; --surface: #ffffff; --surface2: #f0f4f5; --line: #dde4e7; --text: #13212b; --muted: #5d6e78;
  --accent: #0f766e; --accent-2: #115e59; --accent-soft: #e0f2ef; --on-accent: #ffffff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --warn2: #c2410c; --warn2-soft: #ffedd5;
  --bad: #b91c1c; --bad-soft: #fee2e2; --info: #1d4ed8; --info-soft: #dbeafe; --purple: #6d28d9; --purple-soft: #ede9fe;
  --b-libre: #16a34a; --b-ocupada: #2563eb; --b-sucia: #d97706; --b-bloqueada: #64748b; --b-alta: #7c3aed;
  --shadow: 0 1px 2px rgba(16, 33, 43, .06), 0 2px 8px rgba(16, 33, 43, .05);
  --r: 12px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1418; --surface: #141e24; --surface2: #1a262d; --line: #2a3a43; --text: #e4ecef; --muted: #95a7b1;
    --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #123c38; --on-accent: #04201d;
    --ok: #4ade80; --ok-soft: #12321f; --warn: #fbbf24; --warn-soft: #3a2c0b; --warn2: #fb923c; --warn2-soft: #3d2210;
    --bad: #f87171; --bad-soft: #3f1515; --info: #93c5fd; --info-soft: #172a4a; --purple: #c4b5fd; --purple-soft: #2c2050;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1418; --surface: #141e24; --surface2: #1a262d; --line: #2a3a43; --text: #e4ecef; --muted: #95a7b1;
  --accent: #2dd4bf; --accent-2: #5eead4; --accent-soft: #123c38; --on-accent: #04201d;
  --ok: #4ade80; --ok-soft: #12321f; --warn: #fbbf24; --warn-soft: #3a2c0b; --warn2: #fb923c; --warn2-soft: #3d2210;
  --bad: #f87171; --bad-soft: #3f1515; --info: #93c5fd; --info-soft: #172a4a; --purple: #c4b5fd; --purple-soft: #2c2050;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; margin: .2rem 0 .7rem; } h4 { margin: 1rem 0 .4rem; }
h1 small { font-weight: 400; color: var(--muted); font-size: .9rem; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--surface2); padding: 1px 5px; border-radius: 5px; }
small, .sm { font-size: .84rem; } .muted { color: var(--muted); } .neg { color: var(--bad); } .r { text-align: right; } .nowrap { white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.loading { padding: 2rem; color: var(--muted); } .loading.full { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.logo-dot { display: inline-block; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.logo-dot::before, .logo-dot::after { content: ""; position: absolute; background: var(--on-accent); border-radius: 1px; }
.logo-dot::before { left: 11px; top: 6px; width: 6px; height: 16px; } .logo-dot::after { left: 6px; top: 11px; width: 16px; height: 6px; }

/* ---------- botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .5rem 1rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { color: var(--bad); border-color: transparent; background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.btn.big { min-height: 52px; font-size: 1.05rem; padding: .7rem 1.4rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.fld { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; min-width: 0; }
.fld > span { font-size: .88rem; font-weight: 600; color: var(--muted); }
.fld.big > span { font-size: 1.05rem; color: var(--text); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; min-height: 44px; width: 100%; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.fld.big input { font-size: 1.3rem; min-height: 56px; }
.chk { display: flex; gap: .55rem; align-items: flex-start; padding: .4rem 0; cursor: pointer; }
.chk input { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 2px; accent-color: var(--accent); }
.grid2, .grid3, .grid-form { display: grid; gap: 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .span4 { grid-column: 1 / -1; } .full { grid-column: 1 / -1; }
.ok-box, .err-box, .info-box { padding: .75rem 1rem; border-radius: 10px; margin: .5rem 0; }
.ok-box { background: var(--ok-soft); color: var(--ok); } .err-box { background: var(--bad-soft); color: var(--bad); font-weight: 600; } .info-box { background: var(--info-soft); color: var(--info); }
.row-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .5rem 0 1rem; }
.row-actions input { max-width: 320px; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .15rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700;
  background: var(--surface2); color: var(--muted); border: 1px solid transparent; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.warn2 { background: var(--warn2-soft); color: var(--warn2); } .chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); } .chip.purple { background: var(--purple-soft); color: var(--purple); }
.chip.ctl { background: var(--warn2-soft); color: var(--warn2); border-color: var(--warn2); }
.chip.allergy { background: var(--bad); color: #fff; white-space: normal; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0; }

/* ---------- barra superior ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .8rem; padding: .5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .brand { display: flex; align-items: center; gap: .5rem; color: var(--text); text-decoration: none; font-size: 1.05rem; }
.demo-badge { background: var(--warn-soft); color: var(--warn); font-weight: 800; font-size: .75rem; padding: .15rem .5rem; border-radius: 6px; letter-spacing: .05em; }
.mainnav { display: flex; gap: .2rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.mainnav a { padding: .6rem .8rem; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; white-space: nowrap; }
.mainnav a.on, .mainnav a:hover { background: var(--accent-soft); color: var(--accent); }
.top-actions { display: flex; gap: .4rem; align-items: center; margin-left: auto; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.user-btn { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; padding: .3rem .7rem; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.user-btn small { color: var(--muted); }
.btn.contingencia { border-color: var(--warn); color: var(--warn); }
main#view { padding: 1rem; max-width: 1400px; margin: 0 auto; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: .3rem 0 1rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.occ { font-size: 1.05rem; color: var(--muted); } .occ b { color: var(--text); font-size: 1.3rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: thin; }
.tabs a { padding: .7rem .9rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- tablero de camas ---------- */
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: .4rem 0 1rem; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: .35rem; } .lg i { width: 14px; height: 14px; border-radius: 4px; background: var(--c); display: inline-block; }
.st-libre { --c: var(--b-libre); } .st-ocupada { --c: var(--b-ocupada); } .st-sucia { --c: var(--b-sucia); } .st-bloqueada { --c: var(--b-bloqueada); } .st-alta { --c: var(--b-alta); }
.floor h2 { margin: 1rem 0 .5rem; }
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.room { background: var(--surface2); border-radius: var(--r); padding: .6rem; }
.room-h { font-weight: 700; margin-bottom: .4rem; } .room-h small { color: var(--muted); font-weight: 400; }
.beds { display: grid; gap: .5rem; }
.bed { text-align: left; width: 100%; border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 10px; background: var(--surface); color: var(--text);
  padding: .6rem .7rem; font: inherit; cursor: pointer; min-height: 64px; box-shadow: var(--shadow); }
.bed:hover { border-color: var(--c); }
.bed-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.bed-top b { font-size: 1.15rem; } .bed .st { font-size: .78rem; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: .03em; }
.bed-pt { font-weight: 700; font-size: 1.02rem; margin-top: .2rem; } .bed-meta, .bed-dx { font-size: .85rem; color: var(--muted); }
.bed-dx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bed-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.bed.st-libre { background: color-mix(in srgb, var(--b-libre) 7%, var(--surface)); }
.bed.st-sucia { background: color-mix(in srgb, var(--b-sucia) 10%, var(--surface)); }
.bed.st-bloqueada { background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 8px, var(--surface2) 8px, var(--surface2) 16px); }
.bed.st-alta { background: color-mix(in srgb, var(--b-alta) 8%, var(--surface)); }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 1rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th, .tbl td { padding: .55rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl thead th { background: var(--surface2); font-size: .82rem; color: var(--muted); position: sticky; top: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--accent-soft); }
.tbl tr.off td { opacity: .5; } .tbl td.low { color: var(--bad); } .tbl tr.tot td { font-weight: 700; background: var(--surface2); }
.annulled, .annulled td { text-decoration: line-through; opacity: .6; }
.annulled .chip, .note.annulled header .chip { text-decoration: none; }
td.f-ambar, .vv.f-ambar { background: var(--warn-soft); color: var(--warn); font-weight: 700; }
td.f-rojo, .vv.f-rojo { background: var(--bad-soft); color: var(--bad); font-weight: 800; }

/* ---------- banner del paciente ---------- */
.pt-banner { position: sticky; top: 61px; z-index: 20; display: flex; gap: 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: var(--r); padding: .7rem 1rem; margin-bottom: .6rem; box-shadow: var(--shadow); }
.pb-name b { font-size: 1.3rem; } .pb-name span { color: var(--muted); margin-left: .4rem; }
.pb-meta { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .9rem; color: var(--muted); margin-top: .2rem; }
.pb-side { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; max-width: 100%; }
.pb-side .chip.allergy { font-size: .95rem; padding: .35rem .8rem; }
.bedtag { background: var(--accent); color: var(--on-accent); font-weight: 800; padding: .05rem .5rem; border-radius: 6px; }

/* ---------- expediente ---------- */
.olist { margin: 0; padding-left: 1.1rem; } .olist li { margin: .25rem 0; }
.sbar { margin: 0; } .sbar dt { font-weight: 800; color: var(--accent); margin-top: .5rem; } .sbar dd { margin: .1rem 0 0; }
.vgrid { display: flex; flex-wrap: wrap; gap: .4rem; } .vv { padding: .3rem .6rem; border-radius: 8px; background: var(--surface2); }
.order { display: flex; gap: 1rem; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem .9rem; margin-bottom: .5rem; flex-wrap: wrap; }
.order.suspendida { opacity: .7; border-style: dashed; } .order.completada { opacity: .7; }
.o-main { display: flex; gap: .6rem; flex: 1 1 400px; min-width: 0; } .o-ico { font-size: 1.3rem; }
.o-ind { font-size: .9rem; } .o-meta { font-size: .82rem; color: var(--muted); margin-top: .2rem; } .o-ev { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.o-res { margin-top: .4rem; padding: .4rem .6rem; background: var(--info-soft); border-radius: 8px; font-size: .9rem; }
.o-act { display: flex; flex-wrap: wrap; gap: .3rem; align-items: flex-start; }
.sets { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .6rem; }
.orow { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 .7rem; padding: .3rem .8rem .2rem; }
.orow legend { font-weight: 700; padding: 0 .3rem; } .orow .rm { min-height: 28px; padding: 0 .5rem; }
.grid-ord { display: grid; gap: 0 .8rem; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.note header { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.nf { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: .25rem 1rem; margin: 0; }
.nf dt { color: var(--muted); font-size: .88rem; font-weight: 600; } .nf dd { margin: 0; white-space: pre-wrap; }
.note .sig { font-size: .85rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: .5rem; margin-top: .7rem; }
.addendum { background: var(--warn-soft); border-radius: 8px; padding: .5rem .7rem; margin-top: .4rem; font-size: .92rem; }
.note footer { display: flex; gap: .4rem; margin-top: .4rem; }
.draft { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; border-style: dashed; }
.picks { display: flex; flex-wrap: wrap; gap: .3rem; margin: -.4rem 0 .8rem; }
.pick { border: 1px solid var(--line); background: var(--surface2); color: var(--text); border-radius: 999px; padding: .35rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; min-height: 36px; }
.pick:hover { border-color: var(--accent); }
.grid-v { display: grid; gap: 0 .8rem; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; }
.vform input { font-size: 1.1rem; }
.vfoot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.news-pre { font-weight: 700; }
.scales .card { margin: 0; } .sc-item { border: 0; padding: 0; margin: 0 0 .6rem; } .sc-item legend { font-weight: 700; font-size: .92rem; margin-bottom: .2rem; }
.sc-item .chk { padding: .2rem 0; } .sc-total { font-weight: 800; font-size: 1.1rem; }
.eva { display: grid; grid-template-columns: repeat(11, 1fr); gap: 3px; }
.eva label { display: block; } .eva input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.eva span { display: grid; place-items: center; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); font-weight: 700; cursor: pointer; }
.eva input:checked + span { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.eva input:focus-visible + span { outline: 3px solid var(--accent); }

/* ---------- MAR ---------- */
.mar-head { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; } .mar-head input[type=date] { width: auto; }
.turnos { display: flex; gap: .3rem; }
.mar-row { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .7rem; margin-bottom: .5rem; }
.mar-row.susp { opacity: .6; }
.mar-slots { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.slot { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 88px; min-height: 60px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--surface2); color: var(--text); font: inherit; cursor: pointer; padding: .2rem .5rem; }
.slot b { font-size: 1.05rem; } .slot span { font-size: .78rem; font-weight: 700; }
.s-toca { border-color: var(--info); background: var(--info-soft); color: var(--info); }
.s-atrasada { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.s-administrada { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.s-omitida, .s-rechazada { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.s-prn { border-style: dashed; border-color: var(--accent); color: var(--accent); }
.slot-lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid; vertical-align: middle; margin: 0 .25rem 0 .8rem; }
.five { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; }
.five li { padding: .4rem .7rem; border-radius: 8px; font-weight: 700; background: var(--surface2); }
.five li.ok { background: var(--ok-soft); color: var(--ok); } .five li.bad { background: var(--bad-soft); color: var(--bad); }
.radio-row { display: flex; flex-wrap: wrap; gap: 0 1.2rem; }
.scan-card { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; } .scan-card .fld { flex: 1 1 280px; margin: 0; }

/* ---------- enfermería y otros ---------- */
.nurse-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: .8rem; }
.nurse-card { margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.nurse-card header a { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.05rem; }
.nurse-card footer { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: auto; padding-top: .4rem; }
.new-orders { background: var(--info-soft); border-radius: 8px; padding: .5rem .7rem; } .new-orders ul { margin: .3rem 0 .5rem; padding-left: 1.1rem; font-size: .9rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .88rem; font-weight: 600; } .kpi b { font-size: 1.6rem; } .kpi small { color: var(--muted); }
.kpi.neg b { color: var(--bad); }
.stack { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: var(--surface2); } .stack div { background: var(--c); }
.hbar { display: grid; grid-template-columns: 110px 1fr auto; gap: .6rem; align-items: center; margin: .35rem 0; font-size: .9rem; }
.hbar div { background: var(--surface2); border-radius: 6px; height: 14px; } .hbar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
.dash .card { margin: 0; } .dash { gap: 1rem; margin-bottom: 1rem; }
.cfg-room { padding: .4rem 0; border-top: 1px solid var(--line); } .cfg-room .chip { cursor: pointer; border: 2px solid var(--c); background: var(--surface); color: var(--text); font-size: .9rem; min-height: 32px; }
.doc-btns { display: flex; flex-wrap: wrap; gap: .4rem; }
.search-pt { position: relative; } .pt-res { display: grid; gap: .3rem; margin: -.4rem 0 .8rem; }
.pt-row { text-align: left; border: 1px solid var(--line); background: var(--surface2); color: var(--text); border-radius: 8px; padding: .6rem .8rem; font: inherit; cursor: pointer; }
.allergy-box { display: flex; gap: .6rem; align-items: center; background: var(--bad-soft); border-radius: 10px; padding: .6rem .8rem .1rem; margin: .4rem 0 .8rem; }
.allergy-box .fld { flex: 1; } .allergy-box .fld > span { color: var(--bad); }
details.ins, details { margin: .6rem 0; } summary { cursor: pointer; font-weight: 700; padding: .4rem 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }
.legal { background: var(--surface2); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; margin-bottom: .6rem; max-height: 160px; overflow: auto; }
.sig-wrap { display: flex; flex-direction: column; gap: .3rem; } .sig-wrap span { font-weight: 600; color: var(--muted); font-size: .88rem; }
.sigpad { width: 100%; max-width: 600px; aspect-ratio: 10 / 3; border: 2px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.audit td { font-size: .82rem; }

/* ---------- ventanas y avisos ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(8, 20, 26, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); display: flex; flex-direction: column; }
.modal.wide { max-width: 980px; }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 1.15rem; }
.modal .x { border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; width: 44px; height: 44px; cursor: pointer; }
.modal-body { padding: 1rem 1.1rem; } .modal footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.lead { font-size: 1.05rem; }
.warnmodal header { background: var(--bad-soft); border-radius: 16px 16px 0 0; } .warnmodal header h2 { color: var(--bad); }
.alerts { padding-left: 1.2rem; } .alerts li { margin: .35rem 0; font-weight: 700; } .alerts .al-alergia { color: var(--bad); font-size: 1.1rem; }
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; width: min(560px, calc(100% - 2rem)); }
.toast { padding: .8rem 1rem; border-radius: 10px; color: #fff; background: #134e4a; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); }
.toast.bad { background: #991b1b; } .toast.info { background: #1e3a8a; }
.idle-warn { position: fixed; top: 0; left: 0; right: 0; z-index: 150; background: var(--warn-soft); color: var(--warn); padding: .7rem 1rem; display: flex; gap: 1rem; align-items: center; justify-content: center; flex-wrap: wrap; font-weight: 700; border-bottom: 2px solid var(--warn); }

/* ---------- acceso e instalación ---------- */
.login, body.install { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card, .install-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.6rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.install-card { max-width: 720px; } .install-card h1 { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.login .brand { display: flex; gap: .7rem; align-items: center; margin-bottom: 1rem; } .login .brand b { display: block; font-size: 1.2rem; } .login .brand small { color: var(--muted); }
.login-card .btn { width: 100%; }
.demo-note { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: .5rem .7rem; font-weight: 700; }
.checks { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; } .checks .ok { color: var(--ok); } .checks .bad { color: var(--bad); font-weight: 700; }

/* ---------- pantallas chicas (teléfono) ---------- */
@media (max-width: 900px) {
  .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-v { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-ord { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mar-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  main#view { padding: .7rem; }
  .top { padding: .4rem .6rem; gap: .4rem; }
  .top .brand b { max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mainnav { order: 3; flex-basis: 100%; }
  .user-btn small, .btn.contingencia { font-size: .8rem; } .user-btn span { max-width: 28vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .grid2, .grid3, .grid-form { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .grid-v, .grid-ord { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pt-banner { position: static; }
  .nf { grid-template-columns: 1fr; } .nf dt { margin-top: .4rem; }
  .rooms, .nurse-list { grid-template-columns: minmax(0, 1fr); }
  .eva { grid-template-columns: repeat(6, 1fr); }
  .hbar { grid-template-columns: 80px 1fr auto; }
  .modal-back { padding: 0; } .modal { border-radius: 0; min-height: 100vh; }
  h1 { font-size: 1.25rem; }
}
/* ---------- Cabecera: marca, demostración y piezas comunes ---------- */
.brandmark { display: inline-flex; align-items: center; gap: .45rem; }
.brandmark .logo { display: block; border-radius: 8px; flex: none; }
.wordmark { font-weight: 800; letter-spacing: -.02em; font-size: 1.25rem; color: var(--text); text-transform: lowercase; }
.brandmark.big .wordmark { font-size: 1.9rem; }
.brandmark.big .logo { border-radius: 11px; }
.top .brand .clinic-name { color: var(--muted); font-size: .82rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-clinic { margin: -.4rem 0 1rem; color: var(--muted); }
.demo-banner { background: #b45309; color: #fff; text-align: center; font-weight: 800; padding: .35rem 1rem; font-size: .92rem; letter-spacing: .02em; position: relative; z-index: 40; }
.demo-pick { margin-bottom: 1rem; } .demo-pick h2 { margin: 0 0 .2rem; font-size: 1.15rem; }
.demo-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin: .7rem 0; }
.demo-roles .btn { width: 100%; border-color: var(--accent); color: var(--accent); }
.demo-pick details { margin-top: .6rem; }
.login-card { max-width: 460px; }
.cie-wrap { position: relative; }
.cie-res { display: grid; gap: .2rem; position: absolute; left: 0; right: 0; top: 100%; z-index: 60; background: var(--surface); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); border-radius: 10px; max-height: 300px; overflow-y: auto; }
.cie-res:empty { display: none; }
.cie-opt { text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); padding: .55rem .7rem; font: inherit; cursor: pointer; }
.cie-opt:hover, .cie-opt:focus { background: var(--accent-soft); }
.cie-res .muted { padding: .5rem .7rem; margin: 0; }
.fld-dict { position: relative; }
.fld-dict .dict-btn { position: absolute; right: 0; top: -.15rem; }
.dict-btn.rec { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.scan-row { display: flex; gap: .4rem; align-items: stretch; } .scan-row input { flex: 1; min-width: 0; }
.cam-btn { min-width: 52px; font-size: 1.2rem; }
.cam-box { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; max-height: 60vh; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-aim { position: absolute; inset: 18% 15%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); }
.btn.wa { background: #15803d; border-color: #15803d; color: #fff; }
.link-box { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .5rem 0; } .link-box code { word-break: break-all; }
.qr-mini { width: 140px; background: #fff; padding: 4px; border-radius: 8px; } .qr-mini svg { width: 100%; height: auto; display: block; }
.plain { list-style: none; padding: 0; margin: 0; } .plain li { padding: .35rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .5rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.pre { white-space: pre-wrap; }
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 1rem; margin: .3rem 0 .6rem; }
.ed-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; margin: .6rem 0; }
.ed-opt { display: flex; gap: .6rem; border: 2px solid var(--line); border-radius: 12px; padding: .8rem; cursor: pointer; }
.ed-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ed-opt input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--accent); }
.ed-opt b { display: block; font-size: 1.05rem; } .ed-opt small { color: var(--muted); }

/* ---------- agenda ---------- */
.ag-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem .8rem; }
.ag-bar select { width: auto; max-width: 100%; }
.ag-bar input[type=date] { width: auto; }
.seg { display: inline-flex; gap: .25rem; align-items: center; }
.ag-title { margin: .3rem 0 .2rem; }
.ag-dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; background: var(--c, var(--accent)); vertical-align: middle; }
.ag-dot.st-agendada { background: var(--info); } .ag-dot.st-confirmada { background: var(--ok); } .ag-dot.st-llego { background: var(--warn); }
.ag-dot.st-en_consulta { background: var(--purple); } .ag-dot.st-terminada { background: var(--muted); } .ag-dot.st-no_asistio { background: var(--bad); }
.ag-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); max-width: 100%; }
.ag-grid { min-width: calc(56px + var(--cols) * 150px); }
.ag-head, .ag-body { display: grid; grid-template-columns: 56px repeat(var(--cols), minmax(150px, 1fr)); }
.ag-head { position: sticky; top: 0; z-index: 3; background: var(--surface2); border-bottom: 1px solid var(--line); }
.ag-colh { padding: .55rem .5rem; font-weight: 700; text-align: center; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-colh.today { color: var(--accent); }
.ag-times { position: relative; border-right: 1px solid var(--line); }
.ag-times span { position: absolute; left: 0; right: 4px; transform: translateY(-50%); text-align: right; font-size: .75rem; color: var(--muted); }
.ag-times span:first-child { transform: none; }
.ag-col { position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, var(--line) 0, var(--line) 1px, transparent 1px, transparent calc(var(--slot) / 2), color-mix(in srgb, var(--line) 45%, transparent) calc(var(--slot) / 2), transparent calc(var(--slot) / 2 + 1px), transparent var(--slot)); }
.ag-cita { position: absolute; left: 3px; right: 3px; border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: 8px; background: color-mix(in srgb, var(--c) 14%, var(--surface));
  color: var(--text); text-align: left; padding: .15rem .35rem; font: inherit; font-size: .82rem; line-height: 1.2; overflow: hidden; cursor: pointer; z-index: 2; }
.ag-cita small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-cita:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, .15); z-index: 4; }
.ag-cita.st-confirmada { box-shadow: inset 0 0 0 2px var(--ok); } .ag-cita.st-llego { background: var(--warn-soft); }
.ag-cita.st-en_consulta { background: var(--purple-soft); } .ag-cita.st-terminada { opacity: .6; } .ag-cita.st-no_asistio { opacity: .55; text-decoration: line-through; }
.alg-dot { color: var(--bad); font-weight: 800; }
.ag-block { position: absolute; left: 0; right: 0; z-index: 1; color: var(--muted); font-size: .78rem; padding: .2rem .4rem; cursor: pointer; overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--surface2), var(--surface2) 6px, transparent 6px, transparent 12px); border-top: 2px solid var(--line); }
.ag-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 3; pointer-events: none; }
.cita-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.pick-pac { margin-bottom: .4rem; }

/* ---------- sala de espera, recordatorios y caja ---------- */
.sala section > h3 { margin-top: 0; }
.sala-card { cursor: pointer; margin-bottom: .6rem; } .sala-card header { margin-bottom: .2rem; }
.rem { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; } .rem.sent { opacity: .75; }
.rem-act { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.caja-top { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; } .caja-top h2 { margin: 0; }
.pay-methods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin-bottom: .8rem; }
.pay-m input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pay-m span { display: grid; place-items: center; min-height: 52px; border: 2px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; text-transform: capitalize; }
.pay-m input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pay-m input:focus-visible + span { outline: 3px solid var(--accent); }

/* ---------- consulta ---------- */
.cons-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.cons-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-end; } .cons-head h2 { margin: 0 0 .6rem; }
.dictado { background: var(--accent-soft); border-radius: 12px; padding: .8rem .8rem .2rem; margin-bottom: 1rem; }
.dictado textarea { background: var(--surface); }
.imc { display: flex; align-items: center; min-height: 44px; font-weight: 800; font-size: 1.15rem; }
.dx-row { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 0 .6rem; align-items: end; }
.dx-row .dx-rm { margin-bottom: .8rem; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: .7rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; z-index: 5; }
.rx-h { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .3rem; } .rx-h h3 { margin: 0; }
.rx-row .grid-ord { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- odontograma y plan ---------- */
.odo-tools { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); }
.sw-caries { background: #dc2626; } .sw-resina { background: #2563eb; } .sw-amalgama { background: #475569; } .sw-sellador { background: #16a34a; }
.sw-corona { border: 2px solid #ca8a04; border-radius: 50%; } .sw-endodoncia { background: linear-gradient(90deg, transparent 40%, #7c3aed 40%, #7c3aed 60%, transparent 60%); }
.sw-extraccion { background: linear-gradient(45deg, transparent 42%, #dc2626 42%, #dc2626 58%, transparent 58%); } .sw-ausente { background: #cbd5e1; } .sw-implante { background: #0d9488; }
.odo-arch { overflow-x: auto; padding-bottom: .4rem; }
.teeth { display: grid; grid-template-columns: repeat(16, minmax(38px, 1fr)); gap: 3px; margin: .3rem 0; min-width: 640px; }
.teeth:has(.tooth:nth-child(10):last-child) { grid-template-columns: repeat(10, minmax(38px, 60px)); justify-content: center; }
.teeth .tooth:nth-child(8) { margin-right: 6px; }
.teeth:has(.tooth:nth-child(10):last-child) .tooth:nth-child(8) { margin-right: 0; } .teeth:has(.tooth:nth-child(10):last-child) .tooth:nth-child(5) { margin-right: 6px; }
.tooth { display: flex; flex-direction: column; align-items: center; cursor: pointer; user-select: none; }
.tooth .tn { font-size: .78rem; font-weight: 700; color: var(--muted); }
.tooth .tl { font-size: .62rem; color: var(--muted); min-height: .9rem; text-align: center; line-height: 1.1; }
.tooth-svg { width: 100%; max-width: 46px; height: auto; display: block; }
.tooth-svg polygon, .tooth-svg rect[data-s] { stroke: var(--muted); stroke-width: 1; }
.tooth-svg polygon:hover, .tooth-svg rect[data-s]:hover { stroke: var(--accent); stroke-width: 2; }
.tooth-svg.ausente { opacity: .45; }
.progress { position: relative; height: 22px; background: var(--surface2); border-radius: 8px; overflow: hidden; margin: .4rem 0 .6rem; }
.progress i { display: block; height: 100%; background: var(--ok); }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.plan tr.done td { color: var(--muted); }
.plan-head, .plan-row { display: grid; grid-template-columns: 64px 90px minmax(0, 1fr) 120px 40px; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.plan-head span { font-size: .82rem; font-weight: 700; color: var(--muted); }

@media (max-width: 900px) {
  .cons-grid { grid-template-columns: minmax(0, 1fr); }
  .ed-opts { grid-template-columns: minmax(0, 1fr); }
  .rx-row .grid-ord { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .top .brand .clinic-name { display: none; }
  .demo-roles { grid-template-columns: minmax(0, 1fr); }
  .dx-row { grid-template-columns: minmax(0, 1fr) auto; } .dx-row .cie-wrap { grid-column: 1 / -1; }
  .plan-head { display: none; }
  .plan-row { grid-template-columns: 56px minmax(0, 1fr) 40px; } .plan-row [name=descripcion] { grid-column: 1 / -1; grid-row: 2; } .plan-row [name=precio] { grid-column: 1 / 3; grid-row: 3; }
  .pay-methods { grid-template-columns: minmax(0, 1fr); }
  .ag-bar .seg { flex-wrap: wrap; }
  .fld-dict .dict-btn { position: static; margin: -.4rem 0 .6rem; }
}
@media print { .top, .tabs, .row-actions, .btn { display: none !important; } }

/* ---------- páginas para pacientes (citas en línea, mi cita, portal, verificación) ---------- */
body.pub { min-height: 100vh; }
.pub-main { padding: 1rem; display: flex; justify-content: center; }
.pub-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.3rem; width: 100%; max-width: 640px; box-shadow: var(--shadow); }
.pub-card.wide { max-width: 860px; }
.pub-card h1 { margin: .4rem 0 .8rem; } .pub-card h2 { margin: 1.2rem 0 .6rem; font-size: 1.1rem; }
.pub-head { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: .8rem; margin-bottom: .6rem; }
.pub-head > div { text-align: right; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .5rem; }
.opt { text-align: left; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); padding: .8rem; font: inherit; cursor: pointer; min-height: 60px; }
.opt b { display: block; } .opt small { color: var(--muted); }
.opt.on, .opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .4rem; }
.dias { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; } .dias .btn { text-transform: capitalize; }
.cita-big { background: var(--accent-soft); border-radius: 14px; padding: 1rem 1.2rem; margin: .6rem 0 1rem; }
.cita-big p { margin: .2rem 0; } .cita-big .when { font-size: 1.25rem; } .when::first-letter { text-transform: uppercase; }
.pub-actions { display: grid; gap: .5rem; margin: .8rem 0; } .pub-actions .btn { width: 100%; }
.big-qr { width: 200px; margin: .4rem auto; }
.qr-cita { text-align: center; }
@media (max-width: 640px) { .pub-main { padding: .5rem; } .pub-card { padding: 1rem; border-radius: 14px; } .pub-head > div { text-align: left; } }
