/* 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-template-columns: repeat(4, 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: 36px; 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: 32px; }
.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 (Libris), 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: 32px; 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: 40px; height: 40px; 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); }
