/* AdjustNow by Phoraxis — estilos mobile-first (teléfono → tableta → escritorio).
   Lenguaje visual de la familia Phoraxis: azul de marca, superficies limpias, vidrio translúcido y movimiento sutil. */

:root {
  --brand: #0071e3;
  --brand-2: #2997ff;
  --brand-ink: #ffffff;
  --grad: linear-gradient(145deg, #2997ff 0%, #0071e3 52%, #5e5ce6 100%);
  --phx-accent: #0071e3;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --glass: rgba(255, 255, 255, .78);
  --seg-on: #ffffff;
  --ink: #1d1d1f;
  --ink-2: #4b5563;
  --ink-3: #66666c;
  --line: #e3e3e8;
  --focus: #0071e3;
  --ok: #198748;
  --ok-bg: #e7f6ed;
  --warn: #8a5900;
  --warn-bg: #fff5de;
  --danger: #c30013;
  --danger-bg: #ffeceb;
  --info: #0062c4;
  --info-bg: #e8f2fd;
  --lo: #0062c4;
  --hi: #c30013;
  --in: #198748;
  --band: rgba(25, 135, 72, .12);
  --line-fit: #0071e3;
  --line-proj: #d2691e;
  --line-pop: #9aa0a8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .045);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .08), 0 16px 48px rgba(0, 0, 0, .08);
  --radius: 18px;
  --tabbar-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --t1: #0071e3; --t2: #6a3dd6; --t3: #c47600; --t4: #d6336c; --t5: #0699c6; --t6: #198748;
  --body: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --marca: "Syne", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #4aa3ff; --brand-2: #8cc6ff; --brand-ink: #04111f; --phx-accent: #8cc6ff;
    --grad: linear-gradient(145deg, #8cc6ff 0%, #4aa3ff 52%, #ab8ef6 100%);
    --bg: #0e1117; --surface: #161b24; --surface-2: #1d2430; --glass: rgba(18, 22, 30, .78); --seg-on: #2b3444; --ink: #e9edf3; --ink-2: #b4bdca; --ink-3: #9aa5b4; --line: #262f3d;
    --ok: #57d996; --ok-bg: #11291d; --warn: #f6c263; --warn-bg: #2e2410; --danger: #ff8175; --danger-bg: #351714; --info: #8cc6ff; --info-bg: #132339;
    --lo: #8cc6ff; --hi: #ff8175; --in: #57d996; --band: rgba(87, 217, 150, .14);
    --line-fit: #4aa3ff; --line-proj: #ffb271; --line-pop: #6b7684;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .35);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45), 0 16px 48px rgba(0, 0, 0, .35);
    --t1: #4aa3ff; --t2: #ab8ef6; --t3: #e9ad42; --t4: #ff7aa2; --t5: #45c6e8; --t6: #3fcc85;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --brand: #4aa3ff; --brand-2: #8cc6ff; --brand-ink: #04111f; --phx-accent: #8cc6ff;
  --grad: linear-gradient(145deg, #8cc6ff 0%, #4aa3ff 52%, #ab8ef6 100%);
  --bg: #0e1117; --surface: #161b24; --surface-2: #1d2430; --glass: rgba(18, 22, 30, .78); --seg-on: #2b3444; --ink: #e9edf3; --ink-2: #b4bdca; --ink-3: #9aa5b4; --line: #262f3d;
  --ok: #57d996; --ok-bg: #11291d; --warn: #f6c263; --warn-bg: #2e2410; --danger: #ff8175; --danger-bg: #351714; --info: #8cc6ff; --info-bg: #132339;
  --lo: #8cc6ff; --hi: #ff8175; --in: #57d996; --band: rgba(87, 217, 150, .14);
  --line-fit: #4aa3ff; --line-proj: #ffb271; --line-pop: #6b7684;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45), 0 16px 48px rgba(0, 0, 0, .35);
  --t1: #4aa3ff; --t2: #ab8ef6; --t3: #e9ad42; --t4: #ff7aa2; --t5: #45c6e8; --t6: #3fcc85;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.47 var(--body);
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
  /* Resplandor de marca muy tenue en la parte superior */
  background: radial-gradient(900px 420px at 50% -180px, color-mix(in srgb, var(--brand) 11%, transparent), transparent 72%) no-repeat, var(--bg);
  min-height: 100vh;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--brand); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 70%, transparent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--brand) 25%, transparent); }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 4px;
  min-height: calc(56px + var(--safe-t));
  padding: var(--safe-t) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  /* Vidrio translúcido: el contenido se intuye al desplazarse */
  background: var(--glass); color: var(--ink);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.topbar h1 { margin: 0; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: -12px; border: 0; background: none; color: var(--brand); border-radius: 50%; cursor: pointer; transition: background .2s, transform .2s var(--spring); }
.back:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.back:active { transform: scale(.9); }
.back svg { width: 26px; height: 26px; fill: currentColor; }
.back[hidden] { display: none; }
.stale { background: var(--warn-bg); color: var(--warn); padding: 8px 16px; font-size: .875rem; animation: rise .4s var(--ease) both; }
.stale a { color: inherit; font-weight: 600; }

main {
  max-width: 1100px; margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right)) calc(var(--tabbar-h) + var(--safe-b) + 24px) max(16px, env(safe-area-inset-left));
  outline: none;
}

