/* ==========================================================================
   Hemokaan · Bases de UI (v1.0)
   Fuente de verdad: design-system/hemokaan/MASTER.md
   - Tokens con los MISMOS nombres que HabiKaan (--accent, --ink, --line…): familia kaan.
   - Componentes con prefijo .hk-  ·  estados por atributos ARIA cuando existen
     ([aria-invalid], [aria-busy], [aria-current], [aria-selected], [aria-sort]).
   ========================================================================== */

/* ---------- Fuentes (auto-hospedadas, OFL; ver public/fonts) ---------- */
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('../fonts/plus-jakarta-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plus Jakarta Sans'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url('../fonts/plus-jakarta-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/space-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Mono'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('../fonts/space-mono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Space Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/space-mono-700-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Space Mono'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('../fonts/space-mono-700-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------- Tokens ---------- */
:root {
  /* Marca (manual de imagen v1.0) */
  --accent:   #9B1B30;  /* Carmín — acción principal, marca. Blanco encima: 8.1:1 */
  --accent2:  #C4344A;  /* Carmín claro — hover, degradado del símbolo */
  --accent-press: #7E1526;
  --sand:     #F1D492;  /* Arena — brillo, destacados (compartido con HabiKaan) */
  --on-sand:  #5A3E0B;
  --tint:     #F7E7EA;  /* Rubor — fondos de resalte, fila seleccionada */
  --cream:    #FAF6F2;  /* Papel — fondo de página */
  --panel:    #FFFFFF;  /* Superficies (tarjetas, tablas, formularios) */
  --ink:      #25171A;  /* Tinta — texto principal: 16.6:1 sobre blanco */
  --bg:       #1E1214;  /* Oscuro — rail y superficies oscuras */
  --muted:    #6E5D61;  /* Texto secundario: 6.1:1 sobre blanco, 5.8:1 sobre papel (AA) */
  --line:     #E8DCDE;  /* Bordes y divisores */
  --line-strong: #CDBBBF; /* Borde de campos (≥3:1 contra el fondo no exigido, pero visible) */
  --on-accent: #FFFFFF;
  --on-dark:   #F3ECEE;
  --on-dark-dim: #C9BABD;

  /* Estados (iguales en toda la app; SIEMPRE con texto e ícono, nunca solo color) */
  --ok:       #1F6B47; --ok-tint:      #E2F2E9;  /* Apto · Disponible */
  --warn:     #8A5A00; --warn-tint:    #FBEFD6;  /* Diferido · Por caducar */
  --danger:   #A11A1A; --danger-tint:  #FBE3E1;  /* No apto · Baja · Error */
  --neutral:  #475467; --neutral-tint: #EAECF0;  /* Pendiente · Entregada */
  --info:     #1F4E9C; --info-tint:    #E2EBFA;  /* Reservada · Información */

  /* Foco: azul, para no confundirse con error ni con la marca roja */
  --focus: #1F4E9C;
  --focus-on-dark: #9DB8F0;

  /* Tipografía */
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 12px;   /* mínimo absoluto: notas, ayudas */
  --fs-sm: 14px;   /* tablas densas, etiquetas */
  --fs-md: 16px;   /* cuerpo e inputs (16px evita el zoom de iOS) */
  --fs-lg: 18px;   /* título de sección (h3) */
  --fs-xl: 22px;   /* título de tarjeta/panel (h2) */
  --fs-2xl: 28px;  /* título de página (h1) */
  --lh: 1.5;

  /* Espaciado denso (base 4) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  /* Radios */
  --r-sm: 6px;   /* chips, badges */
  --r-md: 10px;  /* botones, campos */
  --r-lg: 14px;  /* tarjetas, tablas */
  --r-xl: 20px;  /* diálogos */

  /* Sombras (sutiles; la jerarquía la da el borde, no la sombra) */
  --sh-1: 0 1px 2px rgba(37, 23, 26, .06), 0 1px 1px rgba(37, 23, 26, .04);
  --sh-2: 0 12px 32px rgba(37, 23, 26, .16), 0 2px 6px rgba(37, 23, 26, .08);

  /* Movimiento */
  --t-fast: 120ms; --t-med: 180ms; --t-slow: 240ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* Capas */
  --z-rail: 60; --z-topbar: 50; --z-menu: 70; --z-toast: 90;

  /* Medidas del cascarón */
  --rail-w: 264px;
  --topbar-h: 60px;
  --control-h: 44px;    /* objetivo táctil mínimo */
  --control-h-sm: 36px; /* solo en tablas densas y barras de filtros */
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%;
  /* El foco (teclado físico o en pantalla) nunca queda bajo la barra superior ni la barra de acciones fija */
  scroll-padding-top: calc(var(--topbar-h) + var(--sp-4)); scroll-padding-bottom: 104px; }
body { margin: 0; background: var(--cream); color: var(--ink); font-family: var(--font); font-size: var(--fs-md); line-height: var(--lh); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: var(--fs-lg); font-weight: 700; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-press); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[id] { scroll-margin-top: calc(var(--topbar-h) + var(--sp-4)); } /* anclas y foco no quedan bajo la barra fija */
.hk-mono, code, kbd { font-family: var(--mono); }
.hk-num { font-variant-numeric: tabular-nums; }
.hk-muted { color: var(--muted); }
.hk-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hk-skip { position: absolute; left: var(--sp-3); top: -100px; z-index: 100; padding: var(--sp-2) var(--sp-4); background: var(--ink); color: #fff; border-radius: var(--r-md); }
.hk-skip:focus { top: var(--sp-3); }
.hk-ico { width: 20px; height: 20px; flex: none; }
.hk-ico--sm { width: 16px; height: 16px; }
.hk-ico--lg { width: 24px; height: 24px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Cascarón: rail (menú lateral) + topbar + página
   ========================================================================== */
.hk-app { min-height: 100vh; }
.hk-nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

.hk-rail { position: fixed; z-index: var(--z-rail); inset: 0 auto 0 0; width: var(--rail-w); background: var(--bg); color: var(--on-dark-dim);
  display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4) var(--sp-3); overflow-y: auto;
  transform: translateX(-100%); transition: transform var(--t-slow) var(--ease); }
.hk-nav-toggle:checked ~ .hk-rail { transform: translateX(0); }
.hk-rail-backdrop { display: none; position: fixed; inset: 0; z-index: calc(var(--z-rail) - 1); background: rgba(30, 18, 20, .55); }
.hk-nav-toggle:checked ~ .hk-rail-backdrop { display: block; }
.hk-rail :focus-visible { outline-color: var(--focus-on-dark); }
.hk-rail-brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-1) var(--sp-2) var(--sp-4); text-decoration: none; }
.hk-rail-brand img { width: 36px; height: 36px; }
.hk-rail-brand span { font-size: 20px; letter-spacing: -.02em; color: var(--on-dark-dim); font-weight: 600; }
.hk-rail-brand b { color: #E58A97; font-weight: 800; }
.hk-rail-group { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-4) var(--sp-2) var(--sp-1);
  font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: #9C8A8E; }
.hk-rail-group::after { content: ""; flex: 1; height: 1px; background: #3A2A2D; }
.hk-rail-item { display: flex; align-items: center; gap: var(--sp-3); min-height: var(--control-h); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-md);
  color: var(--on-dark-dim); text-decoration: none; font-size: 15px; font-weight: 600; transition: background var(--t-fast), color var(--t-fast); }
.hk-rail-item:hover { background: #33232A; color: #fff; }
.hk-rail-item[aria-current="page"] { background: var(--accent); color: var(--on-accent); }
.hk-rail-item .hk-count { margin-left: auto; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--sand); color: var(--on-sand); font-size: 12px; font-weight: 800; text-align: center; line-height: 20px; }
.hk-rail-foot { margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid #3A2A2D; display: flex; flex-direction: column; gap: var(--sp-1); }

.hk-main { min-width: 0; }
.hk-topbar { position: sticky; top: 0; z-index: var(--z-topbar); height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.hk-topbar-burger { display: inline-flex; }
.hk-topbar-spacer { flex: 1; }
.hk-topbar-context { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.hk-topbar-context strong { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hk-topbar-context span { font-size: var(--fs-xs); color: var(--muted); }
.hk-search { display: none; align-items: center; gap: var(--sp-2); width: min(420px, 40vw); height: 40px; padding: 0 var(--sp-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--panel); color: var(--muted); }
.hk-search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: var(--fs-sm); color: var(--ink); }
.hk-search:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.hk-search kbd { font-size: 11px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }
.hk-topbar .hk-search-btn { display: inline-flex; } /* en móvil la búsqueda es un botón que lleva a /buscar */

.hk-page { max-width: 1440px; margin: 0 auto; padding: var(--sp-6) var(--sp-4) var(--sp-12); display: flex; flex-direction: column; gap: var(--sp-6); }
.hk-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); }
.hk-page-head > div:first-child { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.hk-page-head p { color: var(--muted); font-size: var(--fs-sm); }
.hk-page-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* Menú fijo desde 1280: en tablets (vertical u horizontal, ≤ 1194 px) el formulario usa todo el ancho
   y el menú se abre con el botón. */
@media (min-width: 1280px) {
  .hk-rail { transform: none; }
  .hk-rail-backdrop, .hk-topbar-burger { display: none !important; }
  .hk-main { margin-left: var(--rail-w); }
  .hk-page { padding: var(--sp-8) var(--sp-8) var(--sp-12); }
  .hk-search { display: flex; }
}
@media (min-width: 768px) and (max-width: 1279px) { .hk-page { padding: var(--sp-6) var(--sp-6) var(--sp-12); } }
@media (min-width: 640px) { .hk-search { display: flex; } .hk-topbar .hk-search-btn { display: none; } }

/* Migas de pan */
.hk-breadcrumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--muted); }
.hk-breadcrumb li + li::before { content: "/"; margin-right: var(--sp-1); color: var(--line-strong); }
.hk-breadcrumb a { color: var(--muted); text-decoration: none; }
.hk-breadcrumb a:hover { color: var(--ink); text-decoration: underline; }
.hk-breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ==========================================================================
   Superficies y rejillas
   ========================================================================== */
.hk-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.hk-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); }
.hk-card-head h2 { font-size: var(--fs-lg); }
.hk-card-body { padding: var(--sp-5); }
.hk-card-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); background: var(--cream); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.hk-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); }
.hk-grid--kpi { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: var(--sp-3); }
.hk-stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.hk-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }

