/* VARIABLES */
:root {
    /*COLORES*/
    --bg: #f6f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e5e7eb;

    --primary: #3b82f6;
    /* Azul */
    --success: #16a34a;
    /* Verde */
    --danger: #dc2626;
    /* Rojo */
    --indigo: #4f46e5;
    /* Indigo */

    /*ESPACIADO*/
    --r: 12px;
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 24px rgba(0, 0, 0, 0.06);
    color-scheme: light;
}

/* RESETS */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body.layout {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 15px/1.6 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/*UTILIDADES MINIMAS*/
a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

.table__num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/*botones*/
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    transition: background .2, box-shadow .2, border-color .2;
}

.btn:hover {
    background: #65a4e4;
}

.btn:active {
    transform: translateY(0.5px);
}

.btn:focus-visible {
    outline: 2px solid #93c5fd;
    outline-offset: 2px;
}

.btn--primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn--primary:hover {
    filter: brightness(0.95);
}

.btn--sm {
    height: 32px;
    padding: 0 10px;
    font-size: 14px;
}

/*HEADER*/
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    padding: var(--s-4) var(--s-6);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    font-weight: 700;
}

.brand__mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--indigo);
    color: #fff;
    font-size: 12px;
}

.menu {
    display: flex;
    gap: var(--s-2);
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu__link {
    display: block;
    padding: var(--s-2) var(--s-3);
    border-radius: 10px;
    color: var(--muted);
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.menu__link:hover {
    background: #f3f4f6;
    color: var(--text);
}

.menu__link--active {
    background: #eef2ff;
    color: #1f2937;
}

.userchip {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.userchip__avatar {
    width: 24px;
    height: 24px;
    border-radius: 100px;
    object-fit: cover;
}

.userchip__name {
    font-weight: 500;
    font-size: 14px;
}

/* Item con submenu */
.menu__item--has-submenu {
    position: relative;
}

/* Disparador */
.menu__link--trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Flecha */
.menu__caret {
    font-size: 12px;
    opacity: .7;
}

/* Contenedor del submenu */
.menu__submenu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    margin: 8px 0 0;
    padding: var(--s-2) 0;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    z-index: 20;
}

/* Items del submenu */
.menu__submenu-item {
    margin: 0;
}

.menu__submenu-link {
    display: block;
    padding: var(--s-2) var(--s-4);
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
}

.menu__submenu-link:hover {
    background: #f3f4f6;
}

/* Mostrar submenu: hover o enfoque con teclado */
.menu__item--has-submenu:hover>.menu__submenu,
.menu__item--has-submenu:focus-within>.menu__submenu {
    display: block;
}

/* Oculto por defecto si usas [hidden] */
.menu__submenu[hidden] {
    display: none;
}


/*CONTENIDO PRINCIPAL*/
.content {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 var(--s-6);
}

.pagehead__title {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 600;
}

.pagehead_subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/*METRICAS*/
.metrics {
    display: grid;
    gap: var(--s-4);
    grid-template-columns: repeat(12, 1fr);
    /*grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));*/
    margin-top: var(--s-6);
}

.card {
    grid-column: span 4;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
    padding: var(--s-4);
}

@media (max-width: 900px) {
    .card {
        grid-column: span 6;
    }
}

@media (max-width: 600px) {
    .card {
        grid-column: span 12;
    }
}

.card__header {
    margin-bottom: var(--s-2);
}

.card__title {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    font-weight: 500;
}

.card__value {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: .2px;
}

.card--metric {
    background: #fafbff;
}

.card--metric[data-metric="tenants"].card__value {
    color: var(--primary);
}

.card--metric[data-metric="collected"].card__value {
    color: var(--success);
}

.card--metric[data-metric="spent"].card__value {
    color: var(--danger);
}

/*TABLAS*/
.panel {
    margin-top: var(--s-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: var(--shadow);
}

.panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-6);
    border-bottom: 1px solid var(--border);
}

.panel__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.table {
    width: 100%;
    overflow-x: auto;
}

.table__inner {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.table__head th {
    text-align: left;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    background: #f9fafb;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    position: sticky;
    top: 0;
}

.table__body td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    background: #fff;
}

.table__body tr:hover td {
    background: #fbfcff;
}

.actions {
    display: inline-flex;
    gap: var(--s-2);
}

/* Paginación */
.table__pagination {
    display: flex;
    gap: var(--s-2);
    align-items: center;
    justify-content: flex-start;
    /* o flex-end si la quieres a la derecha */
    padding: var(--s-4) var(--s-6);
    border-top: 1px solid var(--border);
}

.pager__btn {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 34px;
    height: 34px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}

.pager__btn:hover {
    background: #f3f4f6;
}

.pager__btn.is-active,
.pager__btn[aria-current="page"] {
    background: #eef2ff;
    /* acorde a tu active del menú */
    border-color: #c7d2fe;
    color: #1f2937;
    font-weight: 600;
}

.pager__btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.pager__btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* puntos suspensivos cuando hay muchas páginas */
.pager__ellipsis {
    color: var(--muted);
    padding: 0 4px;
    user-select: none;
}

/*FORMULARIO*/
.form {
    padding: var(--s-5);
}

.form__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-5);
    align-items: start;
}

