﻿/* Calidad del Servicio Móvil — dashboard autocontenido (marca gob.mx / CRT).
   No toca body/html: el layout del portal controla el fondo y el ancho global. */

.cm-wrap {
    --guinda: #611232;
    --guinda-dark: #4a0e26;
    --guinda-soft: #f7eef1;
    --guinda-border: #e3c8d2;
    --dorado: #c9a253;
    --text: #1d1d23;
    --text-muted: #6b5a60;
    --text-faint: #9a8a90;
    --surface: #ffffff;
    --surface-soft: #faf7f8;
    --border: #ececf1;
    --border-soft: #f0ebed;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow: 0 1px 2px rgba(20,12,18,.05);
    --shadow-card: 0 2px 14px rgba(74,14,38,.06);
    --cm-fs-data: 12px; /* tamaño de la información (barras y tabla) */
    --cm-fs-label: 14px; /* rótulos de filtro (SERVICIO, ENTIDAD...) */
    --cm-fs-control: 14px; /* texto dentro de selects e inputs */

    max-width: 1240px;
    margin: 0 auto;
    font-family: 'Noto Sans', sans-serif;
    color: var(--text);
}

    .cm-wrap *, .cm-wrap *::before, .cm-wrap *::after {
        box-sizing: border-box;
    }

/* ---------- Encabezado ---------- */
.cm-head {
    margin-bottom: 1.75rem;
}

    .cm-head h1 {
        font-size: 3rem;
        font-weight: 700;
        margin: 0 0 .4rem;
        letter-spacing: -.01em;
        color: var(--guinda);
    }

    .cm-head p {
        margin: 1rem 0 1rem;
        color: var(--text-muted);
        font-size: 1.2rem;
    }

.cm-context {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.cm-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--guinda-soft);
    color: var(--guinda);
    border: 1px solid var(--guinda-border);
    border-radius: 999px;
    padding: .35rem .85rem;
    font-size: 1rem;
    font-weight: 600;
}

    .cm-chip b {
        color: var(--text-faint);
        font-weight: 400;
    }

/* ---------- Filtros ---------- */
.cm-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 2rem;
}

.cm-field label {
    display: block;
    font-size: var(--cm-fs-label);
    font-weight: 700;
    color: var(--guinda);
    margin-bottom: .45rem;
}

/* Estilo ÚNICO para todos los controles de formulario (selects e inputs/textbox).
   Un solo lugar: cualquier cambio aplica a todos por igual. */
.cm-field select,
.cm-field input {
    width: 100%;
    font-family: inherit;
    font-size: var(--cm-fs-control);
    font-weight: 500;
    color: var(--text);
    background-color: var(--surface-soft);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .6rem .85rem;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}

/* Solo selects: flecha y comportamiento de lista desplegable. */
.cm-field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23611232' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .85rem center;
}

    .cm-field select:focus,
    .cm-field input:focus {
        outline: none;
        background-color: #fff;
        border-color: var(--guinda);
        box-shadow: 0 0 0 3px rgba(97,18,50,.1);
    }

    .cm-field select:disabled,
    .cm-field input:disabled {
        background-color: #f3eef0;
        color: #b6a9ae;
        cursor: not-allowed;
    }

/* ---------- Títulos de sección ---------- */
.cm-section-title {
    font-size: 1.5rem;
    color: var(--guinda);
    font-weight: 700;
    margin: 0 0 1.25rem;
    padding-bottom: .6rem;
    border-bottom: 2px solid var(--guinda-soft);
    display: flex;
    align-items: center;
    gap: .6rem;
}


/* ---------- Grid de gráficas ---------- */
.cm-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 1.25rem;
    margin-bottom: 2.75rem;
}

.cm-chart {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.3rem 1.4rem 1.5rem;
}

.cm-chart-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.15rem;
}

.cm-chart-title {
    font-size: .95rem;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
}

.cm-better {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: .2rem .55rem;
    white-space: nowrap;
}

/* ---------- Barras horizontales ---------- */
.cm-bar-row {
    display: grid;
    grid-template-columns: 92px 1fr 78px;
    align-items: center;
    gap: .65rem;
    padding: .28rem 0;
}

.cm-bar-name {
    font-size: var(--cm-fs-data);
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}

.cm-bar-row.is-best .cm-bar-name {
    font-weight: 700;
    color: var(--text);
}

.cm-bar-track {
    position: relative;
    height: 22px;
    background: var(--surface-soft);
    border-radius: 6px;
    overflow: hidden;
}

.cm-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border-radius: 6px;
    transition: width .7s cubic-bezier(.22,.61,.36,1);
}

.cm-bar-val {
    font-size: var(--cm-fs-data);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    text-align: right;
}

.cm-bar-row.is-best .cm-bar-val {
    color: var(--guinda);
}