/* KPI */
.hk-stat { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4) var(--sp-5); }
.hk-stat-value { font-family: var(--mono); font-size: 30px; font-weight: 700; line-height: 1.1; }
.hk-stat-label { font-size: var(--fs-sm); font-weight: 600; }
.hk-stat-note { font-size: var(--fs-xs); color: var(--muted); }

/* ==========================================================================
   Botones
   ========================================================================== */
.hk-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: var(--control-h); padding: 0 var(--sp-4);
  border: 1.5px solid transparent; border-radius: var(--r-md); font-size: 15px; font-weight: 700; line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast); }
.hk-btn:active { transform: translateY(1px); }
.hk-btn--primary { background: var(--accent); color: var(--on-accent); }
.hk-btn--primary:hover { background: var(--accent-press); color: var(--on-accent); }
.hk-btn--secondary { background: var(--panel); color: var(--ink); border-color: var(--line-strong); }
.hk-btn--secondary:hover { border-color: var(--ink); color: var(--ink); }
.hk-btn--ghost { background: transparent; color: var(--accent); }
.hk-btn--ghost:hover { background: var(--tint); color: var(--accent-press); }
/* Destructivo: NUNCA relleno fuera de un diálogo de confirmación (el rojo de marca y el de peligro se parecen) */
.hk-btn--danger { background: var(--panel); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, white); }
.hk-btn--danger:hover { background: var(--danger-tint); border-color: var(--danger); color: var(--danger); }
.hk-btn--danger-solid { background: var(--danger); color: #fff; }
.hk-btn--danger-solid:hover { background: #7F1414; color: #fff; }
.hk-btn--sm { min-height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.hk-btn--block { width: 100%; }
.hk-btn--icon { width: var(--control-h); padding: 0; }
.hk-btn--icon.hk-btn--sm { width: var(--control-h-sm); }
.hk-btn[disabled], .hk-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.hk-btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.hk-btn[aria-busy="true"]::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent; animation: hk-spin .7s linear infinite; }
.hk-btn--secondary[aria-busy="true"]::after, .hk-btn--ghost[aria-busy="true"]::after, .hk-btn--danger[aria-busy="true"]::after { border-color: var(--ink) var(--ink) var(--ink) transparent; }
@keyframes hk-spin { to { transform: rotate(360deg); } }

/* Acción destacada de biometría (topbar y recepción) */
.hk-btn--huella { background: var(--ink); color: #fff; }
.hk-btn--huella:hover { background: #000; color: #fff; }
.hk-btn--huella .hk-ico { color: var(--sand); }

/* ==========================================================================
   Formularios
   ========================================================================== */
.hk-form { display: flex; flex-direction: column; gap: var(--sp-6); }
.hk-fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-4); }
.hk-fieldset > legend { padding: 0; margin-bottom: var(--sp-2); font-size: var(--fs-lg); font-weight: 700; }
.hk-form-grid { display: grid; gap: var(--sp-4) var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); }
.hk-span-2 { grid-column: span 2; } .hk-span-all { grid-column: 1 / -1; }
@media (max-width: 639px) { .hk-span-2 { grid-column: 1 / -1; } }

.hk-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hk-label { font-size: var(--fs-sm); font-weight: 700; color: var(--ink); }
.hk-label .hk-req { color: var(--danger); margin-left: 2px; }
.hk-label .hk-opt { color: var(--muted); font-weight: 500; }
.hk-help { font-size: var(--fs-xs); color: var(--muted); }
.hk-error { display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-sm); font-weight: 600; color: var(--danger); }
.hk-error .hk-ico { width: 16px; height: 16px; margin-top: 2px; }

