/* Inicio del panel: gráficas en SVG dibujadas en el servidor. Estilo paisaje de Kaulo: verde montaña, dorado y niebla.
   Los colores van aquí y no en el SVG porque la CSP no aplica style="…"; los textos de valores van en tinta, no en el
   color de la serie (el color solo dice "quién es"). */

.rh-dash {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}
.rh-dash > .card { margin: 0; }
.rh-dash__wide { grid-column: 1 / -1; }

/* En el celular, una gráfica debajo de otra. */
@media (max-width: 640px) {
    .rh-dash { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

.rh-dash__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rh-dash__head .xx-card-title { margin-bottom: 0; }
.rh-dash__scope {
    font-size: .74rem;
    font-weight: 600;
    color: var(--rh-mountains);
    background: var(--xx-neutral-bg);
    border: 1px solid var(--xx-line);
    border-radius: var(--xx-r-pill);
    padding: 2px 10px;
}
.rh-dash__sub { color: var(--xx-neutral-fg); font-size: .85rem; margin: 4px 0 12px; }
.rh-dash__empty { color: var(--xx-neutral-fg); margin: 8px 0 0; }
.rh-dash__note { color: var(--xx-neutral-fg); font-size: .82rem; margin: 10px 0 0; }

/* ── El lienzo ── */
.rh-dash__svg { display: block; width: 100%; height: auto; overflow: visible; }
.rh-dash__svg--columns { max-width: 640px; }
.rh-dash__svg--bars { max-width: 560px; }
.rh-dash__svg--donut { width: 150px; flex: 0 0 150px; }

.rh-dash__svg text { font-family: var(--xx-font-sans); }
.rh-dash__label { fill: var(--xx-ink); font-size: 12px; }
.rh-dash__value { fill: var(--xx-ink); font-size: 12px; font-weight: 600; }
.rh-dash__tick { fill: var(--xx-neutral-fg); font-size: 11px; }
.rh-dash__big { fill: var(--xx-ink); font-size: 22px; font-weight: 700; }
.rh-dash__axis { stroke: var(--xx-line); stroke-width: 1; }
.rh-dash__track { fill: var(--xx-line-2); }

/* Series: a tiempo = montaña, retardo = dorado, justificado = niebla, falta = rojo apagado. */
.rh-dash__fill--ontime, .rh-dash__fill--mountains { fill: var(--rh-mountains); }
.rh-dash__fill--late { fill: var(--rh-sunglow); }
.rh-dash__fill--justified { fill: var(--rh-mist); }
.rh-dash__fill--absent { fill: #b4533c; }
.rh-dash__fill--sky { fill: var(--rh-sky); }

/* El número dentro de un tramo: blanco sobre lo oscuro, tinta sobre lo claro. */
.rh-dash__in { font-size: 11px; font-weight: 600; fill: #fff; }
.rh-dash__in--late, .rh-dash__in--justified { fill: var(--xx-ink); }

.rh-dash__ring-track, .rh-dash__ring { fill: none; stroke-width: 14; }
.rh-dash__ring-track { stroke: var(--xx-line-2); }
.rh-dash__ring--ontime { stroke: var(--rh-mountains); }
.rh-dash__ring--late { stroke: var(--rh-sunglow); }

/* ── Leyenda ── */
.rh-dash__legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 0 0 10px; font-size: .85rem; color: var(--xx-ink); }
.rh-dash__legend li { display: inline-flex; align-items: center; gap: 6px; }
.rh-dash__legend--stack { flex-direction: column; gap: 6px; margin: 0; }
.rh-dash__legend-extra { color: var(--xx-neutral-fg); padding-left: 18px; }
.rh-dash__swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px; }
.rh-dash__swatch--ontime { background: var(--rh-mountains); }
.rh-dash__swatch--late { background: var(--rh-sunglow); }
.rh-dash__swatch--justified { background: var(--rh-mist); }
.rh-dash__swatch--absent { background: #b4533c; }

.rh-dash__donut { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

.rh-dash__details { margin-top: 10px; font-size: .85rem; }
.rh-dash__details summary { color: var(--rh-mountains); cursor: pointer; }
.rh-dash__details table { margin-top: 8px; }

/* ── Pendientes: números grandes que llevan a su pantalla ── */
.rh-dash__tiles {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 10px;
}
.rh-dash__tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    height: 100%;
    padding: 12px 14px;
    background: var(--xx-surface);
    border: 1px solid var(--xx-line);
    border-left: 4px solid var(--rh-mountains);
    border-radius: var(--xx-r-lg);
    color: var(--xx-ink);
    text-decoration: none;
}
.rh-dash__tile:hover { background: var(--xx-surface-2); }
.rh-dash__tile:focus-visible { outline: none; box-shadow: var(--xx-ring); }
.rh-dash__tile--warn { border-left-color: var(--rh-sunglow); }
.rh-dash__tile--zero { border-left-color: var(--xx-line); }
.rh-dash__tile--zero .rh-dash__tile-num { color: var(--xx-neutral-fg); }
.rh-dash__tile-num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.rh-dash__tile-label { font-size: .82rem; color: var(--xx-neutral-fg); }

/* ── Barras y columnas en HTML (el texto se lee igual en cualquier pantalla) ── */
.rh-dash__bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rh-dash__bars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: baseline; }
.rh-dash__bar-label { font-size: .88rem; color: var(--xx-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rh-dash__bar-value { font-size: .88rem; }
.rh-dash__bar-track { grid-column: 1 / -1; display: block; height: 10px; border-radius: 5px; background: var(--xx-line-2); overflow: hidden; }
.rh-dash__bar { display: block; height: 100%; border-radius: 5px; }
.rh-dash__bg--ontime, .rh-dash__bg--mountains { background: var(--rh-mountains); color: #fff; }
.rh-dash__bg--late { background: var(--rh-sunglow); color: var(--xx-ink); }
.rh-dash__bg--justified { background: var(--rh-mist); color: var(--xx-ink); }
.rh-dash__bg--absent { background: #b4533c; color: #fff; }
.rh-dash__bg--sky { background: var(--rh-sky); color: var(--xx-ink); }
.rh-dash__cols { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; align-items: end; border-bottom: 1px solid var(--xx-line); padding-top: 18px; }
.rh-dash__col { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.rh-dash__col-plot { height: 180px; width: 100%; max-width: 56px; display: flex; align-items: flex-end; }
.rh-dash__col-stack { position: relative; width: 100%; display: flex; flex-direction: column; gap: 2px; }
.rh-dash__col-total { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .8rem; font-weight: 700; color: var(--xx-ink); }
.rh-dash__seg { display: flex; align-items: center; justify-content: center; border-radius: 3px; font-size: .72rem; font-weight: 700; min-height: 3px; overflow: hidden; }
.rh-dash__col-day { margin-top: 4px; font-size: .75rem; color: var(--xx-neutral-fg); white-space: nowrap; }
.rh-dash__w-0 { width: 0%; } .rh-dash__h-0 { height: 0%; } .rh-dash__f-0 { flex: 0 0 calc(0% - 2px); }
.rh-dash__w-5 { width: 5%; } .rh-dash__h-5 { height: 5%; } .rh-dash__f-5 { flex: 0 0 calc(5% - 2px); }
.rh-dash__w-10 { width: 10%; } .rh-dash__h-10 { height: 10%; } .rh-dash__f-10 { flex: 0 0 calc(10% - 2px); }
.rh-dash__w-15 { width: 15%; } .rh-dash__h-15 { height: 15%; } .rh-dash__f-15 { flex: 0 0 calc(15% - 2px); }
.rh-dash__w-20 { width: 20%; } .rh-dash__h-20 { height: 20%; } .rh-dash__f-20 { flex: 0 0 calc(20% - 2px); }
.rh-dash__w-25 { width: 25%; } .rh-dash__h-25 { height: 25%; } .rh-dash__f-25 { flex: 0 0 calc(25% - 2px); }
.rh-dash__w-30 { width: 30%; } .rh-dash__h-30 { height: 30%; } .rh-dash__f-30 { flex: 0 0 calc(30% - 2px); }
.rh-dash__w-35 { width: 35%; } .rh-dash__h-35 { height: 35%; } .rh-dash__f-35 { flex: 0 0 calc(35% - 2px); }
.rh-dash__w-40 { width: 40%; } .rh-dash__h-40 { height: 40%; } .rh-dash__f-40 { flex: 0 0 calc(40% - 2px); }
.rh-dash__w-45 { width: 45%; } .rh-dash__h-45 { height: 45%; } .rh-dash__f-45 { flex: 0 0 calc(45% - 2px); }
.rh-dash__w-50 { width: 50%; } .rh-dash__h-50 { height: 50%; } .rh-dash__f-50 { flex: 0 0 calc(50% - 2px); }
.rh-dash__w-55 { width: 55%; } .rh-dash__h-55 { height: 55%; } .rh-dash__f-55 { flex: 0 0 calc(55% - 2px); }
.rh-dash__w-60 { width: 60%; } .rh-dash__h-60 { height: 60%; } .rh-dash__f-60 { flex: 0 0 calc(60% - 2px); }
.rh-dash__w-65 { width: 65%; } .rh-dash__h-65 { height: 65%; } .rh-dash__f-65 { flex: 0 0 calc(65% - 2px); }
.rh-dash__w-70 { width: 70%; } .rh-dash__h-70 { height: 70%; } .rh-dash__f-70 { flex: 0 0 calc(70% - 2px); }
.rh-dash__w-75 { width: 75%; } .rh-dash__h-75 { height: 75%; } .rh-dash__f-75 { flex: 0 0 calc(75% - 2px); }
.rh-dash__w-80 { width: 80%; } .rh-dash__h-80 { height: 80%; } .rh-dash__f-80 { flex: 0 0 calc(80% - 2px); }
.rh-dash__w-85 { width: 85%; } .rh-dash__h-85 { height: 85%; } .rh-dash__f-85 { flex: 0 0 calc(85% - 2px); }
.rh-dash__w-90 { width: 90%; } .rh-dash__h-90 { height: 90%; } .rh-dash__f-90 { flex: 0 0 calc(90% - 2px); }
.rh-dash__w-95 { width: 95%; } .rh-dash__h-95 { height: 95%; } .rh-dash__f-95 { flex: 0 0 calc(95% - 2px); }
.rh-dash__w-100 { width: 100%; } .rh-dash__h-100 { height: 100%; } .rh-dash__f-100 { flex: 0 0 calc(100% - 2px); }

/* ── Pendientes en el celular: carrusel como en JoinApp ──
   Una fila que se desliza con el dedo; cada tarjeta ocupa el 82 % para que se asome la siguiente y se acomoda al
   soltar. Sin barra de desplazamiento; la línea de abajo avisa que hay más. En la computadora siguen en cuadrícula. */
@media (max-width: 640px) {
    .rh-dash__tiles {
        display: flex;
        flex-wrap: nowrap;
        gap: 10px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 10px;
        overscroll-behavior-x: contain;
    }
    .rh-dash__tiles::-webkit-scrollbar { display: none; }
    .rh-dash__tiles > li { flex: 0 0 82%; max-width: 82%; scroll-snap-align: start; }
    .rh-dash__tiles > li > .rh-dash__tile { height: 100%; }
    /* Lo que sí tiene pendientes primero: deslizando, lo primero que se ve es lo que hay que atender. */
    .rh-dash__tiles > li:has(.rh-dash__tile--zero) { order: 1; }
    .rh-dash__tiles::after {
        /* Un respiro al final para que la última tarjeta también pueda quedar alineada al deslizar. */
        content: '';
        flex: 0 0 1px;
    }
    .rh-dash__tiles + .rh-dash__swipe,
    .rh-dash__swipe {
        display: block;
        height: 3px;
        border-radius: 2px;
        background: linear-gradient(90deg, var(--rh-mountains), var(--xx-line-2));
        opacity: .45;
    }
}
@media (min-width: 641px) {
    .rh-dash__swipe { display: none; }
}

/* "Agregar otro equipo": el QR del código. */
.rh-qr { display: block; margin: 8px auto; image-rendering: pixelated; border: 1px solid var(--xx-line); border-radius: 8px; }

/* ── Contadores en carrusel (11-nov) ──
   En el celular, TODAS las filas de tarjetas de contadores (.xx-stats: Expedientes, Checadas, Firmas, semana, Root…)
   son un carrusel como los Pendientes del panel: se deslizan con el dedo y se acomodan al soltar; se asoma la
   siguiente. La línea de abajo (fondo fijo de la caja, no se mueve al deslizar) avisa que hay más. En la computadora
   siguen en cuadrícula. */
@media (max-width: 640px) {
    .xx-stats {
        display: flex;
        flex-wrap: nowrap;
        gap: 10px;
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        overscroll-behavior-x: contain;
        padding-bottom: 12px;
        background: linear-gradient(90deg, var(--rh-mountains), var(--xx-line-2)) left bottom / 100% 3px no-repeat;
    }
    .xx-stats::-webkit-scrollbar { display: none; }
    .xx-stats > .xx-stat { flex: 0 0 62%; max-width: 62%; scroll-snap-align: start; }
    .xx-stats > .xx-stat:hover { transform: none; }
    .xx-stats::after { content: ''; flex: 0 0 1px; }
    /* Una sola tarjeta: no hay nada que deslizar, ni línea. */
    .xx-stats:has(> .xx-stat:only-child) { background: none; padding-bottom: 0; }
}

/* Tablas que se deslizan de lado: el texto oculto para lectores de pantalla (.visually-hidden, "Abrir") es absoluto y,
   sin esto, se ubicaba contra la página y no contra la tabla: se escapaba y ensanchaba TODA la página en el celular
   (lo vio Carlos en Expedientes, 11-nov). Con la caja posicionada, se queda dentro y se desliza con la tabla. */
.table-responsive { position: relative; }

/* ── Manual de Kaulo (11-nov) ──
   El "?" del inicio y la página del manual: índice fijo a la izquierda en la computadora; en el celular el índice va
   arriba como fila que se desliza (igual que los contadores) y las tarjetas a todo lo ancho. */
.rh-help-btn {
    width: 44px; height: 44px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--rh-mountains); color: #fff; font-size: 1.35rem; font-weight: 700; text-decoration: none;
    box-shadow: var(--xx-shadow-sm); transition: transform var(--xx-t), background var(--xx-t);
}
.rh-help-btn:hover, .rh-help-btn:focus-visible { color: #fff; transform: translateY(-1px); background: var(--xx-ink); }
.xx-page-head:has(.rh-help-btn) { flex-direction: row; align-items: flex-start; }

.rh-man { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.rh-man__nav {
    position: sticky; top: 16px;
    background: var(--xx-surface); border: 1px solid var(--xx-line); border-radius: var(--xx-r-lg); padding: 12px;
}
.rh-man__nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--xx-ink-2); font-weight: 700; padding: 2px 8px 8px; }
.rh-man__nav a { display: block; padding: 7px 9px; border-radius: 8px; color: var(--xx-ink); text-decoration: none; font-size: .88rem; }
.rh-man__nav a:hover { background: var(--xx-line); }
.rh-man__content { min-width: 0; }
.rh-man__card {
    background: var(--xx-surface); border: 1px solid var(--xx-line); border-radius: var(--xx-r-lg);
    padding: 20px 22px; margin-bottom: 16px; scroll-margin-top: 16px; overflow-wrap: break-word;
}
.rh-man__card--hero { border-top: 4px solid var(--xx-amber-400); }
.rh-man__card p, .rh-man__card li { color: var(--xx-ink-2); }
.rh-man__card ul, .rh-man__steps { padding-left: 1.25em; }
.rh-man__card li { margin: 5px 0; }
.rh-man__card .btn { margin: 4px 4px 0 0; }
.rh-man__title { font-size: 1.15rem; margin: 0 0 10px; }
.rh-man__sub { font-size: .95rem; margin: 14px 0 6px; }
.rh-man__steps li::marker { font-weight: 700; color: var(--rh-mountains); }
.rh-man__steps a { font-size: .85rem; margin-left: 4px; }
.rh-man__tip { background: var(--xx-amber-50, #fbf6e6); border-radius: 8px; padding: 9px 12px; font-size: .9rem; margin: 10px 0 0; }
.rh-man__foot { color: var(--xx-ink-2); font-size: .9rem; text-align: center; margin: 8px 0 24px; }

@media (max-width: 900px) {
    .rh-man { grid-template-columns: minmax(0, 1fr); }
    .rh-man__nav {
        position: static; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
        padding: 8px; -webkit-overflow-scrolling: touch;
    }
    .rh-man__nav::-webkit-scrollbar { display: none; }
    .rh-man__nav-title { display: none; }
    .rh-man__nav a { flex: 0 0 auto; white-space: nowrap; border: 1px solid var(--xx-line); }
    .rh-man__card { padding: 16px; }
}

/* ── Pie legal y páginas legales (12-nov) ── */
.rh-legal-links { max-width: var(--rh-wrap, 1200px); margin: 0 auto; padding: 18px 28px 28px; font-size: .8rem; color: var(--xx-ink-2);
    display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: space-between; border-top: 1px solid var(--xx-line); }
.rh-legal-links a { color: var(--xx-ink-2); }
.rh-legal-links a:hover { color: var(--xx-ink); }
.xx-auth__main .rh-legal-links { border-top: 0; padding: 18px 0 0; justify-content: center; text-align: center; max-width: 420px; }
.rh-legal-page { background: var(--xx-bg, #f4f6f3); }
.rh-legal-top { max-width: 860px; margin: 0 auto; padding: 22px 20px; display: flex; justify-content: space-between; align-items: center; }
.rh-legal { max-width: 860px; margin: 0 auto 24px; background: var(--xx-surface); border: 1px solid var(--xx-line); border-radius: var(--xx-r-lg);
    padding: clamp(20px, 4vw, 48px); line-height: 1.65; }
.rh-legal h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); margin-bottom: 4px; }
.rh-legal h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.rh-legal .legal__fecha { color: var(--xx-ink-2); font-size: .85rem; margin-bottom: 22px; }
.rh-legal li { margin: 5px 0; }
.rh-legal-page .rh-legal-links { max-width: 860px; border-top: 0; }

/* WhatsApp flotante del acceso. */
.rh-wa-float { position: fixed; right: 18px; bottom: 18px; z-index: 1030; display: inline-flex; align-items: center; gap: 8px;
    background: var(--xx-ink); color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 8px 16px 8px 8px; border-radius: 999px; }
.rh-wa-float:hover { color: #fff; transform: translateY(-2px); }
.rh-wa-float svg { width: 32px; height: 32px; padding: 6px; border-radius: 50%; background: #25d366; }
@media (max-width: 575.98px) { .rh-wa-float span { display: none; } .rh-wa-float { padding: 7px; } }
