/* =============================================================================
   MetricIA — identidad visual
   Producto de analítica: la pantalla la ocupan los datos, no la decoración.
   Azul profundo institucional + verde para lo que suma + fondo claro de trabajo.
   ============================================================================= */

:root {
    --azul: #1f3864;
    --azul-claro: #2d5296;
    --azul-suave: #eef2f9;
    --verde: #0f9d58;
    --verde-suave: #e8f5ee;
    --ambar: #f2a53d;
    --rojo: #d64545;
    --rojo-suave: #fdeced;

    --texto: #16202f;
    --texto-2: #5b6779;
    --texto-3: #8a94a3;
    --borde: #e2e7ee;
    --fondo: #f6f8fb;
    --panel: #ffffff;

    --radio: 10px;
    --sombra: 0 1px 2px rgba(22, 32, 47, .06), 0 4px 14px rgba(22, 32, 47, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    background: var(--fondo);
    color: var(--texto);
    font-size: 14px;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
a { color: var(--azul-claro); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- estructura */

.app { display: flex; min-height: 100vh; }

.lateral {
    width: 220px;
    flex: 0 0 220px;
    background: var(--azul);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.marca {
    padding: 1.1rem 1.15rem;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.02em;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.marca span { color: var(--ambar); }
.marca small {
    display: block;
    font-size: .68rem;
    font-weight: 400;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .55);
    margin-top: .15rem;
}

.menu { padding: .6rem 0; flex: 1; overflow-y: auto; }
.menu a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1.15rem;
    color: rgba(255, 255, 255, .82);
    font-size: .9rem;
    border-left: 3px solid transparent;
}
.menu a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.menu a.active { background: rgba(255, 255, 255, .12); color: #fff; border-left-color: var(--ambar); font-weight: 600; }
.menu .grupo {
    padding: .9rem 1.15rem .3rem;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: rgba(255, 255, 255, .45);
}

.pie-lateral {
    padding: .8rem 1.15rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
    font-size: .78rem;
    color: rgba(255, 255, 255, .6);
}
.pie-lateral a { color: rgba(255, 255, 255, .85); }

.contenido { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.barra-superior {
    background: var(--panel);
    border-bottom: 1px solid var(--borde);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.principal { padding: 1.25rem 1.5rem 3rem; }

/* ---------------------------------------------------------------- paneles */

.panel {
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    margin-bottom: 1.1rem;
}
.panel-cab {
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--borde);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.panel-cuerpo { padding: 1rem; }
.panel-cuerpo.sin-padding { padding: 0; }

.nota {
    font-size: .8rem;
    color: var(--texto-2);
    margin: .2rem 0 0;
}

/* ---------------------------------------------------------------- KPIs */

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: .8rem;
    margin-bottom: 1.1rem;
}
.kpi {
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: .9rem 1rem;
    box-shadow: var(--sombra);
}
.kpi .titulo {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--texto-3);
    font-weight: 600;
}
.kpi .valor {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: .25rem 0 .1rem;
    font-variant-numeric: tabular-nums;
}
.kpi .detalle { font-size: .78rem; color: var(--texto-2); }
.kpi.destacado { border-top: 3px solid var(--verde); }

/* ---------------------------------------------------------------- tablas */

.tabla-scroll { overflow-x: auto; }

table.datos {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
table.datos thead th {
    background: var(--azul-suave);
    color: var(--azul);
    text-align: left;
    font-weight: 650;
    padding: .55rem .7rem;
    border-bottom: 1px solid var(--borde);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
table.datos tbody td {
    padding: .5rem .7rem;
    border-bottom: 1px solid var(--borde);
    vertical-align: top;
}
table.datos tbody tr:hover { background: #fafbfd; }
table.datos .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.datos .fuerte { font-weight: 650; }
table.datos tfoot td {
    padding: .55rem .7rem;
    border-top: 2px solid var(--borde);
    font-weight: 700;
    background: #fbfcfe;
}

/* ---------------------------------------------------------------- barras */

.barras { display: flex; flex-direction: column; gap: .5rem; }
.barra-fila { display: grid; grid-template-columns: 150px 1fr auto; gap: .7rem; align-items: center; }
.barra-fila .etiqueta {
    font-size: .84rem;
    color: var(--texto);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.barra-pista { background: var(--azul-suave); border-radius: 4px; height: 20px; overflow: hidden; }
.barra-valor { background: var(--azul-claro); height: 100%; border-radius: 4px; min-width: 2px; }
.barra-fila .monto {
    font-size: .84rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    color: var(--texto-2);
}
.barra-fila .monto b { color: var(--texto); }

/* ---------------------------------------------------------------- filtros */

.filtros {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
    align-items: flex-end;
}
.campo { display: flex; flex-direction: column; gap: .2rem; }
.campo label {
    font-size: .73rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--texto-3);
    font-weight: 600;
}
.campo input, .campo select {
    border: 1px solid var(--borde);
    border-radius: 7px;
    padding: .38rem .55rem;
    font-size: .86rem;
    font-family: inherit;
    background: #fff;
    color: var(--texto);
    min-width: 140px;
}
.campo input:focus, .campo select:focus {
    outline: none;
    border-color: var(--azul-claro);
    box-shadow: 0 0 0 3px rgba(45, 82, 150, .12);
}
.check { display: flex; align-items: center; gap: .4rem; font-size: .85rem; padding-bottom: .4rem; }

/* ---------------------------------------------------------------- botones */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 1px solid var(--borde);
    background: #fff;
    color: var(--texto);
    border-radius: 7px;
    padding: .4rem .8rem;
    font-size: .85rem;
    font-family: inherit;
    font-weight: 550;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #f4f6fa; text-decoration: none; }
.btn-primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.btn-primario:hover { background: var(--azul-claro); }
.btn-excel { background: var(--verde); border-color: var(--verde); color: #fff; }
.btn-excel:hover { background: #0c8449; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- etiquetas */

.tag {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.tag-ok { background: var(--verde-suave); color: #0b6b3d; }
.tag-alerta { background: #fdf3e3; color: #97620f; }
.tag-mal { background: var(--rojo-suave); color: #a32b2b; }
.tag-neutro { background: var(--azul-suave); color: var(--azul); }

.aviso {
    border-radius: var(--radio);
    padding: .7rem .9rem;
    font-size: .86rem;
    margin-bottom: 1rem;
    border: 1px solid;
}
.aviso-info { background: var(--azul-suave); border-color: #cddaf0; color: var(--azul); }
.aviso-error { background: var(--rojo-suave); border-color: #f3c6c6; color: #a32b2b; }
.aviso-ok { background: var(--verde-suave); border-color: #bfe3ce; color: #0b6b3d; }

.vacio { text-align: center; padding: 2.5rem 1rem; color: var(--texto-3); }

.cargando { color: var(--texto-3); font-size: .86rem; padding: 1rem; }

/* ---------------------------------------------------------------- login */

.login-caja {
    max-width: 380px;
    margin: 8vh auto;
    background: var(--panel);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 1.6rem;
}
.login-caja h1 { margin-bottom: .3rem; }
.login-caja .campo { margin-bottom: .8rem; }
.login-caja .campo input { width: 100%; }
.validation-message { color: var(--rojo); font-size: .8rem; }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
    .app { flex-direction: column; }
    .lateral { width: 100%; flex: none; height: auto; position: static; }
    .menu { display: flex; flex-wrap: wrap; padding: .3rem; }
    .menu .grupo { display: none; }
    .menu a { border-left: none; border-bottom: 3px solid transparent; padding: .5rem .8rem; }
    .menu a.active { border-left: none; border-bottom-color: var(--ambar); }
    .pie-lateral { display: none; }
    .principal { padding: 1rem; }
    .barra-fila { grid-template-columns: 110px 1fr auto; }
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff3cd;
    border-top: 1px solid #ffe69c;
    padding: .7rem 1.2rem;
    z-index: 1000;
    font-size: .86rem;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; font-weight: 700; }
