/* =====================================================================
   Entradas > Consultas (Informe, Estado y Detalle de ingresos).
   Prefijo eq- para no chocar con el resto de app.css.
   ===================================================================== */

.eq-page {
    --eq-ink: #0f223e;
    --eq-muted: #5b6b83;
    --eq-line: #dbe4ef;
    --eq-card: #ffffff;
    --eq-soft: #f1f5fb;
    display: grid;
    gap: 14px;
    align-content: start;
    /* En escritorio .page-shell se estira al alto de la pestaña y encoge a sus
       hijos; estas pantallas son largas (tablero + grilla) y se desplazan
       completas, con la grilla acotada a su propio alto. */
    flex: 0 0 auto !important;
    min-height: auto !important;
}

.eq-page > * { min-width: 0; }

.eq-table-card .data-table-wrap { max-height: 70vh; }

/* ---------- Encabezado ---------- */

.eq-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px 24px;
    padding: 20px 24px;
    border-radius: 16px;
    color: #ffffff;
    background: linear-gradient(120deg, #0f223e 0%, #183f78 55%, #2563eb 100%);
    box-shadow: 0 10px 30px -14px rgba(15, 34, 62, 0.55);
    isolation: isolate;
}

.eq-hero::before {
    content: "";
    position: absolute;
    inset: -40% -10% auto auto;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 65%);
    z-index: -1;
    animation: eq-float 12s ease-in-out infinite alternate;
}

.eq-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
    z-index: -1;
}

