/**
 * CIMA Móvil — Shell de navegación (m.appcima.com)
 * Archivo  : app/movil/shell.css
 * Función  : Header + pila de vistas (stack) + dock de 5 destinos (Consulta al centro,
 *            elevada) + bottom sheet + modal + toast + componentes base. Mobile-first real:
 *            una mano, tap targets ≥44px, safe-area (notch / barra de gestos), sin hover.
 *            CERO colores literales: todo sale de app/movil/palettes.css.
 * Autores  : CIMA Development Group
 * Copyright: © 2024–2026 CIMA Development Group. Todos los derechos reservados.
 */

*, *::before, *::after { box-sizing: border-box; }
/* `hidden` manda siempre: sin esto `.cm-btn { display:flex }` le gana y un botón «oculto» (p. ej. Face ID sin passkeys) se ve. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
html { background: var(--bg); }
/* Miguel 2026-10-09: deslizar hacia abajo RECARGABA la página (tirar para actualizar del navegador) → riesgo en
   plena consulta. Chrome/Android lo decide por el html; Safari iOS 16+ por html y body. El resto lo frena
   shell.js (guardia de toques). La actualización de DATOS propia de cada pantalla sigue (no recarga). */
html, body { overscroll-behavior: none; overflow: hidden; }
body {
    font-family: var(--font); font-size: 16px; line-height: 1.35;
    background: var(--bg); color: var(--text);
    -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none; touch-action: manipulation;
    user-select: none; -webkit-user-select: none;
}
/* de1135 gestos: sin pinch ni doble toque para zoom en toda la app (solo desplazamientos y swipes);
   en la vista o edición de un documento (body.cm-zoom-ok, lo pone shell.js) vuelve el pinch. */
html, body { touch-action: pan-x pan-y; }
body.cm-zoom-ok, html:has(body.cm-zoom-ok) { touch-action: auto; }
input, textarea, [contenteditable] { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; }
.bi { flex-shrink: 0; }

/* ── Aplicación (pantalla completa fija; el scroll vive en cada vista) ── */
#cm-app { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; display: flex; flex-direction: column; background: var(--bg); }

/* ── Header ── */
.cm-hdr {
    flex: 0 0 auto; position: relative; z-index: 5;
    display: flex; align-items: center; gap: 8px;
    padding: env(safe-area-inset-top) 12px 0 12px; min-height: calc(var(--hdr-h) + env(safe-area-inset-top));
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.cm-hdr[hidden] { display: none; }
.cm-hdr h1 { flex: 1; min-width: 0; margin: 0; font-size: 1.15rem; font-weight: 800; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-hdr .cm-back, .cm-hdr .cm-act {
    width: var(--tap); height: var(--tap); border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface-2); color: var(--text); display: grid; place-items: center; font-size: 1.15rem;
    padding: 0; cursor: pointer; transition: transform .12s var(--ease), opacity .15s;
}
.cm-hdr .cm-back { border-color: transparent; background: transparent; }
.cm-hdr .cm-back[hidden], .cm-hdr .cm-act[hidden] { display: none; }
.cm-hdr .cm-act.cm-act-avatar { padding: 0; overflow: hidden; background: var(--surface-2); }
.cm-hdr .cm-act .cm-avatar-btn { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: var(--radius-sm); }
.cm-hdr .cm-back:active, .cm-hdr .cm-act:active { transform: scale(.92); }
.cm-hdr .cm-sub { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em; }

/* ── Pila de vistas ── */
.cm-stack { flex: 1 1 auto; position: relative; overflow: hidden; }
.cm-view {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: none;
    padding: 14px 16px calc(var(--dock-h) + env(safe-area-inset-bottom) + 28px);
    background: var(--bg); will-change: transform;
}
.cm-view[hidden] { display: none; }
.cm-view.cm-root.cm-in { animation: cmFade .2s var(--ease); }
.cm-view.cm-pushed { z-index: 2; animation: cmSlideIn .26s var(--ease); box-shadow: var(--shadow); }
.cm-view.cm-pushed.cm-out { animation: cmSlideOut .22s var(--ease) forwards; pointer-events: none; }
/* Dock SIEMPRE visible (decisión 2026-09-07): fullscreen ya no lo oculta; toda vista reserva su
   alto. cm-fullscreen queda SOLO para noDock (login, sin sesión). */
body.cm-fullscreen .cm-view { padding-bottom: calc(env(safe-area-inset-bottom) + 20px); }
@keyframes cmFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes cmSlideIn { from { transform: translateX(100%); } to { transform: none; } }
@keyframes cmSlideOut { from { transform: none; } to { transform: translateX(100%); } }

/* Tirar para refrescar */
.cm-ptr {
    position: absolute; top: 0; left: 0; right: 0; height: 0; z-index: 3; display: grid; place-items: center;
    pointer-events: none; overflow: visible;
}
.cm-ptr i {
    width: 34px; height: 34px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line);
    display: grid; place-items: center; color: var(--primary); font-size: 1rem; box-shadow: var(--shadow);
    transform: translateY(-46px); opacity: 0; transition: transform .18s var(--ease), opacity .18s;
}
.cm-ptr.cm-arm i { opacity: 1; }
.cm-ptr.cm-busy i { opacity: 1; transform: translateY(12px); animation: cmSpin .8s linear infinite; }
@keyframes cmSpin { to { transform: translateY(12px) rotate(360deg); } }

/* Aviso sin conexión */
.cm-offline {
    position: absolute; left: 12px; right: 12px; top: 8px; z-index: 4; display: flex; align-items: center; gap: 8px;
    padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
    color: var(--muted); font-size: .82rem; font-weight: 600; transform: translateY(-140%); transition: transform .25s var(--ease);
}
.cm-offline.on { transform: none; }
.cm-offline .bi { color: var(--warn); }

/* ── Dock estilo 4 «gota» (de1135): Inicio · Utilidades (rota) · CIMA · Consulta · Mi perfil ──
   La barra y la joroba son un solo SVG que shell.js redibuja con un resorte; el cuadro de color
   (.cm-ind) y la burbuja siguen a la pestaña activa. Colores del tema activo. */
body.cm-fullscreen .cm-dock { transform: translateY(calc(100% + 80px)); } /* solo noDock (login) */
.cm-dock {
    position: absolute; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 6px); z-index: 6;
    height: 60px; display: flex; align-items: stretch;
    -webkit-user-select: none; user-select: none; touch-action: manipulation;
    transition: transform .25s var(--ease), opacity .2s;
}
/* Sin filter (ni drop-shadow): en Safari iOS cualquier filtro sobre la gota en movimiento deja restos al repintar. */
.cm-gota { position: absolute; left: 0; top: -40px; width: 100%; height: 100px; pointer-events: none; overflow: visible; }
.cm-gota path { fill: var(--surface-2); stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.cm-ind {
    position: absolute; left: 0; top: -22px; z-index: 1; width: 50px; height: 50px; border-radius: 16px; pointer-events: none;
    background: var(--primary); box-shadow: 0 6px 20px transparent; box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 45%, transparent);
    transition: scale .3s; will-change: transform;   /* la posición la mueve el resorte de shell.js (colocarGota) */
}
.cm-ind::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; border-radius: inherit; background: rgba(255,255,255,.5); opacity: 0; transition: opacity .6s; }
.cm-dock.cm-press .cm-ind { scale: 1.08; }
.cm-dock.cm-press .cm-ind::after { opacity: .5; }
.cm-dock.cm-sin-gota .cm-ind { opacity: 0; }
.cm-tab {
    position: relative; z-index: 2; flex: 1; min-width: 0; height: 100%; background: none; border: 0; padding: 0 0 4px; cursor: pointer;
    color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    -webkit-tap-highlight-color: transparent; transition: color .3s;
}
.cm-tab .bi { font-size: 1.4rem; line-height: 1; transition: transform .45s cubic-bezier(.3,1.6,.5,1), color .3s; }
.cm-tab .cm-lbl { font-size: .62rem; font-weight: 600; line-height: 1; white-space: nowrap; transition: opacity .2s; }
.cm-tab.active .bi, .cm-tab.active .cm-dock-avatar { transform: translateY(-26px); color: var(--primary-ink); }
/* Estilo «Líquido» (Apariencia): cuadro un poco más chico y más alto, envuelto por la barra */
.cm-dock.cm-estilo-liquido .cm-ind { top: -25px; width: 46px; height: 46px; border-radius: 15px; }
.cm-tab.active .cm-lbl { opacity: 0; }
.cm-tab .cm-dock-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; display: block; border: 1.6px solid currentColor; background: var(--surface-2); transition: transform .45s cubic-bezier(.3,1.6,.5,1); }
.cm-tab.active .cm-dock-avatar { border-color: var(--primary-ink); }
.cm-tab .cm-badge {
    position: absolute; top: 5px; left: calc(50% + 6px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--danger); color: var(--surface); font-size: .62rem; font-weight: 800; display: grid; place-items: center;
}
.cm-tab.active .cm-badge { top: -30px; left: calc(50% + 10px); }
/* Utilidades: puntitos = cuál de las 4; al rotar, su nombre se ve abajo como el de los demás */
.cm-udots { position: absolute; bottom: 3px; left: 50%; translate: -50% 0; display: flex; gap: 3px; transition: opacity .25s; }
.cm-udots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .35; }
.cm-udots i.on { opacity: 1; }
.cm-util.active .cm-udots { color: var(--primary); }
.cm-util.cm-showlbl .cm-lbl { opacity: 1; color: var(--text); font-weight: 700; }
.cm-util.cm-rot .bi { animation: cm-urot .45s cubic-bezier(.3,1.4,.5,1); }
@keyframes cm-urot { 0% { transform: translateY(-25px) rotateY(0); } 50% { transform: translateY(-25px) rotateY(90deg) scale(.8); } 100% { transform: translateY(-25px) rotateY(0); } }
/* CIMA: cuadro con el isotipo; ondas «doppler» periódicas; abierto = relleno primario y logo unicolor */
.cm-cima .cm-tile {
    position: relative; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
    background: var(--surface); background: color-mix(in srgb, var(--primary) 16%, var(--surface)); border: 1px solid var(--line); border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line));
    transition: transform .3s cubic-bezier(.3,1.6,.5,1), background .3s, border-color .3s;
}
.cm-cima .cm-tile svg { width: 26px; height: 26px; position: relative; z-index: 1; }
.cm-cima .lg-a { fill: var(--text); transition: fill .3s; }
.cm-cima .lg-b { fill: var(--primary); transition: fill .3s; }
.cm-cima:active .cm-tile { transform: scale(.92); }
.cm-cima .cm-ring { position: absolute; top: -1px; right: -1px; bottom: -1px; left: -1px; inset: -1px; border-radius: inherit; border: 2px solid var(--primary); opacity: 0; pointer-events: none; animation: cm-doppler 5s ease-out infinite; }
.cm-cima .cm-ring + .cm-ring { animation-delay: .5s; }
@keyframes cm-doppler { 0% { transform: scale(1); opacity: .6; } 30% { transform: scale(1.75); opacity: 0; } 100% { transform: scale(1.75); opacity: 0; } }
.cm-cima.on .cm-tile { background: var(--primary); border-color: transparent; }
.cm-cima.on .lg-a, .cm-cima.on .lg-b { fill: var(--primary-ink); }
.cm-cima.on .cm-ring { animation-duration: 1.6s; }
@media (prefers-reduced-motion: reduce) { .cm-cima .cm-ring { animation: none; } .cm-util.cm-rot .bi { animation: none; } }

