/* Sistema EEG v28 — paleta institucional teal (clínica, profesional y amigable) */
:root {
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --bg: #f3f7f7;
    --surface: #ffffff;
    --bg-subtle: #e9f1f1;
    --text: #0e1b1d;
    --text-secondary: #33474a;
    --text-muted: #647c7e;
    --border: #d2e2e1;
    --border-light: #e6efee;
    --link: #0e7490;
    --link-hover: #0f766e;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #0d9488;
    --accent-hover: #0f766e;
    --accent-soft: #e6f7f4;
    --clinical: #059669;
    --clinical-soft: #e6fcf3;
    --clinical-line: #99f6e4;
    --warning: #e67700;
    --warning-soft: #fff9db;
    --danger: #e03131;
    --danger-soft: #fff5f5;
    --sidebar-w: 252px;
    --config-sidebar-w: 248px;
    --topbar-h: 52px;
    --page-actions-h: 60px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow-sm: 0 1px 3px rgba(11, 18, 32, 0.06);
    --shadow-md: 0 10px 28px rgba(11, 18, 32, 0.09);
    --shadow-lg: 0 20px 48px rgba(11, 18, 32, 0.12);
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --bg-main: var(--bg);
    --bg-elevated: var(--surface);
    --card-bg: var(--surface);
    --border-color: var(--border);
    --text-dark: var(--text);
    --text-main: var(--text-secondary);
    --primary-blue: var(--accent);
    --primary-hover: var(--accent-hover);
    --primary-light: var(--accent-soft);
    --secondary: var(--primary-dark);
    --success: var(--clinical);
    --sidebar-bg: #ffffff;
    --sidebar-text: #0f172a;
    --sidebar-muted: #64748b;
    --win-accent: #0d9488;
    --win-accent-bg: #e6f7f4;
    --win-hover: #eef5f4;
    --win-border: #e6efee;
    --informe-paper-bg: #ffffff;
    --informe-paper-text: #111111;
    --informe-paper-muted: #222222;
    --informe-paper-border: #e0e0e0;
    --field-locked-bg: #f0f4f8;
    --surface-2: #f8fafc;
    --input-h: 44px;
    --input-pad-x: 14px;
    --content-pad-x: clamp(12px, 2.5vw, 24px);
    --content-pad-y: clamp(12px, 2vw, 20px);
    --form-gap: clamp(12px, 1.5vw, 16px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.47;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
code { font-family: Consolas, monospace; font-size: 0.9em; background: var(--bg-subtle); padding: 1px 4px; border: 1px solid var(--border-light); }

/* Shell — navegación estilo Windows 11 */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.35); z-index: 999;
    backdrop-filter: blur(4px);
}
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-w); height: 100vh; height: 100dvh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--win-border);
    display: flex; flex-direction: column; flex-shrink: 0; z-index: 1000;
    box-shadow: 1px 0 0 rgba(0,0,0,0.04);
}
.sidebar-brand {
    padding: 16px 14px 14px; border-bottom: 1px solid var(--win-border);
    display: flex; align-items: center; gap: 12px; min-height: 56px;
    background: var(--sidebar-bg);
}
.brand-mark { flex-shrink: 0; width: 32px; height: 32px; }
.brand-mark svg { width: 32px; height: 32px; }
.brand-mark rect { fill: var(--win-accent) !important; }
.sidebar-brand strong { display: block; font-size: 0.92rem; font-weight: 600; color: var(--sidebar-text); }
.sidebar-brand span { display: block; font-size: 0.72rem; color: var(--sidebar-muted); margin-top: 1px; }
.brand-text strong { color: var(--sidebar-text); }

.sidebar-nav {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 8px 8px 12px;
    scrollbar-width: thin;
}
.nav-section-label {
    font-size: 0.72rem; font-weight: 600;
    color: var(--sidebar-muted); padding: 10px 12px 4px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; margin: 2px 0;
    font-size: 0.88rem; color: var(--sidebar-text);
    border-radius: 8px; transition: background var(--transition);
    min-height: 36px;
}
.nav-item .nav-icon {
    display: flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; flex-shrink: 0; color: var(--sidebar-muted);
}
.nav-item .nav-icon svg { width: 18px; height: 18px; }
.nav-item .nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--win-hover); text-decoration: none; color: var(--sidebar-text); }
.nav-item:hover .nav-icon { color: var(--sidebar-text); }
.nav-item.active {
    background: var(--win-accent-bg); font-weight: 600;
    color: var(--win-accent); box-shadow: inset 3px 0 0 var(--win-accent);
    border-radius: 4px;
}
.nav-item.active .nav-icon { color: var(--win-accent); }

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--win-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-subtle);
    flex-shrink: 0;
}
.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
    padding: 6px 8px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
}
.sidebar-user-card:hover { background: var(--win-hover); text-decoration: none; }
.profile-mini { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-size: 0.82rem; }
.profile-mini-link {
    text-decoration: none; color: inherit; border-radius: var(--radius-md);
    padding: 4px; margin: -4px; transition: background 0.15s;
}
.profile-mini-link:hover { background: var(--win-hover); text-decoration: none; }
.profile-avatar {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
    background: var(--win-accent); color: #fff; font-size: 0.72rem; font-weight: 600;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.profile-avatar-img, .perfil-avatar-img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.profile-info { min-width: 0; flex: 1; }
.profile-name { display: block; font-weight: 600; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.82rem; line-height: 1.3; }
.profile-role {
    display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
    color: var(--sidebar-muted); font-size: 0.7rem; line-height: 1.35; margin-top: 1px;
}
.badge-super {
    display: inline-block; padding: 1px 6px;
    font-size: 0.58rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em;
    background: #fff4ce; color: #835c00; border-radius: 3px;
}
.badge-super--inline { margin-top: 0; vertical-align: middle; }
.sidebar-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--win-border);
}
.sidebar-version-link {
    font-size: 0.68rem;
    color: var(--sidebar-muted);
    min-width: 0;
    white-space: nowrap;
}
.btn-logout {
    flex-shrink: 0;
    font-size: 0.72rem; font-weight: 500; color: var(--sidebar-text);
    padding: 5px 12px;
    border: 1px solid var(--win-border);
    background: var(--surface);
    border-radius: 6px;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.2;
}
.btn-logout:hover { background: var(--win-hover); text-decoration: none; color: var(--sidebar-text); }

.main-content {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
    min-width: 0; background: var(--bg);
    margin-left: var(--sidebar-w); width: calc(100% - var(--sidebar-w));
    height: 100dvh;
}
.app-topbar {
    min-height: var(--topbar-h);
    height: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--win-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: max(8px, env(safe-area-inset-top, 0px)) 16px 10px;
    z-index: 300;
    flex-shrink: 0; box-shadow: 0 1px 0 var(--win-border);
    border-top: 3px solid var(--accent);
    box-sizing: border-box;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.btn-menu {
    display: none; padding: 6px; border: 1px solid var(--win-border);
    background: var(--surface); cursor: pointer; border-radius: 4px;
    color: var(--text-secondary); line-height: 0;
}
.btn-menu svg { width: 20px; height: 20px; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title strong { display: block; font-size: 0.95rem; font-weight: 600; line-height: 1.25; }
.topbar-title span { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date {
    font-size: 0.78rem; color: var(--text-muted); padding: 4px 10px;
    background: var(--bg-subtle); border-radius: 4px; border: 1px solid var(--win-border);
}
.content-wrapper {
    flex: 1; overflow: hidden;
    padding: var(--content-pad-y) var(--content-pad-x); max-width: none; width: 100%;
    display: flex; flex-direction: column;
    min-height: 0;
}
.page-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(13, 148, 136, 0.28) transparent;
}
.page-body::-webkit-scrollbar { width: 8px; }
.page-body::-webkit-scrollbar-thumb {
    background: rgba(13, 148, 136, 0.24);
    border-radius: 999px;
}

/* Barra de acciones al pie del formulario (flujo normal, sin superponer contenido) */
.page-actions-bar,
.form-actions-row {
    position: static;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    margin: 20px 0 0 !important;
    padding: 14px clamp(12px, 2vw, 20px);
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    min-height: var(--page-actions-h);
    box-sizing: border-box;
    flex-shrink: 0;
}
.content-wrapper:has(.page-actions-bar) .page-body,
.content-wrapper:has(.form-actions-row) .page-body {
    padding-bottom: 12px;
}
.content-wrapper--config {
    padding: clamp(8px, 1.2vw, 14px);
    max-width: none;
    width: 100%;
}
.content-wrapper--config .config-layout {
    flex: 1;
    min-height: calc(100dvh - var(--topbar-h) - clamp(16px, 2.5vw, 28px));
}

/* Encabezados y barra de acciones */
.page-toolbar {
    display: flex; justify-content: flex-end; align-items: center;
    flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
}
.page-header, .form-header, .admin-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    flex-wrap: wrap; gap: 12px; margin-bottom: 16px;
    padding-bottom: 10px; border-bottom: 1px solid var(--border-light);
}
.page-header h1, .form-header h1, .admin-header h1 {
    font-size: 1.15rem; font-weight: 600; color: var(--text);
}
.page-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; max-width: 640px; }
.section-heading {
    font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
    color: var(--text-muted); margin-bottom: 8px;
}

/* Inicio — sin hero ni tarjetas decorativas */
.page-intro { margin-bottom: 16px; font-size: 0.88rem; color: var(--text-secondary); }
.page-intro strong { color: var(--text); }
.stats-row {
    display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 20px;
    border: 1px solid var(--border-light); background: var(--surface);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden;
}
.stats-row .stat-item {
    flex: 1; min-width: 120px; padding: 10px 14px;
    border-right: 1px solid var(--border-light);
}
.stats-row .stat-item:last-child { border-right: none; }
.stats-row label { display: block; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.stats-row strong { font-size: 1.1rem; font-weight: 600; }
.stats-row .warn strong { color: var(--warning); }
.stats-row .ok strong { color: var(--clinical); }

.menu-list { list-style: none; border: 1px solid var(--border-light); background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); overflow: hidden; }
.menu-list li { border-bottom: 1px solid var(--border-light); }
.menu-list li:last-child { border-bottom: none; }
.menu-list a {
    display: block; padding: 10px 14px; color: var(--text);
    font-size: 0.9rem;
}
.menu-list a:hover { background: var(--bg-subtle); text-decoration: none; color: var(--accent); }

/* Compat: ocultar componentes viejos “marketing” */
.hero-banner, .hero-badge, .modules-grid, .module-card, .kpi-grid, .kpi-card { display: none !important; }
.planilla-stats, .stats-grid {
    display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 18px;
    border: 1px solid var(--border-light); background: var(--surface);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
    overflow: visible; flex-shrink: 0; position: relative; z-index: 2;
}
.planilla-stat, .stat-card, .tarjeta-total {
    flex: 1; min-width: 120px; padding: 12px 14px;
    border-right: 1px solid var(--border-light); border-radius: 0; box-shadow: none;
}
.planilla-page-body {
    display: block;
    width: 100%;
    max-width: 100%;
    flex: none;
    min-height: auto;
    padding-bottom: 24px;
}
.planilla-table-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    flex: none;
    min-height: auto;
    margin-bottom: 16px;
    overflow: auto hidden;
    -webkit-overflow-scrolling: touch;
    /* Permite scroll horizontal propio y deja que el gesto vertical
       burbujee al contenedor de la página (evita el atrapamiento en iOS). */
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
}
.planilla-table-shell.card-table { overflow: auto hidden; }
.planilla-table-scroll {
    overflow: auto hidden;
    max-height: none;
    flex: none;
    min-height: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
}
.planilla-table-shell table,
.planilla-table-scroll table { min-width: 720px; width: 100%; }
.planilla-table-shell thead th,
.planilla-table-scroll thead th {
    position: sticky; top: 0; z-index: 3;
    background: var(--bg-subtle);
    box-shadow: 0 1px 0 var(--border-light);
}
.planilla-table-shell tfoot td,
.planilla-table-scroll tfoot td {
    position: static;
    box-shadow: none;
}
.planilla-total-bar {
    flex-shrink: 0; display: flex; align-items: center; justify-content: flex-end;
    gap: 10px; padding: 12px 16px; border-top: 2px solid var(--border);
    background: var(--clinical-soft); font-weight: 600; font-size: 0.9rem;
}
.planilla-total-bar .planilla-total-label { margin-right: auto; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.75rem; color: var(--text-secondary); }
.planilla-total-bar .planilla-total-value { font-size: 1.05rem; color: var(--text); }
.planilla-stat:last-child, .stat-card:last-child { border-right: none; }
.planilla-stat label, .stat-card label, .tarjeta-total span {
    display: block; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px;
    text-transform: none; letter-spacing: 0; font-weight: 400;
}
.planilla-stat strong, .stat-card strong, .tarjeta-total .monto-grande {
    font-size: 1.05rem; font-weight: 600;
}
.planilla-stat.accent, .stat-card.accent, .tarjeta-total {
    background: var(--surface); color: inherit; border: none; border-right: 1px solid var(--border-light);
}
.planilla-stat.ok strong { color: var(--clinical); }
.planilla-stat.warn strong { color: var(--warning); }

/* Planillas: scroll vertical en page-body, tabla completa sin caja interna */
.content-wrapper--planilla {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.content-wrapper--planilla .page-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    /* Permitir paneo en ambos ejes: si el ancestro se limita a pan-y,
       el scroll horizontal de la tabla interna queda bloqueado en móviles. */
    touch-action: pan-x pan-y;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
/*
 * Móvil: la planilla usa el scroll NATURAL del documento (vertical) y deja la
 * tabla como único scroller horizontal. Los contenedores con overflow:hidden /
 * overflow-x:hidden (content-wrapper y page-body) rompen el scroll horizontal
 * anidado en iOS Safari; aquí se abren para que el gesto llegue a la tabla.
 */
@media (max-width: 900px) {
    body.layout-planilla .main-content {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }
    .content-wrapper--planilla {
        flex: none;
        min-height: 0;
        overflow: visible;
    }
    .content-wrapper--planilla .page-body {
        flex: none;
        min-height: 0;
        overflow: visible;
        touch-action: auto;
        overscroll-behavior-y: auto;
    }
    .content-wrapper--planilla .planilla-table-shell,
    .content-wrapper--planilla .planilla-table-shell.card-table,
    .content-wrapper--planilla .planilla-table-scroll {
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x pan-y;
        overscroll-behavior-x: contain;
    }
    .content-wrapper--planilla .planilla-table-shell thead th,
    .content-wrapper--planilla .planilla-table-scroll thead th {
        position: static;
    }
}
.content-wrapper--planilla .resumen-tecnicos {
    margin-bottom: 16px;
}
.content-wrapper--planilla .resumen-tecnicos .card-table {
    overflow: auto hidden;
}
.content-wrapper--planilla .resumen-tecnicos h2 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text-secondary);
}