.hk-input, .hk-select, .hk-textarea { width: 100%; min-height: var(--control-h); padding: 0 var(--sp-3); background: var(--panel);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-md); font-size: var(--fs-md); color: var(--ink);
  transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.hk-textarea { min-height: 96px; padding: var(--sp-3); line-height: var(--lh); resize: vertical; }
.hk-select { appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2325171A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
.hk-input::placeholder, .hk-textarea::placeholder { color: #9C8A8E; }
.hk-input:hover, .hk-select:hover, .hk-textarea:hover { border-color: var(--muted); }
.hk-input:focus-visible, .hk-select:focus-visible, .hk-textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.hk-input[aria-invalid="true"], .hk-select[aria-invalid="true"], .hk-textarea[aria-invalid="true"] { border-color: var(--danger); background: #FFFBFA; }
.hk-input[readonly] { background: var(--cream); border-style: dashed; }
.hk-input:disabled, .hk-select:disabled, .hk-textarea:disabled { background: var(--neutral-tint); color: var(--muted); cursor: not-allowed; }
.hk-input--mono { font-family: var(--mono); letter-spacing: .02em; }

/* Campo con unidad (g/dL, ml, kg, mmHg…) */
.hk-input-group { display: flex; align-items: stretch; }
.hk-input-group .hk-input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.hk-input-group:has([aria-invalid="true"]) .hk-addon { border-color: var(--danger); }
.hk-input-group .hk-addon { display: inline-flex; align-items: center; padding: 0 var(--sp-3); border: 1.5px solid var(--line-strong); border-left: 0;
  border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--cream); color: var(--muted); font-family: var(--mono); font-size: var(--fs-sm); white-space: nowrap; }

/* Checkbox y radio nativos con marca */
.hk-check { display: inline-flex; align-items: flex-start; gap: var(--sp-2); min-height: var(--control-h); padding: var(--sp-2) 0; cursor: pointer; font-size: var(--fs-md); }
.hk-check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }

/* Segmentado (Sí / No) — pieza central del cuestionario de historia clínica */
.hk-seg { display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: var(--r-md); overflow: hidden; background: var(--panel); }
.hk-seg label { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 72px; min-height: var(--control-h); padding: 0 var(--sp-4);
  font-weight: 700; cursor: pointer; color: var(--muted); transition: background var(--t-fast), color var(--t-fast); }
.hk-seg label + label { border-left: 1.5px solid var(--line-strong); }
.hk-seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.hk-seg label:has(input:checked) { background: var(--ink); color: #fff; }
.hk-seg label:has(input[value="si"]:checked) { background: var(--warn-tint); color: var(--warn); }
.hk-seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -3px; }

/* Interruptor */
.hk-switch { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--control-h); cursor: pointer; }
.hk-switch input { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; margin: 0; transition: background var(--t-fast); }
.hk-switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--sh-1); transition: transform var(--t-med) var(--ease); }
.hk-switch input:checked { background: var(--ok); }
.hk-switch input:checked::after { transform: translateX(18px); }