/* ── Bottom sheet ── */
.cm-sheet-mask {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 8; background: var(--mask); opacity: 0; pointer-events: none; transition: opacity .25s;
}
.cm-sheet-mask.on { opacity: 1; pointer-events: auto; }
.cm-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; max-height: 82%; overflow-y: auto; overscroll-behavior: contain;
    background: var(--surface); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
    padding: 8px 16px calc(env(safe-area-inset-bottom) + 18px);
    transform: translateY(105%); transition: transform .28s var(--ease);
}
.cm-sheet.on { transform: none; }
.cm-sheet .cm-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 12px; }
.cm-sheet h2 { margin: 2px 0 8px; font-size: 1.05rem; font-weight: 800; }
.cm-sheet .cm-row { min-height: 56px; }

/* ── Modal (nunca confirm/alert nativos) ── */
.cm-modal-mask {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 20; background: var(--mask); display: flex; align-items: center; justify-content: center;
    padding: 24px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.cm-modal-mask.on { opacity: 1; pointer-events: auto; }
.cm-modal {
    width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
    padding: 20px; text-align: center; transform: scale(.96); transition: transform .2s var(--ease); box-shadow: var(--shadow);
}
.cm-modal-mask.on .cm-modal { transform: none; }
.cm-modal .cm-mic { font-size: 1.9rem; color: var(--primary); margin-bottom: 6px; }
.cm-modal .cm-mic.danger { color: var(--danger); }
.cm-modal h3 { margin: 0 0 6px; font-size: 1.05rem; }
.cm-modal p { color: var(--muted); margin: 0 0 16px; font-size: .92rem; line-height: 1.45; white-space: pre-line; }
.cm-modal .cm-actions { display: flex; gap: 10px; }
.cm-modal .cm-actions .cm-btn { margin: 0; }

/* ── Toast ── */
.cm-toasts {
    position: absolute; left: 12px; right: 12px; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 14px);
    z-index: 30; display: flex; flex-direction: column; gap: 8px; pointer-events: none; transition: bottom .25s var(--ease);
}
body.cm-fullscreen .cm-toasts { bottom: calc(env(safe-area-inset-bottom) + 14px); }
.cm-toast {
    pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--text); font-size: .9rem; font-weight: 600;
    box-shadow: var(--shadow); animation: cmToastIn .22s var(--ease);
}
.cm-toast.cm-out { animation: cmToastOut .2s var(--ease) forwards; }
.cm-toast .bi { font-size: 1.1rem; color: var(--primary); }
.cm-toast.ok .bi { color: var(--accent); }
.cm-toast.warn .bi { color: var(--warn); }
.cm-toast.error .bi { color: var(--danger); }
.cm-toast span { flex: 1; min-width: 0; }
.cm-toast button {
    border: 0; background: var(--tint-primary); color: var(--primary); font-weight: 800; padding: 8px 12px; border-radius: 10px;
    min-height: 36px; cursor: pointer; font-size: .85rem;
}
@keyframes cmToastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cmToastOut { to { opacity: 0; transform: translateY(10px); } }

/* ── Componentes base ── */
/* Estilo plano (IG/Threads/X): las "cards" pierden borde y fondo; el contenido se apoya en el
   padding de .cm-view y en los separadores finos de .cm-row. NO reintroducir cajas con borde. */
