/* ── Glucube Design System ────────────────────────────────────────────── */
/* Tokens del «Glucube Design System» (claude.ai, 18-sep-2026). La fuente es la
   oficial (Google Sans Flex), recortada a los ejes wght 100–900 y opsz y al juego
   latino: de 4 MB (ttf) a ~120 KB (woff2). Antes no se cargaba y caía a Inter. */

@font-face {
    font-family: 'Google Sans Flex';
    src: url('fonts/GoogleSansFlex.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    --color-black: #000000;
    --color-white: #ffffff;
    /* escala de opacidad del manual: texto principal / secundario / terciario / deshabilitado */
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.75);
    --text-tertiary: rgba(0, 0, 0, 0.55);
    --text-disabled: rgba(0, 0, 0, 0.35);
    --border-default: #000000;
    --border-subtle: rgba(0, 0, 0, 0.35);
    /* paleta temática: solo para estados (rojo = alerta, forest = OK, naranja = aviso) */
    --color-warm-red: #f12027;
    --color-warm-orange: #ff4b00;
    --color-cool-forest: #0e664b;
    --tracking-default: -0.04em;
    --tracking-headline: -0.06em;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-family);
    background: #fff;
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Nav tab links ─────────────────────────────────────────────────────── */
.tab-link {
    text-decoration: none !important;
}
.tab-link:hover {
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

/* ── Period selector (RadioItems styled as toggle buttons) ─────────────── */
.period-selector label {
    padding: 9px 16px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    cursor: pointer;
    border-left: 1px solid rgba(0,0,0,0.15);
    color: rgba(0,0,0,.75);
    margin: 0 !important;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
}
.period-selector label:first-child {
    border-left: none;
}
.period-selector label:has(input:checked) {
    background: #000;
    color: #fff;
}
.period-selector label:hover:not(:has(input:checked)) {
    background: rgba(0,0,0,0.05);
}
.period-selector input {
    display: none;
}

/* ── View tabs (RadioItems styled as tabs) ─────────────────────────────── */
.view-tabs label {
    padding: 12px 22px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.02em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    color: rgba(0,0,0,.55);
    margin: 0 !important;
    transition: all 0.15s ease;
}
.view-tabs label:has(input:checked) {
    border-bottom: 2px solid #000;
    color: #000;
}
.view-tabs label:hover:not(:has(input:checked)) {
    color: rgba(0,0,0,.75);
}
.view-tabs input {
    display: none;
}

/* ── Year filter (RadioItems styled as segmented control) ──────────────── */
.year-filter-radio label {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    cursor: pointer;
    border-left: 1px solid rgba(0,0,0,0.15);
    color: rgba(0,0,0,.75);
    margin: 0 !important;
    transition: background 0.15s ease;
    display: inline-flex;
    align-items: center;
}
.year-filter-radio label:first-child {
    border-left: none;
}
.year-filter-radio label:has(input:checked) {
    background: #000;
    color: #fff !important;
}
.year-filter-radio label:hover:not(:has(input:checked)) {
    background: rgba(0,0,0,0.05);
}
.year-filter-radio input {
    display: none;
}

/* ── Pulse animation for status bar ──────────────────────────────────── */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── Panel de calidad (REG-000-01) ──────────────────────────────────────── */
.cal-strip {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1px;
    background: #000;
    border: 1px solid #000;
    margin-bottom: 28px;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}
.cal-card {
    border: 1px solid rgba(0,0,0,0.15);
    padding: 18px 20px 20px;
    background: #fff;
    min-width: 0;
}
.cal-card:hover { border-color: #000; }
.cal-row { display: grid; }
.cal-table { overflow-x: auto; }
.cal-table .cal-row { min-width: 1080px; }
.cal-big {
    font-size: 30px; font-weight: 500; letter-spacing: -0.04em;
    line-height: 1; margin-top: 12px;
}
.cal-sub {
    font-size: 11px; color: rgba(0,0,0,.55); letter-spacing: -0.01em; margin-top: 6px;
}
.cal-btn {
    background: #fff; color: #000; border: 1px solid #000; border-radius: 0;
    font-size: 12px; font-weight: 500; letter-spacing: -0.01em; padding: 9px 16px;
    cursor: pointer; font-family: inherit; transition: background 0.15s ease;
}
.cal-btn:hover { background: rgba(0,0,0,0.05); }
.cal-btn-solid { background: #000; color: #fff; }
.cal-btn-solid:hover { background: rgba(0,0,0,0.8); }

@media (max-width: 900px) {
    .cal-strip { grid-template-columns: repeat(2, 1fr); }
    .cal-grid { grid-template-columns: 1fr; }
}

/* Tooltip de cálculo en el nombre de cada indicador */
.cal-tip-target {
    cursor: help;
    border-bottom: 1px dotted rgba(0,0,0,0.35);
}
.cal-tip-target:hover { border-bottom-color: #000; }
.cal-tooltip { opacity: 1 !important; }
.cal-tooltip .tooltip-inner {
    max-width: 380px;
    text-align: left;
    background: #000;
    color: #fff;
    border-radius: 0;
    padding: 12px 14px;
    font-family: 'Google Sans Flex', Inter, system-ui, sans-serif;
    font-size: 12px;
    line-height: 1.45;
    letter-spacing: -0.01em;
}
.cal-tooltip .tooltip-arrow::before { border-top-color: #000; border-right-color: #000; }
.cal-tip-title { font-weight: 500; font-size: 13px; margin-bottom: 6px; }
.cal-tip-line { margin-top: 4px; color: rgba(255,255,255,0.85); }
.cal-tip-foot {
    margin-top: 8px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.55); font-size: 11px;
}
.cal-scope {
    display: inline-flex; align-items: center; padding: 8px 14px;
    font-size: 12px; font-weight: 500; background: #000; color: #fff; letter-spacing: -0.01em;
}

/* Estado de cada tarjeta: el verde (cumple) destaca más que el resto */
.cal-card-ok {
    border-color: #138A4B;
    background: linear-gradient(180deg, rgba(19,138,75,0.07) 0, #fff 120px);
}
.cal-card-ok:hover { border-color: #0E6B3A; }
.cal-strip-hero { grid-template-columns: 1.8fr repeat(5, 1fr); }
@media (max-width: 900px) {
    .cal-strip-hero { grid-template-columns: repeat(2, 1fr); }
    .cal-strip-hero > :first-child { grid-column: 1 / -1; }
}
.cal-cfg-row {
    display: grid;
    grid-template-columns: 1fr auto 280px;
    gap: 16px;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid rgba(0,0,0,0.07);
}
@media (max-width: 900px) {
    .cal-cfg-row { grid-template-columns: 1fr auto; }
    .cal-cfg-row > :last-child { display: none; }
}

/* ── Icono ⓘ con tooltip (dbc.Tooltip + .cal-tooltip) junto a títulos y KPI ── */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 6px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 600;
    font-style: normal;
    line-height: 1;
    text-transform: none;
    letter-spacing: 0;
    opacity: .5;
    cursor: help;
    vertical-align: middle;
    flex-shrink: 0;
    transition: opacity .15s ease;
}
.info-tip:hover, .info-tip:focus-visible { opacity: 1; outline: none; }

/* ── Movimiento (Glucube Design System: fundidos suaves, hover a opacidad .7,
      pulsado a .85; sin rebotes, sin escalados, sin desenfoques) ───────────── */

/* Indicador de carga de marca: tres «puntos» de GLUCUBE. que se encienden en secuencia */
.g-loader {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; padding: 48px 0;
}
.g-loader__dots { display: flex; gap: 8px; }
.g-loader__dot {
    width: 10px; height: 10px; background: var(--color-black);
    opacity: .15; animation: g-dot 1.2s ease-in-out infinite;
}
.g-loader__dot:nth-child(2) { animation-delay: .15s; }
.g-loader__dot:nth-child(3) { animation-delay: .3s; }
.g-loader__txt {
    font-size: 12px; font-weight: 400; letter-spacing: 0; color: var(--text-tertiary);
}
@keyframes g-dot {
    0%, 100% { opacity: .15; }
    35%      { opacity: 1; }
}

/* Mientras carga, la zona de contenido está vacía: sin altura mínima el indicador se
   centraba sobre la línea de la cabecera. Con ella queda debajo, en su sitio. */
#dashboard-monitoreo-content, #subs-content, #soporte-content, #cal-content, #el-metrics-content {
    min-height: 320px;
}

/* Botones y controles: la respuesta del manual (opacidad), con transición */
button, .year-filter-radio label, .period-selector label, .view-tabs label {
    transition: opacity .15s ease, background-color .15s ease, color .15s ease;
}
button:not(:disabled):hover { opacity: .7; }
button:not(:disabled):active { opacity: .85; }

@media (prefers-reduced-motion: no-preference) {
    /* Entrada del contenido: cada bloque funde y sube 8 px, escalonado */
    @keyframes g-fade-up {
        from { opacity: 0; transform: translateY(8px); }
        to   { opacity: 1; transform: none; }
    }
    #dashboard-monitoreo-content > div > *,
    #subs-content > div > *, #subs-cobro > *, #subs-tables > *,
    #soporte-content > *, #cal-content > div > *, #el-metrics-content > *,
    #retencion-panel > *, #calib-mes-panel > *, #monitoreo-status-bar > * {
        animation: g-fade-up .45s cubic-bezier(.2, .7, .2, 1) both;
    }
    #dashboard-monitoreo-content > div > :nth-child(2), #subs-content > div > :nth-child(2),
    #cal-content > div > :nth-child(2), #soporte-content > :nth-child(2) { animation-delay: .06s; }
    #dashboard-monitoreo-content > div > :nth-child(3), #subs-content > div > :nth-child(3),
    #cal-content > div > :nth-child(3), #soporte-content > :nth-child(3) { animation-delay: .12s; }
    #dashboard-monitoreo-content > div > :nth-child(n+4), #subs-content > div > :nth-child(n+4),
    #cal-content > div > :nth-child(n+4), #soporte-content > :nth-child(n+4) { animation-delay: .18s; }

    /* Aparición al hacer scroll (assets/animaciones.js): los bloques que están por
       debajo de la pantalla esperan ocultos y entran al llegar a ellos */
    .g-reveal { opacity: 0; animation: none !important; }
    .g-reveal.g-reveal--in { opacity: 1; animation: g-fade-up .55s cubic-bezier(.2, .7, .2, 1) both !important; }
    /* sus gráficos también esperan: barras y líneas se animan al aparecer */
    .g-reveal:not(.g-reveal--in) .js-plotly-plot .barlayer .point path,
    .g-reveal:not(.g-reveal--in) .js-plotly-plot .scatterlayer .js-line,
    .g-reveal:not(.g-reveal--in) .js-plotly-plot .barlayer text { animation: none !important; visibility: hidden; }

    /* Gráficos: las barras crecen desde la base y las líneas se dibujan */
    @keyframes g-bar-grow {
        from { transform: scaleY(0); }
        to   { transform: scaleY(1); }
    }
    .js-plotly-plot .barlayer .point path {
        transform-box: fill-box; transform-origin: 50% 100%;
        animation: g-bar-grow .6s cubic-bezier(.2, .7, .2, 1) both;
    }
    .js-plotly-plot .barlayer .point:nth-child(2n) path { animation-delay: .03s; }
    .js-plotly-plot .barlayer .point:nth-child(3n) path { animation-delay: .06s; }
    @keyframes g-draw { from { stroke-dashoffset: 3000; } to { stroke-dashoffset: 0; } }
    .js-plotly-plot .scatterlayer .js-line:not([style*="dasharray: 3"]):not([style*="dasharray: 4"]) {
        stroke-dasharray: 3000; animation: g-draw 1.1s cubic-bezier(.3, .6, .2, 1) both;
    }
    @keyframes g-fade { from { opacity: 0; } to { opacity: 1; } }
    .js-plotly-plot .pielayer .slice, .js-plotly-plot .scatterlayer .points,
    .js-plotly-plot .barlayer text, .js-plotly-plot .scatterlayer .textpoint {
        animation: g-fade .5s ease .35s both;
    }
}
