/* Portal "Mi cuenta" — mismos colores y tipografía que la página de Cresagas. */
:root {
    --bg: #F3F5F9;
    --surface: #FFFFFF;
    --surface-2: #EEF2F8;
    --ink: #101A33;
    --ink-soft: #4A5473;
    --ink-faint: #7C86A3;
    --navy: #10206B;
    --navy-deep: #0B1650;
    --flame: #2E6FBA;
    --flame-bright: #5AA3EA;
    --line: #D7DEEB;
    --ok: #1E7F4F;
    --ok-bg: #E3F4EA;
    --warn: #8A5A00;
    --warn-bg: #FFF3D6;
    --bad: #B42318;
    --bad-bg: #FDE7E5;
    --shadow: 0 18px 40px -28px rgba(16, 32, 107, 0.45);
    --radius: 14px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0A0F1E;
        --surface: #111A30;
        --surface-2: #17223D;
        --ink: #EAEFFC;
        --ink-soft: #B7C0DC;
        --ink-faint: #7C88AC;
        --navy: #1B2E86;
        --navy-deep: #060A18;
        --flame: #5AA3EA;
        --flame-bright: #8FC7FF;
        --line: #22304F;
        --ok: #5FD08F;
        --ok-bg: #12301F;
        --warn: #F2C35B;
        --warn-bg: #33270C;
        --bad: #FF8A7E;
        --bad-bg: #3A1512;
        --shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.7);
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "PT Sans", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
    font-family: "Oswald", "PT Sans", sans-serif;
    font-weight: 600;
    letter-spacing: .01em;
    margin: 0 0 .4em;
    line-height: 1.15;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

a { color: var(--flame); }

/* FocusOnNavigate enfoca el h1 al cambiar de página (lectores de pantalla); sin recuadro visible. */
h1:focus, h1:focus-visible { outline: none; }
button { font: inherit; }

/* ---- Barra superior ---- */
.barra {
    background: var(--navy-deep);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}