/* Pregunta del cuestionario (fila) */
.hk-question { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-2) var(--sp-4); align-items: center; padding: var(--sp-3) 0; border-bottom: 1px solid var(--line); }
.hk-question-text { font-weight: 600; }
.hk-question-more { grid-column: 1 / -1; }
.hk-question[data-respuesta="si"] { background: linear-gradient(90deg, var(--warn-tint), transparent 60%); }

/* Resumen de errores (arriba del formulario, recibe el foco al fallar el envío) */
.hk-error-summary { border: 2px solid var(--danger); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); background: #FFFBFA; }
.hk-error-summary h2 { font-size: var(--fs-lg); color: var(--danger); margin-bottom: var(--sp-2); }
.hk-error-summary ul { margin: 0; padding-left: var(--sp-5); }
.hk-error-summary a { color: var(--danger); font-weight: 600; }

/* ==========================================================================
   Avisos: alertas, toasts, estados
   ========================================================================== */
.hk-alert { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--sp-3); align-items: start; padding: var(--sp-4); border-radius: var(--r-lg); border: 1px solid; font-size: var(--fs-sm); }
.hk-alert .hk-ico { margin-top: 1px; }
.hk-alert-title { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.hk-alert--info   { background: var(--info-tint);    border-color: color-mix(in srgb, var(--info) 30%, white);   color: #173B78; }
.hk-alert--ok     { background: var(--ok-tint);      border-color: color-mix(in srgb, var(--ok) 30%, white);     color: #17533A; }
.hk-alert--warn   { background: var(--warn-tint);    border-color: color-mix(in srgb, var(--warn) 30%, white);   color: #6E4800; }
.hk-alert--danger { background: var(--danger-tint);  border-color: color-mix(in srgb, var(--danger) 30%, white); color: #841616; }
.hk-alert .hk-alert-close { margin: -6px -6px 0 0; }

.hk-toasts { position: fixed; z-index: var(--z-toast); right: var(--sp-4); bottom: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-2); width: min(380px, calc(100vw - 32px)); }
.hk-toast { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); background: var(--ink); color: #fff; box-shadow: var(--sh-2);
  font-size: var(--fs-sm); animation: hk-toast-in var(--t-slow) var(--ease); }
.hk-toast .hk-ico { margin-top: 1px; }
.hk-toast--ok .hk-ico { color: #7FD3A6; } .hk-toast--warn .hk-ico { color: var(--sand); } .hk-toast--danger .hk-ico { color: #F5A3A3; }
.hk-toast button { margin-left: auto; background: none; border: 0; color: var(--on-dark-dim); cursor: pointer; min-width: 32px; min-height: 32px; border-radius: var(--r-sm); }
.hk-toast[data-saliendo] { animation: hk-toast-out var(--t-med) ease-in forwards; }
@keyframes hk-toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes hk-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* Estado (diagnóstico / existencia) — punto + texto, nunca solo color */
.hk-estado { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.hk-estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.hk-estado--apto, .hk-estado--disponible       { background: var(--ok-tint);      color: var(--ok); }
.hk-estado--diferido, .hk-estado--por-caducar  { background: var(--warn-tint);    color: var(--warn); }
.hk-estado--no-apto, .hk-estado--baja          { background: var(--danger-tint);  color: var(--danger); }
.hk-estado--pendiente, .hk-estado--entregada   { background: var(--neutral-tint); color: var(--neutral); }
.hk-estado--reservada                          { background: var(--info-tint);    color: var(--info); }
.hk-estado--no-apto::before, .hk-estado--baja::before { border-radius: 1px; transform: rotate(45deg); } /* forma distinta, no solo color */

/* Folio / unidad / grupo: chips en monoespaciada */
.hk-folio { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: var(--r-sm); background: var(--tint); color: var(--accent);
  font-family: var(--mono); font-size: 13px; font-weight: 700; white-space: nowrap; }
.hk-grupo { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 26px; padding: 0 8px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff; font-family: var(--mono); font-size: 13px; font-weight: 700; }
.hk-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--r-sm); background: var(--neutral-tint); color: var(--ink); font-size: 12px; font-weight: 600; }

/* ==========================================================================
   Tablas
   ========================================================================== */
.hk-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); box-shadow: var(--sh-1); }
.hk-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.hk-table caption { text-align: left; padding: var(--sp-3) var(--sp-4); font-weight: 700; }
.hk-table th, .hk-table td { padding: 0 var(--sp-3); height: 48px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); white-space: nowrap; }
.hk-table thead th { position: sticky; top: 0; z-index: 1; height: 40px; background: var(--cream); color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.hk-table tbody tr:hover td { background: #FCF8F6; }
.hk-table tbody tr[aria-selected="true"] td { background: var(--tint); }
.hk-table tbody tr:last-child td { border-bottom: 0; }
.hk-table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hk-table .wrap { white-space: normal; min-width: 200px; }
.hk-table .acciones { text-align: right; width: 1%; }
.hk-table td .hk-sub { display: block; font-size: 12px; color: var(--muted); }
.hk-th-sort { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; min-height: 32px; }
.hk-th-sort::after { content: "↕"; opacity: .45; }
th[aria-sort="ascending"] .hk-th-sort::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .hk-th-sort::after { content: "↓"; opacity: 1; }
.hk-bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-4); background: var(--ink); color: #fff; border-radius: var(--r-lg); font-size: var(--fs-sm); }
.hk-bulkbar .hk-btn--secondary { background: transparent; color: #fff; border-color: #6B5A5E; }

/* Barra de filtros sobre una lista */
.hk-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); }
.hk-toolbar .hk-field { flex: 1 1 180px; max-width: 280px; }
.hk-toolbar .hk-input, .hk-toolbar .hk-select { min-height: var(--control-h-sm); font-size: 15px; }
.hk-toolbar .hk-btn { min-height: var(--control-h-sm); }
.hk-toolbar-grow { flex: 1; }