/* Bloques */
.card, .form-section, .usuario-card, .session-card, .pendiente-card {
    background: var(--surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
    padding: 20px 22px; margin-bottom: 16px;
    border-top: 2px solid var(--clinical-line);
}
.card-title, .form-section h2 {
    font-size: 0.95rem; font-weight: 700; margin-bottom: 0;
    padding-bottom: 0; border-bottom: none;
    color: var(--text);
    display: flex; align-items: center; gap: 8px; line-height: 1.35;
}
.card-title {
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.form-section > h2 {
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}
.form-section h2 svg {
    flex-shrink: 0; width: 20px; height: 20px; color: var(--accent);
}
.form-section-header {
    margin-bottom: 14px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.form-section-header h2 { margin-bottom: 6px; }
.form-section-desc {
    font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; margin: 0;
}
.form-section.highlight, .section-pago {
    border-left: 3px solid var(--warning); background: var(--surface);
}
.session-card {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 8px; padding: 8px 12px; font-size: 0.85rem;
    background: var(--bg-subtle);
}

/* Alertas inline persistentes + avisos */
.alert-box {
    padding: 12px 16px; margin-bottom: 14px;
    border-radius: var(--radius-sm); font-size: 0.88rem;
}
.alert-success { background: var(--clinical-soft); border: 1px solid #a7f3d0; color: #065f46; }
.error-alert, .alert-error { background: var(--danger-soft); border: 1px solid #fecaca; color: var(--danger); }
.notice-card {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; margin-bottom: 14px; border-radius: var(--radius-md);
    font-size: 0.88rem; border: 1px solid var(--border-light); background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.notice-error { border-left: 4px solid var(--danger); background: var(--danger-soft); color: #991b1b; }
.notice-warning { border-left: 4px solid var(--warning); background: var(--warning-soft); color: #92400e; }
.notice-info { border-left: 4px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.notice-card a { color: inherit; font-weight: 600; }

/* Botones */
.btn, .btn-action, .btn-pro, .btn-submit-form, .btn-action-top, .btn-filter,
.btn-liquidar, .btn-check-pro, .btn-save, .btn-danger, .btn-mini, .btn-pagar, .btn-pagar-all, .btn-back {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none;
    background: var(--surface); color: var(--text-secondary);
    line-height: 1.3; transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.btn-primary, .btn-action, .btn-submit-form, .btn-action-top, .btn-filter, .btn-save, .btn-pagar-all {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
    color: #fff; border-color: var(--accent-hover);
}
.btn-primary:hover, .btn-action:hover, .btn-save:hover { filter: brightness(1.05); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn-success, .btn-pagar, .btn-check-pro, .btn-liquidar {
    background: linear-gradient(180deg, #10b981 0%, var(--clinical) 100%);
    color: #fff; border-color: var(--clinical);
}
.btn-success:hover, .btn-pagar:hover { filter: brightness(1.05); color: #fff; text-decoration: none; }
.btn-secondary, .btn-volver, .btn-back {
    background: var(--surface); color: var(--text-secondary); border-color: var(--border-light);
}
.btn-secondary:hover, .btn-back:hover { background: var(--bg-subtle); text-decoration: none; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; border-color: #b91c1c; }
.btn-mini { padding: 5px 10px; font-size: 0.78rem; box-shadow: none; }
.btn-block { display: flex; width: 100%; }

/* Acciones compactas (catálogos y tablas clínicas) */
.btn-action-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0; flex-shrink: 0;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-muted);
    cursor: pointer; text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    box-shadow: none;
}
.btn-action-icon:hover {
    background: var(--bg-subtle); color: var(--accent);
    border-color: var(--accent); text-decoration: none;
}
.btn-action-icon--save {
    background: var(--accent); color: #fff; border-color: var(--accent-hover);
}
.btn-action-icon--save:hover { filter: brightness(1.06); color: #fff; }
.btn-action-icon--danger { color: var(--danger); border-color: rgba(220, 38, 38, 0.25); }
.btn-action-icon--danger:hover {
    background: var(--danger-soft); color: var(--danger); border-color: var(--danger);
}
.catalogo-actions {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 4px; flex-wrap: nowrap; vertical-align: middle;
}
.catalogo-action-form { display: inline-flex; margin: 0; vertical-align: middle; }

/* Formularios — controles unificados (todos los tipos de input de texto) */
.grid-form { display: grid; gap: var(--form-gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.grid-form-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-form-balanced { align-items: start; }
.field-group, .form-group { display: flex; flex-direction: column; min-width: 0; gap: 6px; }
.field-group label, .form-group label {
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0;
    text-transform: none; letter-spacing: 0; line-height: 1.35;
}
.field-group label .hint-text,
.field-group label .label-optional,
.form-group label .hint-text,
.form-group label .label-optional {
    font-weight: 500; font-size: 0.72rem; color: var(--text-muted); margin-left: 4px;
}
body:not(.login-page) input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not(.combo-control__search):not(.cfg-catalog-search-input):not(.uadm-search__input),
select,
textarea {
    min-height: var(--input-h);
    padding: 0 var(--input-pad-x);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    line-height: 1.4;
    background: var(--surface);
    color: var(--text);
    width: 100%;
    max-width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
textarea {
    min-height: 120px;
    padding: 12px var(--input-pad-x);
    resize: vertical;
}
select {
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    cursor: pointer;
}
input[type="file"] {
    min-height: auto;
    padding: 8px 12px;
    font-size: 0.85rem;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    box-shadow: 0 0 0 1000px var(--surface) inset;
    transition: background-color 9999s ease-out 0s;
}
body:not(.login-page) input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}
body:not(.login-page) input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):hover:not(:focus):not([readonly]),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--border);
}
<input[readonly] { background: var(--bg-subtle); color: var(--text-muted); cursor: default; }
input[type="password"].input-narrow { max-width: 320px; margin-bottom: 10px; }
input[type="tel"] { font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.input-edit, .input-edit-select, .input-edit-date, .input-money {
    min-height: auto; padding: 4px 8px; font-size: 0.85rem;
}
.field-group-label {
    font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); line-height: 1.35;
}

.filter-bar, .filter-card, .filtros {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
    padding: 16px 18px; background: var(--surface);
    border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filter-card .form-group { min-width: 120px; flex: 1; }
.search-input-group { display: flex; gap: 6px; }
.btn-lock {
    padding: 6px 10px; border: 1px solid var(--border); background: var(--bg-subtle); cursor: pointer;
}
.hint-text { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; display: block; }
.btn-submit-form { margin-top: 10px; }

/* Tablas */
.table-scroll, .table-container, .card-table {
    background: var(--surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
    overflow: hidden; overflow-x: auto; margin-bottom: 14px;
}
.table-scroll table, .table-container table, .card-table table {
    width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 600px;
}
.table-scroll th, .table-container th, .card-table th {
    background: var(--bg-subtle); padding: 12px 14px; text-align: left;
    font-weight: 700; color: var(--text-secondary); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-light); white-space: nowrap;
}
.table-scroll td, .table-container td, .card-table td {
    padding: 12px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle;
}
.table-scroll tbody tr:nth-child(even) td, .card-table tbody tr:nth-child(even) td { background: var(--table-row-stripe, var(--bg-subtle)); }
.table-scroll tbody tr:hover td, .card-table tbody tr:hover td { background: var(--table-row-hover, color-mix(in srgb, var(--accent) 7%, var(--surface))) !important; }
.cell-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.cell-title { font-weight: 600; display: block; }
.cell-muted { font-size: 0.78rem; color: var(--text-muted); display: block; }
.sobra-cell, .sobra { font-weight: 600; color: var(--danger); text-align: right; background: var(--sobra-cell-bg, var(--surface)); }
.editable { cursor: pointer; }
.editable:hover { background: var(--editable-hover-bg, color-mix(in srgb, var(--warning) 14%, var(--surface))) !important; }
.input-edit { width: 90px; padding: 4px; border: 1px solid var(--accent); text-align: right; }
.input-edit-select { width: auto; min-width: 160px; max-width: 220px; text-align: left; }
.editable-select { cursor: pointer; }
.editable-date { cursor: pointer; }
.input-edit-date { width: auto; min-width: 140px; text-align: left; }
.input-money { max-width: 100px; text-align: right; font-family: Consolas, monospace; font-size: 0.85rem; }
.monto { font-weight: 600; text-align: right; }
.monto.pagado { color: var(--clinical); }
.monto.pendiente { color: var(--warning); }
.table-empty { padding: 24px !important; color: var(--text-muted); text-align: center; }

/* Badges */
.badge, .badge-status, .badge-rol, .badge-pendiente, .badge-pagado {
    display: inline-block; padding: 3px 8px; font-size: 0.72rem; font-weight: 600;
    border: 1px solid var(--border-light); border-radius: 999px;
}
.badge-success, .status-ready, .badge-pagado { background: var(--clinical-soft); color: var(--clinical); border-color: #a5d6a7; }
.badge-warning, .status-wait, .badge-alerta, .badge-pendiente { background: var(--warning-soft); color: var(--warning); border-color: #ffe082; }
.badge-rol.tecnico { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-rol.medico { background: #e3eef3; color: var(--accent); border-color: #90caf9; }

/* Admin */
.usuario-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light);
}
.avatar-admin {
    width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.85rem; color: #fff;
    background: var(--primary); border-radius: var(--radius-sm);
}
.avatar-admin.medico { background: var(--accent); }
.usuario-titulos h3 { font-size: 1rem; font-weight: 600; }
.usuario-meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }
.flex-row { display: flex; flex-wrap: wrap; gap: 16px; }
.mitad { flex: 1; min-width: 280px; }
.divisor { border-left: 1px solid var(--border); padding-left: 16px; }
.section-label { font-size: 0.88rem; font-weight: 600; margin-bottom: 10px; display: block; }
.categoria-titulo { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin: 10px 0 6px; }
.permisos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 6px; }
.checkbox-label {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 12px; border: 1px solid var(--border-light); cursor: pointer;
    font-size: 0.88rem; border-radius: var(--radius-sm); background: var(--surface);
    transition: border-color var(--transition), background-color var(--transition);
}
.checkbox-label:hover { background: var(--bg-subtle); border-color: var(--border); }
.checkbox-label:has(input:checked) {
    border-color: rgba(13, 148, 136, 0.35); background: var(--accent-soft);
}
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; }

/* Bandeja */
.status-summary {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 14px; margin-bottom: 14px;
    border: 1px solid var(--border-light); background: var(--bg-subtle);
    border-radius: var(--radius-md);
}
.count-badge {
    min-width: 44px; padding: 6px 12px; font-size: 1.1rem; font-weight: 600;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--warning);
}
.summary-text h3 { font-size: 0.92rem; font-weight: 600; }
.summary-text p { font-size: 0.82rem; color: var(--text-muted); }
.pendiente-card-header {
    display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light);
}
.pendiente-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.meta-item label { display: block; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.meta-item span { font-weight: 600; font-size: 0.85rem; }
.upload-form {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
    padding: 12px; border: 1px solid var(--border-light); background: var(--bg-subtle);
    border-radius: var(--radius-sm);
}
.upload-form .field-group { flex: 1; min-width: 200px; margin: 0; }

/* Pacientes */
.patient-hero {
    display: flex; gap: 16px; margin-bottom: 0; flex-wrap: wrap;
    padding: 16px 18px; border: 1px solid var(--border-light); background: var(--surface);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.patient-avatar {
    width: 52px; height: 52px; background: linear-gradient(145deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 1rem; font-weight: 700; letter-spacing: 0.02em;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md); flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.22);
}
.patient-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px 16px; flex: 1; align-content: start; }
.patient-hero-compact { margin-bottom: 0; }
.info-item-wide { grid-column: 1 / -1; }
.ultimo-registro-banner { margin-bottom: 16px; }
.ultimo-registro-banner .info-item-wide span { font-size: 1rem; }
.info-item label { display: block; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.info-item span { font-size: 0.92rem; font-weight: 600; }
.search-box { position: relative; margin-bottom: 12px; }
.search-box input { padding-left: 32px; width: 100%; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 14px; height: 14px; pointer-events: none; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 2000; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-content { background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-md); width: 100%; max-width: 560px; padding: 18px; box-shadow: var(--shadow-md); }
.modal-header { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 1rem; font-weight: 600; }
.close-modal { font-size: 1.25rem; cursor: pointer; color: var(--text-muted); line-height: 1; border: none; background: none; }
.modal-body-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-box { background: var(--bg-subtle); padding: 10px; border: 1px solid var(--border-light); }

/* Nav meses */
.nav-meses { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.nav-meses a, .nav-meses .actual { padding: 6px 12px; font-size: 0.82rem; border: 1px solid var(--border-light); border-radius: var(--radius-sm); }
.nav-meses a { background: var(--surface); color: var(--text); }
.nav-meses a:hover { background: var(--bg-subtle); text-decoration: none; }
.nav-meses .actual { background: var(--bg-subtle); font-weight: 600; }

.empty-state {
    text-align: center; padding: 36px 16px;
    border: 1px solid var(--border-light); background: var(--surface);
    border-radius: var(--radius-md);
}
.empty-state-icon { display: none; }
.empty-state h2 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { color: var(--text-muted); font-size: 0.88rem; }

/* Notificaciones */
.notif-wrap { position: relative; }
.notif-bell {
    padding: 4px 10px; border: 1px solid var(--border); background: var(--surface);
    cursor: pointer; font-size: 0.82rem; color: var(--text);
}
.notif-bell:hover { background: var(--bg-subtle); }
.notif-badge {
    display: inline-block; margin-left: 4px; padding: 0 5px;
    background: var(--danger); color: #fff; font-size: 0.68rem; font-weight: 600;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 4px); right: 0;
    width: min(340px, calc(100vw - 24px));
    background: var(--surface); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 1500;
}
.notif-dropdown-head { padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); font-size: 0.82rem; font-weight: 600; display: flex; justify-content: space-between; }
.notif-mark-all { background: none; border: none; color: var(--link); font-size: 0.78rem; cursor: pointer; }
.notif-list { list-style: none; max-height: 280px; overflow-y: auto; }
.notif-item { border-bottom: 1px solid var(--border-light); }
.notif-item.nueva { background: var(--warning-soft); }
.notif-link { display: block; padding: 10px 12px; color: inherit; font-size: 0.82rem; }
.notif-link:hover { background: var(--bg-subtle); text-decoration: none; }
.notif-title { display: block; font-weight: 600; margin-bottom: 2px; }
.notif-msg { display: block; color: var(--text-muted); font-size: 0.78rem; }
.notif-time { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.notif-footer { display: block; text-align: center; padding: 8px; border-top: 1px solid var(--border); font-size: 0.82rem; color: var(--link); }
.notif-footer:hover { background: var(--bg-subtle); text-decoration: none; }

/* Migone */
.theme-migone { --migone: #37474f; --migone-light: #eceff1; }
.theme-migone .migone-header { border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px; }
.theme-migone .migone-header h1 { color: var(--text); font-size: 1.1rem; font-weight: 600; }
.theme-migone .panel-superior { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.theme-migone .filtros, .theme-migone .panel-ocr {
    padding: 14px; border: 1px solid var(--border-light); background: var(--surface);
    border-radius: var(--radius-md);
    flex: 1; min-width: 260px; display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
}
.theme-migone .panel-ocr { background: var(--bg-subtle); }
.theme-migone .table-container th { background: var(--bg-subtle); color: var(--text); }
.theme-migone .migone-meta-row th { background: #cfd8dc !important; color: var(--text) !important; }
.theme-migone .migone-total-row td { font-weight: 600; background: var(--bg-subtle); }
.theme-migone .btn-ocr { background: var(--primary); color: #fff; border-color: var(--primary); }
.theme-migone .ocr-field { flex: 2; min-width: 180px; }
.theme-migone .ocr-status { font-size: 0.82rem; width: 100%; margin-top: 6px; display: block; }
.theme-migone .table-container table { min-width: 960px; font-size: 0.82rem; }
.theme-migone .migone-table-wrap { width: 100%; overflow-x: auto; }
.theme-migone .monto-tecnico { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-weight: 600; color: var(--text); }

.audit-estudio-line { display: block; margin-top: 3px; font-size: 0.72rem; line-height: 1.35; color: var(--text-muted); }
.usuario-audit-line { margin-top: 10px; margin-bottom: 0; }
.usuario-audit-resumen { background: var(--surface-alt, #f8fafb); border-left: 3px solid var(--primary, #0d9488); }
.cell-paciente-audit .audit-estudio-line { margin-top: 4px; }

.filter-card.panel-ocr .btn-ocr { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-card.panel-ocr .ocr-field { flex: 2; min-width: 180px; }
.filter-card.panel-ocr .ocr-status { font-size: 0.82rem; width: 100%; margin-top: 6px; display: block; }
.planilla-table-shell .monto-tecnico { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); font-weight: 600; }

/* Configuración — panel lateral estilo Windows Settings */
.config-layout {
    display: flex; gap: 0; align-items: stretch;
    min-height: calc(100vh - var(--topbar-h) - 48px);
    border: 1px solid var(--win-border); border-radius: var(--radius-lg);
    background: var(--surface); overflow: hidden;
    box-shadow: var(--shadow-sm);
    flex: 1;
    width: 100%;
    max-width: none;
    margin: 0;
}
.config-sidebar {
    flex: 0 0 clamp(200px, 16vw, var(--config-sidebar-w)); width: clamp(200px, 16vw, var(--config-sidebar-w));
    background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--surface) 100%);
    border-right: 1px solid var(--win-border);
    padding: 12px 8px; position: sticky; top: 0; align-self: flex-start;
    max-height: calc(100vh - var(--topbar-h) - 100px); overflow-y: auto;
}
.config-sidebar-title {
    font-size: 0.72rem; font-weight: 600; color: var(--sidebar-muted);
    padding: 4px 12px 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.config-main {
    flex: 1; min-width: 0; min-height: 0; padding: clamp(16px, 2.5vw, 24px);
    overflow-x: hidden; overflow-y: visible;
    container-type: inline-size; container-name: config-main;
}
.sidebar-nav .nav-section-label {
    padding-top: 12px;
}
.sidebar-nav .nav-section-label:first-child {
    padding-top: 4px;
}
.module-page {
    display: flex; flex-direction: column; gap: clamp(12px, 2vw, 16px);
    width: 100%; max-width: none;
}
.insumos-page .page-toolbar {
    justify-content: space-between; align-items: flex-end;
}
.insumos-year-filter {
    display: flex; align-items: center; gap: 8px; margin-left: auto;
}
.insumos-year-filter label {
    font-size: 0.78rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.insumos-year-filter select { width: auto; min-width: 96px; }
.insumos-formula { max-width: 920px; line-height: 1.55; }
@media (max-width: 720px) {
    .insumos-page .page-toolbar { flex-direction: column; align-items: stretch; }
    .insumos-year-filter { margin-left: 0; width: 100%; }
    .insumos-year-filter select { flex: 1; }
}
.config-nav, .win-subnav { display: flex; flex-direction: column; gap: 2px; }
.config-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; font-size: 0.88rem; color: var(--sidebar-text);
    border-radius: 8px; text-decoration: none; min-height: 38px;
    transition: background var(--transition);
}
.config-nav-item .nav-icon {
    display: flex; width: 20px; height: 20px; flex-shrink: 0; color: var(--sidebar-muted);
}
.config-nav-item .nav-icon svg { width: 18px; height: 18px; }
.config-nav-item:hover { background: var(--win-hover); text-decoration: none; color: var(--sidebar-text); }
.config-nav-item.active {
    background: var(--win-accent-bg); color: var(--win-accent); font-weight: 600;
    box-shadow: inset 3px 0 0 var(--win-accent);
}
.config-nav-item.active .nav-icon { color: var(--win-accent); }
.config-toolbar {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end;
    margin-bottom: clamp(12px, 2vw, 16px);
}
.usuario-edit-layout {
    display: flex; flex-direction: column; gap: clamp(14px, 2vw, 18px);
    width: 100%;
    max-width: none;
}
.usuario-edit-columns {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    gap: clamp(14px, 2vw, 18px);
    align-items: start;
}
.usuario-edit-section { margin-bottom: 0; }
.usuario-edit-section .form-section-header { margin-bottom: 16px; }
.usuario-edit-danger { border-color: rgba(220, 38, 38, 0.18); }
.card-actions {
    display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
    margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-light);
}
.card-actions-stack { flex-direction: column; align-items: stretch; }
.card-actions-stack .btn { width: 100%; justify-content: center; }
.permisos-grupos { display: flex; flex-direction: column; gap: 16px; }
.permisos-grupo-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 8px;
}

/* Listado usuarios (configuración) */
.usuarios-table-wrap { overflow-x: auto; }
.usuarios-table { min-width: 880px; table-layout: auto; }
.usuarios-table th,
.usuarios-table td {
    vertical-align: middle;
    line-height: 1.4;
}
.usuarios-table .col-num,
.usuarios-table th.col-num {
    width: 72px;
    text-align: center;
    white-space: nowrap;
}
.usuarios-table .col-accion,
.usuarios-table th.col-accion {
    width: auto;
    min-width: 280px;
    text-align: center;
    white-space: nowrap;
}
.usuarios-table .col-nombre { min-width: 140px; }
.usuarios-table .col-actividad { min-width: 200px; max-width: 280px; }
.usuarios-code {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 0.82rem;
}
.usuarios-audit-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.usuarios-audit-tipo {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.usuarios-audit-meta { color: var(--text-muted); }
.usuarios-audit-empty { color: var(--text-muted); }
.usuarios-row-actions {
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}
.usuarios-row-actions .form-inline { margin: 0; }
.usuarios-row-actions .btn-mini-hint { padding: 4px 8px; color: var(--text-muted); }

.usuario-eliminar-aviso {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(220, 38, 38, 0.2);
    background: rgba(255, 245, 245, 0.7);
}
.usuario-eliminar-aviso--inline {
    margin-top: 0;
    padding: 10px 12px;
    font-size: 0.82rem;
}
.usuario-eliminar-aviso-titulo {
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #c92a2a;
}
.usuario-eliminar-motivos {
    margin: 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 10px;
}
.usuario-eliminar-motivos li { margin: 0; }
.usuario-eliminar-motivos p {
    margin: 4px 0 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-secondary);
}
.usuario-eliminar-accion {
    color: var(--text) !important;
}
.usuario-eliminar-accion span {
    font-weight: 700;
    color: #c92a2a;
}
.usuario-eliminar-inline {
    position: relative;
    display: inline-block;
}
.usuario-eliminar-inline-trigger {
    list-style: none;
    cursor: pointer;
    white-space: nowrap;
}
.usuario-eliminar-inline-trigger::-webkit-details-marker { display: none; }
.usuario-eliminar-inline-panel {
    position: absolute;
    right: 0;
    z-index: 20;
    margin-top: 6px;
    width: min(320px, 85vw);
    box-shadow: var(--shadow-md);
}
.usuario-eliminar-inline[open] .usuario-eliminar-inline-trigger {
    border-color: rgba(220, 38, 38, 0.35);
    color: #c92a2a;
}
.audit-section-head {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 8px; margin-bottom: 10px;
}
.audit-section-head .section-heading { margin-bottom: 0; }

/* Informe clínico — vista idéntica al PDF modelo (Oficio II 216×330 mm, Times 11/12 pt) */
:root {
    --informe-paper-w: 216mm;
    --informe-paper-h: 330mm;
}
.informe-layout { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 16px; align-items: start; }
.informe-meta-grid { display: grid; gap: 10px; font-size: 0.88rem; }
.informe-meta-grid label { display: block; font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.informe-meta-grid span { font-weight: 600; }
.informe-preview-doc {
    width: var(--informe-paper-w);
    max-width: 100%;
    margin: 0 auto;
    padding: 18mm 20mm;
    box-sizing: border-box;
    background: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 0;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.14);
    font-family: "Times New Roman", Times, serif;
    font-size: 11pt;
    line-height: 1.27;
    color: #000000;
}
.informe-doc-header { text-align: center; margin: 0 0 6mm; }
.informe-doc-header p { margin: 0 0 1.4mm; font-size: 11pt; font-weight: 400; color: #000; }
.informe-doc-title { font-size: 12pt !important; font-weight: 700 !important; line-height: 1.25; margin-bottom: 2mm !important; }
.informe-doc-paciente { margin: 0 0 4mm; }
.informe-doc-paciente p { margin: 0 0 1.5mm; font-size: 11pt; font-weight: 400; text-align: left; color: #000; }
.informe-doc-block { margin: 0 0 3mm; }
.informe-doc-block h3,
.informe-doc-block h4 {
    font-family: inherit; font-size: 11pt; font-weight: 700;
    margin: 0 0 1.5mm; letter-spacing: 0; text-transform: none; color: #000;
}
.informe-fixed {
    margin: 0; font-size: 11pt; line-height: 1.27; text-align: justify; color: #000;
}
.informe-body-text { text-align: justify; }
.informe-body-text .informe-linea {
    margin: 0 0 0.5mm; font-size: 11pt; line-height: 1.27; color: #000;
}
.informe-preview-doc .informe-textarea {
    display: block; width: 100%; box-sizing: border-box;
    border: none; border-radius: 0; padding: 0; margin: 0;
    background: transparent; color: #000;
    font-family: "Times New Roman", Times, serif;
    font-size: 11pt; line-height: 1.27; text-align: justify;
    resize: vertical; min-height: 6em;
    box-shadow: none;
}
.informe-preview-doc .informe-textarea::placeholder { color: #888888; font-style: italic; }
.informe-preview-doc .informe-textarea:focus {
    outline: 1px dotted #666666;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: none;
}
.informe-doc-firma { margin-top: 12mm; padding-top: 0; line-height: 1.27; }
.informe-doc-firma p { margin: 0 0 1mm; font-size: 11pt; color: #000; }
.informe-firma-nombre { font-weight: 700; }
.informe-editable-wrap { position: relative; }
.informe-editable-wrap:not(.is-editing) > .informe-modelo-textarea {
    display: none !important;
}
.informe-editable-wrap.is-editing > .informe-live-preview {
    display: none !important;
}
.informe-editable-wrap.is-editing > .informe-modelo-textarea {
    display: block !important;
}
.informe-live-preview { cursor: text; min-height: 1.5em; touch-action: manipulation; }
.informe-editable-wrap .informe-modelo-textarea { touch-action: manipulation; }
.informe-live-preview[hidden] { display: none !important; }
.informe-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; justify-content: flex-end; }

@media print {
    @page {
        size: 216mm 330mm;
        margin: 0;
    }
    .informe-sidebar, .informe-toolbar, .informe-actions, .informe-editor-bar,
    .informe-datos-details, .informe-opciones-clinicas, .informe-panel-opciones, .informe-editor-actions, .app-topbar, .sidebar, .sidebar-overlay { display: none !important; }
    .main-content { margin: 0 !important; width: 100% !important; }
    .content-wrapper { padding: 0 !important; overflow: visible !important; }
    .informe-layout-v2, .informe-editor-page { display: block !important; }
    .informe-preview-doc, .informe-modelo-doc {
        width: var(--informe-paper-w); max-width: none; margin: 0; padding: 14mm 16mm;
        border: none; box-shadow: none; page-break-after: avoid;
    }
    .informe-preview-doc .informe-textarea,
    .informe-modelo-doc .informe-modelo-textarea { border: none !important; outline: none !important; }
    .informe-modelo-firma-img {
        width: 37.6mm;
        height: 20.8mm;
        max-width: 37.6mm;
        max-height: 20.8mm;
    }
}
.pendientes-list { display: grid; gap: 12px; }
.pendiente-card-compact .pendiente-actions { margin-top: 12px; }
.pendiente-actions { display: flex; justify-content: flex-end; }

@media (max-width: 900px) {
    .informe-layout { grid-template-columns: 1fr; }
    .informe-preview-doc { padding: 14mm 12mm; width: 100%; }
}
.config-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.config-panel { border: 1px solid var(--border-light); background: var(--surface); padding: 16px 18px; border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.config-panel h2 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.config-panel p { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 12px; }
.config-user-head { padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--border); background: var(--bg-subtle); }
.catalogos-grid {
    display: grid; grid-template-columns: 1fr; gap: clamp(12px, 2vw, 20px);
    align-items: start; min-width: 0; width: 100%;
}
.catalogos-grid .card {
    min-width: 0; margin-bottom: 0; padding: clamp(14px, 2vw, 20px);
    overflow: hidden; display: flex; flex-direction: column;
}
.catalogos-grid .card-title {
    display: flex; align-items: center; gap: 8px;
}
.catalogos-grid .card-title::before {
    content: ""; width: 4px; height: 18px; border-radius: 2px;
    background: linear-gradient(180deg, var(--accent), var(--clinical));
    flex-shrink: 0;
}
.catalogo-form .search-input-group { align-items: stretch; flex-wrap: nowrap; gap: 8px; }
.catalogo-form .search-input-group input { flex: 1 1 auto; min-width: 0; }
.catalogo-form .search-input-group .btn { flex: 0 0 auto; white-space: nowrap; min-width: 96px; }
.catalogo-table-wrap {
    overflow-x: auto; margin-bottom: 10px;
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
}
.catalogo-table-wrap .catalogo-table { min-width: 0; width: 100%; table-layout: fixed; margin: 0; }
.catalogo-table .col-name { width: auto; }
.catalogo-table .col-studies { width: 80px; }
.catalogo-table .col-actions { width: 88px; }
.catalogo-table th, .catalogo-table td { padding: 10px 12px; vertical-align: middle; }
.catalogo-table td:first-child { word-break: break-word; overflow-wrap: anywhere; }
.catalogo-table th:last-child, .catalogo-table td.cell-actions-catalogo {
    padding-left: 6px; padding-right: 10px; text-align: center;
}
.catalogo-table td.cell-actions-catalogo {
    display: table-cell; white-space: nowrap;
}
.cell-actions-catalogo .catalogo-actions { justify-content: center; }
.catalogo-inline-edit input[type="text"] { width: 100%; min-width: 0; }
.catalogo-table .badge-studies {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 28px; padding: 2px 8px; border-radius: 999px;
    font-size: 0.78rem; font-weight: 600;
    background: var(--clinical-soft); color: var(--clinical);
    border: 1px solid var(--clinical-line);
}
tr.row-editing td { background: var(--accent-soft); }
@media (min-width: 1280px) {
    .catalogos-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@container config-main (max-width: 520px) {
    .catalogo-form .search-input-group { flex-direction: column; align-items: stretch; }
    .catalogo-form .search-input-group .btn { width: 100%; min-width: 0; }
}
@container config-main (max-width: 560px) {
    /* Conversión completa tabla → tarjetas: table/tbody/tr/td en bloque para
       que cada fila ocupe el 100% y el valor no se parta palabra por palabra. */
    .cfg-catalog-panel .catalogo-table,
    .catalogo-table,
    .cfg-catalog-panel .catalogo-table tbody,
    .catalogo-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .catalogo-table thead { display: none; }
    .cfg-catalog-panel .catalogo-table tbody tr,
    .catalogo-table tbody tr {
        display: block;
        width: 100%;
        padding: 12px 14px;
        border-bottom: 1px solid var(--border-light);
    }
    .catalogo-table tbody tr:last-child { border-bottom: none; }
    .cfg-catalog-panel .cfg-catalog-list .catalogo-table tbody td,
    .cfg-catalog-panel .catalogo-table tbody td,
    .catalogo-table td {
        display: block;
        width: 100%;
        max-width: 100%;
        padding: 4px 0;
        border-bottom: none;
        text-align: left !important;
        white-space: normal;
        overflow-wrap: anywhere;
    }
    .catalogo-table td::before {
        content: attr(data-label);
        display: block; font-size: 0.68rem; font-weight: 700;
        text-transform: uppercase; letter-spacing: 0.04em;
        color: var(--text-muted); margin-bottom: 2px;
    }
    .catalogo-table td.table-empty::before { display: none; }
    .catalogo-table td.cell-actions-catalogo::before { margin-bottom: 6px; }
    .cfg-catalog-panel .catalogo-table tbody td.cell-actions-catalogo,
    .catalogo-table td.cell-actions-catalogo {
        display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px;
    }
    .catalogo-table td.cell-actions-catalogo .catalogo-actions { justify-content: flex-start; }
    /* Badge de estudios alineado a la izquierda dentro de la tarjeta */
    .cfg-catalog-panel .catalogo-table tbody td.text-center {
        text-align: left !important;
    }
}
.form-actions-inline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Utilidades */
.accent-text { color: var(--accent); font-weight: 600; }
.alert-link { color: inherit; font-weight: 600; }
.card-spaced { margin-bottom: 14px; }
.mb-section { margin-bottom: 12px; }
.mb-sm { margin-bottom: 8px; }
.mt-section { margin-top: 12px; }
.block-heading { display: block; margin-bottom: 8px; }
.badge-inline { margin-top: 2px; display: inline-block; }
.grid-form-doc { grid-template-columns: 1.5fr 1fr; }
.field-narrow { max-width: 280px; }
.input-monto { font-size: 1rem; font-weight: 600; }
.hint-accent { color: var(--accent); }
.hint-muted { color: var(--text-muted); }
.form-inline { display: inline; }
.row-total td { background: var(--bg-subtle); font-weight: 600; }
.row-total.ok td { background: var(--clinical-soft); }
.planilla-table-shell .row-total td,
.planilla-table-scroll .row-total td { background: var(--bg-subtle); }
.planilla-table-shell .row-total.ok td,
.planilla-table-scroll .row-total.ok td { background: var(--clinical-soft); }
.field-full { grid-column: 1 / -1; }

@media (min-width: 901px) {
    .btn-menu { display: none !important; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; width: 100%; }
    .btn-menu { display: inline-flex; }
    .divisor { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
    .modal-body-grid { grid-template-columns: 1fr; }
    .stats-row .stat-item, .planilla-stat { min-width: 50%; border-bottom: 1px solid var(--border-light); }
    .content-wrapper--planilla .planilla-table-shell table,
    .content-wrapper--planilla .planilla-table-scroll table { min-width: 640px; }
    .content-wrapper--planilla .resumen-tecnicos .card-table table { min-width: 480px; }
    .app-toast-stack { right: 12px; bottom: 12px; left: 12px; max-width: none; }
    .app-toast-stack .app-toast { min-width: 0; width: 100%; }
    .usuario-edit-columns { grid-template-columns: 1fr; }
    .config-layout { flex-direction: column; min-height: auto; border-radius: var(--radius-md); }
    .config-sidebar {
        flex: none; width: 100%; max-height: none; position: relative;
        border-right: none; border-bottom: 1px solid var(--win-border);
        overflow-x: auto; overflow-y: hidden; padding: 8px;
    }
    .config-nav, .win-subnav { flex-direction: row; flex-wrap: nowrap; gap: 4px; }
    .config-nav-item { white-space: nowrap; flex-shrink: 0; font-size: 0.82rem; padding: 8px 10px; }
    .config-sidebar-title { display: none; }
    .config-main { padding: 14px 12px; }
    .catalogos-grid .card { padding: 14px 12px; }
}
@media (max-width: 480px) {
    .content-wrapper { padding: 12px; }
    .page-toolbar { justify-content: stretch; }
    .page-toolbar .btn { flex: 1; text-align: center; }
    .catalogos-grid { grid-template-columns: 1fr; }
    .grid-form, .grid-form-doc, .grid-form-2 { grid-template-columns: 1fr; }
    .patient-hero { flex-direction: column; }
    .patient-info-grid { grid-template-columns: 1fr 1fr; }
    .config-nav { flex-direction: column; gap: 4px; }
    .config-nav a { border-right: none; width: 100%; }
    .stats-row .stat-item, .planilla-stat { min-width: 100%; border-right: none; }
    .content-wrapper--planilla .planilla-table-shell table,
    .content-wrapper--planilla .planilla-table-scroll table { min-width: 520px; font-size: 0.8rem; }
    .content-wrapper--planilla .planilla-table-shell th,
    .content-wrapper--planilla .planilla-table-shell td,
    .content-wrapper--planilla .planilla-table-scroll th,
    .content-wrapper--planilla .planilla-table-scroll td { padding: 10px 8px; }
    .topbar-date { display: none; }
    .table-scroll:not(.catalogo-table-wrap) table { min-width: 520px; font-size: 0.8rem; }
    .form-actions-row { flex-direction: column; padding: 14px; }
    .form-actions-row .btn { width: 100%; justify-content: center; }
    .registro-steps-list { flex-direction: column; align-items: stretch; gap: 10px; }
    .registro-step { padding: 8px 10px; background: var(--bg-subtle); border-radius: var(--radius-sm); }
    .clinical-flow-page { max-width: none; }
    .datos-clinicos-item { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 640px) {
    .grid-form-2 { grid-template-columns: 1fr; }
    .patient-info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .info-item-wide { grid-column: 1 / -1; }
}

/* v13 — diálogos in-app, auditoría, paginación */
#app-dialog-root { position: fixed; inset: 0; pointer-events: none; z-index: 10000; }
#app-dialog-root > * { pointer-events: auto; }
.app-dialog-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
    display: flex; align-items: center; justify-content: center; padding: 16px;
    opacity: 0; transition: opacity 0.2s ease;
}
.app-dialog-overlay.open { opacity: 1; }
.app-dialog {
    background: var(--surface); border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18); width: min(420px, 100%);
    overflow: hidden; border: 1px solid var(--border-light);
}
.app-dialog-head { padding: 14px 18px; font-weight: 600; border-bottom: 1px solid var(--border-light); background: var(--bg-subtle); }
.app-dialog-body { padding: 18px; color: var(--text-secondary); line-height: 1.5; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 16px; }
.app-toast-stack {
    position: fixed; bottom: 20px; right: 20px; z-index: 10001;
    display: flex; flex-direction: column; gap: 10px;
    max-width: min(400px, calc(100vw - 32px));
    pointer-events: none;
}
.app-toast-stack .app-toast { pointer-events: auto; position: relative; bottom: auto; right: auto; }
.app-toast {
    background: var(--surface); border: 1px solid var(--border-light); border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg); padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px;
    transform: translateX(24px); opacity: 0; transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    min-width: 280px;
}
.app-toast.show { transform: translateX(0); opacity: 1; }
.app-toast-icon { flex-shrink: 0; width: 22px; height: 22px; margin-top: 1px; }
.app-toast-icon svg { width: 22px; height: 22px; }
.app-toast-success .app-toast-icon { color: var(--clinical); }
.app-toast-error .app-toast-icon { color: var(--danger); }
.app-toast-warning .app-toast-icon { color: var(--warning); }
.app-toast-info .app-toast-icon { color: var(--accent); }
.app-toast-body { flex: 1; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.45; }
.app-toast-success { border-left: 4px solid var(--clinical); }
.app-toast-error { border-left: 4px solid var(--danger); }
.app-toast-warning { border-left: 4px solid var(--warning); }
.app-toast-info { border-left: 4px solid var(--accent); }
.app-toast-close {
    background: none; border: none; font-size: 1.2rem; cursor: pointer;
    color: var(--text-muted); line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.app-toast-close:hover { color: var(--text); }
.audit-trail {
    padding: 10px 14px; background: var(--bg-subtle); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); font-size: 0.82rem; color: var(--text-secondary);
}
.audit-sep { color: var(--text-muted); margin: 0 6px; }
.pagination { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.pagination-info { font-size: 0.82rem; color: var(--text-muted); }
.badge-link { text-decoration: none; cursor: pointer; }
.badge-link:hover { filter: brightness(0.95); text-decoration: none; }
.badge-migone { background: #e3f2fd; color: #1565c0; border-color: #90caf9; }
.field-locked { background: var(--field-locked-bg) !important; color: var(--text-secondary); }
.cell-actions form { display: inline; }
@media (max-width: 768px) {
    .flex-row { flex-direction: column; }
    .mitad { min-width: 100%; }
    .divisor { border-left: none; padding-left: 0; border-top: 1px solid var(--border-light); padding-top: 14px; }
    .sidebar { width: min(300px, 88vw); }
    .config-nav-item .nav-label { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
    .app-topbar { padding-left: 12px; padding-right: 12px; padding-bottom: 8px; }
    .topbar-title strong { font-size: 0.88rem; }
    .topbar-title span { font-size: 0.7rem; }
    .filter-card, .filter-bar { flex-direction: column; align-items: stretch; }
    .theme-migone .panel-superior { flex-direction: column; }
}

/* ——— Bandeja médica v2 ——— */
.bandeja-page { display: flex; flex-direction: column; gap: 16px; max-width: none; width: 100%; }
.bandeja-hero {
    display: grid; grid-template-columns: auto 1fr; gap: 20px 24px; align-items: start;
    padding: 20px 22px; margin-bottom: 0;
}
.bandeja-hero-stats { display: flex; gap: 12px; flex-wrap: wrap; grid-row: span 2; }
.bandeja-stat {
    min-width: 88px; padding: 12px 14px; text-align: center;
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    background: var(--bg-subtle);
}
.bandeja-stat.primary { border-color: var(--accent); background: var(--accent-soft); }
.bandeja-stat-num { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.bandeja-stat.primary .bandeja-stat-num { color: var(--primary); }
.bandeja-stat-lbl { display: block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-top: 4px; }
.bandeja-hero-text h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.bandeja-hero-text p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; max-width: 520px; }
.bandeja-search {
    grid-column: 2; position: relative; max-width: 420px;
}
.bandeja-search svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.bandeja-search input {
    width: 100%; padding: 10px 12px 10px 38px; border: 1px solid var(--border-light);
    border-radius: var(--radius-md); background: var(--surface); font-size: 0.88rem;
}
.bandeja-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15); }
.bandeja-table-wrap { overflow-x: auto; margin-bottom: 0; }
.bandeja-table { min-width: 720px; }
.bandeja-table th { position: sticky; top: 0; z-index: 2; }
.bandeja-patient { display: block; font-weight: 600; color: var(--text); }
.bandeja-patient-meta { display: none; font-size: 0.75rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
.bandeja-badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
}
.bandeja-badge.pending { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(180,83,9,0.25); }
.bandeja-badge.draft { background: var(--accent-soft); color: var(--primary); border: 1px solid rgba(13, 148, 136, 0.2); }
.bandeja-badge.done { background: rgba(22,163,74,0.12); color: #15803d; border: 1px solid rgba(22,163,74,0.28); font-weight: 700; letter-spacing: 0.04em; }
.bandeja-empty, .bandeja-empty-filter {
    text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 0.9rem;
}
.bandeja-empty.card { padding: 48px 24px; }
.bandeja-empty h2 { font-size: 1.05rem; color: var(--text); margin-bottom: 8px; }
.bandeja-empty-icon {
    width: 56px; height: 56px; margin: 0 auto 16px; color: var(--clinical);
    background: var(--clinical-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center;
}
.bandeja-empty-icon svg { width: 28px; height: 28px; }

/* Bandeja médica — layout ancho completo */
.bandeja-v2 {
    display: block;
    width: 100%;
    max-width: none;
    flex: none;
    min-height: auto;
    padding-bottom: 16px;
}
.content-wrapper--bandeja {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.content-wrapper--bandeja .page-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: block;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}
.bandeja-v2 > .card,
.bandeja-v2 > form,
.bandeja-v2 > .bandeja-v2-table-shell {
    margin-bottom: 14px;
}
.bandeja-v2 > .bandeja-v2-table-shell:last-child {
    margin-bottom: 0;
}
.bandeja-v2-head {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 16px 24px; padding: 18px 20px; margin-bottom: 0;
}
.bandeja-v2-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.bandeja-v2-stat {
    min-width: 96px; padding: 12px 16px; text-align: center;
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    background: var(--bg-subtle);
}
.bandeja-v2-stat.primary { border-color: var(--accent); background: var(--accent-soft); }
.bandeja-v2-stat-num { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.bandeja-v2-stat.primary .bandeja-v2-stat-num { color: var(--primary); }
.bandeja-v2-stat-lbl {
    display: block; font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-muted); margin-top: 4px;
}
.bandeja-v2-intro { flex: 1; min-width: 200px; }
.bandeja-v2-intro h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.bandeja-v2-intro p { font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; margin: 0; }
.bandeja-v2-filters { padding: 16px 18px; margin-bottom: 0; }
.bandeja-v2-filter-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px 14px; align-items: end;
}
.bandeja-v2-search-group input { width: 100%; }
.bandeja-v2-filter-actions .bandeja-v2-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.bandeja-v2-table-shell {
    display: block;
    width: 100%;
    flex: none;
    min-height: auto;
    margin-bottom: 0;
    overflow: auto hidden;
    -webkit-overflow-scrolling: touch;
}
.bandeja-v2-table-scroll {
    overflow: auto hidden;
    max-height: none;
    flex: none;
    min-height: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}
.bandeja-v2-table { width: 100%; min-width: 900px; border-collapse: collapse; table-layout: fixed; }
.bandeja-v2-table th,
.bandeja-v2-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bandeja-v2-table th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-subtle); white-space: nowrap;
    font-weight: 700; color: var(--text-secondary); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.bandeja-v2-table .col-check { width: 44px; min-width: 44px; max-width: 44px; }
.bandeja-v2-table .col-fecha { width: 92px; }
.bandeja-v2-table .col-paciente {
    width: 20%;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}
.bandeja-v2-table .col-ci { width: 88px; }
.bandeja-v2-table .col-inst { width: 16%; }
.bandeja-v2-table .col-estudio { width: 12%; }
.bandeja-v2-table .col-tecnico { width: 13%; }
.bandeja-v2-table .col-estado { width: 104px; }
.bandeja-v2-table .col-action { width: 132px; min-width: 132px; }
.bandeja-v2-table td.col-estado,
.bandeja-v2-table th.col-estado { text-align: center; white-space: nowrap; }
.bandeja-v2-table td.cell-actions,
.bandeja-v2-table th.col-action {
    text-align: center;
    white-space: nowrap;
    overflow: visible;
}
.bandeja-v2-table td.cell-actions {
    display: table-cell;
    vertical-align: middle;
}
.bandeja-v2-table td.cell-actions .btn-mini {
    display: inline-flex;
    vertical-align: middle;
    margin: 0 2px;
}
.bandeja-v2-table td.cell-actions .hint-text { display: inline-block; }
.bandeja-v2-patient { display: block; font-weight: 600; color: var(--text); white-space: normal; }
.bandeja-v2-patient-meta { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* Editor informe — scroll de página completa; acciones al pie del formulario */
.informe-editor-page {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: none;
}
.content-wrapper.informe-editor-layout {
    overflow: visible;
    padding: clamp(4px, 0.8vw, 8px);
    display: flex;
    flex-direction: column;
}
.content-wrapper.informe-editor-layout .page-body {
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 12px;
}
.content-wrapper.informe-editor-layout .informe-editor-page > header,
.content-wrapper.informe-editor-layout .informe-editor-page > details {
    flex-shrink: 0;
}
.content-wrapper.informe-editor-layout .informe-editor-form {
    display: flex;
    flex-direction: column;
}
.content-wrapper.informe-editor-layout .informe-editor-workzone {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: none;
}
.content-wrapper.informe-editor-layout .informe-editor-actions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-top: 1px solid var(--border);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.informe-editor-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin-bottom: 0;
    flex-shrink: 0;
    border-top: 3px solid var(--accent);
}
.informe-editor-bar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-width: 0; }
.informe-editor-meta { display: grid; gap: 2px; min-width: 0; }
.informe-editor-meta strong { font-size: 0.95rem; line-height: 1.3; }
.informe-editor-meta span { font-size: 0.78rem; color: var(--text-muted); }

/* Panel datos — colapsable, sin scroll interno */
.informe-datos-details {
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 0;
    overflow: visible;
    border: 1px solid var(--border-light);
    background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--surface) 100%);
}
.informe-datos-details > summary {
    list-style: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
}
.informe-datos-details > summary::-webkit-details-marker { display: none; }
.informe-datos-summary-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.informe-datos-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.informe-chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    white-space: nowrap;
}
.informe-chip--accent {
    background: var(--accent-soft);
    border-color: var(--clinical-line);
    color: var(--accent);
}
.informe-datos-toggle-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: auto;
}
.informe-datos-body {
    padding: 0 14px 14px;
    border-top: 1px solid var(--border-light);
}
.informe-datos-details:not([open]) .informe-datos-body { display: none; }

.informe-editor-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px 18px;
    margin: 0;
}
.informe-editor-facts div { display: grid; gap: 2px; }
.informe-editor-facts dt {
    font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted);
}
.informe-editor-facts dd { font-size: 0.86rem; font-weight: 600; margin: 0; }
.informe-datos-paciente { margin-bottom: 12px; padding-top: 12px; }
.informe-datos-paciente-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr));
    gap: 10px 16px;
    margin: 0;
}
.informe-datos-paciente-grid div { display: grid; gap: 2px; min-width: 0; }
.informe-datos-paciente-grid dt {
    font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted);
}
.informe-datos-paciente-grid dd { font-size: 0.84rem; font-weight: 600; margin: 0; word-break: break-word; }
.informe-dato-destacado dd { color: var(--accent); }
.informe-dato-sin-registro { color: var(--text-muted); font-style: italic; font-weight: 500; }
.informe-fact-wide { grid-column: 1 / -1; }
.informe-editor-facts--compact {
    margin-top: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.informe-editor-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.informe-editor-workzone {
    overflow: visible;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}
.informe-workzone-split {
    display: flex;
    overflow: visible;
}
.informe-panel-opciones {
    flex: 0 0 var(--informe-panel-w, 300px);
    width: var(--informe-panel-w, 300px);
    min-width: var(--informe-panel-w, 300px);
    max-width: 58%;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    position: relative;
    background: var(--surface);
    border-right: 1px solid var(--border-light);
    transition: width 0.2s ease, min-width 0.2s ease, flex-basis 0.2s ease;
}
.informe-panel-opciones.is-collapsed {
    --informe-panel-w: 48px;
    width: 48px;
    min-width: 48px;
    flex: 0 0 48px;
}
.informe-panel-opciones.is-collapsed .informe-panel-inner,
.informe-panel-opciones.is-collapsed .informe-panel-resizer {
    display: none;
}
.informe-panel-inner {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
}
.informe-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--border-light);
    background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--surface) 100%);
    flex-shrink: 0;
}
.informe-panel-title {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}
.informe-panel-subtitle {
    margin: 3px 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.35;
}
.informe-panel-hint {
    margin: 0 0 12px;
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.informe-panel-collapse {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.informe-panel-collapse:hover {
    background: var(--accent-soft);
    border-color: var(--clinical-line);
    color: var(--accent);
}
.informe-panel-expand {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px 4px;
    border: none;
    background: var(--accent-soft);
    color: var(--accent);
    cursor: pointer;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}
.informe-panel-opciones.is-collapsed .informe-panel-expand {
    display: flex;
}
.informe-panel-expand span {
    writing-mode: vertical-rl;
}
.informe-panel-body {
    flex: 1;
    overflow: visible;
    padding: 12px 14px 16px;
}
.informe-panel-resizer {
    flex: 0 0 10px;
    width: 10px;
    cursor: col-resize;
    touch-action: none;
    background: linear-gradient(90deg, var(--border-light), rgba(13, 148, 136, 0.18), var(--border-light));
    position: relative;
    z-index: 3;
    transition: background 0.15s;
}
.informe-panel-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 32px;
    border-radius: 999px;
    background: rgba(13, 148, 136, 0.45);
}
.informe-panel-resizer:hover,
.informe-panel-resizer.is-active,
.informe-panel-resizer:focus-visible {
    background: rgba(13, 148, 136, 0.22);
    outline: none;
}
body.informe-resizing {
    cursor: col-resize !important;
    user-select: none;
}
body.informe-resizing * {
    cursor: col-resize !important;
}
.informe-panel-preview {
    flex: 1;
    min-width: 0;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(14px, 2.5vw, 28px);
    background: linear-gradient(165deg, #d5e0ea 0%, #e4ebf2 45%, #d8e3ec 100%);
}
.informe-panel-preview--solo {
    flex: 1;
    border-radius: inherit;
}
.informe-panel-preview .informe-modelo-doc {
    margin: 0 auto;
    width: 100%;
    max-width: var(--informe-paper-w);
    flex-shrink: 0;
}
.informe-panel-field { margin-top: 14px; }
.informe-editor-actions {
    justify-content: space-between;
    align-items: center;
}
.informe-monto-estudio--inline {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border-light);
    background: transparent;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
}
.informe-monto-estudio-readonly {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-light);
}
.informe-monto-pago-inst { color: var(--clinical); }
.informe-monto-estudio {
    padding: 14px 16px;
    margin-bottom: 0;
    border: 1px solid var(--border-light);
    background: linear-gradient(135deg, var(--surface) 0%, var(--accent-soft) 120%);
}
.informe-monto-estudio__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.informe-monto-estudio__head strong { font-size: 0.92rem; }
.informe-monto-estudio__hint { font-size: 0.75rem; color: var(--text-muted); }
.informe-monto-estudio__row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: center;
}
.informe-monto-estudio__label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.informe-monto-estudio__input {
    max-width: 220px;
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 10px;
}
.informe-monto-estudio__preview {
    grid-column: 2;
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.informe-monto-estudio__preview strong { color: var(--clinical); }
.audit-monto-total-line { display: block; margin-top: 2px; color: var(--accent); font-size: 0.72rem; }
.monto-pago-inst { font-weight: 600; color: var(--text); background: var(--accent-soft); }
.informe-editor-actions-main {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    flex: 1;
    min-width: 0;
}
.home-audit-master { border-left: 4px solid var(--accent); }
.home-audit-master-inner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
}
.home-audit-master h2 { font-size: 1rem; margin: 0 0 4px; }
.home-audit-master p { margin: 0; font-size: 0.85rem; color: var(--text-muted); }
.audit-master-table { max-height: min(60vh, 520px); overflow: auto; }
.audit-json-details summary { cursor: pointer; font-size: 0.78rem; color: var(--link); }
.audit-json {
    font-size: 0.68rem; max-width: 280px; overflow: auto;
    background: var(--bg-subtle); padding: 6px; border-radius: var(--radius-sm); margin-top: 4px;
}
.informe-modelo-doc {
    width: var(--informe-paper-w); max-width: 100%; box-sizing: border-box;
    min-height: var(--informe-paper-h);
    padding: 14mm 16mm 20mm;
    background: #ffffff; color: #000000;
    border: 1px solid #c8c8c8;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 11pt; line-height: 1.28;
    overflow: visible;
    min-height: min-content;
    flex-shrink: 0;
}
.informe-modelo-header {
    display: grid; grid-template-columns: 92px 1fr 92px;
    gap: 10px 14px; align-items: center; margin-bottom: 8mm;
}
.informe-modelo-logo { display: flex; align-items: center; min-height: 72px; }
.informe-modelo-logo-inst { justify-content: flex-start; }
.informe-modelo-logo-general { justify-content: flex-end; }
.informe-modelo-logo img {
    display: block; max-width: 88px; max-height: 72px;
    width: auto; height: auto; object-fit: contain;
}
/* Estudios sin institución: globo a la izquierda y QR (con texto de servicio) a la derecha. */
.informe-modelo-header--sin-inst { grid-template-columns: 92px 1fr auto; }
.informe-modelo-logo-general .informe-modelo-qr-img {
    max-width: 176px; max-height: 104px;
    width: auto; height: auto; object-fit: contain;
}
.informe-modelo-titles { text-align: center; padding: 0 4px; align-self: center; }
.informe-modelo-titles h1 {
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 13pt; font-weight: 700; letter-spacing: 0.02em;
    margin: 0 0 2mm; color: #000; line-height: 1.2;
    text-shadow: 0 0 0.3px #000, 0 0 0.3px #000;
}
.informe-modelo-medico {
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 11pt; font-weight: 700; margin: 0; color: #000;
}
.informe-modelo-qr { text-align: right; }
.informe-modelo-qr img { width: 68px; height: 68px; display: inline-block; margin-bottom: 4px; }
.informe-modelo-qr p {
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 6.5pt; line-height: 1.35; margin: 0; color: #333; text-align: right;
}
.informe-modelo-paciente { margin-bottom: 5mm; }
.informe-modelo-paciente p { margin: 0 0 1.5mm; font-size: 11pt; }
.informe-modelo-fila-edad {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
}
.informe-modelo-seccion { margin-bottom: 4mm; }
.informe-modelo-seccion h2 {
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 10.5pt; font-weight: 700; color: #1a5276;
    border-bottom: 1.5px solid #1a5276; padding-bottom: 1mm;
    margin: 0 0 2mm; letter-spacing: 0.01em;
}
.informe-modelo-seccion h3 {
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 11pt; font-weight: 700; margin: 0 0 2mm; color: #000;
}
.informe-modelo-cuerpo {
    text-align: justify; margin: 0; font-size: 11pt; color: #000;
}
.informe-modelo-cuerpo .informe-linea { margin: 0 0 0.8mm; }
.informe-modelo-doc .informe-modelo-textarea {
    display: block; width: 100%; box-sizing: border-box;
    border: none; padding: 0; margin: 0; resize: vertical; min-height: 5em;
    background: transparent; color: #000;
    font-family: "Bookman Old Style", "URW Bookman L", Bookman, Georgia, "Times New Roman", serif;
    font-size: 11pt; line-height: 1.28; text-align: justify;
}
.informe-modelo-doc .informe-modelo-textarea:focus {
    outline: 1px dotted #888; background: rgba(255,255,255,0.95);
}
.informe-modelo-firma { margin-top: 12mm; display: flex; flex-direction: column; align-items: flex-start; }
.informe-modelo-firma-linea {
    width: 180px; height: 36px; margin-bottom: 2mm;
    border-bottom: 1.5px solid #1a5276;
    background: linear-gradient(135deg, transparent 40%, rgba(26,82,118,0.08));
}
.informe-modelo-firma-nombre {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt; font-weight: 700; margin: 0 0 1mm;
}
.informe-modelo-firma-rp {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 11pt; font-weight: 700; margin: 0;
}
.informe-modelo-firma-img {
    display: block;
    width: 37.6mm;
    height: 20.8mm;
    margin: 0 0 1mm;
    object-fit: contain;
    object-position: left top;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.informe-modelo-firma-nombre,
.informe-modelo-firma-rp {
    font-family: "Times New Roman", Times, serif;
    font-style: italic;
    font-weight: 700;
}
.informe-edit-placeholder {
    color: #888; font-style: italic; font-size: 10.5pt;
}
.informe-dblclick-hint:not(.is-editing):hover {
    outline: 1px dashed rgba(26, 82, 118, 0.35);
    outline-offset: 2px;
    border-radius: 2px;
}
.informe-descripcion-editable .informe-mod-preview { margin-bottom: 3mm; }
.informe-descripcion-editable .informe-editable-wrap.is-editing .informe-mod-textarea {
    min-height: 140px;
}
.informe-panel-hint--edit {
    margin-top: 12px; padding-top: 10px;
    border-top: 1px solid var(--border-light);
    font-size: 0.78rem;
}
.informe-opciones-clinicas {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
}
.informe-opciones-titulo {
    margin: 0 0 10px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    line-height: 1.35;
}
.informe-opcion-grupo { margin-bottom: 0; }
.informe-opciones-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-muted);
    line-height: 1.4;
}
.informe-modalidad-grid { display: grid; gap: 8px; }
.informe-formato-grid {
    display: grid; gap: 8px;
}
.informe-formato-btn {
    display: block; cursor: pointer;
}
.informe-formato-btn input { position: absolute; opacity: 0; pointer-events: none; }
.informe-formato-btn span {
    display: block; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-light); background: var(--bg-subtle);
    font-size: 0.82rem; font-weight: 600; line-height: 1.35; color: var(--text-secondary);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.informe-formato-btn input:checked + span {
    background: var(--accent-soft); color: var(--accent); border-color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}
.informe-formato-btn:hover span {
    border-color: var(--accent); color: var(--text);
}
.informe-formato-descripciones {
    display: grid; gap: 12px; margin-top: 14px;
}
.informe-formato-mod-label {
    display: block; margin-bottom: 6px; font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted);
}
.informe-formato-mod .informe-mod-textarea { min-height: 120px; font-size: 0.82rem; }
.informe-modalidad-item {
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.informe-modalidad-item:has(.chk-mod:checked) {
    border-color: var(--clinical-line);
    background: var(--accent-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}
.informe-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.86rem;
    line-height: 1.35;
    width: 100%;
}
.informe-toggle input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--accent);
}
.informe-mod-campo { margin-top: 10px; }
.informe-mod-campo .informe-mod-textarea {
    min-height: 4.5em;
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius-sm);
    padding: 8px 10px !important;
    background: #fff !important;
    font-family: var(--font-sans) !important;
    font-size: 0.84rem !important;
    line-height: 1.45 !important;
}
.informe-mod-campo .informe-mod-textarea:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.informe-internado-panel { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.form-section-internado { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.informe-internado-lectura { margin-top: 12px; padding: 12px 14px; border-color: var(--border); background: var(--surface-2); }
.informe-internado-lectura h3 { margin: 0 0 10px; font-size: 0.9rem; font-weight: 700; }
.informe-internado-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 0; }
.informe-internado-facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 2px; }
.informe-internado-facts dd { margin: 0; font-size: 0.88rem; }
.informe-editor-internado { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.bandeja-bulk-actions { padding: 12px 16px; margin-bottom: 10px; }
.bandeja-bulk-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.bandeja-bulk-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.bandeja-bulk-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent);
}

