/* Stage insight pages (/etapa/<key>): number tiles, chart panels, filter chips and tables. Seed look. */

.ins-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1rem;
    margin-bottom: 1.2rem;
}

.ins-back {
    color: var(--muted);
    text-decoration: none;
    font-size: .9rem;
}

.ins-back:hover { color: var(--ink-strong); }

.ins-title {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: 0;
    font-size: 1.6rem;
    color: var(--ink);
}

.ins-head .ins-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .8rem;
    color: var(--muted);
}

.ins-refresh {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    border: 1px solid var(--line-2);
    background: var(--surface);
    color: var(--ink-strong);
    font-size: 1.15rem;
    cursor: pointer;
}

.ins-refresh:hover:not(:disabled) { border-color: var(--line-strong); }
.ins-refresh:disabled { cursor: wait; opacity: .6; }

/* the one row of filters: crop switch and the active selections */
.ins-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    margin-bottom: 1rem;
}

.ins-switch {
    display: inline-flex;
    border: 1px solid var(--line-2);
    border-radius: 1000px;
    background: var(--surface);
    overflow: hidden;
}

.ins-switch button {
    padding: .3rem 1rem;
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font-weight: 600;
    cursor: pointer;
}

.ins-switch button.on {
    background: var(--accent-grad);
    color: var(--on-accent);
}

.ins-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .4rem .25rem .8rem;
    border: 1px solid var(--line-strong);
    border-radius: 1000px;
    background: var(--sel);
    color: var(--accent-ink);
    font-size: .85rem;
    font-weight: 600;
}

.ins-chip button {
    width: 1.3rem;
    height: 1.3rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.ins-chip button:hover { background: rgba(0, 0, 0, .08); }

.ins-hint {
    font-size: .8rem;
    color: var(--faint);
}

/* number tiles */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: .8rem;
    margin-bottom: 1.2rem;
}

.kpi {
    padding: .85rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.kpi-label {
    font-size: .8rem;
    color: var(--muted);
}

.kpi-value {
    margin-top: .15rem;
    font-size: 1.55rem;
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.02em;
    color: var(--kpi-ink);
}

.kpi-note {
    margin-top: .15rem;
    font-size: .76rem;
    color: var(--faint);
}

.kpi.warn .kpi-value { color: var(--warn-ink); }

/* chart panels */
.panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel {
    min-width: 0;
    padding: 1rem 1.1rem 1.1rem;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.panel.wide { grid-column: 1 / -1; }

.panel h2 {
    margin: 0 0 .7rem;
    font-size: 1.05rem;
    color: var(--ink-strong);
}

.panel h2 small {
    margin-left: .4rem;
    font-family: 'Archivo', system-ui, sans-serif;
    font-size: .76rem;
    color: var(--faint);
}

.panel .note {
    margin: .6rem 0 0;
    font-size: .76rem;
    color: var(--faint);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem 1rem;
    margin: -.3rem 0 .6rem;
    font-size: .78rem;
    color: var(--ink-2);
}

.legend i {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    margin-right: .3rem;
    border-radius: 3px;
    vertical-align: -1px;
}

/* tables */
.ins-table-wrap {
    overflow-x: auto;
}

.ins-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .84rem;
    background: var(--surface);
}

.ins-table th,
.ins-table td {
    padding: .35rem .6rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

.ins-table th {
    font-weight: 600;
    color: var(--muted);
    background: var(--surface-3);
}

.ins-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ins-table .wrap { white-space: normal; min-width: 14rem; }
.ins-table .ok { color: var(--accent-ink); font-weight: 600; }
.ins-table .todo { color: var(--warn-ink); font-weight: 600; }

details.rows {
    margin-top: .2rem;
}

details.rows summary {
    margin-bottom: .6rem;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink-2);
    cursor: pointer;
}

.ins-empty {
    padding: 1.2rem;
    border-radius: 16px;
    background: var(--surface-2);
    color: var(--muted);
}

.ins-problem {
    padding: .5rem .8rem;
    border-radius: 10px;
    background: var(--err-bg);
    color: var(--err-ink);
    font-size: .85rem;
}

@media (max-width: 900px) {
    .panels { grid-template-columns: 1fr; }
}