.barra-inner {
    max-width: 720px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.barra img { height: 34px; width: auto; background: #fff; border-radius: 8px; padding: 3px 5px; }
.barra .titulo { font-family: "Oswald", sans-serif; font-size: 1.1rem; letter-spacing: .03em; }
.barra .titulo small { display: block; font-family: "PT Sans", sans-serif; font-size: .78rem; opacity: .75; letter-spacing: 0; }
.barra .espacio { flex: 1; }
.barra button {
    background: transparent;
    color: #fff;
    border: 1.5px solid rgba(255, 255, 255, .4);
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
}
.barra button:hover { border-color: #fff; }

/* ---- Contenido ---- */
.contenido {
    max-width: 720px;
    margin: 0 auto;
    padding: 18px 16px 48px;
}

.tarjeta {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.volver {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 700;
}
.volver:hover { color: var(--flame); }

/* ---- Resumen de saldo ---- */
.saldo {
    background: linear-gradient(135deg, var(--navy-deep), var(--navy));
    color: #fff;
    border: none;
}
.saldo .etiqueta { opacity: .8; font-size: .9rem; }
.saldo .monto {
    font-family: "Oswald", sans-serif;
    font-size: 2.6rem;
    font-weight: 600;
    line-height: 1.1;
    margin: 2px 0 6px;
}
.saldo .detalle { font-size: .95rem; opacity: .9; }
.saldo .depto { font-size: .85rem; opacity: .75; margin-bottom: 12px; }

.estado-chip {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.estado-Pagado, .estado-Registrado { background: var(--ok-bg); color: var(--ok); }
.estado-Pendiente { background: var(--warn-bg); color: var(--warn); }
.estado-Vencido, .estado-Rechazado { background: var(--bad-bg); color: var(--bad); }
.saldo .estado-chip { margin-top: 10px; }

/* ---- Consumo promedio ---- */
.promedio .etiqueta { color: var(--ink-soft); font-size: .9rem; }
.promedio .valor {
    font-family: "Oswald", sans-serif;
    font-size: 2.2rem;
    font-weight: 600;
    line-height: 1.1;
    margin: 2px 0 4px;
}
.promedio .valor small { font-family: "PT Sans", sans-serif; font-size: 1rem; font-weight: 400; color: var(--ink-soft); }
.promedio .nota { margin: 0; }

/* ---- Menú de accesos ---- */
.accesos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}
.acceso {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    color: var(--ink);
    text-decoration: none;
    box-shadow: var(--shadow);
    min-height: 92px;
}
.acceso:hover { border-color: var(--flame); }
.acceso strong { font-family: "Oswald", sans-serif; font-weight: 500; font-size: 1.05rem; }
.acceso span { color: var(--ink-soft); font-size: .88rem; }
.acceso .icono { color: var(--flame); }

/* ---- Datos para pagar ---- */
.banco {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}
.banco:first-of-type { border-top: none; }
.banco .nombre { font-weight: 700; }
.fila-copiar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
}
.fila-copiar .dato { font-variant-numeric: tabular-nums; }
.fila-copiar .dato small { display: block; color: var(--ink-faint); font-size: .78rem; }
.btn-copiar {
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    border-radius: 8px;
    padding: 5px 10px;
    font-size: .85rem;
    cursor: pointer;
    white-space: nowrap;
}
.btn-copiar:hover { border-color: var(--flame); }
.aviso {
    background: var(--warn-bg);
    color: var(--warn);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: .9rem;
    margin-top: 8px;
}
.referencia .concepto { display: block; font-size: 1.35rem; letter-spacing: .03em; margin: 2px 0; }
.referencia .titular { display: block; margin-top: 2px; line-height: 1.3; }
.referencia {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

/* ---- Listas ---- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { border-top: 1px solid var(--line); }
.lista > li:first-child { border-top: none; }
.renglon {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    width: 100%;
    background: none;
    border: none;
    color: inherit;
    text-align: left;
    cursor: default;
}
button.renglon { cursor: pointer; }
.renglon .principal { flex: 1; min-width: 0; }
.renglon .principal strong { display: block; }
.renglon .principal small { color: var(--ink-faint); }
.renglon .importe { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.renglon .importe small { display: block; font-weight: 400; color: var(--ink-faint); font-size: .78rem; }
.importe.abono { color: var(--ok); }

.desglose {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 12px;
    margin: 0 0 12px;
    font-size: .92rem;
}
.desglose dl {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    margin: 0;
}
.desglose dt { color: var(--ink-soft); }
.desglose-periodo { margin: 0 0 8px; color: var(--ink-soft); font-size: .88rem; }
.desglose dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.desglose .total { font-weight: 700; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 4px; }
.desglose .acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.foto-medidor {
    width: 100%;
    max-width: 320px;
    border-radius: 10px;
    border: 1px solid var(--line);
    display: block;
    margin-top: 10px;
}

/* ---- Formularios y botones ---- */
.campo { margin-bottom: 14px; }
.campo label { display: block; font-weight: 700; margin-bottom: 4px; }
.campo small { display: block; color: var(--ink-faint); margin-top: 3px; }
.campo input {
    width: 100%;
    padding: 12px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 1rem;
}
.campo input:focus { outline: none; border-color: var(--flame); }
.campo input.clave { text-transform: uppercase; letter-spacing: .12em; font-variant-numeric: tabular-nums; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 999px;
    padding: 12px 22px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.btn-primario { background: var(--flame); color: #fff; }
.btn-primario:hover { filter: brightness(1.08); }
.btn-primario:disabled { opacity: .6; cursor: default; }
.btn-secundario { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }
.btn-bloque { width: 100%; }

.error {
    background: var(--bad-bg);
    color: var(--bad);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
}
.exito {
    background: var(--ok-bg);
    color: var(--ok);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 14px;
}
.nota { color: var(--ink-soft); font-size: .92rem; }
.vacio { color: var(--ink-faint); text-align: center; padding: 16px 0; }

/* ---- Entrar ---- */
.entrar {
    max-width: 420px;
    margin: 24px auto 0;
}
.entrar .logo { display: block; margin: 0 auto 12px; width: 110px; height: auto; }
.entrar h1 { text-align: center; }
.entrar .intro { text-align: center; color: var(--ink-soft); margin-bottom: 18px; }
.ayuda-clave {
    background: var(--surface-2);
    border-radius: 10px;
    padding: 12px;
    font-size: .9rem;
    color: var(--ink-soft);
    margin-top: 16px;
}

/* ---- Carga ---- */
.cargando-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--ink-soft);
}
.cargando-app img { animation: latido 1.4s ease-in-out infinite; }
@keyframes latido { 50% { opacity: .45; } }
.cargando { color: var(--ink-faint); padding: 20px 0; text-align: center; }

.pie {
    text-align: center;
    color: var(--ink-faint);
    font-size: .85rem;
    margin-top: 24px;
}

#blazor-error-ui {
    background: var(--bad-bg);
    color: var(--bad);
    bottom: 0;
    display: none;
    left: 0;
    padding: 12px 16px;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 12px; }

@media (prefers-color-scheme: dark) {
    /* El azul del botón en oscuro es claro: texto oscuro para que se lea (igual que la página). */
    .btn-primario { color: #071231; }
    /* El logo es azul marino: en fondo oscuro va sobre una placa clara. */
    .entrar .logo { background: #fff; border-radius: 16px; padding: 8px 10px; }
}

@media (max-width: 380px) {
    .accesos { grid-template-columns: 1fr; }
    .saldo .monto { font-size: 2.2rem; }
}