/* Paginación */
.hk-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--muted); }
.hk-pager ol { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--sp-1); }
.hk-pager a, .hk-pager span[aria-current] { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; border-radius: var(--r-md); text-decoration: none; color: var(--ink); font-weight: 600; }
.hk-pager a:hover { background: var(--tint); }
.hk-pager span[aria-current] { background: var(--ink); color: #fff; }

/* ==========================================================================
   Navegación interna: pestañas, pasos, menú desplegable
   ========================================================================== */
.hk-tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); overflow-x: auto; }
.hk-tab { position: relative; display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h); padding: 0 var(--sp-4); background: none; border: 0;
  font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; text-decoration: none; }
.hk-tab:hover { color: var(--ink); }
.hk-tab[aria-selected="true"], .hk-tab[aria-current="page"] { color: var(--accent); }
.hk-tab[aria-selected="true"]::after, .hk-tab[aria-current="page"]::after { content: ""; position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }

/* Pasos del proceso de donación */
.hk-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--sp-2); overflow-x: auto; counter-reset: paso; }
.hk-steps li { flex: 1 0 150px; display: flex; flex-direction: column; gap: 6px; padding-top: var(--sp-3); border-top: 4px solid var(--line); font-size: var(--fs-sm); color: var(--muted); counter-increment: paso; }
.hk-steps li::before { content: "Paso " counter(paso); font-family: var(--mono); font-size: 12px; }
.hk-steps li strong { color: var(--ink); }
.hk-steps li[data-estado="hecho"] { border-top-color: var(--ok); }
.hk-steps li[data-estado="actual"] { border-top-color: var(--accent); }
.hk-steps li[data-estado="actual"] strong { color: var(--accent); }
.hk-steps li[data-estado="bloqueado"] { border-top-style: dashed; }

