/* MedicalTrack BPM — Sistema de diseño Embii AI */
:root {
    /* Negro cálido: superficies próximas, datos blancos, bordes discretos. */
    color-scheme: dark;
    --canvas: #171514;
    --bg-card: #1c1917;
    --border: #2b2825;
    --text: #f5f4f2;
    --text-light: #c5c1bd;
    --border-hover: #514b45;
    --white: var(--bg-card);
    --alt: var(--canvas);
    --sidebar: var(--canvas);
    --gray-light: var(--border);
    --black: var(--text);
    --text-dark: var(--text);
    --text-muted: var(--text-light);
    --gray: var(--text);
    --gray-dark: var(--text-light);
    --bg-soft: var(--canvas);

    /* Compatibilidad con clases y estilos inline existentes.
       Los nombres históricos son neutros; el lima lo define charts.js. */
    --blue: var(--text);
    --blue-dark: var(--text-light);
    --blue-soft: var(--border);
    --yellow: var(--text-light);
    --yellow-dark: var(--text-light);
    --green: var(--text);
    --green-light: var(--text-light);
    --green-soft: var(--alt);
    --warning: var(--text);
    --yellow-soft: var(--alt);
    --red: var(--text);
    --red-soft: var(--alt);
    --orange: var(--text-light);
    --purple: var(--text-light);
    --purple-soft: var(--alt);

    /* Tipografía */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: var(--font-sans);
    --font-mono: var(--font-sans);

    --sidebar-w: 260px;
    --header-h: 68px;
    --radius: 12px;
    --radius-sm: 6px;
    --shadow: none;
    --shadow-md: none;
    --transition: 0.18s ease;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { font-size: 15px; scroll-behavior: smooth; overflow-x: hidden; }

body {
    font-family: var(--font-sans);
    background: var(--canvas);
    color: var(--text);
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.hidden { display: none !important; }

button, input, select, textarea { font-family: var(--font-sans); }
input::placeholder, textarea::placeholder { color: var(--text-light); opacity: 1; }
:focus-visible { outline: 2px solid var(--text-light); outline-offset: 3px; }

/* Números tabulares reutilizables */
.num, .stat-value, .agenda-value, .insurance-amount, .insurance-pct,
.rating-value, .ficha-bar span, .progress-cell span {
    font-family: var(--font-sans);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

/* ===================== LOGIN ===================== */
.login-screen { display: flex; min-height: 100vh; }

.login-left {
    flex: 1;
    background: var(--alt);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 72px;
    position: relative;
    overflow: hidden;
    border-right: 1px solid var(--border);
}

.login-brand {
    position: relative;
    text-align: left;
    color: var(--text);
    max-width: 380px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 0 28px;
    font-size: 22px;
    color: var(--blue);
}

.login-brand h1 {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 44px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
    color: var(--black);
}

.login-brand p { font-size: 15px; color: var(--text-light); }

.brand-divider {
    display: none;
}

.login-brand span {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
}

.login-right {
    width: 480px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    padding: 60px;
}

.login-form-container { width: 100%; max-width: 360px; }

.login-form-header { margin-bottom: 40px; }
.login-form-header h2 {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 30px;
    letter-spacing: -0.01em;
    color: var(--black);
    margin-bottom: 8px;
}
.login-form-header p { color: var(--text-light); font-size: 14px; }

.form-field { margin-bottom: 24px; }
.form-field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper > i { position: absolute; left: 16px; color: var(--text-muted); font-size: 15px; }

.input-wrapper input {
    width: 100%;
    padding: 14px 48px 14px 46px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 15px;
    transition: var(--transition);
    background: var(--alt);
    color: var(--text);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--blue);
    background: var(--white);
}

.toggle-pass {
    position: absolute;
    right: 12px;
    padding: 8px;
    color: var(--text-muted);
    cursor: pointer;
    border: none;
    background: none;
}

.toggle-pass:hover { color: var(--text); }

.btn-login {
    width: 100%;
    padding: 15px;
    background: var(--black);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
}

.btn-login:hover { background: var(--gray-dark); }

.btn-excel {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 500;
    font-size: 13px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.btn-excel:hover {
    background: var(--border);
    border-color: var(--border-hover);
    color: var(--black);
    box-shadow: var(--shadow-md);
}

.login-msg {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.login-msg.error { background: var(--alt); color: var(--text); border: 1px solid var(--border); }

.login-footer {
    margin-top: 48px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ===================== APP LAYOUT ===================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.brand-icon {
    width: 40px;
    height: 40px;
    background: var(--white);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--blue);
}

.brand-name { font-size: 15px; font-weight: 700; color: var(--black); display: block; line-height: 1.2; }
.brand-sub { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}

.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { background: var(--border); color: var(--text); font-weight: 600; }
.nav-link i { width: 18px; text-align: center; font-size: 15px; }

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-light);
}

.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 12px; font-weight: 600; color: var(--text); }
.user-role { display: block; font-size: 10px; color: var(--text-muted); }

.btn-logout {
    padding: 8px;
    color: var(--text-muted);
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-logout:hover { background: var(--red-soft); color: var(--red); }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

.header {
    height: var(--header-h);
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.btn-menu {
    display: none;
    padding: 10px;
    border: none;
    background: none;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
}

.header-title h1 {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 20px;
    color: var(--black);
    letter-spacing: -0.3px;
    margin: 0;
    padding: 0;
}
.header-title p { font-size: 12px; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 12px; }

.search-box { position: relative; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 13px; }

.search-box input {
    padding: 9px 14px 9px 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 12px;
    width: 220px;
    background: var(--canvas);
    color: var(--text);
    transition: var(--transition);
}

.search-box input:focus { outline: none; border-color: var(--blue); background: var(--white); width: 280px; }

.btn-icon-header {
    position: relative;
    width: 38px;
    height: 38px;
    border: none;
    background: none;
    color: var(--text-light);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-icon-header:hover { background: var(--alt); color: var(--text); }

/* Periodos rápidos. Comparte caja con el selector de fechas del header para que
   se lean como un solo control: presets a la izquierda, personalizado al lado. */
.preset-rango {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.preset-btn {
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    color: var(--text-light);
    background: transparent;
    border: none;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.preset-btn:hover { background: var(--alt); color: var(--text); }
.preset-btn.active { background: var(--border); color: var(--text); }

@media (max-width: 1200px) {
    .preset-btn { padding: 7px 9px; font-size: 12px; }
}

/* Selector de rango temporal (Este año / 30 días / Todo) */
.range-selector {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: var(--white);
}
.range-btn {
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1;
    color: var(--text-light);
    background: transparent;
    border: none;
    padding: 6px 13px;
    border-radius: 9999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}
.range-btn:hover { color: var(--text); }
.range-btn.active { background: var(--border); color: var(--text); }
@media (max-width: 900px) {
    .range-btn { padding: 6px 10px; font-size: 12px; }
}

.badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    background: var(--red);
    color: var(--white);
    font-size: 9px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content { flex: 1; padding: 24px 28px 40px; }

.custom-range-inputs { display: flex; align-items: center; gap: 6px; }
.custom-range-inputs.hidden { display: none !important; }

.page { display: none; animation: fadeUp 0.25s ease; }
.page.active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== STATS ===================== */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    box-shadow: none;
    transition: var(--transition);
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-icon {
    display: none !important;
}

.stat-body { display: flex; flex-direction: column; min-width: 0; width: 100%; gap: 4px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.02em; }
.stat-value { font-size: 34px; font-weight: 700; color: #ffffff; line-height: 1.1; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.stat-change { font-size: 11px; font-weight: 500; color: var(--text-muted); margin-top: 2px; }
.stat-change.up { color: #3b82f6; }

/* ===================== GRID & CARDS ===================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }

.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.grid-2 .card { margin-bottom: 0; }

.card-header {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 13px; font-weight: 600; color: var(--text); }
.card-header h3 i { color: var(--text-light) !important; font-size: 12px; }
.card-sub { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }

/* Aclaración bajo un KPI cuando el número solo no se explica */
.stat-note { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* Nota que reemplaza a un gráfico sin datos (mejor que un recuadro vacío) */
.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    margin: 0;
    padding: 0 24px;
    text-align: center;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}

.card-badge {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 3px 8px;
    background: var(--alt);
    border-radius: 9999px;
    color: var(--text-muted);
    font-weight: 500;
}

.card-body { padding: 18px; }
.card-desc { font-size: 12px; color: var(--text-light); margin-bottom: 16px; line-height: 1.6; }

.chart-md { height: 260px; }

/* ===================== FICHAS CLÍNICAS ===================== */
.ficha-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.ficha-row:last-child { border-bottom: none; }

.ficha-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    /* El render de fichas asigna colores inline por persona. */
    background: var(--alt) !important;
    color: var(--text);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.ficha-info { flex: 1; }
.ficha-info strong { font-size: 13px; font-weight: 600; color: var(--text); display: block; }

.ficha-stats { display: flex; gap: 12px; margin-top: 4px; }
.ficha-closed { font-size: 11px; color: var(--text-light); }
.ficha-closed i { margin-right: 3px; }
.ficha-transit { font-size: 11px; color: var(--warning); }
.ficha-transit i { margin-right: 3px; }

.ficha-bar { display: flex; align-items: center; gap: 8px; }
.ficha-bar .bar-track { width: 60px; height: 5px; background: var(--alt); border-radius: 3px; }
.ficha-bar .bar-fill { height: 100%; background: var(--blue); border-radius: 3px; }
.ficha-bar span { font-size: 11px; font-weight: 600; color: var(--text-light); min-width: 28px; }

/* Colores inline del panel de auditoría generado por app.js.
   Se limita la excepción a este panel, sin tocar estructura ni columnas. */
#historia-audit-panel [style*="background"] {
    background: var(--alt) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

#btn-copy-whatsapp {
    background: var(--border) !important;
    color: var(--text) !important;
}
#btn-copy-whatsapp:hover { background: var(--border-hover) !important; }

/* ===================== ACTIVITY ===================== */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-dot.green { background: var(--blue); }
.activity-dot.blue { background: var(--blue); }
.activity-dot.yellow { background: var(--warning); }

.activity-content { font-size: 12px; color: var(--text); }
.activity-content strong { font-weight: 600; }
.activity-time { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ===================== AGENDA ===================== */
.page-header-bar { margin-bottom: 20px; }

.tabs {
    display: flex;
    gap: 4px;
    background: var(--white);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

.tab {
    padding: 7px 14px;
    border: none;
    background: none;
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

.tab:hover { color: var(--text); }
.tab.active { background: var(--border); color: var(--text); }

.agenda-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.agenda-stat:last-child { border-bottom: none; }
.agenda-label { font-size: 13px; color: var(--text-light); }
.agenda-value { font-size: 14px; font-weight: 600; color: var(--black); }
.agenda-value.green { color: var(--text); }
.agenda-value.yellow { color: var(--warning); }
.agenda-value.red { color: var(--red); }

.timeline-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-item .time {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 50px;
}

.timeline-content { flex: 1; font-size: 13px; color: var(--text); }
.timeline-content strong { font-weight: 600; }

.therapist {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===================== BADGES ===================== */
.badge-success, .badge-warning, .badge-complete, .badge-info {
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    background: var(--alt);
    color: var(--text-light);
    border: 1px solid var(--border);
}

/* ===================== TABLE ===================== */
.page-actions { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }

.table-responsive { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--alt);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 14px;
    font-size: 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:hover { background: var(--alt); }

.cell-user { display: flex; align-items: center; gap: 8px; }

.avatar-sm {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    background: var(--alt) !important;
    color: var(--text);
    border: 1px solid var(--border);
}

.cell-user strong { font-size: 12px; font-weight: 600; }

/* ===================== KPIs ===================== */
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress-cell .bar-track { flex: 1; height: 5px; background: var(--alt); border-radius: 3px; }
.progress-cell .bar-fill { height: 100%; background: var(--blue); border-radius: 3px; }
.progress-cell span { font-size: 11px; font-weight: 600; color: var(--text-light); }

/* ===================== INGRESOS ===================== */
.insurance-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.insurance-row:last-child { border-bottom: none; }

.insurance-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
}

.insurance-info { flex: 1; }
.insurance-info strong { font-size: 13px; font-weight: 600; color: var(--text); display: block; }
.insurance-info span { font-size: 11px; color: var(--text-muted); }

.insurance-amount { font-size: 14px; font-weight: 600; color: var(--black); }
.insurance-pct { font-size: 12px; font-weight: 600; color: var(--text-muted); min-width: 36px; text-align: right; }

/* ===================== SATISFACCIÓN ===================== */
.rating-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.rating-row:last-child { border-bottom: none; }

.rating-label { flex: 1; font-size: 13px; color: var(--text); }

/* Pista inline de las barras de satisfacción: solo fondo plano y relleno. */
#satisfaccion-categorias .rating-row > div { background: var(--border) !important; }

.rating-stars { display: flex; gap: 2px; color: var(--warning); font-size: 12px; }
.rating-value { font-size: 13px; font-weight: 600; color: var(--black); min-width: 28px; text-align: right; }

.comment-item {
    padding: 16px;
    background: var(--alt);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.comment-item:last-child { margin-bottom: 0; }

.comment-stars { display: flex; gap: 2px; color: var(--warning); font-size: 12px; margin-bottom: 8px; }
.comment-item p {
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 8px;
}
.comment-author { font-size: 11px; color: var(--text-muted); font-weight: 500; }

/* Últimas evaluaciones de calidad (paciente + calificación) */
.eval-item {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.eval-item:last-child { border-bottom: none; padding-bottom: 0; }
.eval-item:first-child { padding-top: 0; }

.eval-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}
.eval-head strong { font-size: 14px; font-weight: 600; color: var(--text); }

.eval-score {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 500;
    color: var(--blue);
    white-space: nowrap;
}
.eval-score-max { font-size: 11px; color: var(--text-muted); }

.eval-obs {
    font-family: var(--font-sans);
    font-size: 13.5px;
    color: var(--text-light);
    line-height: 1.5;
    margin-top: 6px;
}

.eval-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin-top: 6px;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1200px) {
    .stats-row { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
    .grid-2 { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); box-shadow: var(--shadow-md); }
    .main { margin-left: 0; }
    .btn-menu { display: block; }
}

@media (max-width: 768px) {
    .login-screen { flex-direction: column; }
    .login-left { padding: 40px 24px; min-height: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .login-right { width: 100%; padding: 40px 24px; }
    .stats-row { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .header { padding: 0 16px; }
    .page-actions { flex-direction: column; gap: 12px; align-items: stretch; }
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===================== CONNECTION STATUS ===================== */
.sidebar-status {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}

.connection-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 3.5px 12px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--alt);
    border: 1px solid var(--border);
    white-space: nowrap;
}

.connection-dot {
    width: 6.5px;
    height: 6.5px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s, box-shadow 0.3s;
    flex-shrink: 0;
}

.connection-dot.connected {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.45);
}
.connection-dot.error {
    background: #ef4444;
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.45);
}
.connection-dot.loading {
    background: #3b82f6;
    animation: pulse 1s infinite;
}
.connection-dot.no_endpoint { background: var(--text-muted); }
.connection-dot.idle { background: var(--text-muted); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.connection-text {
    font-weight: 600;
    color: var(--text);
    font-size: 11px;
}

.connection-sep {
    color: var(--text-light);
    opacity: 0.4;
    font-size: 10px;
    user-select: none;
    line-height: 1;
}

.last-updated {
    font-size: 11px;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
    font-weight: 400;
}

.sidebar-embii-credit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 10.5px;
    user-select: none;
    line-height: 1.2;
}

.sidebar-embii-credit .credit-label {
    color: var(--text-muted);
    font-weight: 400;
}

.sidebar-embii-credit .credit-brand {
    color: var(--text-light);
    font-weight: 600;
    text-decoration: none;
    letter-spacing: -0.01em;
    transition: color var(--transition);
}

.sidebar-embii-credit .credit-brand:hover {
    color: var(--text);
}

/* ===================== FILTERS ===================== */
.filters-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select {
    color-scheme: dark;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text);
    background: var(--bg-card);
    cursor: pointer;
    min-width: 180px;
    transition: border-color var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--border-hover);
}

.filter-select option,
select option {
    background-color: #1c1917;
    color: #f5f4f2;
    padding: 6px 10px;
}

.filter-input {
    color-scheme: dark;
}

/* ===================== TEXT HELPERS ===================== */
.text-muted {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* ===================== CARD BADGE CONNECTED ===================== */
.card-badge.connected {
    background: var(--border);
    color: var(--text);
}

/* ===================== REFRESH BUTTON ===================== */
#refresh-btn {
    transition: transform 0.3s;
}

#refresh-btn:active {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .connection-status { display: none; }
    .last-updated { display: none; }
    .filters-row { flex-direction: column; }
    .filter-select { min-width: 100%; }
    .alerts-panel { margin-bottom: 16px; }
}

/* ===================== ALERTS PANEL ===================== */
.alerts-panel {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.alerts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.alerts-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.alerts-header h3 i {
    color: var(--warning);
}

.alerts-count {
    font-family: var(--font-mono);
    background: var(--red);
    color: var(--canvas);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    min-width: 20px;
    text-align: center;
}

.alerts-body {
    padding: 12px 20px;
    max-height: 250px;
    overflow-y: auto;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    transition: background var(--transition);
}

.alert-item:last-child { margin-bottom: 0; }

.alert-warning, .alert-danger, .alert-info, .alert-ok {
    background: var(--alt);
    border: 1px solid var(--border);
    color: var(--text);
}
.alert-viewed { opacity: 0.5; }

.alert-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    color: var(--text-light);
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-content strong {
    display: block;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 2px;
}

.alert-content span {
    font-size: 12px;
    color: var(--text-light);
}

.alert-viewed-tag {
    display: inline-block;
    font-size: 10px;
    background: var(--border);
    color: var(--text-muted);
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 500;
}

.alert-dismiss {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--alt);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all var(--transition);
    flex-shrink: 0;
}

.alert-dismiss:hover {
    background: var(--border);
    border-color: var(--border-hover);
    color: var(--text);
}

/* ===================== NAV BADGE ===================== */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    background: transparent;
    color: transparent;
    margin-left: auto;
}

.nav-badge.active {
    background: var(--red);
    color: var(--canvas);
}

/* ===================== PROCESS FLOW ===================== */
.flow-legend {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.flow-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-light);
}

.flow-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Fichas Pendientes por Cliente */
.pending-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pending-search { flex: 1; min-width: 220px; max-width: 420px; }
.pending-search input { width: 100%; }
.pending-summary { font-size: 13px; color: var(--text-light); font-weight: 500; white-space: nowrap; }
.chart-lg { height: 340px; position: relative; }

/* Resumen Ejecutivo - Hallazgos Clave */
.findings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.finding-card { display: flex; gap: 12px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border);
    box-shadow: var(--shadow); background: var(--alt); }
.finding-card .finding-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; color: var(--text-light); }
.finding-body { display: flex; flex-direction: column; gap: 3px; }
.finding-body strong { font-size: 13.5px; line-height: 1.35; color: var(--text); }
.finding-body span { font-size: 12px; color: var(--text-light); line-height: 1.4; }

/* Tablero de KPIs */
.kpi-cat-row td { background: var(--bg-soft); font-weight: 700; font-size: 11px; letter-spacing: 0.5px; color: var(--text-light); text-transform: uppercase; padding: 8px 12px; }
#kpi-scorecard-table td, #kpi-scorecard-table th { white-space: nowrap; }

/* Fichas por completar - chips de campos faltantes */
.miss-chip { display: inline-block; background: var(--red-soft); color: var(--red); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 9999px; margin: 2px 2px; white-space: nowrap; }
#completar-fisio-filter { min-width: 200px; }

/* Tablas largas de Procesos: scroll interno con encabezado fijo */
.table-responsive:has(#pending-table), .table-responsive:has(#completar-table) { max-height: 460px; overflow-y: auto; }
.table-responsive:has(#pending-table) thead th, .table-responsive:has(#completar-table) thead th { position: sticky; top: 0; background: var(--bg-card); z-index: 2; }

/* Días sin completar - semáforo de antigüedad */
.overdue { font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; padding: 3px 9px; border-radius: 9999px; white-space: nowrap; }
.overdue-high { background: var(--red-soft); color: var(--red); }
.overdue-mid { background: var(--yellow-soft); color: var(--warning); }
.overdue-low { background: var(--alt); color: var(--text-light); }
.risk-flag { display: inline-block; font-size: 10.5px; font-weight: 600; color: var(--red); background: var(--red-soft); padding: 1px 6px; border-radius: 9999px; margin-left: 4px; white-space: nowrap; }

/* Métricas del período */
.period-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period-date { min-width: 140px; }
.period-dash { color: var(--text-light); font-weight: 600; }
.period-range-label { font-size: 12.5px; color: var(--text-light); font-weight: 600; margin-bottom: 14px; }
.delta { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--text-light); }
.delta.down { color: var(--red); }
.delta.flat { color: var(--text-light); }
.sidebar-logo {
    max-width: 95%;
    max-height: 48px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}
.sidebar-brand-custom {
    justify-content: center;
    padding: 10px 15px;
    height: 68px;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border);
}
.login-logo {
    max-width: 260px;
    max-height: 110px;
    margin-bottom: 15px;
    object-fit: contain;
}
.login-brand-custom {
    text-align: center;
}
.select-calidad {
    margin-top: 5px !important;
    width: 100% !important;
    font-size: 11px !important;
    padding: 2px !important;
}

/* ===================== ASISTENTE ===================== */
/* Panel flotante: se superpone al dashboard sin alterar su maquetación. */

.asistente-abrir {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 200;
    width: 52px;
    height: 52px;
    border-radius: 9999px;
    border: 1px solid var(--blue-dark);
    background: var(--blue);
    color: var(--white);
    font-size: 19px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: background 0.15s ease;
}
.asistente-abrir:hover { background: var(--blue-dark); }

.asistente {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 201;
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 540px;
    max-height: calc(100vh - 48px);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.asistente-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.asistente-head strong { display: block; font-size: 14px; color: var(--text); }
.asistente-head span { font-size: 12px; color: var(--text-muted); }

.asistente-cerrar {
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}
.asistente-cerrar:hover { background: var(--alt); color: var(--text); }

.asistente-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.asistente-msg { max-width: 88%; font-size: 13.5px; line-height: 1.55; }
.asistente-msg p { margin: 0; }
.asistente-msg.bot { align-self: flex-start; color: var(--text); }
.asistente-msg.yo {
    align-self: flex-end;
    background: var(--blue-soft);
    color: var(--blue-dark);
    padding: 9px 13px;
    border-radius: 12px 12px 2px 12px;
}
.asistente-msg.bot p + p { margin-top: 9px; }
.asistente-msg.error { color: var(--red); }

/* Cifras y periodos destacados en la respuesta */
.asistente-msg.bot strong { font-family: var(--font-mono); font-weight: 600; color: var(--text-dark, #111827); }

/* Tablas, listas y código estructurados en el chat */
.asistente-tabla-wrap {
    margin: 10px 0;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.asistente-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    line-height: 1.45;
    text-align: left;
}
.asistente-tabla th {
    background: var(--alt);
    color: var(--text-dark, #111827);
    font-weight: 600;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.asistente-tabla td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-soft, #f0f0f0);
    color: var(--text);
}
.asistente-tabla tr:last-child td {
    border-bottom: none;
}
.asistente-tabla tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.015);
}
.asistente-tabla tr:hover {
    background: rgba(31, 108, 159, 0.04);
}
.asistente-heading {
    margin: 11px 0 5px 0;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-dark, #111827);
}
.asistente-msg.bot ul, .asistente-msg.bot ol {
    margin: 7px 0;
    padding-left: 20px;
}
.asistente-msg.bot li {
    margin-bottom: 4px;
}
.asistente-msg.bot li:last-child {
    margin-bottom: 0;
}
.asistente-code {
    background: var(--alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    overflow-x: auto;
    margin: 8px 0;
}
.asistente-inline-code {
    background: var(--alt);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    border: 1px solid var(--border);
}

.asistente-sugerencias { display: flex; flex-wrap: wrap; gap: 6px; }
.asistente-sugerencias button {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-light);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 6px 11px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.asistente-sugerencias button:hover { border-color: var(--blue); color: var(--blue); }

.asistente-form {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}
.asistente-form input {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 13.5px;
    color: var(--text);
    background: var(--alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.asistente-form input:focus { outline: none; border-color: var(--blue); background: var(--white); }
.asistente-form button {
    width: 40px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--blue);
    color: var(--white);
    cursor: pointer;
    font-size: 14px;
}
.asistente-form button:hover { background: var(--blue-dark); }
.asistente-form button:disabled { background: var(--border-hover); cursor: default; }

/* Puntos de "escribiendo" */
.asistente-espera { display: inline-flex; gap: 4px; align-items: center; }
.asistente-espera i {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--text-muted);
    animation: asistentePulso 1.1s infinite ease-in-out;
}
.asistente-espera i:nth-child(2) { animation-delay: 0.16s; }
.asistente-espera i:nth-child(3) { animation-delay: 0.32s; }
@keyframes asistentePulso {
    0%, 70%, 100% { opacity: 0.28; }
    35% { opacity: 1; }
}

@media (max-width: 560px) {
    .asistente { right: 12px; bottom: 12px; width: calc(100vw - 24px); height: calc(100vh - 90px); }
    .asistente-abrir { right: 16px; bottom: 16px; }
}

/* ===================== TABLAS MANIPULABLES ===================== */
/* Ordenar, mover columnas y filtrar. Nada se guarda: al recargar vuelve todo. */

.tabla-barra {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0 0 12px;
}

.tabla-buscar { position: relative; display: flex; align-items: center; width: 260px; }
.tabla-buscar i { position: absolute; left: 11px; font-size: 11px; color: var(--text-muted); }
.tabla-buscar input {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text);
    background: var(--alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 30px;
}
.tabla-buscar input:focus { outline: none; border-color: var(--blue); background: var(--white); }

/* Filtros activos, cada uno quitable */
.tabla-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tabla-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: var(--blue-dark);
    background: var(--blue-soft);
    border-radius: 9999px;
    padding: 4px 6px 4px 11px;
}
.tabla-chip button {
    border: none;
    background: none;
    color: var(--blue-dark);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 3px;
    opacity: 0.65;
}
.tabla-chip button:hover { opacity: 1; }

.tabla-conteo {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.tabla-reset {
    font-family: var(--font-sans);
    font-size: 12px;
    color: var(--text-light);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 11px;
    cursor: pointer;
    white-space: nowrap;
}
.tabla-reset:hover { border-color: var(--border-hover); color: var(--text); }

/* Cabeceras */
th.th-interactivo {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 40px;
}
th.th-interactivo:hover { color: var(--text); }

th.th-interactivo::after {
    content: '';
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 9px;
    color: var(--blue);
    opacity: 0;
}
th.orden-asc::after  { content: '\f062'; opacity: 1; }
th.orden-desc::after { content: '\f063'; opacity: 1; }

.th-filtro {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 9.5px;
    cursor: pointer;
    padding: 4px 5px;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}
th.th-interactivo:hover .th-filtro { opacity: 0.75; }
.th-filtro:hover { background: var(--alt); color: var(--text); opacity: 1; }
.th-filtro.activo { opacity: 1; color: var(--blue); }

th.th-arrastrando { opacity: 0.4; }
th.th-destino { box-shadow: inset 2px 0 0 var(--blue); }

/* Panel de filtro por columna */
.tabla-panel {
    position: absolute;
    z-index: 300;
    width: 232px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tabla-panel-tit {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}

.tabla-panel select,
.tabla-panel input[type="text"],
.tabla-panel input[type="number"] {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 9px;
}
.tabla-panel select:focus,
.tabla-panel input:focus { outline: none; border-color: var(--blue); }

.tabla-panel-acc { display: flex; gap: 6px; }
.tabla-panel-acc button {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 11.5px;
    color: var(--text-light);
    background: var(--alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 5px;
    cursor: pointer;
}
.tabla-panel-acc button:hover { color: var(--text); border-color: var(--border-hover); }

.tabla-panel-lista {
    max-height: 190px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px;
}
.tabla-panel-lista label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text);
    padding: 3px 4px;
    border-radius: 4px;
    cursor: pointer;
}
.tabla-panel-lista label:hover { background: var(--alt); }
.tabla-panel-lista input { accent-color: var(--blue); }
.tabla-panel-lista span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabla-panel-pie { display: flex; gap: 6px; }
.tabla-panel-pie button {
    flex: 1;
    font-family: var(--font-sans);
    font-size: 12px;
    border-radius: var(--radius-sm);
    padding: 7px;
    cursor: pointer;
}
.tp-limpiar { color: var(--text-light); background: var(--white); border: 1px solid var(--border); }
.tp-limpiar:hover { color: var(--text); border-color: var(--border-hover); }
.tp-aplicar { color: var(--white); background: var(--blue); border: 1px solid var(--blue); }
.tp-aplicar:hover { background: var(--blue-dark); }

@media (max-width: 700px) {
    .tabla-buscar { width: 100%; }
    .tabla-conteo { margin-left: 0; }
}

/* Modal Detalle Doctor */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--canvas);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 860px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.modal-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}
.modal-icon {
    font-size: 14px;
    color: var(--text-light);
}
.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--black);
    margin: 0;
    letter-spacing: -0.2px;
}
.modal-subtitle {
    font-size: 12px;
    color: var(--text-light);
    margin: 2px 0 0;
}
.btn-close-modal {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.btn-close-modal:hover {
    color: var(--black);
    background: var(--gray-light);
    border-color: var(--border-hover);
}
.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-body .data-table th {
    position: sticky;
    top: 0;
    background: var(--white);
    z-index: 2;
}

/* Contenedor y Lista de Doctores Referidores */
#an-doctores {
    height: 260px;
    max-height: 260px;
    padding: 10px 14px;
    overflow: hidden;
    box-sizing: border-box;
}

.doctor-list {
    height: 100%;
    max-height: 240px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
}

/* Fila interactiva de Doctor */
.doctor-row-clickable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}
.doctor-row-clickable:hover {
    background: var(--border);
    border-color: var(--border-hover);
}
.doctor-row-clickable:hover .doctor-chevron {
    color: var(--blue);
    transform: translateX(2px);
}
.doctor-row-clickable:hover .doctor-name {
    color: var(--black);
}
.doctor-row-clickable:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}
.doctor-info-col {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.doctor-chevron {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform var(--transition), color var(--transition);
}
.doctor-name {
    color: var(--text);
    font-weight: 500;
    font-size: 13.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.doctor-badge {
    color: var(--blue);
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--blue-soft);
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    white-space: nowrap;
    border: 1px solid var(--border);
}

/* ===================== MAPA DE CALOR (AGENDA) ===================== */
#agenda-heatmap-card {
    margin-bottom: 24px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.heatmap-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--text-light);
    font-weight: 500;
}

