/* Tema único claro con fondo blanco (pedido del usuario).
   Layout: app shell — sidebar on desktop, bottom tab bar on phone; content in a single readable column per view */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --line: #d5dce8;
  --fg: #142033;
  --muted: #586579;
  --accent: var(--acc-l, #2456c9);
  --accent-fg: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --danger: #a3262a;
  --danger-bg: #fbe8e6;
  --warn: #7f5200;
  --warn-bg: #fcf0d6;
  --ok: #1b6a39;
  --ok-bg: #e2f2e7;
  --info: #1f4f86;
  --info-bg: #e5eef9;
  --shadow: 0 1px 2px rgba(20, 32, 51, .06), 0 8px 24px rgba(20, 32, 51, .08);
  --font-ui: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
  --nav-h: 64px;
}
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
* { box-sizing: border-box; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
.num, .mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Shell */
.app { display: grid; grid-template-columns: 1fr; min-height: 100%; }
.side { display: none; }
.main { min-width: 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 20px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)); }
.wrap { max-width: 1080px; margin: 0 auto; display: grid; gap: 20px; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar svg, .side nav svg { width: 22px; height: 22px; }
@media (min-width: 900px) {
  .app { grid-template-columns: 232px 1fr; }
  .tabbar { display: none; }
  .side { display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; padding: 22px 14px; padding-left: max(14px, env(safe-area-inset-left, 0px)); background: var(--surface); border-right: 1px solid var(--line); }
  .side nav { display: grid; gap: 2px; }
  .side nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--fg); text-decoration: none; font-weight: 550; }
  .side nav a:hover { background: var(--surface-2); }
  .side nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .main { padding-block: 28px 48px; padding-left: 32px; padding-right: max(32px, env(safe-area-inset-right, 0px)); }
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 700; flex: none; overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.app.login { grid-template-columns: 1fr; }
.app.login .side, .app.login .tabbar { display: none; }
.app.login .main { padding-bottom: 32px; }
.login-wrap { min-height: 100%; display: grid; place-items: center; padding-block: 24px; }
.login-card { width: 100%; max-width: 420px; gap: 18px; padding: 24px; box-shadow: var(--shadow); }
.brand-wide { background: #ffffff; border-radius: 10px; padding: 6px 10px; border: 1px solid var(--line); max-width: 260px; min-width: 0; }
.brand-wide img { display: block; height: 54px; width: auto; max-width: 100%; object-fit: contain; }
.code-box { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.code-box .field { flex: 1 1 200px; }
.code { font-family: var(--font-data); font-size: 1.05rem; font-weight: 500; letter-spacing: .06em; padding: 4px 10px; border-radius: 6px; background: var(--surface-2); user-select: all; }
.brand-name { font-weight: 650; font-size: .92rem; line-height: 1.2; min-width: 0; }
.brand-sub { font-size: .75rem; color: var(--muted); }
.side-foot { margin-top: auto; font-size: .75rem; color: var(--muted); padding: 0 6px; display: grid; gap: 4px; }
.mob-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (min-width: 900px) { .mob-head { display: none; } }

/* Primitives */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--fg); white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.sm { min-height: 44px; padding: 0 12px; font-size: .88rem; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 650; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.danger { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.plain::before { display: none; }
.alert-band { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 9px; background: var(--danger-bg); color: var(--danger); font-weight: 600; font-size: .9rem; }
.alert-band.neutral { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.alert-band.info { background: var(--info-bg); color: var(--info); font-weight: 500; }
.alert-band svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.empty { display: grid; gap: 8px; justify-items: start; padding: 22px; border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); }
.empty strong { color: var(--fg); }

/* Lists */
.list { display: grid; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 12px 4px; border-top: 1px solid var(--line); min-width: 0; }
.item:first-child { border-top: 0; }
.item .t { font-family: var(--font-data); font-size: .95rem; font-weight: 500; min-width: 3.4em; }
.item .who { min-width: 0; }
.item .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .who span { display: block; color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .acts { display: flex; gap: 6px; align-items: center; }
.item.link { cursor: pointer; border-radius: 6px; }
.item.link:hover { background: var(--surface-2); }
@media (max-width: 560px) {
  .item.cita { grid-template-columns: auto 1fr; }
  .item.cita .acts { grid-column: 1 / -1; justify-content: flex-start; }
}

/* Grids */
.cols { display: grid; gap: 20px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .cols.two { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); } .cols.even { grid-template-columns: 1fr 1fr; } }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface); padding: 14px 16px; display: grid; gap: 2px; }
.stat b { font-family: var(--font-data); font-size: 1.6rem; font-weight: 500; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.warnish b { color: var(--warn); }

/* Week strip */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { display: grid; justify-items: center; gap: 2px; padding: 8px 2px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; min-height: 64px; }
.day small { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.day b { font-family: var(--font-data); font-weight: 500; font-size: 1.1rem; }
.day i { font-style: normal; font-size: .7rem; color: var(--accent); font-weight: 650; min-height: 1em; }
.day.today b { color: var(--accent); }
.day[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.day[aria-pressed="true"] small, .day[aria-pressed="true"] i, .day[aria-pressed="true"] b { color: var(--accent-fg); }

/* Forms */
.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .search { width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
.field .unit { position: relative; }
.field .unit input { padding-right: 52px; font-family: var(--font-data); }
.field .unit em { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: .78rem; color: var(--muted); pointer-events: none; }
.field.bad input, .field.bad textarea, .field.bad select { border-color: var(--danger); }
.err { color: var(--danger); font-size: .82rem; font-weight: 600; }
.grid-f { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-f.wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.span-all { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 12px; min-width: 0; }
legend { padding: 0; margin-bottom: 4px; font-weight: 650; font-size: 1rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 10px 14px; font-weight: 600; font-size: .9rem; min-height: 44px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-fg); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.repeat { display: grid; gap: 10px; }
.rep-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.rep-row .grid-f { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--danger); }
.icon-btn svg { width: 18px; height: 18px; }
.computed { min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 8px; background: var(--surface-2); font-family: var(--font-data); }
.computed small { font-family: var(--font-ui); color: var(--muted); font-size: .78rem; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; background: var(--surface); min-height: 44px; }
.swatch i { width: 30px; height: 30px; border-radius: 50%; display: block; }
.swatch[aria-pressed="true"] { border-color: var(--fg); box-shadow: 0 0 0 1px var(--fg); }

/* Patient header */
.p-head { display: grid; gap: 12px; }
.p-name { font-size: 1.75rem; font-weight: 650; letter-spacing: -.015em; }
.p-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .92rem; }
.p-meta b { color: var(--fg); font-weight: 600; }
.kv { display: grid; gap: 10px; }
.kv div { display: grid; gap: 2px; }
.kv p { margin: 0; white-space: pre-wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem; min-height: 44px; }
.back svg { width: 16px; height: 16px; }
.charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.chart { display: grid; gap: 4px; }
.chart .big { font-family: var(--font-data); font-size: 1.3rem; font-weight: 500; }
.chart .delta { font-size: .8rem; font-weight: 600; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }

/* Nota editor */
.nota-wrap { max-width: 860px; }
.nota-form { display: grid; gap: 16px; }
.actionbar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); z-index: 15; display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 12px 14px; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
@media (min-width: 900px) { .actionbar { bottom: 16px; } }
.save-state { font-size: .82rem; color: var(--muted); }

/* Sheet (modal) */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(8, 14, 12, .45); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .scrim { align-items: center; padding: 24px; } }
.sheet { width: 100%; max-width: 680px; max-height: calc(100% - 24px - env(safe-area-inset-top, 0px)); overflow: auto; background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow); display: grid; gap: 16px; padding: 20px max(18px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); }
@media (min-width: 700px) { .sheet { border-radius: 16px; max-height: 100%; } }
.sheet.wide { max-width: 940px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; position: sticky; top: -20px; background: var(--surface); padding-top: 4px; z-index: 2; }
.sheet form { display: grid; gap: 18px; }
.sheet-foot { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 9px; font-weight: 600; font-size: .9rem; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* Paper (print document). Deliberately fixed paper colors: it is a letter-size sheet that becomes a PDF. */
.paper-frame { overflow: hidden; border-radius: 6px; box-shadow: var(--shadow); background: #fff; }
.paper { width: 816px; min-height: 1056px; background: #ffffff; color: #1a1f1d; font-family: var(--font-ui); font-size: 12.5px; line-height: 1.45; padding: 52px 60px 40px; display: flex; flex-direction: column; gap: 14px; transform-origin: top left; }
.paper.receta { min-height: 0; }
/* Buscador CIE-10 */
.cie-wrap { position: relative; }
.field > .lbl { font-size: .8rem; font-weight: 600; color: var(--muted); }
.cie-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); max-height: 320px; overflow: auto; }
.cie-head { padding: 6px 10px 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.cie-opt { display: grid; grid-template-columns: 4.4em minmax(0, 1fr); gap: 10px; padding: 9px 10px; border-radius: 6px; cursor: pointer; align-items: baseline; }
.cie-opt[aria-selected="true"], .cie-opt:hover { background: var(--accent-soft); }
.cie-opt code { font-family: var(--font-data); font-weight: 500; color: var(--accent); font-size: .9rem; }
.cie-opt span { min-width: 0; }
.cie-opt small { display: block; color: var(--muted); font-size: .76rem; }
.cie-opt mark { background: none; color: inherit; font-weight: 700; }
.cie-empty { padding: 10px; color: var(--muted); font-size: .88rem; }
.pp-head { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; padding-bottom: 14px; border-bottom: 2px solid var(--paper-acc, #2456c9); }
.pp-logo { width: 78px; height: 78px; object-fit: contain; }
.pp-logo.wide { width: auto; height: 84px; max-width: 300px; }
.pp-logo.mono { display: grid; place-items: center; background: var(--paper-acc, #1d6b58); color: #fff; font-weight: 700; font-size: 26px; border-radius: 10px; }
.pp-doc h1 { font-size: 19px; font-weight: 700; color: #111; letter-spacing: -.005em; }
.pp-doc p { margin: 1px 0 0; color: #3d4743; font-size: 11.5px; }
.pp-kind { text-align: right; }
.pp-kind b { display: block; font-size: 14px; color: var(--paper-acc, #1d6b58); text-transform: uppercase; letter-spacing: .08em; }
.pp-kind span { font-family: var(--font-data); font-size: 11px; color: #3d4743; }
.pp-pat { display: grid; grid-template-columns: 2.2fr 1fr 1fr 1.2fr; gap: 1px; background: #d6dcd9; border: 1px solid #d6dcd9; }
.pp-pat div { background: #f6f8f7; padding: 6px 9px; }
.pp-pat small, .pp-sec small, .pp-vit small { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; color: #5b6661; font-weight: 600; }
.pp-pat b { font-weight: 600; font-size: 12.5px; }
.pp-vit { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: #d6dcd9; border: 1px solid #d6dcd9; }
.pp-vit div { background: #fff; padding: 6px 8px; }
.pp-vit b { font-family: var(--font-data); font-weight: 500; font-size: 12px; }
.pp-sec { display: grid; gap: 2px; }
.pp-sec p { margin: 0; white-space: pre-wrap; }
.pp-sec ol, .pp-sec ul { margin: 0; padding-left: 18px; }
.pp-rx { width: 100%; border-collapse: collapse; }
.pp-rx td { padding: 7px 4px; border-top: 1px solid #e1e6e3; vertical-align: top; }
.pp-rx td:first-child { width: 22px; font-family: var(--font-data); color: #5b6661; }
.pp-rx b { font-size: 13px; }
.pp-sign { margin-top: auto; padding-top: 34px; display: grid; justify-items: center; gap: 2px; text-align: center; }
.pp-sign .line { width: 260px; border-top: 1px solid #1a1f1d; margin-bottom: 4px; }
.pp-foot { border-top: 1px solid #d6dcd9; padding-top: 8px; display: flex; justify-content: space-between; gap: 12px; font-size: 10.5px; color: #5b6661; }
.pp-add { border: 1px solid #d6dcd9; padding: 8px 10px; }
.pp-flag { font-size: 10px; color: #8a5a12; }

/* ---- Complementos de la versión Django ---- */
.mensajes { display: grid; gap: 8px; }
.mensaje { padding: 10px 14px; border-radius: 9px; background: var(--ok-bg); color: var(--ok); font-weight: 600; font-size: .9rem; }
.mensaje.error { background: var(--danger-bg); color: var(--danger); }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: .82rem; font-weight: 600; }
.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--danger); }
.form-page { max-width: 860px; }
.radios { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.radios label { cursor: pointer; }
.radios input { position: absolute; opacity: 0; pointer-events: none; }
.radios span { display: block; padding: 10px 14px; font-weight: 600; font-size: .9rem; min-height: 44px; }
.radios input:checked + span { background: var(--accent); color: var(--accent-fg); }
.radios input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
form.inline { display: inline; }
.side-foot form button { background: none; border: 0; padding: 0; color: var(--fg); font-weight: 600; cursor: pointer; text-align: left; }
.chart small { font-size: .75rem; }
.paper-frame.flow { overflow: auto; }
.cuenta-band { display: flex; gap: 8px; align-items: center; font-size: .82rem; color: var(--muted); }
.rx-acts { display: flex; gap: 6px; align-items: flex-end; }
.icon-btn[data-frecuente].guardada { color: var(--accent); border-color: var(--accent); }
.icon-btn[data-frecuente].guardada svg { fill: currentColor; }
.cie-opt .rx-ind { display: block; color: var(--muted); font-size: .8rem; }
.frec-list .item { grid-template-columns: 1fr auto; }
.item .acts { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) { .item.cita .acts { justify-content: flex-start; } .rep-row.rx-row { grid-template-columns: 1fr; } .rx-acts { justify-content: flex-end; } }

/* Marca del producto (Anamo), discreta: la marca principal es la del consultorio */
.libris-marca { font-family: 'IBM Plex Mono', monospace; font-size: .7rem; letter-spacing: .02em; color: var(--muted); }
a.libris-marca { color: var(--muted); }
.aviso { max-width: 760px; margin: 0 auto; padding: 32px 4px 48px; display: grid; gap: 10px; line-height: 1.6; }
.aviso h1 { font-size: 1.7rem; margin: 18px 0 0; }
.aviso h2 { font-size: 1.12rem; margin: 18px 0 0; }
.aviso p, .aviso ul { margin: 0; }
.aviso ul { padding-left: 1.2em; display: grid; gap: 4px; }
details.nuevo-paciente { border-top: 1px solid var(--line); padding-top: 12px; }
details.nuevo-paciente > summary, details.antecedentes > summary { cursor: pointer; font-weight: 650; min-height: 44px; display: flex; align-items: center; }
details.antecedentes { display: grid; gap: 12px; }
details.antecedentes[open] > summary { margin-bottom: 4px; }


/* ===== Dirección «Precisión» (29 oct 2026): barra superior oscura, IBM Plex, superficies grises con tarjetas blancas ===== */
:root {
  --bg: #F5F7FA; --surface: #ffffff; --surface-2: #EEF1F6; --line: #DDE3EC; --fg: #0E1A2B; --muted: #4A5870;
  --ink: #0E1A2B; --ink-2: #1B2A40; --ink-muted: #B8C2D3;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --r: 12px;
}
body { background: var(--bg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1 { font-weight: 700; }
.card { border-radius: var(--r); }
.card-head h2, .card > h2, .panel-title { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.btn { border-radius: 8px; }
.app { display: block; }
.side, .mob-head { display: none !important; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; padding-top: env(safe-area-inset-top, 0px); }
.topbar-in { max-width: 1280px; margin: 0 auto; min-height: 60px; display: flex; align-items: center; gap: 18px; padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); }
.tb-brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.tb-brand .brand-name { color: #fff; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-brand .brand-sub { color: var(--ink-muted); }
.tb-brand .brand-logo { width: 32px; height: 32px; border-radius: 8px; font-family: var(--font-data); font-size: .8rem; }
.tb-brand .brand-wide { padding: 3px 8px; border: 0; border-radius: 8px; }
.tb-brand .brand-wide img { height: 38px; }
.tb-nav { display: none; }
.tb-search { display: none; }
.tb-user { margin-left: auto; position: relative; }
.tb-user summary { list-style: none; cursor: pointer; width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--ink-2); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: .85rem; text-transform: uppercase; }
.tb-user summary::-webkit-details-marker { display: none; }
.tb-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; display: grid; gap: 4px; }
.tb-menu a, .tb-menu button { display: flex; align-items: center; min-height: 40px; padding: 0 8px; border-radius: 6px; color: var(--fg); text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left; width: 100%; }
.tb-menu a:hover, .tb-menu button:hover { background: var(--surface-2); }
.tb-menu strong { padding: 0 8px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.tb-menu .libris-marca { padding: 6px 8px 0; }
.main { padding-top: 24px; }
.wrap { max-width: 1280px; }
.tabbar { background: var(--surface); }
@media (min-width: 900px) {
  .tb-nav { display: flex; gap: 2px; align-self: stretch; }
  .tb-nav a { display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; color: var(--ink-muted); text-decoration: none; font-weight: 500; }
  .tb-nav a svg { width: 18px; height: 18px; }
  .tb-nav a:hover { color: #fff; }
  .tb-nav a[aria-current="page"] { color: #fff; font-weight: 600; box-shadow: inset 0 -3px 0 var(--accent); }
  .tb-search { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 1 300px; min-height: 40px; padding: 0 12px; border-radius: 8px; background: var(--ink-2); color: var(--ink-muted); }
  .tb-search svg { width: 16px; height: 16px; flex: none; }
  .tb-search input { border: 0; background: transparent; color: #fff; width: 100%; min-width: 0; }
  .tb-search input::placeholder { color: var(--ink-muted); }
  .tb-search input:focus { outline: none; }
  .tb-search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
  .tb-user { margin-left: 0; }
  .main { padding: 28px max(32px, env(safe-area-inset-right, 0px)) 48px max(32px, env(safe-area-inset-left, 0px)); }
}

/* Hoy · línea del día */
.dia-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.dia-head .resumen { font-family: var(--font-data); font-size: .88rem; color: var(--muted); }
.dia-grid { display: grid; gap: 20px; align-items: start; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .dia-grid { grid-template-columns: minmax(0, 3fr) minmax(300px, 2fr); } }
.linea { padding: 0; gap: 0; overflow: hidden; }
.linea > .card-head { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.linea ol { list-style: none; margin: 0; padding: 0; }
.linea li { display: grid; grid-template-columns: 70px minmax(0, 1fr); border-bottom: 1px solid var(--surface-2); }
.linea li:last-child { border-bottom: 0; }
.linea .hora { padding: 18px 0 0 18px; font-family: var(--font-data); font-size: .84rem; color: var(--muted); border-right: 1px solid var(--surface-2); }
.linea .bloque-w { padding: 10px 14px; min-width: 0; }
.bloque { padding: 10px 14px; border-radius: 8px; background: var(--bg); display: flex; justify-content: space-between; align-items: center; gap: 10px 14px; flex-wrap: wrap; min-width: 0; }
.bloque .quien { min-width: 0; }
.bloque .quien a { color: var(--fg); text-decoration: none; font-weight: 600; }
.bloque .quien span { color: var(--muted); }
.bloque .acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.bloque.atendida { background: #EEF5EF; }
.bloque.siguiente { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.bloque.apagada { opacity: .6; }
.linea li.siguiente .hora { color: var(--fg); font-weight: 600; }
.linea li.libre .bloque-w { padding: 16px 14px; color: #6B7890; font-size: .88rem; }
.alergia-txt { color: var(--danger); font-weight: 600; font-size: .85rem; }
.sig { display: grid; gap: 14px; }
.sig .nombre { font-size: 1.35rem; font-weight: 700; }
.sig .meta { color: var(--muted); }
.sig dl { margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sig dt { font-size: .75rem; color: var(--muted); }
.sig dd { margin: 2px 0 0; font-family: var(--font-data); font-weight: 600; }
.lista-simple { display: grid; }
.lista-simple a { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--surface-2); }
.lista-simple a:last-child { border-bottom: 0; }
.lista-simple .mono { font-size: .82rem; color: var(--muted); }

/* Historia clínica fijada (nota subsecuente): solo lectura */
.hc-fija { background: #F8FAFC; border-style: solid; gap: 16px; }
.hc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.hc-titulo { display: flex; gap: 12px; align-items: flex-start; }
.hc-titulo svg { width: 22px; height: 22px; flex: none; color: var(--muted); margin-top: 1px; }
.hc-titulo h2 { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hc-titulo p { margin: 2px 0 0; font-size: .9rem; color: var(--fg); }
.hc-grid { margin: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; grid-template-columns: 1fr; }
@media (min-width: 700px) { .hc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hc-item { background: var(--surface); padding: 12px 14px; display: grid; gap: 4px; align-content: start; }
.hc-item dt { font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.hc-item dd { margin: 0; font-size: .95rem; line-height: 1.5; }
.hc-item dd.vacio { color: #6B7890; font-style: italic; }
.hc-item.alerta { background: var(--danger-bg); }
.hc-item.alerta dt, .hc-item.alerta dd { color: var(--danger); }
.hc-item.alerta dd { font-weight: 600; }

/* Dictado con IA */
.dictado textarea { width: 100%; min-height: 120px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); resize: vertical; }
.ia-llenado { background: var(--accent-soft) !important; box-shadow: inset 0 0 0 1px var(--accent); }
/* Filas de diagnóstico y receta: los campos ocupan todo el ancho */
.rep-row .grid-f { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (min-width: 700px) {
  [data-filas="dx"] .rep-row .grid-f { grid-template-columns: minmax(0, 3fr) minmax(140px, 1fr); }
  [data-filas="rx"] .rep-row .grid-f { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Panel de Anamo */
.panel-tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.panel-tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; color: var(--muted); text-decoration: none; font-weight: 500; }
.panel-tabs a[aria-current="page"] { color: var(--fg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.panel-tabs a.avanzado { margin-left: auto; font-size: .85rem; }
.panel-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.panel-stats .stat { background: var(--surface); }
.tabla-w { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabla th { text-align: left; font-size: .75rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
.tabla td > span { display: block; font-size: .84rem; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.apagada td { opacity: .55; }
.tabla td .acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.acceso textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font-family: var(--font-ui); resize: vertical; }

/* ---------- Documentos, adjuntos, cobros, reportes ---------- */
.lista-simple > div { display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--surface-2); }
.lista-simple > div:last-child { border-bottom: 0; }
.doc-botones { display: flex; flex-wrap: wrap; gap: 8px; }
.doc-menu { position: relative; display: inline-block; }
.doc-menu > summary { list-style: none; cursor: pointer; }
.doc-menu > summary::-webkit-details-marker { display: none; }
.doc-menu > div { position: absolute; z-index: 15; top: calc(100% + 6px); left: 0; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(14,26,43,.14); padding: 6px; display: grid; }
.doc-menu > div a { padding: 10px 12px; min-height: 44px; display: flex; align-items: center; box-sizing: border-box; border-radius: 7px; color: var(--fg); text-decoration: none; font-weight: 500; }
.doc-menu > div a:hover { background: var(--surface-2); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 16px; }
.checks label { display: flex; gap: 8px; align-items: center; min-height: 36px; font-weight: 500; }
.checks input { width: 18px; height: 18px; flex: none; }
.seg { flex-wrap: wrap; }
.btn.wa { color: #12814a; border-color: #b9e3cb; gap: 6px; }
.btn.wa:hover { background: #e9f7ef; }
.adj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.adj { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); }
.adj-prev { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.adj-prev img { width: 100%; height: 100%; object-fit: cover; display: block; }
.adj-pdf { display: grid; place-items: center; height: 100%; font-family: var(--font-data); font-weight: 600; color: var(--danger); letter-spacing: .08em; }
.adj-info { padding: 8px 10px 0; display: grid; gap: 2px; min-width: 0; }
.adj-info strong { font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adj-info span { font-size: .75rem; color: var(--muted); }
.adj .acts { padding: 4px 6px 6px; display: flex; flex-wrap: wrap; gap: 2px; }
.adj-form { margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--surface-2); }
.rep-kpis { grid-template-columns: repeat(5, 1fr); margin: 4px 0 4px; }
@media (max-width: 900px) { .rep-kpis { grid-template-columns: repeat(2, 1fr); } }
.barras { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.barras li { display: grid; grid-template-columns: 4.2em 1fr auto; gap: 10px; align-items: center; font-size: .82rem; }
.barra-w { background: var(--surface-2); border-radius: 4px; height: 12px; overflow: hidden; }
.rep-barra { height: 100%; background: var(--accent); border-radius: 4px; }
.seg { position: relative; }
.cobro-metodo { border: 0; padding: 0; margin: 0; }
.cobro-metodo legend { font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.cobro-metodo .seg { display: flex; width: fit-content; max-width: 100%; }
@media (max-width: 900px) { .rep-kpis .stat:last-child { grid-column: 1 / -1; } }

/* ===== 3 nov 2026: cambios del prototipo del 2 nov ===== */
/* Modo oscuro (botón en la barra superior; al principio sigue al sistema). Las hojas impresas siempre son claras. */
:root[data-tema="oscuro"] {
  color-scheme: dark;
  --bg: #0B1320; --surface: #121C2C; --surface-2: #1A2638; --line: #2A3850; --fg: #E4EAF3; --muted: #9AA8BE;
  --ink: #070D17; --ink-2: #1B2A40; --ink-muted: #B8C2D3;
  --accent: color-mix(in srgb, var(--acc-l, #2456c9) 70%, #ffffff); --accent-fg: #0B1320;
  --accent-soft: color-mix(in srgb, var(--acc-l, #2456c9) 26%, var(--surface));
  --danger: #F2A09C; --danger-bg: #3A1716; --warn: #F1C981; --warn-bg: #36280F; --ok: #8FD4A6; --ok-bg: #132D1D;
  --info: #9CC3F0; --info-bg: #14263D; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}
:root[data-tema="claro"] { color-scheme: light; }
:root[data-tema="oscuro"] .hc-fija { background: var(--surface-2); }
:root[data-tema="oscuro"] .bloque.atendida { background: var(--ok-bg); }
:root[data-tema="oscuro"] .linea li.libre .bloque-w, :root[data-tema="oscuro"] .hc-item dd.vacio { color: var(--muted); }
:root[data-tema="oscuro"] .btn.wa { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
:root[data-tema="oscuro"] .btn.wa:hover { background: var(--ok-bg); }
:root[data-tema="oscuro"] .paper-frame { background: #fff; }
.tb-tema { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-muted); display: grid; place-items: center; cursor: pointer; }
.tb-tema:hover { color: #fff; background: var(--ink-2); }
.tb-tema svg { width: 20px; height: 20px; }
:root[data-tema="oscuro"] .t-luna, :root:not([data-tema="oscuro"]) .t-sol { display: none; }

/* Nota: columna lateral con alergias, historia, nota anterior y firma */
.nota-wrap.con-lateral { max-width: 1240px; }
.nota-cols { display: grid; gap: 20px; align-items: start; }
.nota-main { display: grid; gap: 20px; min-width: 0; }
.nota-main .nota-form { display: grid; gap: 20px; }
.nota-lateral { display: grid; gap: 14px; min-width: 0; }
@media (min-width: 1100px) {
  .nota-cols { grid-template-columns: minmax(0, 1fr) 320px; }
  .nota-lateral { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; overscroll-behavior: contain; padding-bottom: 4px; }
}
.lat-sec { gap: 8px; padding: 14px 16px; grid-template-columns: minmax(0, 1fr); }
.lat-sec .btn { white-space: normal; text-align: center; justify-content: center; height: auto; }
.lat-sec .card-head .btn { padding-inline: 8px; }
.lat-sec h2 { font-size: .95rem; }
.lat-sec p { margin: 0; }
.lat-alerta { border-color: var(--danger); background: var(--danger-bg); }
.lat-alerta h2, .lat-alerta p { color: var(--danger); font-weight: 600; }
.lat-fija { font-size: .78rem; margin: 0; }
.lat-dl { margin: 0; display: grid; gap: 2px; font-size: .88rem; }
.lat-dl dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin-top: 8px; }
.lat-dl dt:first-child { margin-top: 0; }
.lat-dl dd { margin: 0; overflow-wrap: anywhere; }
.lat-dl dd.vacio { color: var(--muted); font-style: italic; }
.lat-firma .btn { width: 100%; justify-content: center; }
.evolucion > span:first-child { font-size: 1rem; font-weight: 650; color: var(--fg); }
.evolucion textarea { min-height: 7.5em; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

/* Signos vitales compactos */
.signos { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.sv { display: grid; gap: 4px; align-content: start; min-width: 0; }
.sv > span:first-child { font-size: .78rem; font-weight: 600; color: var(--muted); }
.sv input { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-family: var(--font-data); }
.sv em { font-style: normal; font-size: .72rem; color: var(--muted); margin-top: -2px; }
.sv-ta { grid-column: span 2; }
.sv-ta-in { display: flex; align-items: center; gap: 6px; }
.sv-ta-in b { color: var(--muted); }
.sv.heredado input { border-style: dashed; color: var(--muted); }
.sv .her { font-style: normal; font-weight: 500; font-size: .68rem; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 1px 5px; margin-left: 2px; white-space: nowrap; }
.sv-imc .computed { min-height: 44px; display: flex; align-items: center; gap: 6px; font-family: var(--font-data); }
.sv-mas { gap: 6px; }

/* Pronóstico por botones */
.pronostico { display: grid; gap: 8px; }
.pronostico.bad .radios { border-color: var(--danger); }
.pr-fila { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.pr-l { min-width: 8.5em; font-weight: 600; font-size: .9rem; }
.radios.sm span { padding: 9px 12px; font-size: .85rem; }
.solicitar { gap: 8px; align-items: center; }
.ia-avisos { border: 1px solid var(--warn); background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 8px 12px; font-size: .88rem; }
.ia-avisos ul { margin: 0; padding-left: 18px; }
.ia-estudios { display: grid; gap: 10px; }
.estudio-revision { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--surface-2); }
.estudio-revision textarea { font-size: .85rem; }

/* Motivo de seguimiento (resumen del paciente) */
.seguimiento { gap: 14px; }
.seg-dx { display: grid; gap: 8px; }
.sd { display: flex; gap: 14px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.sd code { font-family: var(--font-data); color: var(--accent); font-weight: 600; min-width: 4.2em; padding-top: 2px; }
.sd .dn { font-weight: 550; }
.sd.main { background: var(--accent-soft); }
.sd.main .dn { font-size: 1.05rem; font-weight: 650; }
.seg2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.seg-rx { margin: 4px 0 0; padding-left: 18px; font-size: .9rem; }

/* Solicitudes */
.solicitud { gap: 16px; }
.solicitud h3 { margin-bottom: 6px; }
.sol-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.sol-q { flex: 1 1 260px; }
.sol-pri { flex: 0 0 160px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--fg); font-size: .85rem; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.mine { padding: 0 4px 0 0; }
.chip.mine button { border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; padding: 6px 4px 6px 12px; min-height: 34px; }
.chip.mine .del { padding: 4px 8px; font-size: 1rem; color: var(--muted); }
.sol-cols { display: grid; gap: 16px; }
@media (min-width: 900px) { .sol-cols { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } .sol-sel { position: sticky; top: 76px; } }
.sol-cat { columns: 2 260px; column-gap: 18px; }
.sol-cat fieldset { break-inside: avoid; border: 0; padding: 0; margin: 0 0 14px; }
.sol-cat legend { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); padding: 0; margin-bottom: 4px; }
.ck { display: flex; gap: 8px; align-items: flex-start; padding: 6px 4px; border-radius: 6px; cursor: pointer; font-size: .9rem; line-height: 1.35; }
.ck:hover { background: var(--surface-2); }
.ck input { margin-top: 2px; width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.pp2 { font-size: .7rem; color: var(--warn); background: var(--warn-bg); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
.sol-sel { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--surface-2); }
.sol-lista-sel { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
.lsi { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .88rem; padding: 2px 0; }
.lsi .icon-btn { min-height: 32px; min-width: 32px; }
.sol-sel .row { flex-wrap: nowrap; }
.sol-sel input[type=text] { flex: 1; min-width: 0; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }

/* Ventana de notas anteriores */
.ventana-notas { background: var(--bg); }
.nota-prev summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 44px; }

/* ---------- Importador ---------- */
.importando{display:flex;gap:14px;align-items:center}
.giro{width:28px;height:28px;border-radius:50%;border:3px solid var(--line,#d5dce8);border-top-color:var(--accent,#2456c9);animation:giro 1s linear infinite;flex:none}
@keyframes giro{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.giro{animation:none}}
.imp-pac.bad{border-color:var(--danger,#a3262a)}
.imp-ficha{margin-top:4px}
.field.falta input,.field.falta select{border-color:var(--warn,#b86e00)}
.imp-notas{display:flex;flex-direction:column;gap:6px}
.imp-nota{display:grid;grid-template-columns:auto 1fr;gap:10px;align-items:start;padding:8px 0;border-top:1px solid var(--line,#e3e8f0)}
.imp-nota input[type=date]{min-height:40px;padding:0 8px}
.imp-nota summary{cursor:pointer;min-height:44px;padding-block:11px;box-sizing:border-box}
.imp-conflictos{font-size:.88rem;background:var(--surface-2,#f4f6fa);border-radius:8px;padding:8px 12px}
.imp-conflictos ul{margin:4px 0 0 18px;padding:0}
.importado-original{white-space:pre-wrap;font-family:var(--mono,'IBM Plex Mono',monospace);font-size:.8rem;max-height:420px;overflow:auto;margin:8px 0 0}
.guia-importar>div{align-items:flex-start;gap:16px}.guia-importar>div>span:last-child{text-align:left;flex:1}
.nota-imp .t{color:var(--muted,#586579)}
/* ---------- Plantilla de especialidad ---------- */
.esp-sec{border:0;padding:0;margin:0 0 8px}
.esp-sec legend{font-weight:600;font-size:.95rem;margin-bottom:6px}
.esp-checks{border:0;padding:0;margin:0}
.esp-checks legend{font-size:.85rem;color:var(--muted,#586579);margin-bottom:4px}
.esp-negado{font-weight:600}
.esp-libre{display:grid;grid-template-columns:minmax(0,1fr) minmax(220px,300px);gap:12px;align-items:start}
.esp-libre textarea{width:100%;min-height:180px;resize:vertical;line-height:1.45}
.esp-recordatorio{background:var(--surface-2,#f4f6fa);border:1px solid var(--line);border-radius:8px;padding:8px 12px;font-size:.84rem;color:var(--muted)}
.esp-recordatorio ul{margin:4px 0 0;padding-left:16px}.esp-recordatorio li{margin:2px 0}.esp-recordatorio b{color:var(--fg);font-weight:600}
.sin-recordatorio .esp-recordatorio{display:none}.sin-recordatorio .esp-libre{grid-template-columns:minmax(0,1fr)}
.esp-rec-toggle{justify-content:flex-end;margin:-4px 0 4px}
.base-bar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:6px 0 10px}
.base-bar .btn,.esp-rec-toggle .btn{min-height:44px}
.base-estado{font-size:.82rem}
.nota-archivos-lista{margin:0 0 8px;padding-left:18px}.nota-archivos-lista:empty{display:none}.nota-archivos-lista li{margin:4px 0;min-height:28px}
.nota-archivos label.btn{min-height:44px;cursor:pointer}
.vp-opciones{display:flex;flex-wrap:wrap;gap:8px}.vp-opciones .btn{min-height:44px;gap:8px}
.vp-color{width:12px;height:12px;border-radius:50%;display:inline-block;flex:none}
.vp-marco{display:flex;flex-direction:column;gap:12px}
@media (max-width:720px){.esp-libre{grid-template-columns:minmax(0,1fr)}.esp-recordatorio{margin-top:-4px}}
/* ---------- Directorio y horarios ---------- */
.horario-fila{gap:8px;align-items:center;margin-bottom:8px}
.horario-fila select,.horario-fila input{min-height:44px}
/* ---------- SUIVE ---------- */
.tabla.suive th,.tabla.suive td{padding:6px 6px;font-size:.82rem;text-align:center;white-space:nowrap}
.tabla.suive td:first-child,.tabla.suive th:first-child{text-align:left;white-space:normal;min-width:16em}
.suive-grupo td{background:var(--surface-2,#f4f6fa);font-weight:600;text-align:left!important}
@media print{.topbar,.tabbar,.back,.btn{display:none!important}.main{padding:0}}
/* ---------- Receta media carta y sobre hoja membretada ---------- */
.paper.receta.media{width:216mm;min-height:139.7mm;padding:8mm 11mm 7mm;font-size:.78rem}
.paper.receta.media .pp-head{padding-bottom:6px}
.paper.receta.media .pp-logo{max-height:14mm}
.paper.receta.media .pp-sec{margin-top:5px}
.paper.receta.media .pp-sign{margin-top:12px}
.paper.receta.membretada .pp-head,.paper.receta.membretada .pp-foot{display:none}
.paper.receta.membretada{padding-top:var(--margen-membrete,40mm)}
.cita-badges{display:inline-flex;gap:4px;flex-wrap:wrap;margin-left:4px}

/* ---------- Nueva cita: elegir o registrar paciente ---------- */
.paciente-elegir{display:grid;gap:10px;padding-bottom:12px;border-bottom:1px solid var(--line,#e3e8f0)}
.nuevo-paciente[open]{border:1px solid var(--accent,#2456c9);border-radius:12px;padding:12px}
.nuevo-paciente summary{font-weight:600;cursor:pointer;min-height:44px;display:flex;align-items:center}

/* ---------- Hoy: bienvenida y «¿Qué tenemos hoy?» ---------- */
.bienvenida { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; background: var(--surface, #fff);
  border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 14px; padding: 22px 24px; }
.bienvenida .bv-texto { min-width: 0; flex: 1 1 360px; display: grid; gap: 6px; }
.bienvenida .bv-saludo { margin: 0; color: var(--muted); font-size: .95rem; }
.bienvenida h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); color: var(--fg); overflow-wrap: anywhere; }
.bienvenida .bv-frase { margin: 0; font-size: 1.05rem; max-width: 62ch; }
.bienvenida .bv-acciones .btn { min-height: 44px; }
.linea > .card-head.que-hoy { padding: 18px 18px 14px; }
.card-head.que-hoy h2 { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 700; letter-spacing: -.01em; text-transform: none; color: var(--fg); }
@media (max-width: 560px) { .bienvenida { padding: 18px 16px; } .bienvenida .bv-acciones { width: 100%; } .bienvenida .bv-acciones .btn { flex: 1 1 auto; } }

/* ---------- Agenda: botón visible para abrir el calendario ---------- */
.calendario-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1.5px solid var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 650; cursor: pointer; }
.calendario-btn:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.calendario-btn svg { flex: none; }
.calendario-btn input[type=date] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.calendario-btn input[type=date]::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

/* Fotografías clínicas ligadas a una nota (Dermatología) */
.fotos-nota { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.fotos-nota a { display: grid; gap: 6px; text-decoration: none; color: var(--fg); font-size: .82rem; min-height: 44px; }
.fotos-nota img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
/* Reporte financiero: gráficas SVG del servidor */
.graf-fin { width: 100%; height: auto; display: block; }
.graf-fin.h { max-width: 520px; }

/* Objetivos táctiles de al menos 44 px (revisión con Playwright, nov 2026) */
details > summary { min-height: 44px; padding-block: 11px; box-sizing: border-box; cursor: pointer; }
.tb-brand { min-height: 44px; display: flex; align-items: center; }
.bloque .quien a { display: inline-flex; align-items: center; min-height: 44px; }

/* Ayuda */
.ayuda-temas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 16px; }
.ayuda-tema { text-decoration: none; color: var(--fg); padding: 0; overflow: hidden; gap: 0; }
.ayuda-tema img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; border-bottom: 1px solid var(--line); display: block; }
.ayuda-tema > div { padding: 14px 16px; display: grid; gap: 4px; }
.ayuda-tema h2 { font-size: 1.05rem; text-transform: none; letter-spacing: 0; color: var(--fg); }
.ayuda-tema p { margin: 0; font-size: .9rem; }
.ayuda-tema:hover { box-shadow: 0 0 0 2px var(--accent); }
.ayuda-cuerpo { display: grid; gap: 20px; align-items: start; }
@media (min-width: 1000px) { .ayuda-cuerpo { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.ayuda-pasos { margin: 0; padding-left: 22px; display: grid; gap: 12px; font-size: 1rem; line-height: 1.5; }
.ayuda-figura { margin: 0; padding: 8px; }
.ayuda-figura img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.ayuda-figura figcaption { font-size: .8rem; padding: 4px 4px 0; }

/* Aviso de prueba o suscripción */
.aviso-cuenta { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; font-weight: 600; font-size: .92rem; }
.aviso-cuenta.info { background: var(--info-bg); color: var(--info); }
.aviso-cuenta.warn { background: var(--warn-bg); color: var(--warn); }
.aviso-cuenta.danger { background: var(--danger-bg); color: var(--danger); }
.planes-app { display: grid; gap: 10px; }
.planes-app input:checked + span .muted { color: inherit; opacity: .9; }
.tipo-cita.apagado { opacity: .75; }
.chips-sug { display: flex; flex-wrap: wrap; gap: 8px; }
/* Acomodo de la pantalla de la nota */
.nota-cols > .nota-main, .nota-cols > .nota-lateral { min-width: 0; }
.area-plegada > summary { font-weight: 650; }
.area-plegada[open] > summary { margin-bottom: 8px; }
.area-plegada > section.card, .area-plegada > details.card { border: 0; padding: 0; box-shadow: none; }
.vista-diseno { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.vd-col { display: grid; gap: 6px; align-content: start; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.vd-col small { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.vd-area { display: block; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); color: var(--fg); font-size: .85rem; }
.vd-area.plegada { background: var(--surface-2); color: var(--muted); }
.diseno-tabla select { min-height: 44px; }
@media (max-width: 640px) { .vista-diseno { grid-template-columns: 1fr; } }
/* Modo acomodar de la nota */
.acomodo-banda { display: grid; gap: 8px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); border: 1.5px solid var(--accent); }
.acomodando .area { outline: 2px dashed color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 3px; border-radius: 12px; }
.acomodo-barra { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px; margin-bottom: 8px; border-radius: 10px; background: var(--surface-2); }
.acomodo-barra b { flex: 1 1 140px; font-size: .9rem; }
.acomodo-asa { cursor: grab; touch-action: none; font-size: 1.1rem; min-width: 44px; }
.acomodo-arrastrando { box-shadow: 0 12px 30px rgba(14, 26, 43, .25); opacity: .95; background: var(--surface); }
.acomodo-hueco { border: 2px dashed var(--accent); border-radius: 12px; background: var(--accent-soft); min-height: 56px; }
.acomodo-plegada > :not(.acomodo-barra):not(summary) { opacity: .45; }
.acomodo-ocultas { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.acomodando .nota-lateral { position: static; max-height: none; overflow: visible; min-height: 120px; }
.acomodando .nota-cols { align-items: stretch; }
.acomodando .nota-lateral { align-content: start; border-radius: 12px; background: color-mix(in srgb, var(--accent) 4%, transparent); }
.ia-estudios-activar > summary { list-style: none; display: inline-flex; padding-block: 0; }
.ia-estudios-activar > summary::-webkit-details-marker { display: none; }
.ia-estudios-activar[open] { display: grid; gap: 6px; justify-items: start; }
.esp-recordatorio .spread { align-items: center; }
.rec-editor { display: grid; gap: 8px; }
.rec-editor textarea { font-size: .88rem; }
.esp-checks { position: relative; }
.esp-opc-editar { justify-self: start; margin: 2px 0 6px; }
.opc-editor { display: grid; gap: 8px; margin-top: 8px; }
/* Botones con textos largos (plantilla reutilizable, laboratorio con IA): pueden ocupar varios renglones en el celular */
.base-bar .btn, .ia-estudios .btn, .ia-estudios-activar .btn, .esp-opc-editar { white-space: normal; text-align: left; height: auto; padding-block: 8px; }
.base-bar { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }

/* Nota en borrador: lo capturado con la plantilla de otra especialidad */
.esp-anteriores{border-left:4px solid var(--accent)}
.esp-anteriores .esp-ant-nombre{font-weight:600}

/* Estudios a la vista y laboratorios graficados (expediente y nota) */
.vista-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.nota-cols .vista-grid { grid-template-columns: 1fr; }
.vista-estudio { margin: 0; display: grid; gap: 6px; }
.vista-img { display: block; min-height: 120px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.vista-img img { display: block; width: 100%; height: auto; max-height: 420px; object-fit: contain; }
.vista-img .adj-pdf { min-height: 120px; }
.vista-estudio figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .88rem; }
.vista-estudio figcaption .mono { color: var(--muted); font-size: .8rem; }
.vista-estudio figcaption form { margin-left: auto; }
.labs-fuente { margin: 8px 0 0; font-size: .8rem; }
.labs-nota .charts { grid-template-columns: 1fr; }
label.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; }
label.check input { width: 20px; height: 20px; }
/* Pediatría: edad exacta y gráficas de crecimiento */
.edad-detalle { font-size: .85rem; }
.crec-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.chart.crec { margin: 0; }
.chart.crec figcaption { font-size: .75rem; }
