/* popo131 — estilos propios, mobile-first */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1c2430;
    --muted: #5d6878;
    --border: #dde1e7;
    --primary: #1f5fa8;
    --primary-text: #ffffff;
    --danger: #b3261e;
    --ok: #1e7a3c;
    --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

.topbar {
    background: var(--primary);
    padding: 12px 16px;
}

.brand {
    color: var(--primary-text);
    font-weight: 700;
    text-decoration: none;
    font-size: 1.1rem;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}

h1 { font-size: 1.35rem; margin: 0 0 8px; }

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

.btn {
    display: inline-block;
    min-height: 44px;
    padding: 10px 18px;
    border: 0;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-text);
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 24px 16px;
}

@media (min-width: 768px) {
    .container { padding: 24px; }
    h1 { font-size: 1.6rem; }
}

/* Barra superior con usuario */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--primary-text); font-size: 0.9rem; }
.topbar-name { font-weight: 600; }
.topbar-link {
    color: var(--primary-text);
    background: none;
    border: 0;
    padding: 8px 0;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}
.inline { display: inline; margin: 0; }

/* Formularios */
.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.form { display: flex; flex-direction: column; gap: 6px; }
.form label { font-weight: 600; margin-top: 8px; }
.form input {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem; /* 16px evita el zoom automático en iOS */
    background: var(--surface);
    color: var(--text);
}
.form input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.btn-block { width: 100%; margin-top: 16px; }
.muted { color: var(--muted); font-size: 0.9rem; font-weight: 400; }