.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
}

.legend-box.sat-high {
    background: rgba(59, 130, 246, 0.28);
    border: 1px solid #3b82f6;
}

.legend-box.sat-med {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
}

.legend-box.sat-low {
    background: #201d1b;
    border: 1px solid #38332e;
}

.heatmap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 5px;
    margin: 4px 0 0 0;
}

.heatmap-table th {
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: transparent;
    border: none;
    text-align: center;
}

.heatmap-table th.th-fisio {
    text-align: left;
    min-width: 170px;
    padding-left: 12px;
}

.heatmap-table th.th-summary {
    text-align: right;
    min-width: 140px;
    padding-right: 14px;
}

.heatmap-table td {
    border: none;
    padding: 0;
}

.heatmap-table td.heatmap-fisio-col {
    padding: 10px 12px;
    vertical-align: middle;
}

.heatmap-fisio-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.heatmap-fisio-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.heatmap-cell {
    border-radius: var(--radius-sm, 6px);
    transition: all var(--transition, 0.18s ease);
    cursor: default;
    user-select: none;
}

.heatmap-cell-inner {
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 54px;
    text-align: center;
}

.heatmap-cell-pac {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    color: var(--text);
}

.heatmap-cell-pac small {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-light);
    margin-left: 2px;
}

.heatmap-cell-pct {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Saturación > 85%: Azul suave con contraste en tema oscuro cálido */
.heatmap-cell.heat-saturated {
    background: rgba(59, 130, 246, 0.22);
    border: 1px solid rgba(59, 130, 246, 0.38);
}
.heatmap-cell.heat-saturated .heatmap-cell-pac {
    color: #eff6ff;
}
.heatmap-cell.heat-saturated .heatmap-cell-pct {
    color: #93c5fd;
}
.heatmap-cell.heat-saturated:hover {
    background: rgba(59, 130, 246, 0.34);
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.18);
}