.cm-best-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--dorado);
    margin-left: .35rem;
    vertical-align: middle;
}

/* ---------- Tabla ---------- */
.cm-count {
    font-size: .85rem;
    color: var(--text-faint);
    margin: 0 0 1rem;
}

.cm-table-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    padding: 2rem;
}

table.cm-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0px;
}

.cm-table thead th {
    text-align: left;
    letter-spacing: .04em;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--guinda);
    padding: 1.1rem 1.4rem;
    border-bottom: 2px solid var(--border-soft);
    white-space: nowrap;
}

.cm-col-rank {
    width: 1%;
}

.cm-table tbody td {
    padding: .95rem 1.4rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
    font-size: var(--cm-fs-data);
}

.cm-table tbody tr:last-child td {
    border-bottom: none;
}

.cm-table tbody tr {
    transition: background .12s;
}

    .cm-table tbody tr:hover {
        background: var(--surface-soft);
    }

.cm-rank {
    font-variant-numeric: tabular-nums;
    color: var(--text-faint);
    font-weight: 600;
}

.cm-op {
    display: flex;
    align-items: center;
    gap: .7rem;
    font-weight: 600;
}

.cm-op-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cm-badge {
    display: inline-block;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: .03em;
    color: var(--guinda);
    background: var(--guinda-soft);
    border: 1px solid var(--guinda-border);
    border-radius: 6px;
    padding: .2rem .55rem;
}

.cm-val-cell {
    display: flex;
    align-items: center;
    gap: .8rem;
    min-width: 200px;
}

.cm-val-track {
    flex: 1;
    height: 8px;
    background: var(--surface-soft);
    border-radius: 4px;
    overflow: hidden;
}

.cm-val-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .5s ease;
}

.cm-val-num {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: var(--cm-fs-data);
    white-space: nowrap;
    min-width: 92px;
    text-align: right;
}

/* ---------- Vacío ---------- */
.cm-empty, .cm-table-empty {
    text-align: center;
    color: var(--text-faint);
    padding: 2rem 1rem;
    font-style: italic;
    font-size: .9rem;
}

.cm-charts .cm-empty {
    grid-column: 1 / -1;
}

/* ---------- Responsive: tabla -> tarjetas (una por operador) ---------- */
@media (max-width: 860px) {
    /* Menos padding lateral en pantallas chicas. */
    .cm-wrap {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Barras: nombres más angostos para que quepan en celular. */
    .cm-bar-row {
        grid-template-columns: 78px 1fr 64px;
        gap: .45rem;
    }

    /* Ocultamos el encabezado de columnas: cada fila se vuelve tarjeta. */
    .cm-table thead {
        display: none;
    }

    .cm-table,
    .cm-table tbody {
        display: block;
        width: 100%;
    }

        /* Cada fila = una tarjeta con su propio borde, sombra y separación. */
        .cm-table tbody tr {
            display: block;
            background: var(--surface);
            border: 1px solid var(--border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-card);
            padding: .35rem 1.1rem;
            margin-bottom: 1rem;
        }

            .cm-table tbody tr:hover {
                background: var(--surface);
            }

        /* Cada celda = una línea "RÓTULO ........ dato". */
        .cm-table tbody td {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 1rem;
            width: 100%;
            min-width: 0;
            padding: .7rem 0;
            border-bottom: 1px solid var(--border-soft);
            text-align: right;
        }

        .cm-table tbody tr td:last-child {
            border-bottom: none;
        }

        /* Rótulo a la izquierda (tomado del data-label). */
        .cm-table tbody td::before {
            content: attr(data-label);
            flex: 0 0 auto;
            text-align: left;
            font-size: .72rem;
            text-transform: uppercase;
            letter-spacing: .04em;
            font-weight: 700;
            color: var(--text-faint);
        }

    /* Empujamos el dato hacia la derecha y dejamos que encoja sin salirse. */
    .cm-rank {
        margin-left: auto;
    }

    .cm-op {
        flex: 1 1 auto;
        min-width: 0;
        justify-content: flex-end;
    }

        .cm-op span {
            overflow: hidden;
            text-overflow: ellipsis;
        }

    .cm-val-cell {
        flex: 1 1 auto;
        min-width: 0;
        max-width: 72%;
    }

    .cm-val-num {
        min-width: 0;
    }

    /* Mensaje "sin resultados" ocupa toda la tarjeta. */
    .cm-table tbody td.cm-table-empty {
        display: block;
        text-align: center;
        border-bottom: none;
    }

        .cm-table tbody td.cm-table-empty::before {
            content: none;
        }
}

@media (prefers-reduced-motion: reduce) {
    .cm-bar-fill, .cm-val-fill {
        transition: none;
    }
}