@media(max-width:800px) {
    .form__grid {
        grid-template-columns: 1fr;
    }
}

.form__field {
    display: grid;
    gap: 6px;
    align-self: start;
}

.form__field--full {
    grid-column: 1/-1;
}

.form__label {
    font-weight: 600;
    color: var(--muted);
    font-size: 14px;
}

.form__req {
    color: var(--danger);
    margin-left: var(--s-1);
}

.form__input,
.form__select {
    width: 100%;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    box-shadow: 0 1px rgba(0, 0, 0, .02) inset;
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.form__error {
    display: none;
    color: var(--danger);
    font-size: var(--s-3);
}

.form .form__field:has(:is(input, select, textarea):invalid) .form__error {
    display: block;
}

.form__actions {
    margin-top: var(--s-6);
    display: flex;
    gap: var(--s-3);
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* hints */
.form__hint {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

/* archivo */
.form__input--file {
    padding: 8px 10px;
    /* apariencia coherente con inputs */
    background: #fff;
}

/* preview */
.form__preview {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form__preview img {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.form__preview-caption {
    color: var(--muted);
    font-size: 14px;
}

/* contraseña + toggle */
.form__password {
    position: relative;
    display: grid;
}

.form__password .form__input {
    padding-right: 42px;
}

.form__toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.form__toggle .icon {
    width: 18px;
    height: 18px;
    fill: #64748b;
}

.form__toggle[aria-pressed="true"] .icon {
    fill: #111827;
}

/*LOGIN*/
.auth__main {
    min-height: calc(100vh - 140px);
    display: grid;
    place-items: start center;
    padding: var(--s-6);
}

.auth__panel {
    width: 100%;
    max-width: 560px;
}

.auth__grid {
    grid-template-columns: 1fr;
}

.link {
    color: var(--indigo);
    font-weight: 600;
}

.link:hover {
    text-decoration: underline;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    user-select: none;
    cursor: pointer;
}

.check__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.check__box {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #fff;
    display: inline-block;
}

.check__input:checked+.check__box {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: inset 0 0 0 3px #fff;
}

.check__label {
    font-size: 14px;
    color: var(--text);
}

.check__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.form__actions--split {
    justify-content: space-between;
}

/* botón “fantasma”/outline */
.btn--ghost {
    background: #fff;
    color: var(--indigo);
    border-color: var(--indigo);
}

.btn--ghost:hover {
    filter: brightness(0.98);
}

/*flip login */
/* --- Flip 3D --- */
.flip {
    perspective: 1200px;
    position: relative;
}

/* Mantén altura “suave” al cambiar de cara */
.flip {
    transition: height .25s ease;
}

.flip__inner {
    position: relative;
    transform-style: preserve-3d;
    transition: transform .6s ease;
    min-height: 260px;
    /* asegúrate de que tenga algo de alto base */
}

.flip__face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    /* oculta cara posterior */
}

.flip__face--back {
    transform: rotateY(180deg);
}

/* Estado flipped */
.flip.is-flipped .flip__inner {
    transform: rotateY(180deg);
}

/* Accesibilidad: si el usuario prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .flip__inner {
        transition: none;
    }

    .flip {
        transition: none;
    }
}

/*MODAL*/
.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, .45);
}

.modal__dialog {
    position: relative;
    margin: 6vh auto 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: min(720px, 92vw);
    max-height: 88vh;
    overflow: auto;
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-6);
    border-bottom: 1px solid var(--border);
}

.modal__title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal__close {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

/*FOOTER*/
.footer {
    margin: 48px auto 24px;
    text-align: center;
    color: var(--muted);
}

footer__copy {
    margin: 0;
    font-size: 14px;
}