.cm-card { background: transparent; border: 0; border-radius: 0; padding: 12px 0; margin-bottom: 10px; }
.cm-card.tight { padding-bottom: 4px; }
.cm-h { margin: 4px 2px 9px; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.cm-card > .cm-h { margin: 0 0 6px; }
.cm-big { font-size: 1.55rem; font-weight: 800; margin: 2px 0; }
.cm-muted { color: var(--muted); }
.cm-strong { color: var(--text); font-weight: 700; }
.cm-accent { color: var(--accent); }
.cm-row {
    display: flex; align-items: center; gap: 12px; padding: 11px 0; min-height: 60px; border-bottom: 1px solid var(--line);
    cursor: pointer; transition: opacity .12s; -webkit-user-select: none;
}
.cm-row:last-child { border-bottom: 0; }
.cm-row:active { opacity: .7; }
.cm-row.static { cursor: default; }
.cm-row.static:active { opacity: 1; }
.cm-row .cm-ic {
    width: 40px; height: 40px; flex: 0 0 40px; border-radius: 11px; background: var(--surface-2); color: var(--primary);
    display: grid; place-items: center; font-size: 1.2rem; font-weight: 800;
}
.cm-row .cm-ic.accent { background: var(--tint-accent); color: var(--accent); }
.cm-row .cm-tx { flex: 1; min-width: 0; }
.cm-row .cm-tx b { display: block; font-size: .95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-row .cm-tx small { display: block; color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-row .cm-chev { color: var(--muted); font-size: .95rem; }
.cm-pill { flex-shrink: 0; font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--tint-accent); color: var(--accent); }
.cm-pill.primary { background: var(--tint-primary); color: var(--primary); }
.cm-pill.danger { background: var(--tint-danger); color: var(--danger); }
.cm-pill.muted { background: var(--surface-2); color: var(--muted); }
.cm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 13px; }
.cm-stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.cm-stat .n { font-size: 1.35rem; font-weight: 800; color: var(--primary); }
.cm-stat .l { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.cm-btn {
    width: 100%; min-height: 48px; border: 0; border-radius: 13px; padding: 12px 14px; font-weight: 700; font-size: .98rem; cursor: pointer;
    background: var(--primary); color: var(--primary-ink); display: flex; align-items: center; justify-content: center; gap: 9px;
    transition: transform .12s var(--ease), opacity .15s; margin-top: 10px;
}
.cm-btn:active { transform: scale(.98); }
.cm-btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }
.cm-btn.danger { background: var(--tint-danger); color: var(--danger); border: 1px solid transparent; border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.cm-btn:disabled { opacity: .55; cursor: default; }
.cm-input {
    width: 100%; min-height: 48px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
    border-radius: var(--radius-sm); padding: 12px 14px; font-family: inherit; font-size: 16px; margin-bottom: 10px; outline: 0;
}
.cm-input::placeholder { color: var(--muted); }
/* Safari iOS: fecha y hora nativas ignoran width:100% y se salían por la derecha (hoja «Nueva cita», demo 16/10) */
input[type="date"], input[type="time"], input[type="datetime-local"] { -webkit-appearance: none; appearance: none; display: block; max-width: 100%; min-width: 0; box-sizing: border-box; text-align: left; }
input[type="date"]::-webkit-date-and-time-value, input[type="time"]::-webkit-date-and-time-value { text-align: left; }
.cm-input:focus { box-shadow: var(--focus); border-color: var(--primary); }
.cm-search { position: relative; }
.cm-search .bi { position: absolute; left: 14px; top: 15px; color: var(--muted); pointer-events: none; }
.cm-search .cm-input { padding-left: 40px; }
.cm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-chip {
    min-height: 36px; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
    font-size: .85rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.cm-chip.active { background: var(--tint-primary); color: var(--primary); border-color: transparent; }
/* Chips del buscador de pacientes (T8, D4: botones del buscador de escritorio) — tap target ≥44px */
.cm-search-chips { margin-bottom: 4px; }
.cm-search-chips .cm-chip { min-height: 44px; }

/* ── Agenda: tira de 7 días (T7) ── */
.cm-days-wrap { display: flex; align-items: center; gap: 4px; margin: 2px 0 14px; }
.cm-days { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.cm-days::-webkit-scrollbar { display: none; }
.cm-days .cm-chip {
    flex: 1 0 auto; min-width: 44px; min-height: 44px; flex-direction: column; gap: 1px; padding: 6px 10px;
    line-height: 1.15; text-transform: capitalize; position: relative;
}
/* Punto: el día tiene citas (Data.agendaSemana). Absoluto para no mover el número. */
.cm-days .cm-chip .cm-dot { position: absolute; bottom: 4px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: var(--primary); }
.cm-days .cm-chip b { font-size: .68rem; font-weight: 700; }
.cm-days .cm-chip small { font-size: .82rem; font-weight: 800; }
.cm-days .cm-chip.cm-hoy:not(.active) { border-color: var(--primary); color: var(--primary); }
.cm-days-nav {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
    color: var(--text); display: grid; place-items: center; font-size: 1rem; cursor: pointer; padding: 0;
}
.cm-days-nav:active { transform: scale(.92); }

/* ── Formularios en bottom sheet (Nueva cita, T7) ── */
.cm-form { padding-top: 2px; }
.cm-field { margin-bottom: 14px; }
.cm-field label { display: block; font-size: .78rem; font-weight: 700; color: var(--muted); margin: 0 0 6px 2px; }
.cm-field #cmNcResultados { margin-top: 4px; }
.cm-field .cm-btn.ghost { margin-top: 8px; }
textarea.cm-input { min-height: 64px; resize: vertical; padding-top: 12px; }

/* ── Consulta clínica por etapas (T8b) ── */
.cm-etapas { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 0 14px; padding-bottom: 2px; }
.cm-etapas::-webkit-scrollbar { display: none; }
.cm-etapas .cm-chip { flex: 0 0 auto; min-height: 44px; }
.cm-vitals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.cm-vitals .cm-field { margin-bottom: 0; }
.cm-vitals-ta { display: flex; align-items: center; gap: 4px; }
.cm-vitals-ta .cm-input { margin-bottom: 0; padding-left: 8px; padding-right: 8px; text-align: center; }
.cm-vitals-ta span { color: var(--muted); font-weight: 700; }
.cm-dx-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.cm-dx-list .cm-chip { cursor: pointer; }
.cm-interim { color: var(--muted); font-size: .85rem; font-style: italic; padding: 0 2px 10px; margin-top: -6px; }
.cm-interim[hidden] { display: none; }

/* ── Manos libres (T17): grabadora, panel de revisión, tabla de laboratorio ── */
.cm-rec-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 4px 10px; }
.cm-rec {
    width: 84px; height: 84px; border-radius: 50%; border: 0; background: var(--tint-primary); color: var(--primary);
    display: grid; place-items: center; font-size: 2rem; transition: transform .15s var(--ease), background .2s, color .2s;
}
.cm-rec:active { transform: scale(.94); }
.cm-rec.on { background: var(--tint-danger); color: var(--danger); animation: cmRecPulse 1.4s ease-in-out infinite; }
@keyframes cmRecPulse {
    0%, 100% { box-shadow: 0 0 0 0 transparent; box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 35%, transparent); }
    50% { box-shadow: 0 0 0 14px transparent; box-shadow: 0 0 0 14px color-mix(in srgb, var(--danger) 0%, transparent); }
}
.cm-rec-time { font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); }
.cm-rec-hint { font-size: .82rem; color: var(--muted); text-align: center; max-width: 260px; }
.cm-wave { display: flex; align-items: flex-end; gap: 3px; height: 28px; }
.cm-wave[hidden] { display: none; }
.cm-wave span { width: 4px; border-radius: 2px; background: var(--danger); animation: cmWave .9s ease-in-out infinite; opacity: .85; }
.cm-wave span:nth-child(2) { animation-delay: .1s; }
.cm-wave span:nth-child(3) { animation-delay: .2s; }
.cm-wave span:nth-child(4) { animation-delay: .3s; }
.cm-wave span:nth-child(5) { animation-delay: .4s; }
@keyframes cmWave { 0%, 100% { height: 6px; } 50% { height: 26px; } }

.cm-review { display: flex; flex-direction: column; gap: 10px; margin: 10px 0 4px; }
.cm-review-item { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.cm-review-item .cm-rv-h { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.cm-review-item .cm-rv-act { display: flex; gap: 8px; }
.cm-review-item .cm-rv-act .cm-btn { flex: 1; margin: 0; padding: 9px 10px; font-size: .85rem; }
.cm-rv-v { font-size: .92rem; white-space: pre-wrap; margin-bottom: 8px; word-break: break-word; }

.cm-rol-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.cm-rol-row:last-child { border-bottom: 0; }
.cm-rol-row .cm-rv-v { flex: 1; margin-bottom: 0; font-size: .86rem; color: var(--muted); }
.cm-rol-chip { flex-shrink: 0; min-height: 36px; padding: 6px 12px; }

.cm-lab-table { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 12px; }
.cm-lab-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cm-lab-row:last-child { border-bottom: 0; }
.cm-lab-name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 700; }
.cm-lab-ref { font-size: .72rem; color: var(--muted); font-weight: 500; }
.cm-lab-val { font-size: .85rem; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.cm-lab-flag { flex-shrink: 0; font-size: .68rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; background: var(--tint-accent); color: var(--accent); }
.cm-lab-flag.alto { background: var(--tint-danger); color: var(--danger); }
.cm-lab-flag.bajo { background: transparent; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.cm-check-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px 14px; }
.cm-check-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.cm-check-row label { font-size: .88rem; color: var(--text); }

/* Acordeón (Configuración: todo en la MISMA vista) */
/* Acordeones planos (IG/Threads/X): filas sin caja; feedback al tocar con fondo redondeado */
.cm-acc { border: 0; border-radius: 0; overflow: hidden; margin-bottom: 0; background: transparent; }
.cm-acc .cm-hd { display: flex; align-items: center; gap: 12px; padding: 15px 4px; min-height: 54px; cursor: pointer; -webkit-user-select: none; border-radius: 12px; }
.cm-acc .cm-hd:active { background: var(--surface-2); }
.cm-acc .cm-hd .bi:first-child { color: var(--primary); font-size: 1.15rem; width: 26px; text-align: center; }
.cm-acc .cm-hd b { flex: 1; font-size: .95rem; }
.cm-acc .cm-hd .cm-chev { color: var(--muted); transition: transform .2s var(--ease); font-size: .9rem; }
.cm-acc.open .cm-hd .cm-chev { transform: rotate(90deg); }
.cm-acc .cm-bd { display: none; padding: 0 4px 14px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.cm-acc.open .cm-bd { display: block; animation: cmFade .18s var(--ease); }
/* T10: contenido REAL (formularios/filas) dentro de un acordeón usa el color de texto normal —
   el gris de .cm-bd es solo para el copy descriptivo simple (Plantillas, notas de ayuda). */
.cm-acc .cm-bd .cm-form, .cm-acc .cm-bd .cm-row { color: var(--text); }

/* Pasos numerados (T13a: guía de instalación iOS en Usuario) */
.cm-steps { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.cm-step { display: flex; align-items: center; gap: 12px; }
.cm-step-n {
    flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--tint-primary); color: var(--primary);
    font-size: .8rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.cm-step .bi { flex-shrink: 0; color: var(--primary); font-size: 1.05rem; width: 22px; text-align: center; }
.cm-step span:last-child { font-size: .9rem; }

/* Selector de paleta (dentro de Usuario › Apariencia) */
.cm-paletas { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.cm-paleta {
    flex: 1 1 0; min-width: 56px; min-height: 64px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface-2);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer; padding: 6px 4px;
    font-size: .68rem; font-weight: 700; color: var(--muted);
}
.cm-paleta i { width: 22px; height: 22px; border-radius: 50%; display: block; border: 2px solid var(--surface); }
.cm-paleta.sel { border-color: var(--primary); color: var(--text); }

/* Perfil — la tarjeta ES la entrada a "Mi perfil" (única puerta; sin fila ni botón de header) */
.cm-profile { display: flex; align-items: center; gap: 14px; cursor: pointer; -webkit-user-select: none; }
.cm-profile:active { opacity: .7; }
.cm-profile .cm-tx { flex: 1; min-width: 0; }
.cm-profile .cm-chev { color: var(--muted); font-size: .95rem; }
.cm-profile .cm-avatar { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 16px; font-size: 1.8rem; background: var(--surface-2); color: var(--primary); display: grid; place-items: center; overflow: hidden; }
.cm-profile .cm-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-profile .cm-avatar img.cm-fb { object-fit: contain; padding: 12px; } /* fallback: isotipo CIMA */
.cm-profile b { display: block; font-size: 1.05rem; }
.cm-profile small { color: var(--muted); font-size: .85rem; }

/* Login (pantalla completa, sin dock) */
.cm-login { display: flex; flex-direction: column; min-height: calc(100% - 20px); padding-top: 8vh; }
/* Logo por máscara (T4b): toma el color del texto del tema activo, nunca un color fijo. */
.cm-logo-mask {
    display: block; width: min(60%, 240px); aspect-ratio: 251.5 / 76; margin: 0 auto 18px; background: var(--text);
    -webkit-mask: url('../style/icon/cima_logo.svg') center / contain no-repeat;
    mask: url('../style/icon/cima_logo.svg') center / contain no-repeat;
}
.cm-login-title { text-align: center; font-size: 1.15rem; font-weight: 800; margin: 0 0 22px; }
.cm-login-pass { position: relative; }
.cm-login-pass .cm-input { padding-right: 46px; }
.cm-login-eye {
    position: absolute; right: 4px; top: 4px; width: 40px; height: 40px; border: 0; background: transparent;
    color: var(--muted); font-size: 1.05rem; display: grid; place-items: center; cursor: pointer;
}
.cm-login-remember { display: flex; align-items: center; gap: 9px; font-size: .88rem; color: var(--muted); margin: 2px 0 4px; -webkit-user-select: none; user-select: none; }
.cm-login-remember input { width: 18px; height: 18px; accent-color: var(--primary); }
.cm-login #cm-login-passkey { margin-top: 10px; }
.cm-login-forgot { display: block; width: 100%; text-align: center; background: transparent; border: 0; color: var(--primary); font-size: .88rem; font-weight: 700; padding: 16px 8px 0; cursor: pointer; }
.cm-login-ver { text-align: center; color: var(--muted); font-size: .72rem; margin-top: auto; padding-top: 24px; }

/* Cuentas recientes (T4b): tarjetas encima del formulario para cambiar de cuenta rápido. */
.cm-cuentas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.cm-cuenta {
    display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 10px; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); -webkit-user-select: none; user-select: none;
}
.cm-cuenta:active { opacity: .8; }
.cm-cuenta-av {
    flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
    background: var(--tint-primary); color: var(--primary); font-weight: 800; font-size: .95rem;
}
.cm-cuenta-tx { flex: 1; min-width: 0; }
.cm-cuenta-tx b { display: block; font-size: .92rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-cuenta-tx small { display: block; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-cuenta-x {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: .78rem;
}
.cm-cuenta-x:active { opacity: .7; }

.cm-error { color: var(--danger); background: var(--tint-danger); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .86rem; font-weight: 600; margin-bottom: 10px; }

/* Vista de detalle genérica */
.cm-detail p { color: var(--muted); font-size: .92rem; line-height: 1.5; margin: 0 0 12px; }
.cm-empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: .92rem; }
.cm-empty .bi { display: block; font-size: 2.2rem; margin-bottom: 10px; color: var(--line); }

/* Botón pequeño de fila (T9: eliminar archivo por fila, sin usar el chevron de drill-down) */
.cm-row-del {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0;
    background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: .85rem; cursor: pointer;
}
.cm-row-del:active { opacity: .7; transform: scale(.94); }

/* T9 — Chat: burbujas + barra de entrada fija abajo */
/* Con pocos mensajes la barra quedaba a media pantalla: la lista llena el alto y los mensajes se apilan abajo. */
.cm-bubbles { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; padding: 4px 0 14px; min-height: calc(100% - 64px - var(--dock-h) - env(safe-area-inset-bottom)); }
.cm-bubble { max-width: 78%; align-self: flex-start; background: var(--surface-2); border-radius: 16px; padding: 9px 12px; }
.cm-bubble .cm-bubble-txt { font-size: .92rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.cm-bubble .cm-bubble-hora { font-size: .68rem; color: var(--muted); text-align: right; margin-top: 3px; }
.cm-bubble.mine { align-self: flex-end; background: var(--tint-primary); }
.cm-chatbar { position: -webkit-sticky; position: sticky; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; padding: 10px 0 2px; background: var(--bg); }
.cm-chatbar .cm-input { margin-bottom: 0; }
.cm-chatbar .cm-btn { width: 48px; height: 48px; min-height: 48px; flex: 0 0 48px; margin-top: 0; padding: 0; border-radius: 50%; }

/* T9 — Notas: barra lateral con el color GUARDADO de la nota (única excepción a cero color
   literal: la variable --nota-color la pone el propio dato de la nota, inline, por fila) */
.cm-note-row { position: relative; padding-left: 12px; }
.cm-note-color { position: absolute; left: 0; top: 8px; bottom: 8px; width: 4px; border-radius: 3px; background: var(--nota-color, var(--line)); }

/* Recursos del médico: firma/sello/header/footer/plantillas/logos (screens/recursos.js) */
.cm-res-preview {
    height: 80px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
    display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 10px;
}
.cm-res-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cm-res-preview-sq { height: 90px; width: 90px; margin-left: auto; margin-right: auto; }
.cm-res-wide {
    width: 100%; max-height: 140px; min-height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--surface); display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 10px;
}
.cm-res-wide img { max-width: 100%; max-height: 140px; object-fit: contain; }
.cm-res-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: .78rem; padding: 6px; text-align: center; }
.cm-res-empty .bi { font-size: 1.3rem; }
.cm-res-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-res-actions .cm-btn { flex: 1 1 auto; margin: 0; }
.cm-block-btn { width: 100%; margin: 0 0 4px; }
.cm-res-nota { font-size: .76rem; margin-top: 8px; }
.cm-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .88rem; margin-bottom: 12px; }
.cm-switch-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }

/* Firma dibujada: lienzo táctil apaisado a pantalla completa */
.cm-sig-wrap { flex: 1 1 auto; min-height: 220px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; margin-bottom: 14px; }
.cm-sig-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.cm-sig-actions .cm-btn { flex: 1 1 0; }

/* Plantillas de documento: fila con miniatura + acciones */
.cm-tpl-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.cm-tpl-row:last-child { border-bottom: 0; }
.cm-tpl-thumb {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2);
    display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted);
}
.cm-tpl-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cm-tpl-row .cm-tx { flex: 1; min-width: 0; }
.cm-tpl-row .cm-tx b { display: block; font-size: .92rem; font-weight: 700; }
.cm-tpl-row .cm-tx small { display: block; color: var(--muted); font-size: .78rem; }
.cm-tpl-star {
    flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: .9rem;
}
.cm-tpl-star:active { opacity: .7; }