.eq-hero-teal { background: linear-gradient(120deg, #0f223e 0%, #0f5f6b 55%, #0d9488 100%); }
.eq-hero-violet { background: linear-gradient(120deg, #0f223e 0%, #3b2a7a 55%, #7c3aed 100%); }

.eq-hero-text { display: grid; gap: 4px; max-width: 720px; }

.eq-hero-kicker {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.75;
}

.eq-hero h1 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.eq-hero p {
    margin: 0;
    font-size: 0.88rem;
    opacity: 0.85;
}

.eq-hero-meta { display: flex; flex-wrap: wrap; gap: 8px; }

.eq-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(6px);
    font-size: 0.8rem;
    font-weight: 600;
}

.eq-pill b {
    font-size: 0.66rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}

.eq-hero-art {
    position: absolute;
    right: 22px;
    top: 14px;
    width: 64px;
    height: 64px;
    fill: none;
    stroke: rgba(255, 255, 255, 0.22);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    z-index: -1;
}

@keyframes eq-float {
    from { transform: translate(0, 0); }
    to { transform: translate(-60px, 40px); }
}

/* ---------- Filtro ---------- */

.eq-filter-card {
    display: grid;
    gap: 12px;
    padding: 14px 18px;
    border: 1px solid var(--eq-line);
    border-radius: 14px;
    background: var(--eq-card);
    box-shadow: 0 1px 2px rgba(15, 34, 62, 0.06);
}

.eq-filter-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 14px;
}

.eq-filter-grid > label {
    display: grid;
    gap: 4px;
    width: var(--field-width, 220px);
    max-width: 100%;
}

.eq-filter-grid input:not([type="checkbox"]) { width: 100%; }

.eq-filter-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.eq-range-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.eq-chip {
    border: 1px solid var(--eq-line);
    background: var(--eq-soft);
    color: #35506f;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.eq-chip:hover { border-color: #93b4e6; transform: translateY(-1px); }

.eq-chip.is-active {
    background: #183556;
    border-color: #183556;
    color: #ffffff;
}

.eq-search-button { display: inline-flex; align-items: center; gap: 8px; min-width: 140px; justify-content: center; }

.eq-search-button svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.eq-check {
    display: inline-flex !important;
    grid-auto-flow: column;
    align-items: center;
    gap: 8px !important;
    width: auto !important;
    height: 36px;
    padding: 0 12px;
    border: 1px dashed var(--eq-line);
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #35506f;
    cursor: pointer;
}

.eq-warning {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #fcd34d;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ---------- Cuerpo ---------- */

.eq-body {
    position: relative;
    display: grid;
    gap: 14px;
    min-width: 0;
}

/* ---------- Indicadores ---------- */

.eq-kpis {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.eq-kpi {
    --tone: #475569;
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 4px;
    padding: 14px 16px 14px 16px;
    border: 1px solid var(--eq-line);
    border-radius: 14px;
    background: var(--eq-card);
    box-shadow: 0 1px 2px rgba(15, 34, 62, 0.06);
    animation: eq-rise 420ms ease both;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.eq-kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 24px -14px rgba(15, 34, 62, 0.45); }

.eq-kpi::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--tone);
}

.eq-kpi::after {
    content: "";
    position: absolute;
    right: -30px;
    bottom: -30px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: var(--tone);
    opacity: 0.06;
}

.eq-kpi.tone-blue { --tone: #2563eb; }
.eq-kpi.tone-green { --tone: #16a34a; }
.eq-kpi.tone-amber { --tone: #d97706; }
.eq-kpi.tone-red { --tone: #dc2626; }
.eq-kpi.tone-violet { --tone: #7c3aed; }
.eq-kpi.tone-slate { --tone: #475569; }

.eq-kpis .eq-kpi:nth-child(2) { animation-delay: 50ms; }
.eq-kpis .eq-kpi:nth-child(3) { animation-delay: 100ms; }
.eq-kpis .eq-kpi:nth-child(4) { animation-delay: 150ms; }
.eq-kpis .eq-kpi:nth-child(5) { animation-delay: 200ms; }
.eq-kpis .eq-kpi:nth-child(6) { animation-delay: 250ms; }

.eq-kpi-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: color-mix(in srgb, var(--tone) 12%, transparent);
}

.eq-kpi-icon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--tone);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.eq-kpi-label {
    color: var(--eq-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding-right: 40px;
}

.eq-kpi-value {
    color: var(--eq-ink);
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.eq-kpi-foot { color: #64748b; font-size: 0.76rem; }

.eq-kpi-meter {
    height: 6px;
    border-radius: 999px;
    background: #eef2f8;
    overflow: hidden;
}

.eq-kpi-meter > i {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #f59e0b, #16a34a);
    transition: width 600ms cubic-bezier(.2, .8, .2, 1);
}

@keyframes eq-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Tarjetas ---------- */

.eq-grid-2,
.eq-grid-3 {
    display: grid;
    gap: 14px;
    align-items: stretch;
}

.eq-grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.eq-grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

.eq-card {
    display: grid;
    align-content: start;
    gap: 12px;
    min-width: 0;
    padding: 16px 18px;
    border: 1px solid var(--eq-line);
    border-radius: 14px;
    background: var(--eq-card);
    box-shadow: 0 1px 2px rgba(15, 34, 62, 0.06);
    animation: eq-rise 480ms ease both;
}

.eq-span-2 { grid-column: 1 / -1; }

.eq-card > header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 6px 10px;
}

.eq-card h2 { margin: 0; color: var(--eq-ink); font-size: 0.98rem; font-weight: 800; }

.eq-card-note { color: #64748b; font-size: 0.76rem; }

.eq-callout {
    padding: 8px 12px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.8rem;
}

.eq-table-card { min-height: 320px; }

/* ---------- Tendencia ---------- */

.eq-trend svg { width: 100%; height: auto; display: block; }

.eq-grid-line { stroke: #e8eef7; stroke-width: 1; }

.eq-axis { fill: #7b8aa1; font-size: 11px; font-variant-numeric: tabular-nums; }
.eq-axis-left { text-anchor: end; }
.eq-axis-right { text-anchor: start; fill: #b45309; }
.eq-axis-x { text-anchor: middle; }

.eq-bar {
    fill: url(#eqBarGrad);
    transform-box: fill-box;
    transform-origin: bottom;
    animation: eq-grow 600ms cubic-bezier(.2, .8, .2, 1) both;
    cursor: pointer;
}

.eq-bar:hover { fill: #f59e0b; }

@keyframes eq-grow {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

.eq-line {
    fill: none;
    stroke: #f59e0b;
    stroke-width: 2.4;
    stroke-linejoin: round;
    stroke-linecap: round;
    stroke-dasharray: 4000;
    stroke-dashoffset: 4000;
    animation: eq-draw 1400ms ease forwards 300ms;
}

.eq-area { opacity: 0; animation: eq-fade 900ms ease forwards 700ms; }

.eq-dot { fill: #ffffff; stroke: #f59e0b; stroke-width: 2; opacity: 0; animation: eq-fade 400ms ease forwards 1200ms; }

@keyframes eq-draw { to { stroke-dashoffset: 0; } }
@keyframes eq-fade { to { opacity: 1; } }

.eq-trend-legend { display: flex; gap: 16px; justify-content: center; color: var(--eq-muted); font-size: 0.78rem; }
.eq-trend-legend span { display: inline-flex; align-items: center; gap: 6px; }
.eq-key-bar { width: 12px; height: 12px; border-radius: 3px; background: #2563eb; }
.eq-key-line { width: 16px; height: 3px; border-radius: 3px; background: #f59e0b; }

.eq-chart-empty {
    display: grid;
    place-items: center;
    min-height: 160px;
    border: 1px dashed var(--eq-line);
    border-radius: 12px;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ---------- Dona ---------- */

.eq-donut {
    display: grid;
    grid-template-columns: minmax(130px, 170px) 1fr;
    align-items: center;
    gap: 14px;
}

.eq-donut svg { width: 100%; height: auto; overflow: visible; }


.eq-donut-track { fill: none; stroke: #eef2f8; stroke-width: 14; }

.eq-donut-seg {
    fill: none;
    stroke-width: 14;
    cursor: pointer;
    transition: opacity 180ms ease, stroke-width 180ms ease;
    animation: eq-fade 600ms ease both;
}

.eq-donut-seg:hover { stroke-width: 17; }
.eq-donut-seg.is-dim { opacity: 0.25; }

.eq-donut-value { fill: var(--eq-ink); font-size: 17px; font-weight: 800; text-anchor: middle; }
.eq-donut-label { fill: #7b8aa1; font-size: 8.5px; font-weight: 700; text-anchor: middle; text-transform: uppercase; letter-spacing: 0.08em; }

.eq-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }

.eq-legend li {
    display: grid;
    grid-template-columns: 10px 1fr auto 46px;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: 0.8rem;
    transition: background 140ms ease;
}

.eq-legend li.is-clickable { cursor: pointer; }
.eq-legend li.is-clickable:hover { background: var(--eq-soft); }
.eq-legend li.is-active { background: #e8f0fc; box-shadow: inset 0 0 0 1px #bcd0f1; }
.eq-legend li.is-zero { opacity: 0.5; }
.eq-legend i { width: 10px; height: 10px; border-radius: 3px; }
.eq-legend-name { color: #35506f; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eq-legend strong { color: var(--eq-ink); font-variant-numeric: tabular-nums; }
.eq-legend small { color: #7b8aa1; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Ranking ---------- */

.eq-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.eq-rank li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; }

.eq-rank-pos {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--eq-soft);
    color: #35506f;
    font-size: 0.74rem;
    font-weight: 800;
}

.eq-rank li:first-child .eq-rank-pos { background: #fef3c7; color: #92400e; }

.eq-rank-body { display: grid; gap: 4px; min-width: 0; }

.eq-rank-head { display: flex; justify-content: space-between; gap: 10px; font-size: 0.82rem; }

.eq-rank-name { color: #35506f; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.eq-rank-head strong { color: var(--eq-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.eq-rank-track { height: 7px; border-radius: 999px; background: #eef2f8; overflow: hidden; }

.eq-rank-track > i {
    display: block;
    height: 100%;
    border-radius: 999px;
    animation: eq-slide 700ms cubic-bezier(.2, .8, .2, 1) both;
    transform-origin: left;
}

@keyframes eq-slide { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.eq-rank small { color: #7b8aa1; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.eq-rank-empty { display: block !important; color: #94a3b8; font-size: 0.84rem; }

/* ---------- Recorrido de estados ---------- */

.eq-flow {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.eq-stage {
    --stage: #64748b;
    position: relative;
    overflow: hidden;
    display: grid;
    justify-items: start;
    gap: 2px;
    padding: 12px 14px 16px;
    border: 1px solid var(--eq-line);
    border-radius: 14px;
    background: linear-gradient(160deg, color-mix(in srgb, var(--stage) 9%, #ffffff) 0%, #ffffff 60%);
    text-align: left;
    font: inherit;
    cursor: pointer;
    animation: eq-rise 420ms ease both;
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease, border-color 160ms ease;
}

.eq-stage:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -16px color-mix(in srgb, var(--stage) 80%, #000); }

.eq-stage.is-active {
    border-color: var(--stage);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--stage) 35%, transparent), 0 12px 24px -16px var(--stage);
}

.eq-stage.is-dim { opacity: 0.55; }
.eq-stage.is-empty .eq-stage-count { color: #94a3b8; }

.eq-stage-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin-bottom: 4px;
    border-radius: 9px;
    background: var(--stage);
    box-shadow: 0 6px 14px -6px var(--stage);
}

.eq-stage-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.eq-stage-name { color: #35506f; font-size: 0.74rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }

.eq-stage-count { color: var(--eq-ink); font-size: 1.6rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }

.eq-stage-share,
.eq-stage-units { color: #64748b; font-size: 0.72rem; }

.eq-stage-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: var(--stage);
    border-radius: 0 4px 4px 0;
    transition: width 600ms cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Solicitado vs recepcionado ---------- */

.eq-versus { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }

.eq-gauge {
    --p: 0;
    position: relative;
    width: 120px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: conic-gradient(#16a34a calc(var(--p) * 1%), #eef2f8 0);
    display: grid;
    place-items: center;
    transition: background 400ms ease;
}

.eq-gauge-inner {
    display: grid;
    place-items: center;
    width: 86px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: inset 0 2px 6px rgba(15, 34, 62, 0.08);
}

.eq-gauge-inner strong { color: var(--eq-ink); font-size: 1.15rem; font-weight: 800; line-height: 1; }
.eq-gauge-inner span { color: #7b8aa1; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

.eq-versus-bars { display: grid; gap: 10px; }

.eq-vbar { display: grid; grid-template-columns: 96px 1fr auto; gap: 8px; align-items: center; font-size: 0.8rem; }
.eq-vbar span { color: #35506f; font-weight: 700; }
.eq-vbar strong { color: var(--eq-ink); font-variant-numeric: tabular-nums; }
.eq-vbar-track { height: 10px; border-radius: 999px; background: #eef2f8; overflow: hidden; }
.eq-vbar-track > i { display: block; height: 100%; border-radius: 999px; transition: width 600ms cubic-bezier(.2, .8, .2, 1); }
.eq-vbar-track > i.is-sol { background: linear-gradient(90deg, #93c5fd, #2563eb); }
.eq-vbar-track > i.is-rec { background: linear-gradient(90deg, #86efac, #16a34a); }
.eq-vbar-track > i.is-pen { background: linear-gradient(90deg, #fcd34d, #d97706); }

.eq-lines-split { display: grid; gap: 6px; }

.eq-stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #eef2f8; }
.eq-stack > i { display: block; height: 100%; transition: width 600ms ease; }

.eq-stack-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--eq-muted); font-size: 0.74rem; }
.eq-stack-legend span { display: inline-flex; align-items: center; gap: 5px; }
.eq-stack-legend i { width: 9px; height: 9px; border-radius: 3px; }

/* ---------- Celdas de la grilla ---------- */

td.eq-state { white-space: nowrap; }

td.eq-state::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--dot, #94a3b8);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, #94a3b8) 20%, transparent);
    vertical-align: middle;
}

td.eq-state { font-weight: 700; color: color-mix(in srgb, var(--dot, #475569) 80%, #0f223e); }

td.eq-state-10 { --dot: #94a3b8; }
td.eq-state-20 { --dot: #0ea5e9; }
td.eq-state-30 { --dot: #f59e0b; }
td.eq-state-40 { --dot: #22c55e; }
td.eq-state-50 { --dot: #8b5cf6; }
td.eq-state-60 { --dot: #15803d; }
td.eq-state-70 { --dot: #dc2626; }
td.eq-state-90 { --dot: #64748b; }
td.eq-state-reubicado { --dot: #2563eb; }

td.eq-cell-warn { color: #b45309; font-weight: 700; }
td.eq-cell-violet { color: #6d28d9; font-weight: 700; }
td.eq-cell-strong { font-weight: 800; color: #0f223e; }

/* ---------- Pantallas angostas ---------- */

@media (max-width: 720px) {
    .eq-hero { padding: 16px; }
    .eq-hero h1 { font-size: 1.25rem; }
    .eq-hero-art { display: none; }
    .eq-donut { grid-template-columns: 1fr; justify-items: center; }
    .eq-donut svg { max-width: 170px; }
    .eq-legend { width: 100%; }
    .eq-versus { grid-template-columns: 1fr; justify-items: center; }
    .eq-versus-bars { width: 100%; }
    .eq-filter-grid > label { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .eq-page *, .eq-page *::before, .eq-page *::after {
        animation: none !important;
        transition: none !important;
    }
    .eq-line { stroke-dashoffset: 0; }
    .eq-area, .eq-dot { opacity: 1; }
}

/* La dona se apila cuando su tarjeta es angosta, para no cortar la leyenda. */
.eq-card { container-type: inline-size; }

@container (max-width: 400px) {
    .eq-donut { grid-template-columns: 1fr; justify-items: center; }
    .eq-donut svg { max-width: 160px; }
    .eq-legend { width: 100%; }
}