.bandeja-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 0;
}

.bandeja-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bandeja-tab:hover {
    text-decoration: none;
    color: var(--text);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border-light));
}

.bandeja-tab.is-active {
    background: var(--accent-soft, color-mix(in srgb, var(--accent) 14%, transparent));
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    color: var(--accent);
}

.bandeja-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.6rem;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    background: color-mix(in srgb, currentColor 12%, transparent);
    font-variant-numeric: tabular-nums;
}

.bandeja-v2-table .col-medico {
    min-width: 140px;
}
.bandeja-select-all { margin: 0; }
.bandeja-v2-table .col-check {
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    text-align: center;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border-light);
}
.bandeja-v2-table th.col-check {
    z-index: 4;
    background: var(--bg-subtle);
}
.bandeja-v2-table .col-check-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 0.72rem;
    color: var(--text-muted);
}
.bandeja-row-check {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
}
.bandeja-row-check input[type="checkbox"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.bandeja-row-check-ui {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface) 80%, transparent);
}
.bandeja-row-check-ui::after {
    content: "";
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    margin-top: -2px;
    transition: transform 0.12s ease;
}
.bandeja-row-check input:checked + .bandeja-row-check-ui {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}
.bandeja-row-check input:checked + .bandeja-row-check-ui::after {
    transform: rotate(45deg) scale(1);
}
.bandeja-row-check input:focus-visible + .bandeja-row-check-ui {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.bandeja-select-all input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 0;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.bandeja-v2-table tr.bandeja-row-selectable.is-selected td {
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.bandeja-v2-table tr.bandeja-row-selectable.is-selected td.col-check {
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.registro-steps { padding: 14px 16px; margin-bottom: 0; }
.registro-steps-list {
    display: flex; flex-wrap: wrap; gap: 8px 24px; list-style: none; margin: 0; padding: 0;
}
.registro-step {
    display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 0.88rem;
    min-width: 0;
}
.registro-step-num {
    width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.82rem;
    flex-shrink: 0;
}
.registro-step-label { min-width: 0; }
.registro-step.active { color: var(--text); font-weight: 600; }
.registro-step.active .registro-step-num { border-color: var(--accent); background: var(--accent-soft); color: var(--primary); }
.registro-step.done { color: var(--clinical); }
.registro-step.done .registro-step-num {
    border-color: var(--clinical); background: var(--clinical-soft); color: var(--clinical);
}
.datos-clinicos-list { display: grid; gap: 10px; }
.datos-clinicos-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 16px; text-decoration: none; color: inherit; transition: border-color 0.15s, box-shadow 0.15s;
}
.datos-clinicos-item:hover { border-color: var(--accent); box-shadow: var(--shadow-md); text-decoration: none; }
.datos-clinicos-item-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-datos-clinicos { display: flex; flex-direction: column; gap: clamp(12px, 2vw, 16px); max-width: none; width: 100%; }
.form-datos-clinicos .form-section { margin-bottom: 0; }
.form-actions-row {
    display: flex; flex-wrap: wrap; gap: 10px;
    justify-content: flex-end;
    align-items: center;
}
.clinical-flow-page {
    display: flex; flex-direction: column; gap: clamp(12px, 2vw, 16px);
    width: 100%; max-width: none;
}
.clinical-flow-page .page-toolbar { margin-bottom: 0; }
.clinical-flow-page .registro-steps { margin-bottom: 0; }
.form-section-contact .grid-form-2 { gap: clamp(14px, 2.5vw, 20px); }
.form-section-contact .field-group input { font-size: 0.94rem; }
.form-section-internado .informe-internado-panel {
    margin-top: 14px; padding: 16px;
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    background: var(--surface-2);
}
.form-section-internado .grid-form-2 { margin-top: 4px; }
.form-datos-clinicos textarea#datos_relevantes { min-height: 140px; }

/* Base de pacientes — scroll en page-body */
body:has(.patientdb-layout) .page-body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.patientdb-page {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
    overflow: visible;
    padding-bottom: 24px;
}
.patientdb-hero {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 12px 16px; margin-bottom: 12px; padding: 14px 16px;
}
.patientdb-hero__text .section-heading { margin: 0 0 4px; }
.patientdb-hero__actions { margin: 0; }
.patientdb-filters { padding: 14px 16px; margin-bottom: 12px; }
.patientdb-filters-row {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px;
}
.patientdb-search { flex: 1; min-width: 220px; margin-bottom: 0; }
.patientdb-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.patientdb-total { margin: 10px 0 0; }
.patientdb-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    overflow-y: visible;
    margin-bottom: 12px;
}
.patientdb-table-wrap table {
    width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 720px;
}
.patientdb-table-wrap th {
    background: var(--bg-subtle); padding: 12px 14px; text-align: left;
    font-weight: 700; color: var(--text-secondary); font-size: 0.75rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-light); white-space: nowrap;
}
.patientdb-table-wrap td {
    padding: 12px 14px; border-bottom: 1px solid var(--border-light); vertical-align: middle;
    color: var(--text-secondary);
}
.patientdb-table-wrap tbody tr:nth-child(even) td { background: var(--table-row-stripe, var(--bg-subtle)); }
.patientdb-table-wrap tbody tr:hover td { background: var(--table-row-hover, color-mix(in srgb, var(--accent) 7%, var(--surface))) !important; }
.patientdb-page .pagination { margin-top: 4px; margin-bottom: 8px; }