/* Mensajes */
.alert { padding: 12px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; }
.alert-ok { color: var(--ok); background: #e9f6ee; border-color: #b9e0c7; }
.alert-error { color: var(--danger); background: #fdecea; border-color: #f5c2bd; }

/* Gestión de usuarios (H7.1) */
h2 { font-size: 1.1rem; margin: 0 0 8px; }
.encabezado { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lista { list-style: none; margin: 12px 0 0; padding: 0; }
.lista-item { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-top: 1px solid var(--border); }
.lista-item a { display: flex; gap: 10px; align-items: baseline; text-decoration: none; font-size: 1.05rem; }
.lista-item .depto { min-width: 3.5em; }
.lista-item .muted { overflow-wrap: anywhere; }
.inactivo { opacity: 0.65; }
.badge { display: inline-block; font-size: 0.78rem; padding: 2px 8px; border-radius: 999px; background: #e8eef7; color: var(--primary); margin-right: 4px; }
.badge-off { background: #fdecea; color: var(--danger); }
.campo-error { color: var(--danger); font-size: 0.9rem; }
.form input[aria-invalid="true"] { border-color: var(--danger); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400 !important; margin-top: 16px !important; }
.check input { min-height: 0; width: 22px; height: 22px; margin-top: 2px; flex: none; }
.btn-secundario { background: #e8eef7; color: var(--primary); }
.btn-peligro { background: var(--danger); }
.password-temporal code { display: block; font-size: 1.6rem; letter-spacing: 0.08em; text-align: center; padding: 12px; background: var(--bg); border-radius: var(--radius); user-select: all; }
@media (min-width: 768px) {
    .lista-item { flex-direction: row; align-items: baseline; gap: 16px; }
    .lista-item a { flex: 0 0 40%; }
    .lista-item .muted { flex: 1; }
}

/* Estado de cuenta (H2.1) */
.cifra { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: var(--radius); margin: 8px 0 12px; }
.cifra-deuda { background: #fdecea; color: var(--danger); }
.cifra-ok { background: #e9f6ee; color: var(--ok); }
.cifra-etiqueta { font-size: 0.9rem; font-weight: 600; }
.cifra-monto { font-size: 1.8rem; line-height: 1.2; }
.cifra-ok .cifra-monto { font-size: 1.35rem; }
.cifra-nota { font-size: 0.95rem; }
.datos { margin: 0 0 8px; }
.datos > div { padding: 10px 0; border-top: 1px solid var(--border); }
.datos dt { font-weight: 600; }
.datos dd { margin: 4px 0 0; }
.badge-ok { background: #e9f6ee; color: var(--ok); }

/* Saldos iniciales (H7.2) */
.opciones { border: 0; padding: 0; margin: 8px 0 0; }
.opciones legend { font-weight: 600; padding: 0; }
.opciones .check { margin-top: 8px !important; }
.lista-item.historial { flex-direction: column !important; align-items: flex-start !important; gap: 2px; }
.anulado .monto { text-decoration: line-through; color: var(--muted); }
.saldo-previo { border-top: 1px solid var(--border); padding-top: 10px; }

/* Gastos (H3.3) */
.form select {
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
}
.form input[type="file"] { padding: 8px; }
.form select[aria-invalid="true"] { border-color: var(--danger); }
.lista-item.gasto { flex-direction: column !important; align-items: stretch !important; gap: 2px; }
.gasto-cabeza { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.gasto-cabeza .monto { min-width: 6.5em; }
.anulado .gasto-cabeza span { text-decoration: line-through; color: var(--muted); }
.anular summary { cursor: pointer; color: var(--danger); padding: 6px 0; width: max-content; }
.anular .form { padding: 8px 0; }

/* Contribución (H2.2) */
.medidor { width: 100%; height: 14px; margin: 4px 0 8px; }
.total-gastos { margin: 8px 0; font-size: 1.05rem; }

/* Mis pagos (H2.3) */
.lista-item.pago { flex-direction: column !important; align-items: stretch !important; gap: 2px; }
.motivo { margin: 6px 0 0; font-size: 0.95rem; }
.centrado { text-align: center; }

/* Revisión de fichas y recibo (H3.1) */
.ficha-enlace { display: flex; gap: 12px; align-items: flex-start; color: inherit; text-decoration: none; width: 100%; }
.ficha-datos { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.miniatura { width: 72px; height: 96px; object-fit: cover; border-radius: var(--radius); background: var(--bg); flex: none; }
.foto-ficha { display: block; max-width: 100%; height: auto; border-radius: var(--radius); }
.badge-aviso, .alert-aviso { background: #fff4e0; color: #8a5300; }
.alert-aviso { border-color: #f0d29a; }
.btn-whatsapp { background: #128c4a; }
.enlace-recibo code { display: block; word-break: break-all; padding: 10px; background: var(--bg); border-radius: var(--radius); user-select: all; }
.recibo-monto { font-size: 2rem; font-weight: 700; margin: 4px 0 8px; }

/* Meses pagados (H2.4) */
.lista-item.mes { flex-direction: column !important; align-items: stretch !important; gap: 2px; }
.mes-cabeza { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.mes-cabeza strong { min-width: 5.5em; }
.mes-monto { margin-left: auto; font-weight: 600; }
.aplicaciones { list-style: none; margin: 4px 0 0; padding: 0 0 0 12px; border-left: 3px solid var(--border); font-size: 0.92rem; color: var(--muted); }
.aplicaciones li { padding: 2px 0; }

/* Salud financiera (H3.2) */
.resumen-mes dd { font-size: 1.15rem; font-weight: 600; }
.dif { color: var(--ok); }
.dif.negativo { color: var(--danger); }
.lista-item.moroso { flex-wrap: wrap; gap: 4px 12px; }
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.tabla { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.tabla th, .tabla td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.tabla th[scope="row"], .tabla thead th:first-child { text-align: left; }
.tabla tfoot th, .tabla tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.accesos { display: flex; flex-wrap: wrap; gap: 8px; }

/* Verificación en dos pasos (H4.0) */
.qr-2fa { display: flex; justify-content: center; align-items: center; min-height: 220px; margin: 8px 0 12px; padding: 12px; background: #fff; border-radius: var(--radius); }
.qr-2fa img, .qr-2fa canvas { max-width: 100%; height: auto; }
.secreto-2fa code { display: block; font-size: 1.15rem; letter-spacing: 0.06em; text-align: center; word-break: break-all; padding: 10px; background: var(--bg); border-radius: var(--radius); user-select: all; }

/* Avisos (H5.1) */
.form textarea {
    min-height: 140px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text);
    resize: vertical;
}
.form textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.form textarea[aria-invalid="true"] { border-color: var(--danger); }
.aviso-mensaje { overflow-wrap: anywhere; }

/* Avisos del condómino y antirrebote (H5.2) */
.aviso-nuevo { border-left: 4px solid #f0a73a; padding-left: 10px; }
.banner-aviso a { font-weight: 600; }
.en-espera, button:disabled { opacity: 0.55; cursor: wait; }
a.en-espera { pointer-events: none; }

/* Configuración (H7.4): fieldset solo para deshabilitar el formulario sin 2FA */
.form fieldset.campos { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