/* Menú desplegable con <details> (sin JS) */
.hk-menu { position: relative; }
.hk-menu > summary { list-style: none; }
.hk-menu > summary::-webkit-details-marker { display: none; }
.hk-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-menu); min-width: 220px; padding: var(--sp-1); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-2); display: flex; flex-direction: column; }
.hk-menu-list a, .hk-menu-list button { display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; padding: 0 var(--sp-3); border-radius: var(--r-md); background: none; border: 0; text-align: left;
  color: var(--ink); text-decoration: none; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.hk-menu-list a:hover, .hk-menu-list button:hover { background: var(--tint); }
.hk-menu-list .hk-menu-danger { color: var(--danger); }
.hk-menu-list hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-1) 0; }

/* ==========================================================================
   Diálogo (<dialog> nativo: atrapa el foco y cierra con Esc)
   ========================================================================== */
.hk-dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--r-xl); background: var(--panel); color: var(--ink); box-shadow: var(--sh-2); }
.hk-dialog::backdrop { background: rgba(30, 18, 20, .55); }
.hk-dialog[open] { animation: hk-dialog-in var(--t-slow) var(--ease); }
@keyframes hk-dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.hk-dialog-body { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); }
.hk-dialog-body h2 { font-size: var(--fs-xl); }
.hk-dialog-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--line); background: var(--cream); }
.hk-dialog--danger .hk-dialog-body h2 { color: var(--danger); }

/* ==========================================================================
   Vacío, carga, captura de huella
   ========================================================================== */
.hk-empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-12) var(--sp-6); text-align: center; color: var(--muted); }
.hk-empty .hk-ico { width: 40px; height: 40px; color: var(--line-strong); }
.hk-empty strong { color: var(--ink); font-size: var(--fs-lg); }
.hk-skel { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, #F1E9EA 25%, #F8F2F2 50%, #F1E9EA 75%); background-size: 200% 100%; animation: hk-skel 1.2s linear infinite; }
@keyframes hk-skel { to { background-position: -200% 0; } }
.hk-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: hk-spin .7s linear infinite; }

.hk-huella { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-8) var(--sp-6); border: 2px dashed var(--line-strong); border-radius: var(--r-xl); text-align: center; background: var(--cream); }
.hk-huella .hk-huella-ico { width: 72px; height: 72px; color: var(--accent); }
.hk-huella[data-estado="leyendo"] { border-color: var(--info); background: var(--info-tint); }
.hk-huella[data-estado="leyendo"] .hk-huella-ico { color: var(--info); animation: hk-pulso 1.2s ease-in-out infinite; }
.hk-huella[data-estado="encontrado"] { border-style: solid; border-color: var(--ok); background: var(--ok-tint); }
.hk-huella[data-estado="no-encontrado"] { border-style: solid; border-color: var(--warn); background: var(--warn-tint); }
@keyframes hk-pulso { 50% { opacity: .45; } }