/* Logos: rejilla de miniaturas con borrado por celda */
.cm-logos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; padding: 4px 0 2px; }
.cm-logo-item {
    position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface);
    display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted);
}
.cm-logo-item img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cm-logo-del {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
    background: var(--bg); background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text); display: grid; place-items: center; font-size: .68rem;
}
.cm-logo-del:active { opacity: .7; }

/* Mi perfil (T12) — foto grande + botón "Cambiar foto" */
.cm-perfil-foto { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.cm-perfil-foto-img {
    width: 96px; height: 96px; border-radius: 50%; background-color: var(--surface-2); border: 1px solid var(--line);
    background-size: cover; background-position: center;
}
.cm-perfil-foto .cm-btn { width: auto; margin-top: 0; padding: 10px 18px; }

/* Mi perfil (T12) — horario semanal: fila día + chip activo/inactivo + hora inicio/fin */
.cm-week { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cm-week:last-child { border-bottom: 0; }
.cm-week-dia { flex: 0 0 32px; font-size: .82rem; font-weight: 700; color: var(--text); }
.cm-week .cm-chip { flex: 0 0 auto; min-height: 36px; padding: 6px 10px; font-size: .78rem; }
.cm-week .cm-input { flex: 1; min-width: 0; margin-bottom: 0; padding: 8px 10px; }
.cm-week.off { opacity: .55; }

/* Mi perfil (T12) — lista desplegable del autocompletar de especialidad */
.cm-select-list { margin-top: 6px; border: 1px solid var(--line); border-radius: var(--radius-sm); max-height: 240px; overflow-y: auto; background: var(--surface); }

/* ── Consulta por modelo (Objetivo 1a) ── */

/* Etiqueta de grupo dentro de una tira de chips (motivo/antecedentes/exam agrupados) */
.cm-chip-group {
    width: 100%; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 10px 0 2px;
}
.cm-chip-group:first-child { margin-top: 0; }

/* Chip de medición (antropometría: peso, talla, IMC…) y su variante calculada (IMC) */
.cm-chip.measure { gap: 5px; }
.cm-chip.measure .mv { font-weight: 800; }
.cm-chip.measure .mu { font-size: .72rem; font-weight: 600; color: var(--muted); }
.cm-chip-clear {
    display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
    margin: -6px -8px -6px 0; border: 0; background: none; color: inherit; font-size: .78rem; line-height: 1;
    cursor: pointer; border-radius: 50%; flex-shrink: 0;
}
.cm-chip.computed { cursor: default; }
.cm-chip.computed.wait { opacity: .55; }

/* Checklist de examen (Goldman y similares): casillas por grupo + subchips + puntaje */
.cm-checklist {
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px;
    background: transparent; background: color-mix(in srgb, var(--primary) 5%, transparent);
}
.cl-group { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 10px 0 4px; }
.cl-group:first-child { margin-top: 0; }
label.cl-item { display: flex; align-items: center; gap: 10px; min-height: 44px; }
label.cl-item input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--primary); }
.cl-item.auto { opacity: .85; }
.cl-sub { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 30px; margin: 2px 0 8px; }
.cl-score { font-weight: 800; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

/* Bloque de estudio (Estudios): cabecera colapsable + chips del catálogo + textarea libre */
.cm-study-block {
    border: 1px solid var(--line); border-left: 3px solid var(--primary); border-radius: var(--radius-sm);
    background: var(--surface); padding: 10px 12px; margin-bottom: 10px;
}
.cm-study-head { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.cm-study-head .cm-study-name { font-weight: 700; flex-shrink: 0; }
.cm-study-sum { flex: 1; min-width: 0; color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-study-head .cm-study-del {
    flex-shrink: 0; width: 44px; height: 44px; margin: -8px -8px -8px 0; border: 0; background: none; color: var(--muted);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.cm-study-body { padding-top: 8px; }
.cm-study-body[hidden] { display: none; }

/* Tratamiento: fila de medicamento activo con posología (tres selects) */
.cm-med-item { width: 100%; }
.cm-med-item.active .cm-chip { width: 100%; }
.cm-med-pos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 4px; }
@media (max-width: 359px) { .cm-med-pos { grid-template-columns: 1fr; } }
.cm-select {
    width: 100%; min-height: 44px; border: 1px solid var(--input-border); background: var(--input-bg); color: var(--text);
    border-radius: var(--radius-sm); padding: 8px 10px; font-family: inherit; font-size: .88rem; outline: 0;
}
.cm-select:focus { box-shadow: var(--focus); border-color: var(--primary); }

/* Colapsable genérico (secciones de indicaciones, grupos de favoritos…) */
.cm-collapse { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 10px; }
.cm-collapse-head { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 700; }
.cm-collapse-head .bi { transition: transform .15s var(--ease); }
.cm-collapse-head.open .bi { transform: rotate(180deg); }
.cm-collapse-body { padding-top: 6px; }
.cm-collapse-body[hidden] { display: none; }

/* Estrella de favorito (estudios/dx/medicamentos) */
.cm-star {
    width: 44px; height: 44px; border: 0; background: none; color: var(--muted); cursor: pointer; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
}
.cm-star.on { color: var(--accent); }

/* Contador +/- (chips de medición y duraciones en el bottom sheet) */
.cm-stepper { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 0; }
.cm-stepper button {
    width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
    color: var(--text); font-size: 1.2rem; font-weight: 700; cursor: pointer; padding: 0; display: grid; place-items: center;
}
.cm-stepper button:active { transform: scale(.92); }
.cm-stepper input {
    width: 80px; min-height: 44px; text-align: center; border: 1px solid var(--input-border); background: var(--input-bg);
    color: var(--text); border-radius: var(--radius-sm); font-size: 1.05rem; font-weight: 700; outline: 0; -moz-appearance: textfield;
}
.cm-stepper input::-webkit-outer-spin-button, .cm-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cm-stepper input:focus { box-shadow: var(--focus); border-color: var(--primary); }
.cm-stepper-unit { color: var(--muted); font-size: .88rem; font-weight: 600; }

/* Texto auxiliar pequeño */
.cm-mini { font-size: .78rem; color: var(--muted); }

/* Tira de etapas: punto que marca una etapa con contenido */
.cm-etapa-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* Diagnóstico: supertexto y resultados del buscador CIE-10 */
.cm-dx-text { min-height: 90px; }
.cm-results { display: flex; flex-direction: column; margin-top: 6px; }
.cm-result { display: flex; align-items: center; gap: 8px; min-height: 44px; border-bottom: 1px solid var(--line); cursor: pointer; }
.cm-result:last-child { border-bottom: 0; }
.cm-result b { color: var(--primary); font-weight: 800; flex-shrink: 0; }

/* Ancho grande (tablet en vertical): centrar el contenido, el dock sigue abajo */
@media (min-width: 640px) {
    .cm-view { padding-left: max(16px, calc(50% - 300px)); padding-right: max(16px, calc(50% - 300px)); }
    .cm-hdr { padding-left: max(12px, calc(50% - 304px)); padding-right: max(12px, calc(50% - 304px)); }
    .cm-dock { left: max(10px, calc(50% - 300px)); right: max(10px, calc(50% - 300px)); }
    .cm-toasts { left: max(12px, calc(50% - 300px)); right: max(12px, calc(50% - 300px)); }   /* iPad: el aviso en la misma columna que el contenido */
}

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

/* Documentos (1c.1): visor de hojas D1 (documento.js) + visor de archivos R2 */
.cm-doc-stage { padding: 12px; background: var(--bg); }
.cm-doc-sheets { transform-origin: top center; }
.cm-doc-sheet {
    background: var(--paper); color: var(--ink); box-shadow: var(--shadow); margin: 0 auto 14px auto;
    box-sizing: border-box; position: relative; flex: 0 0 auto;
}
.cm-doc-body { white-space: pre-wrap; word-wrap: break-word; font-family: Georgia, 'Times New Roman', serif; font-size: 13px; line-height: 1.5; }
/* Barra inferior fija dentro de la vista (pegada al fondo del scroll de .cm-view, no del documento) */
.cm-doc-bar {
    position: -webkit-sticky; position: sticky; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); z-index: 2; display: flex; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px;
}
.cm-doc-bar button {
    flex: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; border: 0; background: none; color: var(--text); font-family: inherit; font-size: .66rem; font-weight: 600; padding: 6px 4px 4px; cursor: pointer;
}
.cm-doc-bar button .bi { font-size: 1.25rem; line-height: 1; }
.cm-doc-bar button:active { opacity: .7; }
.cm-doc-bar-mas { font-size: 1.3rem; line-height: 1; font-weight: 800; }
/* Visor de archivo (imagen/video/PDF de R2) */
img.cm-doc-file, video.cm-doc-file { display: block; max-width: 100%; height: auto; margin: 0 auto; }
iframe.cm-doc-file { display: block; width: 100%; height: calc(100vh - 220px); min-height: 320px; border: 0; }
/* Fila de historial (sheet «Historial») */
.cm-hist-row { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.cm-hist-row:last-child { border-bottom: 0; }
.cm-hist-row b { display: block; font-size: .92rem; font-weight: 700; }
.cm-hist-row small { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }

/* Generar documentos (1c.2): sheet de tipo → estudios/días/especialidad → vista previa (generar.js) */
.cm-gen-opts {
    display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 10px 12px 8px;
    background: var(--surface); border-bottom: 1px solid var(--line);
}
.cm-gen-opts::-webkit-scrollbar { display: none; }
.cm-gen-opts .cm-chip { flex: 0 0 auto; min-height: 36px; white-space: nowrap; }
/* Barra inferior fija de la vista previa: mismo patrón que .cm-doc-bar (icono + rótulo, 44px) */
.cm-gen-bar {
    position: -webkit-sticky; position: sticky; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); z-index: 2; display: flex; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 4px;
}
.cm-gen-bar button {
    flex: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; border: 0; background: none; color: var(--text); font-family: inherit; font-size: .66rem; font-weight: 600; padding: 6px 4px 4px; cursor: pointer;
}
.cm-gen-bar button .bi { font-size: 1.25rem; line-height: 1; }
.cm-gen-bar button:active { opacity: .7; }
#cmGenGuardar { color: var(--primary); }
/* Editor de texto plano a pantalla completa (regenera el documento al aceptar) */
/* de1135: editor de texto a pantalla completa — su alto lo fija generar.js con visualViewport (sigue al teclado) */
.cm-gen-editor { display: block; width: 100%; min-height: 240px; height: 60vh; resize: none; box-sizing: border-box; padding: 14px; border-radius: 16px; font-family: Georgia, 'Times New Roman', serif; font-size: 17px; line-height: 1.55; }

/* ── Ficha del paciente (1b) ── */

/* Fila de segmentos (Datos · Antecedentes · Consultas · Archivos · Pediatría · Laboratorio) */
.cm-seg { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 10px 0 14px; padding-bottom: 2px; }
.cm-seg::-webkit-scrollbar { display: none; }
.cm-seg button {
    flex: 0 0 auto; min-height: 44px; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--line);
    background: var(--surface-2); color: var(--text); font-size: .85rem; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
}
.cm-seg button.active { background: var(--tint-primary); color: var(--primary); border-color: transparent; }

/* Interruptor accesible (Normales/No contributorio, Adulto-Pediátrico, WhatsApp/Telegram…) */
.cm-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; cursor: pointer; -webkit-user-select: none; user-select: none; }
.cm-switch-label { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; }
.cm-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.cm-switch-track {
    flex-shrink: 0; width: 46px; height: 26px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line);
    position: relative; transition: background .15s, border-color .15s;
}
.cm-switch-thumb {
    position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface);
    box-shadow: var(--shadow); transition: transform .15s var(--ease);
}
.cm-switch input:checked + .cm-switch-track { background: var(--primary); border-color: transparent; }
.cm-switch input:checked + .cm-switch-track .cm-switch-thumb { transform: translateX(20px); background: var(--primary-ink); }
.cm-switch input:focus-visible + .cm-switch-track { box-shadow: var(--focus); }