/* Saturación 70-85%: Azul cielo tenue */
.heatmap-cell.heat-optimal {
    background: rgba(59, 130, 246, 0.09);
    border: 1px solid rgba(59, 130, 246, 0.20);
}
.heatmap-cell.heat-optimal .heatmap-cell-pac {
    color: #dbeafe;
}
.heatmap-cell.heat-optimal .heatmap-cell-pct {
    color: #60a5fa;
}
.heatmap-cell.heat-optimal:hover {
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.40);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

/* Saturación < 70%: Gris oscuro disponible */
.heatmap-cell.heat-available {
    background: #201d1b;
    border: 1px solid #2e2a26;
}
.heatmap-cell.heat-available .heatmap-cell-pac {
    color: var(--text-light);
}
.heatmap-cell.heat-available .heatmap-cell-pct {
    color: #78716c;
}
.heatmap-cell.heat-available:hover {
    background: #272320;
    border-color: #423c36;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.heatmap-summary-col {
    padding: 10px 14px;
    text-align: right;
    vertical-align: middle;
}

.heatmap-summary-pac {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.heatmap-summary-hrs {
    font-size: 11px;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}

/* ===================== CENTRO DE REPORTES ===================== */
.reportes-hero {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 24px;
}
.reportes-hero code {
    background: rgba(255, 255, 255, 0.06);
    color: #60a5fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 12px;
}
.reportes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}
.reporte-card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    height: 100%;
}
.reporte-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.reporte-tag {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 9px;
    border-radius: 9999px;
}
.tag-gerencial {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.25);
}
.tag-operativo {
    display: inline-block;
    background: rgba(113, 113, 122, 0.15);
    color: #a1a1aa;
    border: 1px solid rgba(113, 113, 122, 0.3);
}
.tag-comercial {
    background: rgba(255, 255, 255, 0.08);
    color: #f5f4f2;
    border: 1px solid var(--border);
}
.reporte-badge-format {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-weight: 600;
}
.reporte-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.3;
}
.reporte-title i {
    color: #3b82f6;
    font-size: 18px;
    flex-shrink: 0;
}
.reporte-desc {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 16px;
}
.reporte-meta-box {
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: var(--text-muted);
}
.meta-row strong {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    max-width: 65%;
}
.reporte-preview-container {
    margin-bottom: 20px;
    flex: 1;
}
.preview-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.preview-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-weight: 600;
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.preview-table td {
    padding: 7px 10px;
    color: var(--text-light);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.preview-table tr:last-child td {
    border-bottom: none;
}
/* Matriz Ejecutiva Mensual Reporte A */
.table-reporte-ejecutivo {
    min-width: 650px;
}
.table-reporte-ejecutivo th,
.table-reporte-ejecutivo td {
    padding: 5px 7px;
    font-size: 10.5px;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.table-reporte-ejecutivo th {
    text-align: center;
    background: #1e1b18;
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid var(--border);
}
.table-reporte-ejecutivo .col-sticky-indicador {
    text-align: left;
    position: sticky;
    left: 0;
    background: #171514;
    z-index: 2;
    min-width: 130px;
    max-width: 150px;
    font-weight: 500;
    border-right: 1px solid var(--border);
    text-overflow: ellipsis;
    overflow: hidden;
}
.table-reporte-ejecutivo th.col-sticky-indicador {
    z-index: 6;
    background: #1e1b18;
}
.table-reporte-ejecutivo .col-total-anual {
    background: rgba(255, 255, 255, 0.03);
    font-weight: 700;
    border-left: 1px solid var(--border);
    color: var(--text);
}
.table-reporte-ejecutivo .reporte-section-row td {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10.5px;
    padding: 8px 10px;
    text-align: left;
    position: sticky;
    left: 0;
}
.table-reporte-ejecutivo .row-destacada td {
    background: rgba(255, 255, 255, 0.02);
    font-weight: 600;
    color: var(--text);
}
.table-reporte-ejecutivo .row-subindicador .col-sticky-indicador {
    padding-left: 18px;
    color: var(--text-muted);
}

.btn-descarga-reporte {
    width: 100%;
    padding: 12px 16px;
    background: var(--border);
    color: #ffffff;
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    margin-top: auto;
}
.btn-descarga-reporte:hover {
    background: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.28);
}

/* ==========================================================================
   Efecto de Resaltado Copilot (Guía visual azul vibrante con halo sutil)
   ========================================================================== */
.copilot-pulse {
    position: relative;
    outline: 2px solid #3b82f6 !important;
    outline-offset: 3px !important;
    border-radius: var(--radius-sm, 6px);
    animation: copilotGlow 2.5s ease-in-out infinite;
    transition: all 0.3s ease;
    z-index: 40;
}

@keyframes copilotGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.65), 0 0 16px rgba(59, 130, 246, 0.35);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.15), 0 0 24px rgba(59, 130, 246, 0.55);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0), 0 0 16px rgba(59, 130, 246, 0.2);
    }
}