/* Expediente paciente — ficha completa */
.patient-expediente-page { display: flex; flex-direction: column; gap: 16px; padding-bottom: 28px; }
.patient-expediente-top {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 14px 18px;
    padding: clamp(14px, 2.5vw, 20px);
    border-radius: var(--radius-md);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--surface)) 0%, var(--surface) 55%),
        var(--surface);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}
.patient-expediente-eyebrow {
    margin: 0 0 4px; font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent);
}
.patient-expediente-title {
    margin: 0; font-size: clamp(1.25rem, 2.8vw, 1.65rem); line-height: 1.25;
    color: var(--text-primary); font-weight: 750;
}
.patient-expediente-doc {
    margin: 6px 0 0; font-size: 0.88rem; color: var(--text-secondary);
}
.patient-expediente-toolbar { margin: 0; flex-wrap: wrap; gap: 8px; }
.patient-expediente-nav {
    display: flex; flex-wrap: wrap; gap: 8px;
    position: sticky; top: 0; z-index: 5;
    padding: 8px 0;
    background: color-mix(in srgb, var(--bg-page, var(--bg)) 92%, transparent);
    backdrop-filter: blur(8px);
}
.patient-expediente-nav a {
    display: inline-flex; align-items: center;
    padding: 7px 12px; border-radius: 999px;
    font-size: 0.8rem; font-weight: 650; text-decoration: none;
    color: var(--text-secondary);
    background: var(--surface); border: 1px solid var(--border-light);
}
.patient-expediente-nav a:hover {
    color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--border-light));
}
.patient-expediente-ficha { padding: clamp(14px, 2vw, 18px); scroll-margin-top: 56px; }
.patient-expediente-ficha__head { margin-bottom: 12px; }
.patient-expediente-ficha__head .section-heading { margin: 0 0 4px; }
.patient-expediente-ficha__hint {
    margin: 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.4;
}
.patient-expediente-hero { margin-bottom: 14px; border: none; box-shadow: none; padding: 0; background: transparent; }
.patient-expediente-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.patient-expediente-bloque {
    padding: 12px 14px; border-radius: var(--radius-sm);
    background: var(--bg-subtle); border: 1px solid var(--border-light);
}
.patient-expediente-bloque__title {
    margin: 0 0 8px; font-size: 0.78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.patient-expediente-texto {
    margin: 0; font-size: 0.9rem; line-height: 1.55; color: var(--text-primary);
    white-space: pre-wrap; word-break: break-word;
}
.patient-expediente-vacio { margin: 0; font-size: 0.88rem; color: var(--text-muted); font-style: italic; }

/* Historia clínica */
.hc-section { padding: clamp(14px, 2vw, 20px); scroll-margin-top: 56px; }
.hc-section__head {
    display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
    gap: 12px; margin-bottom: 14px;
}
.hc-section__head .section-heading { margin: 0 0 4px; }
.hc-section__hint { margin: 0; max-width: 52ch; font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }
.hc-patient-meta {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
    gap: 10px; margin-bottom: 16px;
}
.hc-meta-item {
    padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--bg-subtle); border: 1px solid var(--border-light);
}
.hc-meta-item span {
    display: block; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 3px;
}
.hc-meta-item strong { font-size: 0.92rem; color: var(--text-primary); font-weight: 650; }
.hc-form-toolbar,
.hc-view .hc-form-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 14px;
}
.hc-form-toolbar h3,
.hc-view .hc-form-toolbar h3 { margin: 0; font-size: 1.05rem; }
.hc-view-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.hc-group {
    margin: 8px 0 16px; padding: 14px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--accent) 4%, var(--bg-subtle));
    border: 1px solid var(--border-light);
}
.hc-group__title {
    margin: 0 0 12px; font-size: 0.82rem; font-weight: 750;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent);
}
.hc-form .field-group { margin-bottom: 12px; }
.hc-form textarea {
    width: 100%; min-height: 88px; resize: vertical;
    font: inherit; line-height: 1.45;
}
.hc-form-actions {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--border-light);
}
.hc-empty {
    text-align: center; padding: 28px 16px;
    border: 1px dashed var(--border); border-radius: var(--radius-sm);
    background: var(--bg-subtle);
}
.hc-empty p { margin: 0 0 12px; color: var(--text-secondary); }
.hc-list { display: flex; flex-direction: column; gap: 10px; }
.hc-list-item {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 14px;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    background: var(--surface);
}
.hc-list-item__main h3 { margin: 0 0 4px; font-size: 0.95rem; line-height: 1.35; }
.hc-list-item__meta { margin: 0; font-size: 0.76rem; color: var(--text-muted); }
.hc-list-item__actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.hc-view-fecha {
    display: inline-flex; flex-direction: column; gap: 2px;
    margin-bottom: 14px; padding: 10px 12px;
    border-radius: var(--radius-sm); background: var(--bg-subtle); border: 1px solid var(--border-light);
}
.hc-view-fecha span { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.hc-view-block { margin-bottom: 12px; }
.hc-view-block h5 {
    margin: 0 0 6px; font-size: 0.78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted);
}
.hc-view-text {
    margin: 0; padding: 10px 12px; border-radius: var(--radius-sm);
    background: var(--bg-subtle); border: 1px solid var(--border-light);
    font-size: 0.9rem; line-height: 1.55; color: var(--text-primary);
    word-break: break-word;
}
.hc-view-empty { margin: 0; font-size: 0.86rem; color: var(--text-muted); font-style: italic; }
.hc-readonly-banner {
    margin: 0; padding: 12px 14px; border-radius: var(--radius-sm);
    background: var(--warning-soft); border: 1px solid #fcd34d; color: var(--text-secondary);
}
.patient-estudios-section { padding: clamp(14px, 2vw, 18px); scroll-margin-top: 56px; }
.patient-estudios-section__head { margin-bottom: 12px; }
.patient-estudios-section__head .section-heading { margin: 0 0 4px; }
.patientdb-table-wrap--nested {
    margin-bottom: 0; box-shadow: none; border: 1px solid var(--border-light);
}
.patient-estudio-meta {
    display: block; margin-top: 2px; font-size: 0.72rem; color: var(--text-muted); font-weight: 400;
}
.patientdb-estudios-table .cell-actions {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.modal-estudio-expediente { max-width: min(720px, 96vw); }
.modal-estudio-grid { margin-bottom: 12px; }
.modal-estudio-clinico {
    margin-top: 10px; padding: 12px 14px;
    background: var(--bg-subtle); border: 1px solid var(--border-light); border-radius: var(--radius-sm);
}
.modal-estudio-clinico h3 {
    margin: 0 0 8px; font-size: 0.78rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.modal-estudio-texto {
    margin: 0; font-size: 0.88rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.modal-estudio-internado {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 16px; margin: 0 0 8px;
}
.modal-estudio-internado dt {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.modal-estudio-internado dd { margin: 2px 0 0; font-weight: 600; font-size: 0.88rem; }
.modal-estudio-actions {
    margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-light);
}
.modal-estudio-actions[hidden],
.modal-estudio-informe-pendiente[hidden],
#md_internado_wrap[hidden] { display: none !important; }
.modal-estudio-informe-ok {
    margin: 0 0 10px; font-size: 0.82rem; color: var(--text-secondary);
}
.modal-estudio-actions-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-estudio-informe-pendiente {
    margin-top: 14px; padding: 12px 14px;
    background: var(--warning-soft); border: 1px solid #fcd34d;
    border-radius: var(--radius-sm);
}
.modal-estudio-informe-pendiente .badge-warning { margin-bottom: 8px; }
.modal-estudio-informe-pendiente p {
    margin: 0; font-size: 0.84rem; line-height: 1.5; color: var(--text-secondary);
}
@media (max-width: 720px) {
    .patient-expediente-top { align-items: stretch; }
    .patient-expediente-toolbar .btn,
    .patient-expediente-toolbar form { width: 100%; }
    .patient-expediente-toolbar .btn { justify-content: center; }
    .patient-expediente-nav { gap: 6px; }
    .patient-expediente-nav a { flex: 1 1 auto; justify-content: center; }
    .hc-section__head .btn,
    .hc-list-item__actions .btn,
    .hc-list-item__actions form { width: 100%; }
    .hc-list-item__actions { width: 100%; }
    .hc-list-item__actions .btn { justify-content: center; }
}
@media (max-width: 640px) {
    .patientdb-page .patientdb-table-wrap table,
    .patientdb-estudios-table { min-width: 0; }
    .patientdb-page #tablaPacientes thead,
    .patientdb-estudios-table thead { display: none; }
    .patientdb-page #tablaPacientes tbody tr,
    .patientdb-estudios-table tbody tr {
        display: block; padding: 12px 14px; border-bottom: 1px solid var(--border-light);
    }
    .patientdb-page #tablaPacientes tbody tr:last-child,
    .patientdb-estudios-table tbody tr:last-child { border-bottom: none; }
    .patientdb-page #tablaPacientes td,
    .patientdb-estudios-table td {
        display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
        padding: 5px 0; border: none; text-align: right !important;
    }
    .patientdb-page #tablaPacientes td::before,
    .patientdb-estudios-table td::before {
        content: attr(data-label);
        font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: 0.04em; color: var(--text-muted); text-align: left; flex-shrink: 0;
    }
    .patientdb-page #tablaPacientes td.cell-actions,
    .patientdb-estudios-table td.cell-actions {
        flex-direction: column; align-items: stretch; padding-top: 10px;
    }
    .patientdb-page #tablaPacientes td.cell-actions::before,
    .patientdb-estudios-table td.cell-actions::before { margin-bottom: 4px; }
    .patientdb-page #tablaPacientes .cell-actions .btn,
    .patientdb-estudios-table .cell-actions .btn { width: 100%; justify-content: center; }
    .modal-body-grid { grid-template-columns: 1fr; }
}

/* Switch / toggle UI */
.ui-switch-row { margin: 8px 0; }
.ui-switch {
    display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none;
}
.ui-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ui-switch-track {
    width: 44px; height: 24px; border-radius: 999px; background: var(--border);
    position: relative; transition: background 0.18s ease; flex-shrink: 0;
}
.ui-switch-track::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.18s ease;
}
.ui-switch input:checked + .ui-switch-track { background: var(--accent); }
.ui-switch input:checked + .ui-switch-track::after { transform: translateX(20px); }
.ui-switch-label { font-weight: 600; font-size: 0.88rem; }
.insumos-stats .stat-item.primary strong { color: var(--primary); }
.insumos-panels { align-items: start; }
.bandeja-filtro-hint { margin: 0 0 10px 2px; }
.informe-dblclick-hint { cursor: text; min-height: 2em; }
.informe-dblclick-hint:empty::after { content: 'Doble clic para editar…'; color: #888; font-style: italic; }
.informe-modelo-enc-extra { font-family: Arial, Helvetica, sans-serif; font-size: 8pt; margin: 1mm 0 0; color: #333; }
.informe-modelo-logo-vacio { min-width: 88px; }
.informe-modelo-qr-vacio { min-width: 72px; }
.informe-audit-text { font-weight: 500 !important; font-size: 0.8rem !important; color: var(--text-muted); }
.informe-mod-preview { margin-bottom: 3mm; }
.informe-modalidad-btn {
    display: inline-flex; cursor: pointer;
}
.informe-modalidad-btn input { position: absolute; opacity: 0; pointer-events: none; }
.informe-modalidad-btn span {
    display: inline-block; padding: 8px 12px; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--surface); font-size: 0.84rem; font-weight: 600;
}
.informe-modalidad-btn input:checked + span {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.informe-fact-wide { grid-column: 1 / -1; }
.informe-editor-facts .informe-fact-wide dd { font-weight: 400; white-space: pre-wrap; }
.informe-editor-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

@media (max-width: 1100px) {
    .bandeja-v2-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .informe-workzone-split {
        flex-direction: column;
        overflow: visible;
    }
    .informe-panel-opciones {
        flex: 0 0 auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: none;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
    }
    .informe-panel-opciones.is-collapsed {
        width: 100% !important;
        min-width: 0 !important;
        flex: 0 0 auto !important;
        max-height: 48px;
    }
    .informe-panel-opciones.is-collapsed .informe-panel-expand {
        flex-direction: row;
        writing-mode: horizontal-tb;
        width: 100%;
        padding: 10px 14px;
    }
    .informe-panel-opciones.is-collapsed .informe-panel-expand span {
        writing-mode: horizontal-tb;
    }
    .informe-panel-resizer { display: none; }
    .informe-panel-preview {
        flex: none;
        overflow: visible;
        padding: 12px;
    }
    /* La hoja se ajusta al ancho de la pantalla (el PDF exportado siempre es Oficio II) */
    .informe-panel-preview .informe-modelo-doc,
    .informe-modelo-doc {
        width: 100%;
        max-width: 100%;
        min-height: 0;
    }
}
@media (max-width: 768px) {
    .bandeja-v2-filter-grid { grid-template-columns: 1fr 1fr; }
    .bandeja-v2-filter-actions { grid-column: 1 / -1; }
    .bandeja-v2-filter-actions .bandeja-v2-btns { width: 100%; }
    .bandeja-v2-filter-actions .btn { flex: 1; justify-content: center; }
    /* Hoja del informe en pantalla móvil: se ajusta y sigue legible */
    .informe-modelo-doc { padding: 18px 16px 26px; }
    .informe-modelo-header,
    .informe-modelo-header--sin-inst {
        grid-template-columns: auto 1fr auto;
        gap: 6px 8px;
        margin-bottom: 5mm;
    }
    .informe-modelo-logo { min-height: 0; }
    .informe-modelo-logo img { max-width: 44px; max-height: 44px; }
    .informe-modelo-logo-general .informe-modelo-qr-img { max-width: 88px; max-height: 54px; }
    .informe-modelo-titles { padding: 0 2px; }
    .informe-modelo-titles h1 { font-size: 11pt; margin-bottom: 1mm; }
    .informe-modelo-medico { font-size: 9.5pt; }
    .informe-modelo-enc-extra { font-size: 8pt; }
    .informe-modelo-fila-edad { flex-direction: column; gap: 2px; justify-content: flex-start; }
    /* Panel de datos: chips que envuelven y no se cortan */
    .informe-datos-details > summary { gap: 8px 12px; }
    .informe-datos-chips { flex-basis: 100%; flex: 1 1 100%; }
    .informe-datos-toggle-hint { margin-left: 0; }
    .informe-chip { white-space: normal; }
    /* ——— Bandeja médica: una card por estudio en móvil ——— */
    /* Neutralizar el contenedor tipo tabla (borde/overflow lo pone eeg-theme-v4) */
    body.eeg-ui-v4 .content-wrapper--bandeja .bandeja-v2-table-shell,
    .content-wrapper--bandeja .bandeja-v2-table-shell,
    .bandeja-v2-table-shell,
    .bandeja-v2-table-scroll {
        overflow: visible;
        border: none;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }
    .bandeja-v2-table { width: 100%; min-width: 0; table-layout: auto; }
    .bandeja-v2-table thead { display: none; }
    .bandeja-v2-table,
    .bandeja-v2-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }
    /* Cada fila = card independiente */
    .bandeja-v2-table tr {
        display: flex;
        flex-direction: column;
        gap: 9px;
        width: 100%;
        min-width: 0;
        margin: 0 0 12px;
        padding: 15px 16px;
        background: var(--surface);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
    }
    /* Sin rayado ni hover de tabla dentro de las cards (vence dark-mode) */
    body.eeg-ui-v4 .bandeja-v2-table tbody tr td,
    .bandeja-v2-table tbody tr:nth-child(even) td {
        background: transparent;
    }
    /* Reset de celdas: vence a los anchos fijos col-* (especificidad 0,2,1) */
    .bandeja-v2-table td,
    .bandeja-v2-table td.col-check,
    .bandeja-v2-table td.col-fecha,
    .bandeja-v2-table td.col-paciente,
    .bandeja-v2-table td.col-ci,
    .bandeja-v2-table td.col-inst,
    .bandeja-v2-table td.col-estudio,
    .bandeja-v2-table td.col-tecnico,
    .bandeja-v2-table td.col-estado,
    .bandeja-v2-table td.col-medico,
    .bandeja-v2-table td.col-action {
        display: block;
        width: 100%;
        max-width: none;
        min-width: 0;
        padding: 0;
        border: none;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        text-align: left !important;
        vertical-align: top;
    }
    .bandeja-v2-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 0.62rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-muted);
        margin-bottom: 3px;
    }
    /* Nombre del paciente arriba y destacado */
    .bandeja-v2-table td.col-paciente { order: -1; }
    .bandeja-v2-table td.col-paciente .bandeja-v2-patient {
        font-size: 1rem;
        line-height: 1.3;
    }
    /* Selección arriba de todo, con separador */
    .bandeja-v2-table td.col-check {
        display: flex;
        align-items: center;
        gap: 10px;
        order: -2;
        padding-bottom: 9px;
        border-bottom: 1px dashed var(--border-light);
    }
    .bandeja-v2-table td.col-check::before { margin-bottom: 0; }
    .bandeja-v2-table td.col-check:not(:has(.bandeja-row-check)) { display: none; }
    .bandeja-v2-table tr.bandeja-row-selectable.is-selected {
        border-color: color-mix(in srgb, var(--accent) 45%, var(--border-light));
        background: color-mix(in srgb, var(--accent) 7%, var(--surface));
    }
    /* Acciones al pie de la card, en botones cómodos */
    .bandeja-v2-table td.cell-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 2px;
        padding-top: 11px;
        border-top: 1px dashed var(--border-light);
    }
    .bandeja-v2-table td.cell-actions::before { flex-basis: 100%; }
    .bandeja-v2-table td.cell-actions .btn,
    .bandeja-v2-table td.cell-actions .btn-mini {
        flex: 1 1 auto;
        min-width: 120px;
        margin: 0;
        justify-content: center;
    }
    .bandeja-v2-table-scroll { max-height: none; }
}
@media (max-width: 480px) {
    .bandeja-v2-filter-grid { grid-template-columns: 1fr; }
    .informe-editor-bar { padding: 8px 10px; }
    .informe-datos-summary { padding: 8px 10px; }
    .informe-datos-body { padding: 0 10px 10px; }
    .informe-datos-paciente-grid {
        grid-template-columns: 1fr 1fr;
    }
    .informe-panel-preview { padding: 10px; }
    .page-actions-bar,
    .form-actions-row { flex-direction: column; align-items: stretch; }
    .content-wrapper.informe-editor-layout .informe-editor-actions,
    .content-wrapper.informe-editor-layout .informe-editor-actions-main { flex-direction: column; width: 100%; }
    .page-actions-bar .btn,
    .content-wrapper.informe-editor-layout .informe-editor-actions .btn,
    .form-actions-row .btn,
    .informe-editor-exit { width: 100%; justify-content: center; }
}