/* Rejilla de formulario (Datos, filiación…): 1 columna; `.dos` = 2 en ≥360px */
.cm-form-grid { display: grid; grid-template-columns: 1fr; gap: 4px 12px; }
@media (min-width: 360px) { .cm-form-grid.dos { grid-template-columns: 1fr 1fr; } }

/* Subpanel indentado (detalle de una condición/hábito activado) */
.cm-panel { border: 1px solid var(--line); border-radius: var(--radius-sm); background: transparent; background: color-mix(in srgb, var(--primary) 5%, transparent); padding: 10px 12px; margin: 6px 0 14px 14px; }

/* Vacunas: fila por biológico con celdas de dosis (fecha + lote apilados) */
.cm-imm-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 12px; margin-bottom: 8px; }
.cm-imm-row-head { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 700; font-size: .9rem; }
.cm-imm-row-head .bi:last-child { margin-left: auto; color: var(--muted); transition: transform .15s var(--ease); }
.cm-imm-row.open .cm-imm-row-head .bi:last-child { transform: rotate(90deg); }
.cm-imm-cells { display: none; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; padding: 2px 0 10px; }
.cm-imm-row.open .cm-imm-cells { display: grid; }
.cm-imm-cell { display: flex; flex-direction: column; gap: 4px; }
.cm-imm-cell label { font-size: .66rem; color: var(--muted); font-weight: 700; text-align: center; }
.cm-imm-cell input { min-height: 38px; padding: 6px 6px; font-size: .78rem; margin-bottom: 0; text-align: center; }