/* Ficha de persona (encabezado de donador/paciente) */
.hk-persona { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-4); }
.hk-avatar { width: 56px; height: 56px; border-radius: var(--r-lg); background: var(--tint); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; object-fit: cover; flex: none; }
.hk-persona-datos { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hk-persona-datos strong { font-size: var(--fs-lg); }
.hk-meta { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); color: var(--muted); }

/* Lista de definiciones (detalle de un registro) */
.hk-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: var(--sp-4) var(--sp-5); margin: 0; }
.hk-dl div { display: flex; flex-direction: column; gap: 2px; }
.hk-dl dt { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hk-dl dd { margin: 0; font-weight: 600; }

/* Barra de acciones fija al pie (formularios largos de captura) */
.hk-actionbar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4); background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); }
.hk-actionbar .hk-actionbar-info { margin-right: auto; font-size: var(--fs-sm); color: var(--muted); }

/* ==========================================================================
   Acceso (login) — pantalla dividida: marca | formulario. Una columna < 960 px.
   ========================================================================== */
.hk-auth-body { background: var(--cream); }
.hk-auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.hk-auth-marca { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: var(--sp-12) var(--sp-8) var(--sp-8); background-color: var(--bg); color: var(--on-dark);
  /* Patrón de módulos de la familia kaan, muy tenue */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Crect x='14' y='14' width='12' height='12' rx='3.5' fill='%23ffffff' fill-opacity='0.045'/%3E%3C/svg%3E");
  background-size: 40px 40px; }
.hk-auth-marca-centro { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-4); text-align: center; }
.hk-auth-iso { width: clamp(112px, 14vw, 176px); height: auto; filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .35)); }
.hk-auth-wordmark { margin-top: var(--sp-2); font-size: clamp(36px, 4vw, 52px); font-weight: 600; letter-spacing: -.02em; line-height: 1; color: var(--on-dark-dim); }
.hk-auth-wordmark b, .hk-auth-logo-movil b { font-weight: 800; color: #E58A97; }
.hk-auth-lema { font-size: var(--fs-lg); color: var(--on-dark-dim); max-width: 26ch; }
.hk-auth-familia { font-family: var(--mono); font-size: var(--fs-xs); letter-spacing: .1em; text-transform: uppercase; color: #9C8A8E; }

.hk-auth-panel { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: var(--sp-8);
  padding: var(--sp-10) var(--sp-6) calc(var(--sp-6) + env(safe-area-inset-bottom)); }
.hk-auth-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: var(--sp-6); }
.hk-auth-logo-movil { display: none; align-items: center; gap: var(--sp-3); }
.hk-auth-logo-movil span { font-size: 26px; font-weight: 600; letter-spacing: -.02em; color: var(--muted); }
.hk-auth-logo-movil b { color: var(--accent); }
.hk-auth-titulo { display: flex; flex-direction: column; gap: var(--sp-2); }
.hk-auth-titulo p { color: var(--muted); }
.hk-auth-form { display: flex; flex-direction: column; gap: var(--sp-5); }
.hk-auth-form .hk-input { min-height: 52px; font-size: 17px; }
.hk-auth-entrar { min-height: 52px; font-size: 16px; margin-top: var(--sp-1); }
.hk-auth-ayuda { font-size: var(--fs-sm); color: var(--muted); text-wrap: pretty; }
.hk-auth-pie { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2) var(--sp-5); font-size: var(--fs-xs); color: var(--muted); }
.hk-auth-pie a { color: var(--muted); }
.hk-auth-pie a:hover { color: var(--ink); }

/* Mostrar/ocultar contraseña: el botón es el "addon" del campo */
.hk-password .hk-password-ver { min-width: 52px; justify-content: center; cursor: pointer; background: var(--panel); color: var(--muted); font: inherit; }
.hk-password .hk-password-ver:hover { color: var(--ink); background: var(--cream); }
.hk-password .hk-password-ver[aria-pressed="true"] { color: var(--accent); }
.hk-password .hk-password-ver:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.hk-password:focus-within .hk-password-ver { border-color: var(--focus); }
.hk-bloq-mayus { display: inline-flex; align-items: center; gap: 6px; color: var(--warn); font-weight: 700; }
.hk-bloq-mayus[hidden] { display: none; }