/* ---------- Barra de pestañas inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--glass); border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.tabbar[hidden] { display: none; }
.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0; color: var(--ink-3); text-decoration: none; font-size: .6875rem; font-weight: 600; transition: color .2s; }
/* Píldora del ítem activo (aparece con un pequeño rebote) */
.tabbar a::before { content: ""; position: absolute; top: 7px; left: 50%; width: 54px; height: 30px; margin-left: -27px; border-radius: 15px;
  background: color-mix(in srgb, var(--brand) 14%, transparent); opacity: 0; transform: scale(.5); transition: opacity .25s, transform .35s var(--spring); }
.tabbar a svg { position: relative; width: 24px; height: 24px; fill: currentColor; transition: transform .35s var(--spring); }
.tabbar a span { position: relative; }
.tabbar a:active svg { transform: scale(.86); }
.tabbar a.on { color: var(--brand); }
.tabbar a.on::before { opacity: 1; transform: scale(1); }
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tarjetas y secciones ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 14px; box-shadow: var(--shadow); min-width: 0; }
.card.accent { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: inset 4px 0 0 var(--brand), var(--shadow); }
.card-h { margin: 0 0 12px; font-size: 1.0625rem; font-weight: 700; letter-spacing: -.015em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec-h { margin: 24px 4px 10px; font-family: var(--mono); font-size: .6875rem; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); font-weight: 500; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); font-size: .75rem; color: var(--ink-2); }
.tag { font-size: .6875rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
p { margin: 0 0 8px; }
.lead { font-size: 1.0625rem; color: var(--ink-2); }
.big { font-size: 1.625rem; font-weight: 700; margin: 4px 0 8px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.big small { display: block; font-size: .875rem; font-weight: 500; color: var(--ink-2); margin-top: 2px; }
.bul { margin: 0 0 8px; padding-left: 20px; }
.bul li { margin: 4px 0; }

/* ---------- Tira de paciente ---------- */
.pstrip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: inherit; box-shadow: var(--shadow); min-height: 60px;
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s; }
a.pstrip:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
a.pstrip:hover .chev { transform: translateX(3px); color: var(--brand); }
.pstrip-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); flex: none; }
.pstrip-ic .ic { width: 20px; height: 20px; }
.pstrip-t { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pstrip-t b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstrip-t small { color: var(--ink-2); font-size: .8125rem; overflow-wrap: anywhere; }
.chev { font-size: 1.5rem; color: var(--ink-3); line-height: 1; transition: transform .25s var(--ease), color .25s; }

/* ---------- Módulos (inicio) ---------- */
.modules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.module { --tone: var(--t1); position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 124px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; box-shadow: var(--shadow); min-width: 0;
  transition: transform .3s var(--ease), box-shadow .3s, border-color .3s; }
/* Brillo del color del módulo en la esquina */
.module::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--tone) 16%, transparent), transparent 70%); opacity: .7; transition: opacity .3s, transform .4s var(--ease); pointer-events: none; }
.module:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--tone) 35%, var(--line)); }
.module:hover::after { opacity: 1; transform: scale(1.25); }
.module:active { transform: scale(.97); transition-duration: .1s; }
.module-ic { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--tone) 72%, #fff), var(--tone) 60%, color-mix(in srgb, var(--tone) 80%, #000));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--tone) 35%, transparent); transition: transform .35s var(--spring); }
.module:hover .module-ic { transform: scale(1.08) rotate(-4deg); }
.module-ic .ic { width: 22px; height: 22px; fill: currentColor; }
.module-t { display: flex; flex-direction: column; min-width: 0; }
.module-t b { font-size: .9375rem; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
.module-t small { color: var(--ink-3); font-size: .75rem; margin-top: 2px; line-height: 1.3; }
.t1 { --tone: var(--t1); } .t2 { --tone: var(--t2); } .t3 { --tone: var(--t3); }
.t4 { --tone: var(--t4); } .t5 { --tone: var(--t5); } .t6 { --tone: var(--t6); }

/* ---------- Formularios ---------- */
.field { margin: 0 0 12px; min-width: 0; }
.field label, .flabel { display: block; font-size: .8125rem; font-weight: 600; color: var(--ink-2); margin: 0 0 6px; }
.req { color: var(--danger); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input, .input-wrap select, .mini input, .mini select {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px;
  font: inherit; font-size: 16px; /* evita zoom automático en iOS */
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  appearance: none; -webkit-appearance: none; transition: border-color .2s, box-shadow .2s, background .2s;
  font-variant-numeric: tabular-nums;
}
.input-wrap.has-unit input { padding-right: 76px; }
.input-wrap .unit { position: absolute; right: 12px; pointer-events: none; color: var(--ink-3); font-size: .8125rem; max-width: 68px; text-align: right; line-height: 1.1; }
.input-wrap.select::after { content: ""; position: absolute; right: 14px; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg) translateY(-3px); pointer-events: none; }
.input-wrap.select select { padding-right: 36px; }
input:focus, select:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.field.invalid input { border-color: var(--danger); }
.field.warning input { border-color: var(--warn, #c27a00); }
.hint { display: block; margin-top: 4px; font-size: .75rem; color: var(--ink-3); line-height: 1.35; }
.err { display: block; font-size: .75rem; color: var(--danger); min-height: 0; }
.field.warning .err { color: var(--warn, #9a6100); }
.err:empty { display: none; }
input[type="datetime-local"] { min-height: 48px; }
.grid2, .grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { grid-template-columns: 1fr 1fr; }
.grid2 > .wide { grid-column: 1 / -1; }
.mini { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin-bottom: 10px; }
.mini span { font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.mini.wide { grid-column: 1 / -1; }

.seg { display: flex; gap: 4px; padding: 4px; margin: 0 0 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 1 0; min-width: max-content; min-height: 40px; padding: 8px 10px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .2s, color .2s, box-shadow .2s, transform .2s var(--spring); }
.seg button:active { transform: scale(.96); }
.seg button.on { background: var(--seg-on); color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 2px 8px rgba(0, 0, 0, .05); }
.card .seg:last-child { margin-bottom: 0; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--line); }
.toggle-row:first-of-type { border-top: 0; }
.toggle-label { font-size: .9375rem; }
.toggle-label .hint { margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; border-radius: 16px; background: var(--line); position: relative; cursor: pointer; transition: background .25s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .35s var(--spring); }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin: 12px 0; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--brand); }
/* Campo trampa del registro (solo lo rellenan robots): fuera de pantalla, no display:none. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px; border-radius: 13px; border: 1px solid transparent; font: inherit; font-size: .9375rem; font-weight: 600; letter-spacing: -.01em; text-decoration: none; cursor: pointer;
  background: var(--grad); color: var(--brand-ink); box-shadow: 0 2px 10px color-mix(in srgb, var(--brand) 28%, transparent);
  transition: transform .2s var(--spring), box-shadow .25s, filter .2s, background-color .2s, border-color .2s; }
.btn:hover { filter: brightness(1.06); box-shadow: 0 4px 18px color-mix(in srgb, var(--brand) 36%, transparent); }
.btn .ic { width: 18px; height: 18px; fill: currentColor; }
.btn.primary { background: var(--grad); color: var(--brand-ink); }
.btn.ghost { background: var(--surface); color: var(--brand); border-color: var(--line); box-shadow: none; }
.btn.ghost:hover { filter: none; background: color-mix(in srgb, var(--brand) 7%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: 0 2px 10px color-mix(in srgb, var(--danger) 28%, transparent); }
:root[data-theme="dark"] .btn.danger { color: #1a0605; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.danger { color: #1a0605; } }
.btn.block { display: flex; width: 100%; }
.btn:active { transform: scale(.97); filter: brightness(.96); transition-duration: .08s; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.btn-row .btn { flex: 1 1 auto; }
.small-btn { min-height: 40px; font-size: .875rem; }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-3); cursor: pointer; flex: none; transition: color .2s, border-color .2s, transform .2s var(--spring); }
.icon-btn:active { transform: scale(.9); }
.icon-btn .ic { width: 20px; height: 20px; fill: currentColor; }
.icon-btn.del:hover, .icon-btn.del:active { color: var(--danger); border-color: var(--danger); }

/* ---------- Listas de dosis/niveles ---------- */
.rows { list-style: none; margin: 0 0 4px; padding: 0; counter-reset: r; }
.row-item { padding: 10px 0; border-top: 1px solid var(--line); }
.row-item:first-child { border-top: 0; padding-top: 0; }
.row-grid { display: grid; grid-template-columns: 1fr 1fr 44px; grid-template-areas: "at at del" "mg ti del"; gap: 0 8px; align-items: end; }
.row-grid > label:nth-child(1) { grid-area: at; }
.row-grid > label:nth-child(2) { grid-area: mg; }
.row-grid > label:nth-child(3) { grid-area: ti; }
.row-grid > .del { grid-area: del; align-self: center; }
.row-grid.lv { grid-template-areas: "at at del" "mg mg del"; }
.row-grid .mini { margin-bottom: 6px; }
.empty { color: var(--ink-3); font-size: .875rem; padding: 8px 0; }
details.gen { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.card > details.gen:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
details summary { cursor: pointer; font-weight: 600; font-size: .9375rem; color: var(--brand); min-height: 40px; display: flex; align-items: center; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "›"; display: inline-block; width: 16px; transition: transform .15s; font-size: 1.25rem; line-height: 1; }
details[open] summary::before { transform: rotate(90deg); }
details.refs { margin-top: 8px; }
details.refs ol { padding-left: 20px; font-size: .8125rem; color: var(--ink-2); }
details.refs li { margin: 6px 0; overflow-wrap: anywhere; }

/* ---------- Resultados ---------- */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0; }
.stat { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.stat-l { font-size: .75rem; color: var(--ink-3); font-weight: 600; line-height: 1.3; }
.stat-v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; margin-top: 2px; }
.stat-u { font-size: .75rem; font-weight: 500; color: var(--ink-2); margin-left: 2px; }
.stat.in { border-color: color-mix(in srgb, var(--in) 45%, var(--line)); } .stat.in .stat-v { color: var(--in); }
.stat.lo { border-color: color-mix(in srgb, var(--lo) 45%, var(--line)); } .stat.lo .stat-v { color: var(--lo); }
.stat.hi { border-color: color-mix(in srgb, var(--hi) 45%, var(--line)); } .stat.hi .stat-v { color: var(--hi); }
.kvs { margin: 4px 0 8px; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-2); font-size: .875rem; }
.kv .v { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.kv .v small { display: block; font-weight: 400; font-size: .75rem; color: var(--ink-3); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: 8px 0; border-radius: 10px; font-size: .875rem; line-height: 1.4; border: 1px solid transparent; }
.alert-ic { flex: none; font-weight: 700; width: 18px; text-align: center; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert.danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert a { color: inherit; font-weight: 700; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .875rem; }
.tbl th, .tbl td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { text-align: left; padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl thead th { font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 650; white-space: nowrap; }
.tbl tbody th { font-weight: 600; }
.tbl small { display: block; font-weight: 400; font-size: .6875rem; color: var(--ink-3); white-space: nowrap; }
.tbl small.hi { color: var(--hi); font-weight: 700; }
.tbl td.in { color: var(--in); font-weight: 700; } .tbl td.lo { color: var(--lo); font-weight: 700; } .tbl td.hi { color: var(--hi); font-weight: 700; }
.tbl.small { font-size: .8125rem; }
.regimens tbody tr { cursor: pointer; }
.regimens tbody tr.sel { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.regimens tbody tr.sel th:first-child { box-shadow: inset 3px 0 0 var(--brand); padding-left: 8px; }
.best { color: #d49a00; margin-right: 4px; }

/* ---------- Gráfico ---------- */
.chart { margin: 0; }
.chart figcaption { font-size: .875rem; font-weight: 600; margin-bottom: 4px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.v { stroke-dasharray: 2 4; }
.chart .axis { stroke: var(--ink-3); stroke-width: 1.2; }
.chart .tick { fill: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .axis-l { fill: var(--ink-2); font-size: 12px; }
.chart .band { fill: var(--band); }
.chart .line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.fit { stroke: var(--line-fit); }
.chart .line.proj { stroke: var(--line-proj); stroke-dasharray: 7 5; }
.chart .line.pop { stroke: var(--line-pop); stroke-width: 1.8; stroke-dasharray: 3 4; }
.chart .obs { fill: var(--surface); stroke: var(--hi); stroke-width: 3; }
.chart .mark { stroke: var(--ink-3); stroke-dasharray: 4 3; }
.chart .mark-t { fill: var(--ink-2); font-size: 11px; }
.chart .cursor { stroke: var(--ink-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-read { min-height: 1.4em; font-size: .75rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .75rem; color: var(--ink-2); margin-top: 4px; }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid; }
.lg.fit i { border-color: var(--line-fit); }
.lg.proj i { border-color: var(--line-proj); border-top-style: dashed; }
.lg.pop i { border-color: var(--line-pop); border-top-style: dotted; }
.lg.obs i { width: 10px; height: 10px; border: 2.5px solid var(--hi); border-radius: 50%; }
.lg.band i { height: 10px; border: 0; background: var(--band); outline: 1px solid color-mix(in srgb, var(--in) 40%, transparent); }

/* ---------- Pacientes ---------- */
.plist { list-style: none; padding: 0; margin: 0 0 12px; }
.pitem { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.pbtn { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 60px; padding: 10px 14px; text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; box-shadow: var(--shadow); }
.pbtn small { color: var(--ink-3); font-size: .8125rem; }
.pitem.cur .pbtn { border-color: var(--brand); box-shadow: inset 4px 0 0 var(--brand), var(--shadow); }

/* ---------- Aviso inicial ---------- */
.hero-card { text-align: center; padding: 32px 18px 24px; }
.hero-card .lead { margin: 16px auto 0; max-width: 32ch; }
.hero-card h2 { margin: 12px 0 4px; font-size: 1.5rem; }
.brand-big svg { width: 72px; height: 72px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px); transform: translate(-50%, 24px) scale(.96); opacity: 0; pointer-events: none; max-width: min(92vw, 480px); padding: 12px 18px; border-radius: 16px;
  background: rgba(29, 29, 31, .92); color: #fff; font-size: .875rem; font-weight: 500; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); transition: opacity .25s, transform .45s var(--spring); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.toast.ok { background: rgba(18, 112, 53, .95); } .toast.warn { background: rgba(122, 79, 0, .95); } .toast.danger { background: rgba(170, 16, 30, .95); }
body.gated .toast { bottom: calc(var(--safe-b) + 18px); }

.ic { width: 20px; height: 20px; fill: currentColor; vertical-align: middle; }

/* ---------- Teléfonos pequeños ---------- */
@media (max-width: 359px) {
  .modules { grid-template-columns: 1fr; }
  .module { min-height: 0; flex-direction: row; align-items: center; }
  .big { font-size: 1.375rem; }
  .stat-v { font-size: 1.125rem; }
}

/* ---------- Tableta ---------- */
@media (min-width: 600px) {
  .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .modules { grid-template-columns: repeat(3, 1fr); }
  .row-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) 44px; grid-template-areas: "at mg ti del"; }
  .row-grid.lv { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 44px; grid-template-areas: "at mg del"; }
  .table-wrap { margin: 0; padding: 0; }
}

@media (min-width: 900px) {
  main { padding-top: 20px; }
  main.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); grid-template-areas: "form live" "post live"; grid-template-rows: auto 1fr; gap: 0 16px; align-items: start; }
  main.split > .form-col { grid-area: form; min-width: 0; }
  main.split > .post-col { grid-area: post; min-width: 0; }
  main.split > #live { grid-area: live; min-width: 0; }
  main.split > #live { position: sticky; top: 64px; max-height: calc(100vh - 80px - var(--tabbar-h)); overflow-y: auto; overscroll-behavior: contain; padding-bottom: 8px; }
  main.split > #live:empty { display: none; }
  main[data-view="home"] .modules { grid-template-columns: repeat(3, 1fr); }
  .tabbar { max-width: 640px; left: 50%; transform: translateX(-50%); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}

/* ---------- Impresión ---------- */
@media print {
  .topbar, .tabbar, .no-print, .toast, .stale, .seg, details.gen, .btn, .icon-btn { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; max-width: none; display: block !important; }
  .card { box-shadow: none; break-inside: avoid; border-color: #bbb; }
  main.split > #live { position: static; }
  body.printing-sheet main, body.printing-sheet .stale { display: none !important; }
}

/* Hoja de informe imprimible (solo en impresión) */
#print-sheet { display: none; }
@media print {
  @page { margin: 14mm; }
  body.printing-sheet #print-sheet { display: block; }
  .sheet { color: #000; font-size: 10.5pt; }
  .sheet-head { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid #0071e3; padding-bottom: 6px; margin-bottom: 10px; }
  .sheet-head span { color: #555; }
  .sheet-text { white-space: pre-wrap; font-family: inherit; margin: 0 0 8px; }
  .sheet-chart { margin: 6px 0; break-inside: avoid; }
  .sheet-chart svg { width: 100%; height: auto; max-height: 70mm; }
  .sheet-h { font-size: 11pt; margin: 8px 0 2px; }
  .sheet-refs { font-size: 8.5pt; margin: 0; padding-left: 18px; }
  .sheet-foot { border-top: 1px solid #999; margin-top: 10px; padding-top: 4px; font-size: 8pt; color: #444; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Grupos con un solo módulo: tarjeta horizontal a ancho completo */
.modules > .module:only-child { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; }
/* En 2 columnas, el último módulo de un grupo impar ocupa la fila completa (sin hueco) */
@media (max-width: 599px) {
  .modules > .module:last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 0; }
}

/* ---------- Marca AdjustNow by Phoraxis ---------- */
.topmark { display: inline-flex; margin-right: 8px; }
.topmark .logo-mark { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 2px 8px color-mix(in srgb, #0071e3 30%, transparent); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark { position: relative; display: inline-flex; flex: none; }
.brand .logo-mark { position: relative; flex: none; border-radius: 23%; box-shadow: 0 6px 20px color-mix(in srgb, #0071e3 30%, transparent); }
/* Aura que respira detrás del isotipo (pantallas de acceso) */
.brand-mark.glow::before { content: ""; position: absolute; inset: -38%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(41, 151, 255, .34) 0%, rgba(94, 92, 230, .12) 45%, transparent 68%); animation: aura 4.2s ease-in-out 1.2s infinite; }
.brand-t { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-family: var(--marca); font-size: 1.625rem; font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.brand-name b { font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.brand-by { display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; font-family: var(--mono); font-size: .75rem; letter-spacing: .06em; color: var(--ink-3); }
.brand.stacked { flex-direction: column; text-align: center; }
.brand.stacked .brand-t { align-items: center; }
.brand.stacked .brand-name { font-size: 2.25rem; margin-top: 10px; }
.home-brand { margin: 6px 2px 16px; }
.made-by { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 10px 0 0; font-family: var(--mono); font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- Logotipo de Phoraxis (copia del oficial) ---------- */
.phoraxis-logo { display: inline-flex; align-items: center; gap: calc(var(--phx-h, 16px) * .42); color: var(--ink); vertical-align: middle; line-height: 1; text-transform: none; letter-spacing: 0; }
.phx-mark { flex: none; display: block; }
.phx-accent-fill { fill: var(--phx-accent); }
.phx-word { font-family: var(--marca); font-weight: 800; font-size: calc(var(--phx-h, 16px) * 1.36); letter-spacing: -.01em; text-transform: uppercase; line-height: .8; padding-top: .06em; }
.phx-x { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
@supports not ((-webkit-background-clip: text) or (background-clip: text)) { .phx-x, .brand-name b { -webkit-text-fill-color: currentColor; background: none; color: var(--brand); } }
.phx-mark.full { color: var(--ink); overflow: visible; }
.ph-radar { stroke: var(--phx-accent); transform-box: view-box; transform-origin: 60px 60px; }
.ph-cama { transform-box: fill-box; transform-origin: center; }
.ph-marca-anillo, .ph-marca-halo { stroke: var(--phx-accent); transform-box: view-box; transform-origin: 82px 38px; }
.ph-marca-halo { stroke-opacity: .5; }
.ph-marca-punto { fill: var(--phx-accent); }
@media (prefers-reduced-motion: no-preference) {
  .ph-radar { animation: phRadar 3.6s linear infinite; }
  .ph-cama { animation: phCama 3.6s ease-out infinite; }
  .ph-marca-anillo { animation: phMarca 1.8s ease-out infinite; }
}
@keyframes phRadar { 0% { transform: scale(.1); opacity: .9; } 90% { opacity: .15; } 100% { transform: scale(1); opacity: 0; } }
@keyframes phCama { 0% { fill-opacity: 1; transform: scale(1.7); } 14%, 100% { fill-opacity: .4; transform: scale(1); } }
@keyframes phMarca { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes aura { 0%, 100% { transform: scale(.9); opacity: .4; } 50% { transform: scale(1.08); opacity: .9; } }
.about-brand { margin-bottom: 10px; }

/* ---------- Cuenta y suscripción ---------- */
body.gated main { padding-bottom: calc(var(--safe-b) + 24px); }
.auth-hero { text-align: center; padding: 16px 8px 8px; }
.auth-hero .lead { margin: 10px 0 4px; }
main[data-view="login"], main[data-view="register"], main[data-view="forgot"], main[data-view="reset"], main[data-view="offline"] { max-width: 460px; }
.center { text-align: center; }
.form-err { margin: 4px 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: .875rem; }
.input-wrap input[type="email"], .input-wrap input[type="password"] { font-size: 1rem; }
.btn[disabled] { opacity: .6; cursor: default; }
.plans { display: grid; gap: 12px; }
.plan.featured { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow); }
.plan-price { margin: 0 0 10px; font-size: 1.5rem; }
.plan-price small { font-size: .875rem; color: var(--ink-3); }
.price-tbd { font-size: 1rem; color: var(--ink-3); font-weight: 600; }
.badge { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 99px; background: var(--brand); color: var(--brand-ink); }
.small .ic { width: 14px; height: 14px; fill: currentColor; vertical-align: -2px; }
@media (min-width: 760px) { .plans { grid-template-columns: repeat(3, 1fr); } }

/* Vista previa embebida: el visor no permite imprimir */
.embedded [data-action="print"] { display: none; }

/* Fase demo: accesos rápidos a las cuentas de prueba */
.demo-panel { border-style: dashed; }
.demo-btns { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.demo-btns .btn { min-height: 40px; padding: 8px 10px; font-size: .875rem; }
.demo-btns .btn.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }

/* ---------- Panel de propietarios ---------- */
.owner-strip { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: inset 4px 0 0 var(--brand), var(--shadow); }
.adm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 8px; }
.adm-head p { margin: 0; }
.adm-tabs a { flex: 1 1 0; min-width: max-content; min-height: 40px; padding: 8px 12px; border-radius: 9px; color: var(--ink-2); font-size: .875rem; font-weight: 600; text-decoration: none; display: grid; place-items: center; white-space: nowrap; }
.adm-tabs a.on { background: var(--seg-on); color: var(--brand); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.adm-grid { display: grid; gap: 0 12px; }
.adm-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 8px; }
.adm-toolbar .input-wrap { flex: 1 1 180px; }
.adm-toolbar p { flex: 1 1 220px; margin: 0; }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 12px; }
.kpi { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 0; }
.kpi-l { font-size: .75rem; color: var(--ink-3); font-weight: 600; line-height: 1.3; }
.kpi-v { font-size: 1.375rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 4px; overflow-wrap: anywhere; color: var(--ink); }
.kpi-s { font-size: .75rem; color: var(--ink-2); margin-top: 2px; line-height: 1.35; }

.chip { display: inline-block; font-size: .6875rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.danger { background: var(--danger-bg); color: var(--danger); } .chip.info { background: var(--info-bg); color: var(--info); }
.chip.muted { background: var(--surface-2); color: var(--ink-3); border-color: var(--line); }
.chip.brand { background: color-mix(in srgb, var(--brand) 15%, transparent); color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.fchip { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer; }
.fchip span { color: var(--ink-3); font-weight: 500; margin-left: 2px; }
.fchip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.fchip.on span { color: inherit; opacity: .85; }

.urow { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.urow:first-of-type { border-top: 0; }
.urow:hover .urow-main b { color: var(--brand); }
.urow-main { display: flex; flex-direction: column; min-width: 0; }
.urow-main b { font-weight: 650; overflow-wrap: anywhere; }
.urow-main small { color: var(--ink-3); font-size: .8125rem; overflow-wrap: anywhere; }
.urow-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; flex: none; max-width: 55%; }
.urow-meta small { font-size: .75rem; color: var(--ink-2); }
.urow-meta small.muted { color: var(--ink-3); }

.bars { margin: 0; }
.bars figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.bars-plot { position: relative; display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--ink-3);
  background: linear-gradient(var(--line), var(--line)) 0 18px / 100% 1px no-repeat; }
.bars-max { position: absolute; top: 0; left: 0; font-size: .6875rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.bars-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: .8125rem; color: var(--ink-3); }
.bar-col { position: relative; flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; outline-offset: 1px; }
.bar { display: block; width: 100%; max-width: 28px; background: var(--brand); border-radius: 4px 4px 0 0; }
.bar-col:hover .bar, .bar-col:focus .bar { background: var(--brand-2); }
.bar-col:hover::after, .bar-col:focus::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); z-index: 2;
  padding: 6px 8px; border-radius: 8px; background: var(--ink); color: var(--surface); font-size: .75rem; font-weight: 600; white-space: nowrap; pointer-events: none; }
.bar-col:first-child:hover::after, .bar-col:first-child:focus::after { left: 0; transform: none; }
.bar-col:last-child:hover::after, .bar-col:last-child:focus::after { left: auto; right: 0; transform: none; }
.bars-x { display: flex; gap: 4px; margin-top: 4px; }
.bars-x span { flex: 1 1 0; text-align: center; font-size: .6875rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; }

.hbars { list-style: none; margin: 0 0 12px; padding: 0; }
.hbars a { display: grid; grid-template-columns: minmax(96px, 40%) 1fr auto; align-items: center; gap: 10px; padding: 6px 0; color: inherit; text-decoration: none; font-size: .875rem; }
.hbars b { font-variant-numeric: tabular-nums; min-width: 24px; text-align: right; }
.hb-t { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hb { display: block; height: 100%; border-radius: 5px; background: var(--ink-3); }
.hb.ok { background: var(--ok); } .hb.warn { background: var(--warn); } .hb.danger { background: var(--danger); } .hb.info { background: var(--info); } .hb.brand { background: var(--brand); }

.loglist { list-style: none; margin: 0 0 8px; padding: 0; }
.loglist li { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .875rem; }
.loglist li:first-child { border-top: 0; }
.log-at { font-size: .75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.pay-tbl td:nth-child(2), .pay-tbl th:nth-child(2) { text-align: left; }
.pay-tbl tr.refunded td { color: var(--ink-3); }
.pay-tbl .btn { min-height: 32px; padding: 4px 10px; font-size: .75rem; }

.uhead { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.uhead > div { flex: 1; min-width: 0; }
.uname { margin: 0; font-size: 1.125rem; overflow-wrap: anywhere; }
.uhead p { margin: 0; overflow-wrap: anywhere; }
textarea { width: 100%; min-height: 84px; padding: 10px 12px; font: inherit; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent); }
.linkbox { margin: 0 0 10px; }
.linkbox-in { width: 100%; min-height: 44px; margin: 0 0 8px; padding: 8px 10px; font: inherit; font-size: .8125rem; color: var(--ink-2); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.price-row { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 10px 0 0; min-width: 0; }
.price-row legend { font-weight: 650; padding: 0 0 6px; }
.flow { list-style: none; counter-reset: fl; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.flow li { counter-increment: fl; display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto; column-gap: 10px; font-size: .875rem; }
.flow li::before { content: counter(fl); grid-row: span 2; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: .8125rem; }
.flow li span { color: var(--ink-2); }
.checklist { list-style: none; margin: 0 0 8px; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); font-size: .875rem; }
.checklist li:first-child { border-top: 0; }
.checklist li > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.checklist small { color: var(--ink-3); overflow-wrap: anywhere; }
.ck { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .75rem; font-weight: 800; background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.checklist .ok .ck { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.checklist .no .ck { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.code { margin: 0; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-size: .75rem; overflow-x: auto; white-space: pre; }

@media (min-width: 600px) {
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
  .adm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
.kpi { transition: transform .3s var(--ease), box-shadow .3s; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-v { font-family: var(--body); letter-spacing: -.02em; }
.kpi-l { font-family: var(--mono); font-size: .625rem; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; }
.log-at { font-family: var(--mono); font-weight: 400; letter-spacing: .02em; }
.bar { background: var(--grad); }
.fchip { transition: background .2s, color .2s, border-color .2s, transform .2s var(--spring); }
.fchip:active { transform: scale(.95); }
.urow { transition: background .2s; border-radius: 10px; }
.chip { letter-spacing: .01em; }

/* ---------- Acceso: escena de marca ---------- */
.auth-hero { position: relative; padding: 28px 8px 14px; }
.auth-hero .brand-name { font-size: 2.375rem; }
.auth-hero .lead { margin: 14px auto 4px; max-width: 30ch; }
form .btn.block + .center, form .btn.block + p { margin-top: 14px; }
.btn.block + .btn.block { margin-top: 8px; }

/* ---------- Movimiento ----------
   Solo al cambiar de pantalla (main.enter): los bloques entran escalonados. Los re-renderizados de la misma
   pantalla (escribir, elegir una opción) no se animan. Todo se desactiva con «reducir movimiento». */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.92); } 100% { opacity: 1; transform: none; } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: none; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: none; } }

main.enter > *, main.enter .form-col > *, main.enter .post-col > *, main.enter.split > #live { animation: rise .5s var(--ease) both; }
main.enter > :nth-child(2), main.enter .form-col > :nth-child(2) { animation-delay: .04s; }
main.enter > :nth-child(3), main.enter .form-col > :nth-child(3) { animation-delay: .08s; }
main.enter > :nth-child(4), main.enter .form-col > :nth-child(4) { animation-delay: .12s; }
main.enter > :nth-child(5), main.enter .form-col > :nth-child(5) { animation-delay: .16s; }
main.enter > :nth-child(6), main.enter .form-col > :nth-child(6) { animation-delay: .2s; }
main.enter > :nth-child(7), main.enter .form-col > :nth-child(7) { animation-delay: .24s; }
main.enter > :nth-child(n+8), main.enter .form-col > :nth-child(n+8) { animation-delay: .28s; }
main.enter.split > #live { animation-delay: .1s; }
main.enter .post-col > * { animation-delay: .2s; }
/* Módulos del inicio: cascada propia dentro de cada grupo */
main.enter .modules > .module { animation: pop .45s var(--ease) both; }
main.enter .modules > .module:nth-child(2) { animation-delay: .05s; }
main.enter .modules > .module:nth-child(3) { animation-delay: .1s; }
main.enter .modules > .module:nth-child(n+4) { animation-delay: .15s; }

/* Resultados, avisos y secciones desplegables */
main.enter .alert { animation: fade .4s ease .1s both; }
details[open] > :not(summary) { animation: rise .3s var(--ease) both; }
.stat { transition: border-color .3s, background .3s; }
main.enter .bar { transform-origin: bottom; animation: grow-y .7s var(--ease) both; }
main.enter .bar-col:nth-child(3n+1) .bar { animation-delay: .15s; }
main.enter .bar-col:nth-child(3n+2) .bar { animation-delay: .22s; }
main.enter .bar-col:nth-child(3n) .bar { animation-delay: .29s; }
main.enter .hb { transform-origin: left; animation: grow-x .7s var(--ease) .2s both; }

/* E2.5: datos de administración completos, también en teléfono. */
.row-grid.dose-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; grid-template-areas: none; }
.row-grid.dose-row > label, .row-grid.dose-row > .field { grid-area: auto; min-width: 0; }
.row-grid.dose-row > label:first-child { grid-column: 1 / 3; }
.row-grid.dose-row > .del { grid-area: auto; grid-column: 3; grid-row: 1 / 5; }
/* E1.7 · Calibración de Adjust y electrificación de NOW. */
.brand .adaptive-mark, .topmark .adaptive-mark { border-radius: 0; box-shadow: none; }
.brand-name { white-space: nowrap; display: inline-flex; align-items: baseline; }
.brand-adjust { display: inline-flex; }
.calibration-letter { display: inline-block; height: 1.1em; overflow: hidden; vertical-align: bottom; }
.calibration-track { display:flex; flex-direction:column; transform:translateY(-7.7em); }
.calibration-track > span { display:block; height:1.1em; line-height:1.1; flex:none; }
.brand .brand-now { position:relative; display:inline-block; }
.electric-brand .brand-now { background:none; -webkit-text-fill-color:currentColor; color:#81ceff; text-shadow:0 0 8px #25a9ff99,0 0 24px #168aff70; }
.now-bolt { position:absolute; width:clamp(230px,35vw,560px); height:clamp(230px,45vh,560px); bottom:.45em; left:50%; transform:translateX(-50%); overflow:visible; opacity:0; pointer-events:none; z-index:12; filter:drop-shadow(0 0 14px #37bbff); }
.now-bolt path { fill:none; stroke:#e5fdff; stroke-width:3; stroke-linecap:round; stroke-linejoin:round; stroke-dasharray:2400; stroke-dashoffset:2400; }
.now-bolt .bolt-halo { stroke:#48bfff; stroke-width:14; opacity:.45; }
.now-bolt .bolt-branch { stroke-width:1.5; stroke:#81ceff; }
.now-arcs { position:absolute; inset:-.1em -.08em; width:calc(100% + .16em); height:calc(100% + .2em); overflow:visible; opacity:0; pointer-events:none; filter:drop-shadow(0 0 3px #b6f5ff); }
.now-arcs path { fill:none; stroke:#c8f8ff; stroke-width:1; stroke-dasharray:18 70; }
.now-arcs .arc-cross { stroke:#72d4ff; stroke-width:.7; stroke-dasharray:8 55; }
@keyframes calibrate { 0% { transform:translateY(0); } 100% { transform:translateY(-7.7em); } }
@keyframes now-strike { from { stroke-dashoffset:2400; } 55%,100% { stroke-dashoffset:0; } }
@keyframes now-bolt { 0% { opacity:0; } 8% { opacity:.65; } 40%,100% { opacity:0; } }
@keyframes now-power { 0%,80% { color:#8fa9bd; text-shadow:none; } 90% { color:#edfdff; text-shadow:0 0 15px #b6f5ff,0 0 48px #168aff; } 100% { color:#81ceff; text-shadow:0 0 8px #25a9ff99,0 0 24px #168aff70; } }
@keyframes electric-flow { from { stroke-dashoffset:0; } to { stroke-dashoffset:-176; } }
@keyframes electric-breathe { 0%,100% { filter:drop-shadow(0 0 2px #4cbdff); } 50% { filter:drop-shadow(0 0 7px #87e8ff); } }
@keyframes arcs-on { to { opacity:.85; } }
@media (prefers-reduced-motion:no-preference) {
 .electric-brand .calibration-track { animation:calibrate calc(1.4s + var(--slot)*.12s) cubic-bezier(.12,.5,.16,1) both; }
 .electric-brand .now-bolt { animation:now-bolt .5s ease-out 2s both; }
 .electric-brand .now-bolt path { animation:now-strike .09s ease-out 2s both; }
 .electric-brand .brand-now { animation:now-power 2.5s ease-out both,electric-breathe 2.4s ease-in-out 2.5s infinite; }
 .electric-brand .now-arcs { animation:arcs-on .3s ease-out 2.3s forwards; }
 .electric-brand .now-arcs path { animation:electric-flow 1.8s linear 2.3s infinite; }
}
.energy-paused .brand-now, .energy-paused .now-arcs path { animation-play-state:paused; }
.energy-paused .now-arcs { opacity:0 !important; }
.motion-reset *, .motion-reset::after { animation:none !important; }
@media(prefers-reduced-motion:reduce) { .now-bolt,.now-arcs { display:none; } }

.calibration-track > span { text-align:center; }
.energy-suspended *, .energy-suspended svg path { animation-play-state:paused !important; }
.topmark .adaptive-mark { background:#081b2d; border-radius:6px; }

/* Módulos que el plan actual no incluye */
.module.locked { opacity: .62; }
.module.locked .module-t small { color: var(--muted, inherit); font-style: italic; }

/* Registro rápido: pegar varias filas */
textarea.paste { width: 100%; box-sizing: border-box; font: inherit; font-size: .875rem; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; margin: 6px 0; resize: vertical; }
.summary-card .big { margin: 4px 0 8px; }
details.safety-fold > summary, details.more-warn > summary { font-size: .875rem; }