/* Curva de crecimiento: SVG con percentiles P3–P97 */
.cm-curve { width: 100%; height: 260px; display: block; }
.cm-curve .cc-grid { stroke: var(--line); stroke-width: 1; }
.cm-curve .cc-p { fill: none; stroke: var(--muted); stroke-width: 1.3; }
.cm-curve .cc-p50 { stroke: var(--primary); stroke-width: 2.2; }
.cm-curve .cc-pt { fill: var(--accent); }
.cm-curve .cc-lbl { fill: var(--muted); font-size: 9px; }

/* Laboratorio: tarjeta de último valor por prueba */
.cm-lab-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 8px; cursor: pointer; }
.cm-lab-card .lc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cm-lab-card .lc-name { font-weight: 700; font-size: .9rem; }
.cm-lab-card .lc-val { font-size: 1.05rem; font-weight: 800; flex-shrink: 0; }
.cm-lab-card .lc-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: .76rem; margin-top: 2px; }
.cm-lab-hist { padding-top: 8px; margin-top: 4px; border-top: 1px dashed var(--line); }

/* Foto grande de cabecera (88px) */
.cm-avatar-lg {
    width: 88px; height: 88px; border-radius: 50%; background-color: var(--surface-2); border: 1px solid var(--line);
    background-size: cover; background-position: center; flex-shrink: 0; display: grid; place-items: center; color: var(--muted); font-size: 2rem;
}

/* ── Marca «va al informe» en cada campo de la consulta (Miguel 2026-09-07) ── */
.cm-h.cm-h-inf { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cm-inf-mark {
    flex: 0 0 auto; width: 36px; height: 36px; margin: -8px -6px -8px 0; border-radius: var(--radius-sm); border: 0;
    background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 1.15rem; cursor: pointer; padding: 0;
}
.cm-inf-mark.on { color: var(--primary); }
.cm-inf-mark:active { transform: scale(.92); }

/* ── Candado «desliza para editar» (ui/candado.js), igual que la web app ──
   Bloquea la EDICIÓN, no la lectura: el contenido se ve y se desplaza normal; los controles quedan
   inertes y una barra fija abajo ofrece deslizar para editar. Sin capa ni desenfoque. */
.cm-lock-host { position: relative; }
.cm-lock-host.cm-locked .cm-input, .cm-lock-host.cm-locked .cm-select, .cm-lock-host.cm-locked .cm-chip,
.cm-lock-host.cm-locked .cm-switch, .cm-lock-host.cm-locked .cm-row-del, .cm-lock-host.cm-locked .cm-inf-mark,
.cm-lock-host.cm-locked .cm-btn, .cm-lock-host.cm-locked .cm-star, .cm-lock-host.cm-locked .cm-stepper,
.cm-lock-host.cm-locked [data-medida], .cm-lock-host.cm-locked [data-frase], .cm-lock-host.cm-locked .cm-med-pos { pointer-events: none; }
.cm-lock-host.cm-locked .cm-input, .cm-lock-host.cm-locked .cm-select { opacity: .85; }
.cm-lock-host.cm-locked .cm-collapse-head, .cm-lock-host.cm-locked .cm-study-head, .cm-lock-host.cm-locked .cm-acc .cm-hd, .cm-lock-host.cm-locked .cm-seg, .cm-lock-host.cm-locked .cm-row[data-k] { pointer-events: auto; }
.cm-lock {
    position: -webkit-sticky; position: sticky; bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 8px); z-index: 4; display: flex; justify-content: center; padding: 10px 0 2px; pointer-events: none;
}
.cm-lock-card { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: auto; }
.cm-lock-track {
    position: relative; width: min(280px, 80vw); height: 56px; border-radius: 28px; overflow: hidden;
    background: var(--surface); background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid transparent; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent); box-shadow: var(--shadow);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.cm-lock-hint {
    position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; display: flex; align-items: center; justify-content: center; padding-left: 44px;
    font-size: .8rem; font-weight: 700; color: var(--text); pointer-events: none; white-space: nowrap; transition: opacity .15s;
}
.cm-lock-knob {
    position: absolute; top: 4px; left: 4px; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
    font-size: 1.35rem; color: var(--primary-ink); cursor: grab; touch-action: none; user-select: none;
    /* Rojo VIVO y traslúcido como el candado de la web app. */
    background: var(--danger); background: color-mix(in srgb, var(--danger) 78%, transparent); border: 1px solid var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 90%, transparent);
    box-shadow: var(--shadow); transition: background .2s;
}
.cm-lock-knob.open { background: var(--accent); background: color-mix(in srgb, var(--accent) 78%, transparent); border-color: var(--accent); border-color: color-mix(in srgb, var(--accent) 90%, transparent); }
.cm-lock-sub { display: none; }