/* Informe editor v2 (legacy) */
.informe-page { max-width: none; width: 100%; }
.informe-toolbar { justify-content: space-between; }
.informe-layout-v2 {
    display: grid; grid-template-columns: minmax(260px, 300px) 1fr; gap: 20px; align-items: start;
}
.informe-sidebar { position: sticky; top: calc(var(--topbar-h) + 12px); padding: 18px; margin-bottom: 0; }
.informe-sidebar-head { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border-light); }
.informe-status-pill {
    display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px;
}
.informe-status-pill.pending { background: var(--warning-soft); color: var(--warning); }
.informe-status-pill.draft { background: var(--accent-soft); color: var(--primary); }
.informe-status-pill.done { background: var(--clinical-soft); color: var(--clinical); }
.informe-patient-name { font-size: 1.05rem; font-weight: 700; line-height: 1.3; margin-bottom: 4px; }
.informe-patient-sub { font-size: 0.82rem; color: var(--text-muted); }
.informe-facts { display: grid; gap: 12px; margin: 0 0 14px; }
.informe-facts div { display: grid; gap: 2px; }
.informe-facts dt { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.informe-facts dd { font-size: 0.88rem; font-weight: 600; color: var(--text); margin: 0; line-height: 1.4; }
.informe-main { min-width: 0; }

@media (max-width: 960px) {
    .bandeja-hero { grid-template-columns: 1fr; }
    .bandeja-hero-stats { grid-row: auto; }
    .bandeja-search { grid-column: 1; max-width: none; }
    .hide-md { display: none; }
    .informe-layout-v2 { grid-template-columns: 1fr; }
    .informe-sidebar { position: static; }
}
@media (max-width: 720px) {
    .hide-sm { display: none; }
    .show-sm { display: block !important; }
    .bandeja-table thead { display: none; }
    .bandeja-table, .bandeja-table tbody, .bandeja-table tr, .bandeja-table td { display: block; width: 100%; min-width: 0; }
    .bandeja-table tr {
        padding: 14px 16px; border-bottom: 1px solid var(--border-light);
        margin-bottom: 0;
    }
    .bandeja-table td {
        padding: 4px 0; border: none; text-align: left !important;
    }
    .bandeja-table td::before {
        content: attr(data-label);
        display: block; font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
        letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 2px;
    }
    .bandeja-table td.cell-actions::before { margin-bottom: 8px; }
    .bandeja-table td.cell-actions .btn { width: 100%; justify-content: center; }
}

/* ——— Inicio / panel principal ——— */
.home-page {
    display: flex; flex-direction: column; gap: clamp(14px, 2vw, 22px);
    width: 100%; max-width: none; margin: 0;
    padding-bottom: 8px;
    container-type: inline-size;
    container-name: home;
}
.home-body-grid {
    display: grid; grid-template-columns: 1fr; gap: clamp(14px, 2vw, 22px);
    align-items: start;
}
.home-body-grid > .home-section:only-child { grid-column: 1 / -1; }
.home-welcome {
    padding: 0; overflow: hidden; margin-bottom: 0;
    background: linear-gradient(135deg, var(--surface) 0%, var(--bg-subtle) 100%);
    border-color: var(--border-light);
}
.home-welcome-grid {
    display: grid; grid-template-columns: 1fr auto; gap: 20px 24px;
    align-items: start; padding: 22px 24px;
}
.home-welcome-user { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.home-avatar {
    width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; font-weight: 700; letter-spacing: 0.02em;
    color: #fff; background: linear-gradient(145deg, var(--accent), var(--primary-dark));
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.25);
}
.home-welcome-copy { min-width: 0; }
.home-greeting {
    font-size: 1.15rem; line-height: 1.35; color: var(--text); margin-bottom: 8px;
}
.home-greeting strong { font-weight: 700; }
.home-role-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.home-role-badge {
    display: inline-flex; align-items: center; padding: 4px 10px;
    border-radius: 999px; font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--primary); background: var(--accent-soft); border: 1px solid rgba(13, 148, 136, 0.18);
}
.home-lead {
    font-size: 0.92rem; color: var(--text-secondary); line-height: 1.55; max-width: 640px;
}
.home-welcome-aside { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; }
.home-date-chip, .home-alert-chip {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
    border-radius: var(--radius-md); font-size: 0.82rem; border: 1px solid var(--border-light);
    background: var(--surface); color: var(--text-secondary);
}
.home-date-chip svg { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.home-alert-chip { border-color: rgba(180, 83, 9, 0.25); background: var(--warning-soft); color: var(--warning); }
.home-alert-chip strong { font-size: 1rem; margin-right: 2px; }
.home-section { display: flex; flex-direction: column; gap: 12px; }
.home-section-head { display: flex; flex-direction: column; gap: 2px; }
.home-section-title {
    font-size: 0.95rem; font-weight: 700; color: var(--text); margin: 0;
}
.home-section-sub { font-size: 0.82rem; color: var(--text-muted); margin: 0; }
.home-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.5rem), 1fr));
    gap: clamp(10px, 1.5vw, 14px);
}
.home-kpi {
    padding: 16px 18px; border-radius: var(--radius-md);
    border: 1px solid var(--border-light); background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.home-kpi.primary { border-color: rgba(13, 148, 136, 0.25); background: linear-gradient(180deg, var(--accent-soft), var(--surface)); }
.home-kpi.warn { border-color: rgba(180, 83, 9, 0.22); }
.home-kpi.ok { border-color: rgba(5, 150, 105, 0.22); }
.home-kpi-value {
    display: block; font-size: 1.75rem; font-weight: 800; line-height: 1.1;
    color: var(--text); margin-bottom: 4px;
}
.home-kpi.primary .home-kpi-value { color: var(--primary); }
.home-kpi.warn .home-kpi-value { color: var(--warning); }
.home-kpi.ok .home-kpi-value { color: var(--clinical); }
.home-kpi-label {
    display: block; font-size: 0.82rem; font-weight: 600; color: var(--text);
}
.home-kpi-hint {
    display: block; margin-top: 4px; font-size: 0.72rem; color: var(--text-muted);
}
.home-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: clamp(10px, 1.5vw, 14px);
}
.home-module-card {
    display: flex; align-items: center; gap: 14px; padding: 16px 18px;
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    background: var(--surface); box-shadow: var(--shadow-sm);
    color: inherit; text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.home-module-card:hover {
    text-decoration: none; border-color: var(--accent);
    box-shadow: var(--shadow-md); transform: translateY(-1px);
}
.home-module-icon {
    width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-subtle); color: var(--accent);
}
.home-module-icon svg { width: 22px; height: 22px; }
.home-module-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.home-module-body strong {
    display: block; font-size: 0.92rem; color: var(--text); line-height: 1.3;
}
.home-module-body span {
    display: block; font-size: 0.78rem; color: var(--text-muted); line-height: 1.45;
}
.home-module-arrow { color: var(--text-muted); flex-shrink: 0; }
.home-module-arrow svg { width: 18px; height: 18px; }
.home-module-card:hover .home-module-arrow { color: var(--accent); }
.home-recent-list { padding: 0; overflow: hidden; margin-bottom: 0; }
.home-recent-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border-light);
    color: inherit; text-decoration: none; transition: background 0.12s;
}
.home-recent-item:last-child { border-bottom: none; }
.home-recent-item:hover { background: var(--bg-subtle); text-decoration: none; }
.home-recent-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.home-recent-main strong {
    display: block; font-size: 0.9rem; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-recent-main span {
    display: block; font-size: 0.78rem; color: var(--text-muted);
    line-height: 1.45; word-break: break-word;
}
.home-recent-cta {
    flex-shrink: 0; font-size: 0.78rem; font-weight: 700; color: var(--accent);
    white-space: nowrap;
}
.home-empty {
    padding: 28px 22px; text-align: center; color: var(--text-muted);
    font-size: 0.88rem; line-height: 1.55; margin-bottom: 0;
}
.home-tip {
    display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; margin-bottom: 0;
    background: var(--bg-subtle);
}
.home-tip-icon {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
}
.home-tip-icon svg { width: 20px; height: 20px; }
.home-tip strong { display: block; font-size: 0.92rem; margin-bottom: 4px; }
.home-tip p { font-size: 0.84rem; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }

/* Inicio — adaptación al ancho real del panel (sidebar incluida) */
@container home (max-width: 679px) {
    .home-welcome-grid { grid-template-columns: 1fr; padding: 18px 16px; }
    .home-welcome-aside { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
    .home-greeting { font-size: clamp(1rem, 4.5vw, 1.08rem); }
    .home-kpi-grid { grid-template-columns: 1fr; }
    .home-modules { grid-template-columns: 1fr; }
    .home-recent-item { flex-direction: column; align-items: flex-start; }
}
@container home (min-width: 480px) and (max-width: 679px) {
    .home-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container home (min-width: 680px) and (max-width: 899px) {
    .home-welcome-grid { grid-template-columns: 1fr auto; padding: 20px 22px; }
    .home-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .home-modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container home (min-width: 900px) {
    .home-welcome-grid { padding: 22px clamp(20px, 2.5vw, 28px); }
    .home-body-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); }
    .home-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .home-section-modules .home-modules { grid-template-columns: 1fr; }
}
@container home (min-width: 1100px) {
    .home-greeting { font-size: 1.2rem; }
    .home-kpi-value { font-size: clamp(1.75rem, 2.2vw, 2rem); }
    .home-section-modules .home-modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container home (min-width: 1320px) {
    .home-welcome-user { gap: 18px; }
    .home-avatar { width: 62px; height: 62px; font-size: 1.12rem; }
    .home-module-card { padding: 18px 20px; }
}

/* ——— Perfil de usuario ——— */
.perfil-page { display: flex; flex-direction: column; gap: 16px; max-width: none; width: 100%; }
.perfil-alert {
    padding: 16px 18px; border-color: rgba(180, 83, 9, 0.25);
    background: var(--warning-soft); margin-bottom: 0;
}
.perfil-alert strong { display: block; margin-bottom: 4px; }
.perfil-alert p { margin: 0 0 12px; color: var(--text-secondary); font-size: 0.88rem; line-height: 1.5; }
.perfil-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.perfil-card { margin-bottom: 0; padding: 20px 22px; }
.perfil-header { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.perfil-avatar-wrap {
    width: 88px; height: 88px; border-radius: 22px; overflow: hidden; flex-shrink: 0;
    background: linear-gradient(145deg, var(--accent), var(--primary-dark));
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px rgba(13, 148, 136, 0.22);
}
.perfil-avatar-fallback { color: #fff; font-size: 1.4rem; font-weight: 700; }
.perfil-header-copy { min-width: 0; }
.perfil-header-copy h2 { font-size: 1.2rem; margin-bottom: 4px; line-height: 1.3; }
.perfil-role { color: var(--text-muted); font-size: 0.84rem; margin-bottom: 12px; }
.perfil-meta { display: grid; gap: 10px; margin: 0; }
.perfil-meta div { display: grid; gap: 2px; }
.perfil-meta dt { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.perfil-meta dd { margin: 0; font-size: 0.92rem; font-weight: 600; color: var(--text); word-break: break-word; }
.perfil-photo-form { border-top: 1px solid var(--border-light); padding-top: 16px; }
.perfil-photo-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.field-hint { display: block; margin-top: 4px; font-size: 0.75rem; color: var(--text-muted); }
.perfil-section-title { font-size: 1rem; margin-bottom: 4px; }
.perfil-section-sub { font-size: 0.84rem; color: var(--text-muted); margin-bottom: 14px; line-height: 1.5; }
.perfil-password-form { display: grid; gap: 12px; max-width: 420px; }
@media (min-width: 860px) {
    .perfil-grid { grid-template-columns: 1.1fr 0.9fr; align-items: start; }
    .perfil-card-main { grid-row: span 2; }
}

/* ——— Cambio obligatorio de contraseña ——— */
.pwd-change-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.pwd-change-shell { width: min(100%, 560px); }
.pwd-change-card { padding: 24px 22px; margin-bottom: 0; }
.pwd-change-head { text-align: center; margin-bottom: 18px; }
.pwd-change-icon {
    width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px;
    display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent);
}
.pwd-change-icon svg { width: 28px; height: 28px; }
.pwd-change-head h1 { font-size: 1.2rem; margin-bottom: 8px; }
.pwd-change-head p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.55; }
.pwd-change-reasons { display: grid; gap: 10px; margin-bottom: 18px; }
.pwd-reason {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px;
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    background: var(--bg-subtle);
}
.pwd-reason-icon {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 800; color: #fff;
}
.pwd-reason-icon.primera { background: var(--accent); }
.pwd-reason-icon.igual { background: var(--warning); }
.pwd-reason strong { display: block; font-size: 0.88rem; margin-bottom: 3px; }
.pwd-reason p { margin: 0; font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.pwd-reason code { font-size: 0.8rem; padding: 1px 6px; border-radius: 4px; background: var(--surface); border: 1px solid var(--border-light); }
.pwd-change-form { display: grid; gap: 12px; }
.pwd-change-rules {
    margin: 0; padding-left: 18px; color: var(--text-muted); font-size: 0.8rem; line-height: 1.6;
}
.pwd-change-footer {
    margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-light);
    display: grid; gap: 10px;
}
.pwd-change-footer p {
    margin: 0; text-align: center; font-size: 0.82rem; color: var(--text-muted); line-height: 1.5;
}
@media (max-width: 480px) {
    .pwd-change-card { padding: 18px 16px; }
}

/* Fallback sin container queries */
@supports not (container-type: inline-size) {
    @media (max-width: 768px) {
        .home-welcome-grid { grid-template-columns: 1fr; padding: 18px 16px; }
        .home-welcome-aside { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
        .home-greeting { font-size: 1.05rem; }
        .home-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .home-modules { grid-template-columns: 1fr; }
    }
    @media (max-width: 480px) {
        .home-kpi-grid { grid-template-columns: 1fr; }
        .home-recent-item { flex-direction: column; align-items: flex-start; }
    }
    @media (min-width: 901px) {
        .home-body-grid { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); }
        .home-section-modules .home-modules { grid-template-columns: 1fr; }
    }
    @media (min-width: 1200px) {
        .home-section-modules .home-modules { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    }
}

/* ——— Modo oscuro automático (preferencia del sistema) ——— */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #0c1117;
        --surface: #151c26;
        --bg-subtle: #1a2330;
        --text: #e8edf4;
        --text-secondary: #c5cdd8;
        --text-muted: #8b98a8;
        --border: #2d3a4d;
        --border-light: #243044;
        --link: #5eead4;
        --link-hover: #99f6e4;
        --primary: #5eead4;
        --primary-dark: #14312e;
        --accent: #2dd4bf;
        --accent-hover: #5eead4;
        --accent-soft: #12332f;
        --clinical: #34d399;
        --clinical-soft: #0d3320;
        --clinical-line: #1e3a2f;
        --warning: #fbbf24;
        --warning-soft: #422006;
        --danger: #f87171;
        --danger-soft: #450a0a;
        --sidebar-bg: #101a1a;
        --sidebar-text: #eafaf7;
        --sidebar-muted: #8fa9a6;
        --sidebar-border: rgba(255, 255, 255, 0.08);
        --win-accent: #2dd4bf;
        --win-accent-bg: rgba(45, 212, 191, 0.14);
        --win-hover: rgba(255, 255, 255, 0.06);
        --win-border: rgba(255, 255, 255, 0.08);
        --field-locked-bg: #243044;
        --surface-2: #1a2330;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
    }

    .sidebar-footer { background: var(--bg-subtle); }
    .btn-logout { background: var(--surface); color: var(--sidebar-text); border-color: var(--win-border); }
    .config-sidebar { background: var(--bg-subtle); }
    .badge-super { background: #422006; color: #fcd34d; }
    .badge-super--inline { background: rgba(251, 191, 36, 0.12); color: #fcd34d; border: 1px solid rgba(251, 191, 36, 0.22); }
    .badge-migone { background: #1e3a5f; color: #93c5fd; border-color: #2563eb; }
    .table-scroll tbody tr:nth-child(even) td,
    .card-table tbody tr:nth-child(even) td,
    .patientdb-table-wrap tbody tr:nth-child(even) td { background: var(--table-row-stripe); }
    .table-scroll tbody tr:hover td,
    .card-table tbody tr:hover td,
    .patientdb-table-wrap tbody tr:hover td { background: var(--table-row-hover) !important; }
    .editable:hover { background: var(--editable-hover-bg) !important; }
    .sobra-cell, .sobra, .celda-sobra { background: var(--sobra-cell-bg); }
    .theme-migone .migone-meta-row th { background: var(--bg-subtle) !important; }
    .informe-modelo-doc,
    .informe-modelo-doc p,
    .informe-modelo-doc h1,
    .informe-modelo-doc h2,
    .informe-modelo-doc h3,
    .informe-modelo-doc .informe-modelo-textarea,
    .informe-modelo-doc .informe-modelo-textarea:focus {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .informe-modelo-seccion h2 { color: #1a5276 !important; border-bottom-color: #1a5276 !important; }
    .bandeja-search input:focus { box-shadow: 0 0 0 3px rgba(116, 143, 252, 0.22); }
    .app-dialog-overlay { background: rgba(0, 0, 0, 0.65); }
    .planilla-total-bar { background: var(--clinical-soft); border-top-color: var(--border); }
    .planilla-table-shell .row-total.ok td,
    .planilla-table-scroll .row-total.ok td { background: var(--clinical-soft); }
    input, select, textarea { background: var(--surface); color: var(--text); border-color: var(--border); }
    select {
        background-color: var(--surface);
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b98a8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    }
    input::placeholder, textarea::placeholder { color: var(--text-muted); }
}

/* Copyright (inicio, login, historial de versiones) */
.app-copyright {
    margin-top: auto;
    padding: 16px 12px 8px;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.55;
    color: var(--text-muted);
    flex-shrink: 0;
}
.app-copyright__text { margin: 0 0 6px; max-width: 920px; margin-inline: auto; }
.app-copyright__meta { margin: 0; font-size: 0.68rem; }
.app-copyright__meta a { color: var(--link); text-decoration: none; }
.app-copyright__meta a:hover { text-decoration: underline; }
.app-copyright--login {
    margin-top: 16px;
    padding: 12px 0 0;
    border-top: 1px solid var(--border-light);
    background: transparent;
}
.app-copyright--minimal { margin-top: 24px; padding-top: 20px; }

/* Historial de versiones */
.version-page-intro p { margin: 0 0 8px; }
.version-page-intro p:last-child { margin-bottom: 0; }
.version-timeline { display: flex; flex-direction: column; gap: 18px; }
.version-release { padding: 0; overflow: hidden; }
.version-release__head {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-subtle);
}
.version-release__badge {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-hover);
    font-weight: 700;
    font-size: 0.82rem;
}
.version-release__title { margin: 0 0 4px; font-size: 1.05rem; }
.version-release__date { font-size: 0.78rem; color: var(--text-muted); }
.version-changes { list-style: none; margin: 0; padding: 0; }
.version-change {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
}
.version-change:last-child { border-bottom: none; }
.version-change__type {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    align-self: start;
}
.version-change--feature .version-change__type { background: var(--clinical-soft); color: var(--clinical); }
.version-change--fix .version-change__type { background: var(--warning-soft); color: var(--warning); }
.version-change--security .version-change__type { background: var(--danger-soft); color: var(--danger); }
.version-change--ui .version-change__type { background: var(--win-accent-bg); color: var(--win-accent); }
.version-change--infra .version-change__type { background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-light); }
.version-change__body strong { display: block; margin-bottom: 4px; font-size: 0.92rem; }
.version-change__body p { margin: 0 0 6px; font-size: 0.84rem; color: var(--text-secondary); line-height: 1.5; }
.version-change__files {
    display: inline-block;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    word-break: break-word;
}
.versiones-public-wrap { max-width: 960px; margin: 0 auto; padding: 24px 20px 40px; position: relative; z-index: 1; }
.versiones-public-head { margin-bottom: 24px; }
.versiones-public-head h1 { margin: 12px 0 6px; font-size: 1.5rem; }
.versiones-public-head p { margin: 0; color: var(--text-muted); }

@media (max-width: 640px) {
    .version-change { grid-template-columns: 1fr; gap: 6px; }
    .app-copyright__text { font-size: 0.66rem; }
}

@media print {
    .sidebar, .app-topbar, .config-sidebar { display: none !important; }
    .app-copyright { border-top: 1px solid #ccc; color: #333; }
}

/* Margen operativo — indicador global ingresos vs gastos */
.margen-operativo-page { display: flex; flex-direction: column; gap: 14px; }
.margen-operativo-filtro { margin-bottom: 0; }
.margen-operativo-panel { padding: 16px 18px; border-left: 4px solid var(--accent); }
.margen-operativo-panel--compact { margin-bottom: 14px; }
.margen-operativo-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.margen-operativo-head h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.margen-operativo-periodo { margin: 4px 0 0; font-size: 0.78rem; color: var(--text-muted); }
.margen-operativo-hero {
    text-align: center; padding: 18px 14px; margin-bottom: 14px;
    border-radius: var(--radius-md);
    background: linear-gradient(160deg, var(--accent-soft) 0%, var(--surface) 100%);
    border: 1px solid var(--clinical-line);
}
.margen-operativo-hero.warn {
    background: linear-gradient(160deg, var(--warning-soft) 0%, var(--surface) 100%);
    border-color: #fcd34d;
}
.margen-operativo-hero.danger {
    background: linear-gradient(160deg, var(--danger-soft) 0%, var(--surface) 100%);
    border-color: #fca5a5;
}
.margen-operativo-pct {
    display: block; font-size: clamp(2.2rem, 6vw, 3rem); font-weight: 800;
    line-height: 1.1; color: var(--accent); letter-spacing: -0.02em;
}
.margen-operativo-hero.warn .margen-operativo-pct { color: var(--warning); }
.margen-operativo-hero.danger .margen-operativo-pct { color: var(--danger); }
.margen-operativo-pct-label {
    display: block; margin-top: 4px; font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
}
.margen-operativo-formula {
    margin: 8px 0 0; font-size: 0.72rem; color: var(--text-muted);
}
.margen-operativo-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
    gap: 10px;
}
.margen-operativo-metric {
    padding: 12px 14px; border-radius: var(--radius-md);
    border: 1px solid var(--border-light); background: var(--bg-subtle);
}
.margen-operativo-metric-label {
    display: block; font-size: 0.68rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 4px;
}
.margen-operativo-metric strong { font-size: 1rem; }
.margen-operativo-metric-hint {
    display: block; margin-top: 4px; font-size: 0.72rem; color: var(--text-muted); line-height: 1.35;
}
.margen-operativo-metric.resultado { border-color: var(--clinical-line); background: var(--accent-soft); }
.margen-operativo-detalle { margin-top: 14px; }
.margen-operativo-detalle summary {
    cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--link);
}
.margen-operativo-breakdown {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px 16px; margin: 10px 0 0;
}
.margen-operativo-breakdown dt {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.margen-operativo-breakdown dd { margin: 2px 0 0; font-weight: 600; font-size: 0.88rem; }

/* Insumos EEG v2 — layout responsive */
.insumos-v2 {
    display: flex;
    flex-direction: column;
    gap: clamp(14px, 2vw, 20px);
    width: 100%;
    max-width: none;
}
.insumos-v2-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 16px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    border-top: 3px solid var(--accent);
}
.insumos-v2-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.insumos-v2-periodo { flex: 1; min-width: min(100%, 280px); margin: 0; }
.insumos-v2-periodo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
    gap: 10px 12px;
}
.insumos-v2-periodo .field-group { margin: 0; }
.insumos-v2-periodo label { font-size: 0.72rem; margin-bottom: 4px; }
.insumos-v2-periodo select { width: 100%; }
.insumos-v2-dashboard {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(12px, 2vw, 18px);
    align-items: start;
}
.insumos-v2-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: clamp(14px, 2vw, 18px);
    min-width: 0;
}
.insumos-v2-card--margen { border-top: 3px solid var(--accent); }
.insumos-v2-card--costo { border-top: 3px solid var(--primary); }
.insumos-v2-card-head { margin-bottom: 14px; }
.insumos-v2-card-head h2 {
    margin: 0 0 4px;
    font-size: clamp(0.92rem, 2vw, 1rem);
    font-weight: 700;
}
.insumos-v2-card-head p {
    margin: 0;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.insumos-v2-hero {
    text-align: center;
    padding: clamp(14px, 2.5vw, 20px) 12px;
    margin-bottom: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}
.insumos-v2-hero--margen {
    background: linear-gradient(165deg, var(--accent-soft) 0%, var(--surface) 100%);
    border-color: var(--clinical-line);
}
.insumos-v2-hero--margen.warn {
    background: linear-gradient(165deg, var(--warning-soft) 0%, var(--surface) 100%);
    border-color: #fcd34d;
}
.insumos-v2-hero--margen.danger {
    background: linear-gradient(165deg, var(--danger-soft) 0%, var(--surface) 100%);
    border-color: #fca5a5;
}
.insumos-v2-hero--costo {
    background: linear-gradient(165deg, #e0f2fe 0%, var(--surface) 100%);
    border-color: #7dd3fc;
}
.insumos-v2-hero-value {
    display: block;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 800;
    line-height: 1.1;
    color: var(--accent);
    letter-spacing: -0.02em;
}
.insumos-v2-hero--costo .insumos-v2-hero-value { color: var(--primary); }
.insumos-v2-hero--margen.warn .insumos-v2-hero-value { color: var(--warning); }
.insumos-v2-hero--margen.danger .insumos-v2-hero-value { color: var(--danger); }
.insumos-v2-hero-label {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.insumos-v2-hero-formula {
    margin: 8px 0 0;
    font-size: 0.72rem;
    color: var(--text-muted);
    word-break: break-word;
}
.insumos-v2-metricas {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}
.insumos-v2-metrica {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
}
.insumos-v2-metrica h3 {
    margin: 0 0 4px;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.insumos-v2-metrica strong { font-size: 0.95rem; }
.insumos-v2-metrica p {
    margin: 6px 0 0;
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.insumos-v2-metrica code {
    font-size: 0.7rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--surface);
}
.insumos-v2-metrica--resultado {
    border-color: var(--clinical-line);
    background: var(--accent-soft);
}
.insumos-v2-pasos {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.insumos-v2-paso {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
}
.insumos-v2-paso--subtotal { background: var(--surface); }
.insumos-v2-paso--resultado {
    border-color: var(--clinical-line);
    background: var(--accent-soft);
}
.insumos-v2-paso-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border-light);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}
.insumos-v2-paso-body strong {
    display: block;
    font-size: 0.84rem;
    margin-bottom: 4px;
}
.insumos-v2-paso-body p {
    margin: 0 0 6px;
    font-size: 0.74rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.insumos-v2-paso-valor {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}
.insumos-v2-paso-formula {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
    word-break: break-word;
}
.insumos-v2-paso-formula--final { font-size: 0.82rem; }
.insumos-v2-paso-alerta {
    display: block;
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--warning);
    font-style: italic;
}
.insumos-v2-detalle { margin-top: 12px; }
.insumos-v2-detalle summary {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--link);
    padding: 4px 0;
}
.insumos-v2-breakdown {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin: 10px 0 0;
}
.insumos-v2-breakdown div {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
}
.insumos-v2-breakdown dt {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.insumos-v2-breakdown dd {
    margin: 4px 0 0;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
}
.insumos-v2-breakdown-total {
    border: 1px solid var(--clinical-line);
    background: var(--accent-soft) !important;
}
.insumos-v2-nota {
    margin: 10px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
}
.insumos-v2-compras {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: clamp(12px, 2vw, 18px);
    align-items: start;
}
.insumos-v2-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.insumos-v2-form .btn-primary { width: 100%; }
.insumos-v2-empty {
    margin: 0;
    padding: 20px 12px;
    text-align: center;
    font-size: 0.86rem;
    color: var(--text-muted);
}
.insumos-v2-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}
.insumos-v2-table {
    width: 100%;
    min-width: 420px;
    border-collapse: collapse;
    font-size: 0.84rem;
}
.insumos-v2-table th,
.insumos-v2-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}
.insumos-v2-table th {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-subtle);
}
.insumos-v2-table tbody tr:last-child td { border-bottom: none; }
@media (max-width: 1100px) {
    .insumos-v2-dashboard { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .insumos-v2-compras { grid-template-columns: 1fr; }
    .insumos-v2-top { flex-direction: column; align-items: stretch; }
    .insumos-v2-nav .btn { flex: 1; justify-content: center; }
}
@media (max-width: 600px) {
    .insumos-v2-table { min-width: 0; }
    .insumos-v2-table thead { display: none; }
    .insumos-v2-table tbody tr {
        display: block;
        padding: 12px 14px;
        border-bottom: 1px solid var(--border-light);
    }
    .insumos-v2-table tbody tr:last-child { border-bottom: none; }
    .insumos-v2-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 5px 0;
        border: none;
        text-align: right !important;
    }
    .insumos-v2-table td::before {
        content: attr(data-label);
        font-size: 0.65rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }
    .insumos-v2-table td:last-child {
        justify-content: flex-end;
        padding-top: 10px;
    }
    .insumos-v2-table td:last-child::before { display: none; }
    .insumos-v2-paso { grid-template-columns: 24px minmax(0, 1fr); }
    .insumos-v2-paso-num { width: 24px; height: 24px; font-size: 0.72rem; }
}

/* ============================================================
   Refuerzo responsive global — móvil / tablet
   Reglas transversales para todo el proyecto.
   ============================================================ */

/* Guardas anti-desborde horizontal: ningún contenedor rompe el ancho. */
.app-shell, .main-content, .content-wrapper, .page-body { max-width: 100%; }
.form-section, .card, .notice-card, .alert-box, .patient-hero { min-width: 0; }
/* Texto largo (correos, URLs, nombres, documentos) hace wrap en vez de desbordar. */
.field-group span, .hint-text, .audit-trail,
.patient-info-grid span, .info-item span,
.card p, .form-section p, .form-section-desc { overflow-wrap: anywhere; }

@media (max-width: 900px) {
    /* iOS hace zoom automático al enfocar campos con font-size < 16px. */
    body:not(.login-page) input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]),
    select,
    textarea { font-size: 16px; }
    /* Grilla C.I. / fecha a una columna cómoda antes del breakpoint mínimo. */
    .grid-form-doc { grid-template-columns: 1fr; }
    /* La barra superior no debe empujar contenido fuera de pantalla. */
    .app-topbar { gap: 8px; }
    .topbar-title strong { font-size: 0.9rem; }
}

@media (max-width: 480px) {
    /* Encabezados de página apilados y de ancho completo en teléfonos. */
    .page-header, .form-header, .admin-header { flex-direction: column; align-items: stretch; }
    .page-header .btn, .form-header .btn, .admin-header .btn { width: 100%; justify-content: center; }
    .topbar-right { gap: 8px; }
    /* Modales ocupan casi todo el ancho disponible. */
    .modal, .app-modal__card, .app-dialog { max-width: calc(100vw - 24px); }
}