@media (max-width: 959px) {
  .hk-auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .hk-auth-marca { flex-direction: row; justify-content: center; padding: var(--sp-6) var(--sp-4); min-height: 0; }
  .hk-auth-marca-centro { flex-direction: row; gap: var(--sp-3); }
  .hk-auth-iso { width: 52px; filter: none; }
  .hk-auth-wordmark { margin: 0; font-size: 30px; }
  .hk-auth-lema, .hk-auth-familia { display: none; }
  .hk-auth-panel { justify-content: flex-start; padding-top: var(--sp-10); }
}
@media (max-width: 479px) {
  .hk-auth-marca { display: none; }
  .hk-auth { grid-template-rows: 1fr; }
  .hk-auth-logo-movil { display: flex; }
  .hk-auth-panel { padding-top: var(--sp-8); }
}

/* ==========================================================================
   Firma con el dedo (tablet) — <div class="hk-firma" data-firma="campo_hidden">
   ========================================================================== */
.hk-firma { display: flex; flex-direction: column; gap: var(--sp-2); }
.hk-firma-lienzo { position: relative; height: 220px; border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--panel); overflow: hidden; }
.hk-firma-lienzo canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.hk-firma-lienzo::after { content: ""; position: absolute; left: var(--sp-6); right: var(--sp-6); bottom: 52px; border-bottom: 1.5px solid var(--line-strong); pointer-events: none; }
.hk-firma-guia { position: absolute; left: var(--sp-6); bottom: 24px; font-size: var(--fs-sm); color: var(--muted); pointer-events: none; }
.hk-firma[data-con-firma] .hk-firma-guia { visibility: hidden; }
.hk-firma[data-con-firma] .hk-firma-lienzo { border-style: solid; border-color: var(--ink); }
.hk-firma-lienzo:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ==========================================================================
   Tablet y táctil
   Puntero grueso = dedo: controles de 48 px (Android), nada de 36 px, 8 px mínimo entre objetivos.
   Nada en Hemokaan depende del hover: menús y acciones se abren con toque.
   ========================================================================== */
.hk-btn, .hk-seg label, .hk-tab, .hk-check, .hk-switch, .hk-rail-item, .hk-menu-list a, .hk-menu-list button, .hk-pager a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hk-btn:active { filter: brightness(.92); }
.hk-seg label:active, .hk-menu-list a:active, .hk-menu-list button:active, .hk-rail-item:active { filter: brightness(.95); }

@media (pointer: coarse) {
  :root { --control-h: 48px; --control-h-sm: 44px; }
  .hk-input, .hk-select { font-size: 17px; }
  .hk-check { min-height: 48px; align-items: center; gap: var(--sp-3); }
  .hk-check input, .hk-table input[type="checkbox"] { width: 24px; height: 24px; }
  .hk-seg label { min-height: 52px; min-width: 88px; font-size: 17px; }
  .hk-question { padding: var(--sp-4) 0; }
  .hk-question-text { font-size: 17px; }
  .hk-switch input { width: 52px; height: 30px; }
  .hk-switch input::after { width: 24px; height: 24px; }
  .hk-switch input:checked::after { transform: translateX(22px); }
  .hk-table th, .hk-table td { height: 56px; }
  .hk-menu-list a, .hk-menu-list button { min-height: 48px; }
  .hk-pager a, .hk-pager span[aria-current] { min-width: 48px; height: 48px; }
  .hk-row, .hk-page-actions, .hk-dialog-foot, .hk-card-foot, .hk-actionbar { gap: var(--sp-3); }
  .hk-th-sort { min-height: 44px; }
  .hk-firma-lienzo { height: 260px; }
}

/* Pantallas angostas o tablet vertical estrecha: la pregunta arriba, el Sí/No debajo a todo lo ancho */
@media (max-width: 600px) {
  .hk-question { grid-template-columns: 1fr; }
  .hk-question .hk-seg { width: 100%; }
  .hk-question .hk-seg label { flex: 1; }
  .hk-actionbar .hk-actionbar-info { flex-basis: 100%; }
  .hk-actionbar .hk-btn { flex: 1; }
}

/* Barra de acciones y avisos respetan la zona segura (barra de inicio del iPad) */
.hk-actionbar { padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom)); }
.hk-toasts { bottom: calc(var(--sp-4) + env(safe-area-inset-bottom)); }

@media print {
  .hk-rail, .hk-topbar, .hk-actionbar, .hk-toasts, .hk-page-actions { display: none !important; }
  .hk-main { margin: 0 !important; }
  body { background: #fff; }
}