/* ── Herramientas al lado de cada textbox de la consulta: micrófono, imagen y miniaturas ── */
.cm-ta-tools { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin: -6px 0 10px; }
.cm-ta-thumbs { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; min-width: 0; }
.cm-ta-thumb { position: relative; width: 56px; height: 56px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.cm-ta-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-ta-thumb-del { position: absolute; top: 0; right: 0; width: 22px; height: 22px; border: 0; border-radius: 0 0 0 var(--radius-sm); background: var(--bg); background: color-mix(in srgb, var(--bg) 70%, transparent); color: var(--text); display: grid; place-items: center; padding: 0; font-size: .8rem; }
.cm-ta-btns { display: flex; gap: 6px; flex: 0 0 auto; }
.cm-ta-btn { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; font-size: 1.1rem; padding: 0; cursor: pointer; }
.cm-ta-btn.on { color: var(--primary-ink); background: var(--primary); border-color: transparent; }
.cm-ta-btn:active { transform: scale(.94); }
.cm-lock-host.cm-locked .cm-ta-btn, .cm-lock-host.cm-locked .cm-ta-thumb-del { pointer-events: none; opacity: .5; }

/* ── Laboratorio: carga masiva (texto / foto / panel), revisión y pruebas dinámicas ── */
.cm-lab-acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.cm-lab-acciones .cm-btn { margin: 0; font-size: .84rem; padding-left: 8px; padding-right: 8px; }
#cmPfLabAgregar { margin-bottom: 12px; } /* la primera tarjeta de valores quedaba pegada al botón */
.cm-lab-foto { width: 100%; max-height: 220px; object-fit: contain; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); margin-bottom: 10px; display: block; }
.cm-lab-fotobtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cm-lab-fotobtns .cm-btn { margin: 0; }
.cm-lab-panel { max-height: 52vh; max-height: 52dvh; overflow-y: auto; margin: 8px 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 10px; }
.cm-lab-sub { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; padding: 10px 0 4px; }
.cm-lab-prow { display: flex; align-items: center; gap: 10px; min-height: 46px; border-bottom: 1px solid var(--line); }
.cm-lab-prow:last-child { border-bottom: 0; }
.cm-lab-prow label { flex: 1; min-width: 0; font-size: .86rem; font-weight: 600; }
.cm-lab-prow .cm-input { flex: 0 0 96px; min-height: 38px; padding: 6px 8px; margin: 4px 0; text-align: right; font-size: .9rem; }
.cm-lab-rev { margin-bottom: 8px; }
.cm-lab-rrow { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cm-lab-rrow:last-child { border-bottom: 0; }
.cm-lab-rrow.sin .cm-select { border-color: var(--warn); }
.cm-lab-rname { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.cm-lab-rrow .cm-select { margin-bottom: 6px; }
.cm-lab-rvals { display: flex; gap: 8px; align-items: center; }
.cm-lab-rvals .cm-input { flex: 1; min-width: 0; margin: 0; }
.cm-lab-rvals .cm-row-del { flex: 0 0 auto; }
.cm-lab-opc .cm-check-row { padding: 4px 2px 8px; }
.cm-lab-dt { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px; }
.cm-lab-dt-h { font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.cm-lab-dt-h small { color: var(--muted); font-weight: 600; }
.cm-lab-dt-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.cm-lab-dt-cell label { display: block; font-size: .66rem; color: var(--muted); font-weight: 700; text-align: center; margin-bottom: 3px; }
.cm-lab-dt-cell .cm-input { min-height: 40px; padding: 6px; text-align: center; margin: 0; font-size: .88rem; }
.cm-lab-curva { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.cm-lab-curva > .bi:first-child { color: var(--primary); font-size: 1.2rem; }
.cm-lab-curva > .bi:last-child { margin-left: auto; color: var(--muted); }
.cm-lab-curva span { display: flex; flex-direction: column; min-width: 0; }
.cm-lab-curva b { font-size: .88rem; }
.cm-lab-curva small { color: var(--muted); font-size: .74rem; }
.cm-lab-fecha { font-size: .8rem; color: var(--muted); margin: -4px 0 8px; }
.cm-lab-svg { height: 220px; }
.cm-lab-svg path { fill: none; stroke-width: 2.2; }
.cm-lab-svg .cc-grid { stroke: var(--line); stroke-width: 1; }
.cm-lab-svg .cc-lbl { fill: var(--muted); font-size: 9px; }
.cm-lab-svg .lc-s0, .cm-lab-leg .lc-s0 { stroke: var(--primary); }
.cm-lab-svg .lc-s1, .cm-lab-leg .lc-s1 { stroke: var(--accent); }
.cm-lab-svg .lc-s2, .cm-lab-leg .lc-s2 { stroke: var(--warn); }
.cm-lab-svg .lc-s3, .cm-lab-leg .lc-s3 { stroke: var(--danger); }
.cm-lab-svg circle.lc-s0 { fill: var(--primary); } .cm-lab-svg circle.lc-s1 { fill: var(--accent); } .cm-lab-svg circle.lc-s2 { fill: var(--warn); } .cm-lab-svg circle.lc-s3 { fill: var(--danger); }
.cm-lab-legs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 8px 0 4px; }
.cm-lab-leg { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; }
.cm-lab-leg i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; background: currentColor; }
.cm-lab-leg .lc-s0 { color: var(--primary); } .cm-lab-leg .lc-s1 { color: var(--accent); } .cm-lab-leg .lc-s2 { color: var(--warn); } .cm-lab-leg .lc-s3 { color: var(--danger); }
.cm-lab-leg small { color: var(--muted); font-weight: 500; }

/* de1094 (6) Orden por voz: lo que entendió la IA, para confirmar con un toque */
.cm-ov-orden { padding: 12px 14px; border-radius: var(--radius-sm, 12px); background: var(--surface-2, var(--surface)); border: 1px solid var(--line); margin-bottom: 12px; }
.cm-ov-orden small { display: block; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.cm-ov-orden p { margin: 0; font-size: 1rem; line-height: 1.45; color: var(--text); }
/* de1094 (6) Sugerencias de la IA: aviso arriba y detalle (confianza, razón) bajo cada una */
.cm-rv-notice { font-size: .8rem; color: var(--muted); padding: 8px 10px; margin-bottom: 10px; border-radius: var(--radius-sm, 10px); background: var(--tint-accent, var(--surface-2)); }
.cm-rv-d { font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* ── de1112: botón Guardar con estado (cabecera de la consulta) ──
   ok = todo guardado (✓) · dirty = cambios sin guardar (brillo con --cm-glow, que el shell elige
   entre el color principal del tema y el del texto según el contraste) · saving = guardando. */
.cm-hdr .cm-save { position: relative; transition: transform .12s var(--ease), box-shadow .35s, border-color .35s, background .35s, opacity .15s; }
.cm-hdr .cm-save[hidden] { display: none; }
.cm-save .cm-save-ok { display: none; position: absolute; right: 4px; bottom: 4px; width: 15px; height: 15px; border-radius: 50%; place-items: center; font-size: .6rem; font-style: normal; background: var(--accent); color: var(--primary-ink); }
.cm-save[data-st="ok"] .cm-save-ok { display: grid; }
.cm-save[data-st="dirty"] {
    border-color: var(--cm-glow, var(--save-glow, var(--primary))); border-color: color-mix(in srgb, var(--cm-glow, var(--save-glow, var(--primary))) 70%, transparent);
    background: var(--surface-2); background: color-mix(in srgb, var(--cm-glow, var(--save-glow, var(--primary))) 16%, var(--surface-2));
    animation: cm-save-glow 1.8s ease-in-out infinite;
}
.cm-save[data-st="saving"] { opacity: .7; }
/* queued = guardado SOLO en el teléfono (la cola lo enviará): nube, sin ✓, brillo apagado.
   rejected = el servidor no aceptó algo: marca de alerta. Ninguno de los dos es «guardado». */
.cm-save .cm-save-q, .cm-save .cm-save-x { display: none; position: absolute; right: 3px; bottom: 3px; width: 16px; height: 16px; border-radius: 50%; place-items: center; font-size: .62rem; font-style: normal; font-weight: 800; }
.cm-save[data-st="queued"] .cm-save-q { display: grid; background: var(--surface); color: var(--warn); border: 1px solid var(--line); }
.cm-save[data-st="queued"] { border-color: var(--warn); border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.cm-save[data-st="rejected"] .cm-save-x { display: grid; background: var(--danger); color: var(--primary-ink); }
.cm-save[data-st="rejected"] { border-color: var(--danger); border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
@keyframes cm-save-glow {
    0%, 100% { box-shadow: 0 0 10px transparent; box-shadow: 0 0 10px color-mix(in srgb, var(--cm-glow, var(--save-glow, var(--primary))) 35%, transparent); }
    50% { box-shadow: 0 0 0 4px transparent, 0 0 18px var(--cm-glow, var(--save-glow, var(--primary))); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cm-glow, var(--save-glow, var(--primary))) 22%, transparent), 0 0 18px color-mix(in srgb, var(--cm-glow, var(--save-glow, var(--primary))) 55%, transparent); }
}
@media (prefers-reduced-motion: reduce) { .cm-save[data-st="dirty"] { animation: none; box-shadow: 0 0 0 3px transparent; box-shadow: 0 0 0 3px color-mix(in srgb, var(--cm-glow, var(--save-glow, var(--primary))) 35%, transparent); } }

/* ── de1112: candado GRANDE = el ORIGINAL de os.appcima.com en el teléfono (sin panel) ──
   Riel 300×104 de vidrio oscuro, perilla redonda de 90 px roja (verde al abrir) con candado de
   3rem y «desliza para editar». Pegado (sticky) a media pantalla mientras se desplaza; debajo
   se ve todo lo guardado, apenas atenuado. Tokens --lock-* en palettes.css (mismos valores de os). */
.cm-lock.cm-lock-big { position: -webkit-sticky; position: sticky; top: 30vh; bottom: auto; height: 0; padding: 0; overflow: visible; z-index: 6; align-items: flex-start; }
.cm-lock-big .cm-lock-card { gap: 16px; padding: 0; background: none; border: 0; box-shadow: none; }
.cm-lock-big .cm-lock-track {
    width: 300px; max-width: 80vw; height: 104px; border-radius: 52px;
    background: var(--lock-track-bg); border: 1px solid var(--lock-track-line); box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
    backdrop-filter: none; -webkit-backdrop-filter: none;
}
.cm-lock-big .cm-lock-hint { padding-left: 60px; font-size: .82rem; font-weight: 600; color: var(--lock-fg); }
.cm-lock-big .cm-lock-knob {
    top: 7px; left: 7px; width: 90px; height: 90px; font-size: 3rem; color: var(--lock-fg);
    background: var(--lock-red); background: color-mix(in srgb, var(--lock-red) 65%, var(--lock-knob-bg)); border: 1px solid var(--lock-knob-line);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
.cm-lock-big .cm-lock-knob.open { background: var(--lock-green); background: color-mix(in srgb, var(--lock-green) 65%, var(--lock-knob-bg)); border-color: var(--lock-knob-line); }
.cm-lock-host.cm-locked.cm-lock-big-host > :not(.cm-lock) { opacity: .72; transition: opacity .2s; }

/* ── de1112: Guardar con todo guardado = ATENUADO (no hay nada que hacer) ── */
.cm-save[data-st="ok"] { opacity: .5; }

html[data-paleta="matrix"] .cm-hdr h1 { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0; }
/* Esquemas claros con la app instalada: franja oscura detrás de la barra de estado (hora y batería en blanco). */
html[data-paleta="landing"] body::before {
    content: ""; position: fixed; z-index: 50; left: 0; right: 0; top: 0; height: env(safe-area-inset-top, 0px); pointer-events: none;
    background: var(--status-strip);
}

/* ── de1112: Apariencia como en BASE móvil (filas con muestra de 5 colores, nombre y descripción) ── */
.cm-schemes { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.cm-scheme { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface-2); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.cm-scheme.sel { border-color: var(--primary); }
.cm-scheme .cm-sw { display: grid; grid-template-columns: repeat(5, 10px); gap: 3px; padding: 6px; border-radius: 10px; flex: none; }
.cm-scheme .cm-sw i { width: 10px; height: 22px; border-radius: 3px; display: block; }
.cm-scheme .cm-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cm-scheme .cm-t b { font-size: .95rem; }
.cm-scheme .cm-t span { font-size: .78rem; color: var(--muted); }
.cm-scheme .cm-ok { color: var(--primary); opacity: 0; font-size: 1.1rem; }
.cm-scheme.sel .cm-ok { opacity: 1; }

/* ── de1112: deslizador de los valores numéricos (hoja de medida del examen) ── */
.cm-range { display: block; width: 100%; height: 34px; margin: 2px 0 0; accent-color: var(--primary); cursor: pointer; }
.cm-range-scale { display: flex; justify-content: space-between; margin: -4px 2px 10px; font-size: .72rem; font-weight: 600; color: var(--muted); }

/* ── de1112: hoja «Cambios por enviar» (ui/pendientes.js) ── */
.cm-pend { display: flex; flex-direction: column; gap: 8px; padding-bottom: 6px; }
.cm-pend .cm-h { margin: 6px 2px 0; }
.cm-pend-it { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.cm-pend-it.no { border-color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.cm-pend-it .cm-tx small { display: block; color: var(--muted); font-size: .78rem; }
.cm-pend-it .cm-pend-err { color: var(--danger); }
.cm-pend-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-pend-acts .cm-btn, .cm-pend-it > .cm-btn { width: auto; flex: 1 1 auto; min-height: 40px; }
.cm-lock-big .cm-lock-dbl { display: inline-flex; } .cm-lock-big .cm-lock-dbl .bi + .bi { margin-left: -.45em; }
/* de1112: nota breve junto a Guardar («Guardado automático»). */
.cm-hdr .cm-save-note { font-size: .7rem; font-weight: 700; color: var(--muted); white-space: nowrap; opacity: 0; transform: translateX(6px); transition: opacity .25s, transform .25s; pointer-events: none; }
.cm-hdr .cm-save-note.on { opacity: 1; transform: none; }

/* de1135: interruptor «Guardado automático» en Configuración */
.cm-autosave { padding: 6px 14px; margin-bottom: 10px; }
.cm-autosave .cm-switch-label small { display: block; font-size: .74rem; font-weight: 500; margin-top: 2px; line-height: 1.3; }

/* de1135: panel de órdenes del botón CIMA (ui/cima_ordenes.js), justo encima del dock */
.cm-ordenes {
    position: absolute; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 96px); z-index: 7;
    border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 18px 40px rgba(0,0,0,.35);
    padding: 12px; display: flex; flex-direction: column; gap: 10px;
    transform: translateY(14px); opacity: 0; pointer-events: none; transition: transform .35s cubic-bezier(.3,1.4,.5,1), opacity .2s;
}
.cm-ordenes.on { transform: none; opacity: 1; pointer-events: auto; }
.cm-ord-st { display: flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.cm-ord-st b { color: var(--text); font-weight: 700; }
.cm-ord-tx { flex: 1; min-width: 0; }
.cm-ord-mic { width: 34px; height: 34px; border-radius: 11px; border: 0; display: grid; place-items: center; flex: none; cursor: pointer; background: transparent; background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary); }
.cm-ordenes.cm-ord-off .cm-ord-mic { background: var(--surface-2); color: var(--muted); }
.cm-ord-wave { display: flex; align-items: center; gap: 3px; height: 18px; flex: none; }
.cm-ord-wave i { width: 3px; height: 6px; border-radius: 3px; background: var(--primary); animation: cm-owave .9s ease-in-out infinite; }
.cm-ord-wave i:nth-child(2) { animation-delay: .12s; } .cm-ord-wave i:nth-child(3) { animation-delay: .24s; } .cm-ord-wave i:nth-child(4) { animation-delay: .36s; } .cm-ord-wave i:nth-child(5) { animation-delay: .48s; }
@keyframes cm-owave { 0%, 100% { height: 5px; } 50% { height: 18px; } }
.cm-ordenes.cm-ord-off .cm-ord-wave { display: none; }
.cm-ord-field { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 4px 4px 4px 12px; margin: 0; }
.cm-ord-field input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; padding: 8px 0; outline: none; }
.cm-ord-field input::placeholder { color: var(--muted); }
.cm-ord-send { width: 40px; height: 40px; border-radius: 11px; border: 0; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; cursor: pointer; }
.cm-ord-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-ord-chips button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 99px; padding: 7px 11px; font-size: .78rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.cm-ord-chips button .bi { color: var(--primary); }
@media (prefers-reduced-motion: reduce) { .cm-ord-wave i { animation: none; } }

/* de1135: dock de acciones del documento, POR DELANTE del dock principal (shell.js pintarDockAcciones).
   Misma base que el dock; Guardar con el morado del ecosistema (--save-glow). Las barras viejas
   (.cm-doc-bar, .cm-gen-bar) quedan como respaldo oculto. */
.cm-dock2 {
    position: absolute; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 6px); z-index: 7;
    height: 60px; display: flex; align-items: stretch; -webkit-user-select: none; user-select: none; touch-action: manipulation;
    opacity: 0; transform: translateY(24px); pointer-events: none; transition: opacity .2s, transform .35s cubic-bezier(.3,1.4,.5,1);
}
@media (min-width: 640px) { .cm-dock2 { left: max(10px, calc(50% - 300px)); right: max(10px, calc(50% - 300px)); } }
.cm-dock2-base { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; border-radius: 22px; background: var(--surface-2); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.28); }
body.cm-dock2-on .cm-dock2 { opacity: 1; transform: none; pointer-events: auto; }
body.cm-dock2-on .cm-dock { opacity: 0; transform: translateY(18px) scale(.96); pointer-events: none; }
body.cm-dock2-on .cm-doc-bar, body.cm-dock2-on .cm-gen-bar { display: none; }
.cm-dock2 .cm-tab .cm-lbl { opacity: 1; }
.cm-dock2 .cm-tab:active .bi { transform: scale(.9); }
.cm-dock2 .cm-save2 { color: var(--save-glow, var(--primary)); }
.cm-dock2 .cm-save2 .bi { width: 40px; height: 30px; border-radius: 11px; display: grid; place-items: center; background: transparent; background: color-mix(in srgb, var(--save-glow, var(--primary)) 18%, transparent); }

/* de1137: marcar imágenes (ui/marcar.js) — miniaturas con marcas y editor a pantalla completa */
.cm-ta-mk { position: relative; display: block; width: 100%; height: 100%; }
.cm-ta-mk img { width: 100%; height: 100%; object-fit: fill; display: block; }
.cm-ta-marks { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cm-mk-view { display: flex; flex-direction: column; padding-bottom: calc(env(safe-area-inset-bottom) + 80px) !important; }
.cm-mk-tools { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; flex: none; }
.cm-mk-tools::-webkit-scrollbar { display: none; }
.cm-mk-tool { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 56px; padding: 7px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: .66rem; font-weight: 700; cursor: pointer; }
.cm-mk-tool svg { width: 22px; height: 22px; }
.cm-mk-tool.on { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.cm-mk-stage { flex: 1; min-height: 240px; display: grid; place-items: center; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.cm-mk-wrap { position: relative; }
.cm-mk-wrap img { width: 100%; height: 100%; display: block; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cm-mk-svg { position: absolute; top: 0; right: 0; bottom: 0; left: 0; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.cm-mk-svg.cm-mk-borrar { cursor: not-allowed; }
.cm-mk-colores { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; padding: 8px 0 12px; }
.cm-mk-color { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--line); background: var(--mk); cursor: pointer; }
.cm-mk-color.on { border-color: var(--primary); box-shadow: var(--focus); }
/* de1137 F2: hoja de capas (activa = borde del primario; ojo a la derecha, 44 px) */
.cm-mk-capas { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.cm-mk-capa { display: flex; align-items: stretch; gap: 8px; }
.cm-mk-capa-nom { flex: 1; min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.cm-mk-capa-nom .cm-tx { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cm-mk-capa-nom .cm-tx b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-mk-capa-nom .cm-tx small { color: var(--muted); }
.cm-mk-capa-nom:disabled { cursor: default; opacity: .8; }
.cm-mk-capa.on .cm-mk-capa-nom { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.cm-mk-capa.on .cm-mk-capa-nom .bi { color: var(--primary); }
.cm-mk-capa-pt { flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%; background: var(--mk); border: 2px solid var(--line); }
.cm-mk-capa-ojo { flex: 0 0 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 1.15rem; cursor: pointer; }

/* Modo Pacientes: rol sin consultation:create → «Nueva consulta» atenuado con el motivo (el toque avisa) */
body.cm-sin-consulta [data-k="nueva-consulta"] { opacity: .45; filter: grayscale(1); }
body.cm-sin-consulta [data-k="nueva-consulta"]::after { content: ' · Tu rol no puede crear consultas'; font-size: .72em; font-weight: 600; }

/* de1136: vista previa de los cambios de la IA (lo quitado tachado, lo nuevo resaltado) */
.cm-ia-prev .cm-h { margin-top: 14px; }
.cm-ia-orden { margin: 4px 0; font-weight: 700; }
.cm-ia-op-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.cm-ia-diff { font-size: .9rem; line-height: 1.5; white-space: normal; -webkit-user-select: text; user-select: text; }
.cm-ia-prev del, .cm-ia-ficha del { color: var(--danger); text-decoration: line-through; background: var(--tint-danger, transparent); border-radius: 4px; }
.cm-ia-prev ins, .cm-ia-ficha ins { color: var(--accent); text-decoration: none; font-weight: 700; background: var(--surface-2); background: color-mix(in srgb, var(--accent) 18%, transparent); border-radius: 4px; }
.cm-ia-ficha { display: block; margin-top: 3px; font-size: .82rem; }
.cm-ia-nota { font-size: .78rem; margin: 6px 2px 0; }
.cm-ia-no ul { margin: 6px 0 0; padding-left: 18px; font-size: .86rem; }
.cm-ia-no li { margin: 4px 0; }

/* Panel CIMA: acciones inteligentes de la pantalla visible (consulta, documento) arriba de todo */
.cm-ord-ctx { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cm-ord-h { font-size: .68rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cm-ord-acc { display: flex; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 14px; padding: 9px 11px; cursor: pointer; font: inherit; }
.cm-ord-acc .bi { color: var(--primary); font-size: 1.1rem; }
.cm-ord-acc b { display: block; font-size: .86rem; }
.cm-ord-acc small { display: block; font-size: .72rem; color: var(--muted); }

/* «Pedir recarga» (ui/recarga.js): franja fija bajo el encabezado, colores del tema */
.cm-recarga {
    position: absolute; left: 10px; right: 10px; top: calc(var(--hdr-h) + env(safe-area-inset-top) + 8px); z-index: 9;
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px;
    background: var(--surface); border: 1px solid var(--warn); box-shadow: 0 10px 30px rgba(0,0,0,.3);
    font-size: .86rem; line-height: 1.35; color: var(--text);
}
.cm-recarga > .bi { color: var(--warn); font-size: 1.2rem; flex: none; }
.cm-recarga span { flex: 1; min-width: 0; }
.cm-recarga .cm-btn { flex: none; width: auto; min-height: 38px; padding: 0 12px; margin: 0; }

/* Avisos en este teléfono (ui/avisos.js) */
.cm-avisos-info { font-size: .86rem; line-height: 1.45; }
.cm-avisos-pasos { margin: 6px 0 6px 18px; padding: 0; }
.cm-avisos-pasos li { margin: 3px 0; }
#cmAvisos .cm-switch-label small { display: block; font-size: .74rem; font-weight: 500; margin-top: 2px; }
#cmAvisos .cm-seg { margin: 8px 0; flex-wrap: wrap; }
#cmAvisos .cm-btn { margin-top: 6px; }
