/* Portal del consorcio - estilos.
   Pensado para celular primero: lo que esta fuera de un @media es el diseno chico;
   los @media (min-width) lo amplian. */

:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #1c2430;
    --muted: #687383;
    --line: #d8dee6;
    --nav: #17202b;
    --nav-soft: #222d3a;
    --accent: #0d9488;
    --accent-strong: #0f766e;
    --danger: #b42318;
    --credit: #7a4b00;
    --ok: #067647;
    --warn-bg: #fff7e6;
    --radius: 10px;
    --gutter: 14px;
}

* {
    box-sizing: border-box;
}

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

body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.4;
    margin: 0;
}

a {
    color: var(--accent-strong);
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid rgb(13 148 136 / 45%);
    outline-offset: 2px;
}

.skip-link {
    background: var(--nav);
    border-radius: 0 0 8px 0;
    color: #fff;
    left: 0;
    padding: 10px 14px;
    position: absolute;
    top: -60px;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* ---------- Estructura ---------- */

.app-shell {
    min-height: 100vh;
}

.sidebar {
    background: var(--nav);
    color: #fff;
    padding: 10px var(--gutter);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
}

.brand strong {
    display: block;
}

.brand small {
    color: var(--muted);
}

.sidebar .brand small {
    color: #aeb8c5;
    display: block;
    margin-top: 2px;
}

.brand-mark {
    background: #0d1724 url("../img/logo.png") center / cover no-repeat;
    border-radius: 8px;
    flex: none;
    height: 40px;
    width: 40px;
}

.nav-toggle-checkbox {
    display: none;
}

.nav-toggle-label {
    align-items: center;
    background: var(--nav-soft);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    font-size: 22px;
    height: 44px;
    justify-content: center;
    margin-left: auto;
    width: 44px;
}

.main-nav {
    display: none;
    gap: 4px;
    padding: 12px 0 6px;
}

.nav-toggle-checkbox:checked ~ .main-nav {
    display: grid;
}

.main-nav a {
    border-radius: 8px;
    color: #d9e1ea;
    padding: 12px;
    text-decoration: none;
}

.main-nav a:hover,
.main-nav a.active {
    background: var(--nav-soft);
    color: #fff;
}

.main-nav a.active {
    box-shadow: inset 3px 0 0 var(--accent);
}

.content {
    min-width: 0;
    padding: 16px var(--gutter) 40px;
}

.topbar {
    align-items: flex-start;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.topbar h1,
.section-heading h2,
.info-card h3,
.form-card h3 {
    margin: 0;
}

.topbar h1 {
    font-size: 24px;
}

.topbar-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-pill {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.user-pill:hover {
    color: var(--accent-strong);
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    margin: 0 0 4px;
    text-transform: uppercase;
}

.auth-help,
.metric span,
.metric small,
.info-card small {
    color: var(--muted);
}

/* ---------- Componentes ---------- */

.panel,
.metric,
.info-card,
.form-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.panel {
    margin-bottom: 16px;
    padding: 16px;
}

.edit-panel {
    margin-top: 16px;
}

.section-heading {
    align-items: flex-start;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.section-heading h2 {
    font-size: 20px;
}

.button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 700;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    text-decoration: none;
}

.button:hover {
    border-color: #9aa7b6;
}

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

.button.primary:hover {
    background: var(--accent-strong);
}

.button.subtle {
    background: #f8fafc;
    color: #465363;
    font-size: 14px;
    padding: 6px 12px;
}

.button.subtle.active {
    background: #e6fffb;
    border-color: #99f6e4;
    color: var(--accent-strong);
}

.button.disabled {
    cursor: default;
    opacity: 0.55;
}

.inline-form {
    display: inline;
    margin: 0;
}

.share-native[hidden] {
    display: none;
}

.tag,
.status {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    white-space: nowrap;
}

.tag {
    background: #eef2f6;
    color: #465363;
    text-decoration: none;
}

a.tag:hover {
    background: #e2e8f0;
}

.status.is-danger {
    background: #fef3f2;
    color: var(--danger);
}

.status.is-credit,
.status.is-pending {
    background: var(--warn-bg);
    color: var(--credit);
}

.status.is-ok {
    background: #ecfdf3;
    color: var(--ok);
}

.notice {
    background: #ecfdf3;
    border: 1px solid #abefc6;
    border-radius: 8px;
    color: #067647;
    font-weight: 700;
    margin-bottom: 14px;
    padding: 10px 12px;
}

.notice.danger {
    background: #fef3f2;
    border-color: #fecdca;
    color: var(--danger);
}

.auth-help {
    font-size: 14px;
    margin: 0 0 14px;
}

/* Metricas */

.metrics-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    margin-bottom: 16px;
}

.metric {
    display: grid;
    gap: 4px;
    padding: 16px;
}

.metric strong {
    font-size: 22px;
    overflow-wrap: anywhere;
}

.metric.highlight {
    background: var(--nav);
    border-color: var(--nav);
}

.metric.highlight span,
.metric.highlight small {
    color: #aeb8c5;
}

.metric.highlight strong {
    color: #fff;
    font-size: 28px;
}

/* Pendientes del panel */

.attention-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: 1fr;
    margin-bottom: 16px;
}

.attention {
    background: var(--warn-bg);
    border: 1px solid #f5d9a8;
    border-left: 4px solid #d99a2b;
    border-radius: var(--radius);
    color: var(--ink);
    display: grid;
    gap: 2px;
    padding: 12px 14px;
    text-decoration: none;
}

.attention:hover {
    border-color: #d99a2b;
}

.attention strong {
    font-size: 15px;
}

.attention span {
    color: #5b4a2a;
    font-size: 14px;
}

.attention em {
    color: var(--accent-strong);
    font-size: 13px;
    font-style: normal;
    font-weight: 700;
    margin-top: 4px;
}

/* Pestanas de seccion */

.tabs {
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.tabs a {
    border-bottom: 3px solid transparent;
    color: #465363;
    flex: none;
    font-weight: 700;
    padding: 12px 14px;
    text-decoration: none;
}

.tabs a:hover {
    color: var(--accent-strong);
}

.tabs a[aria-current="page"] {
    border-bottom-color: var(--accent);
    color: var(--accent-strong);
}

/* Formularios */

.split-layout,
.panel-grid {
    align-items: start;
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1fr);
}

.form-card {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.edit-form {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
}

.form-actions {
    align-items: end;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    grid-column: 1 / -1;
}

label {
    color: #465363;
    display: grid;
    font-size: 13px;
    font-weight: 700;
    gap: 6px;
}

input,
select {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    min-height: 44px;
    padding: 8px 10px;
    width: 100%;
}

label.check-label {
    align-items: flex-start;
    display: flex;
    font-weight: 400;
    gap: 8px;
}

label.check-label input {
    flex: none;
    margin-top: 3px;
    min-height: 0;
    width: auto;
}

input[type="file"] {
    background: #f8fafc;
    border: 1px dashed #b8c2cf;
    color: #465363;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    padding: 5px;
}

input[type="file"]::file-selector-button {
    background: var(--nav-soft);
    border: 0;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    margin-right: 10px;
    min-height: 28px;
    padding: 6px 10px;
}

input[type="file"]:hover,
input[type="file"]:focus {
    background: #eef6f6;
    border-color: var(--accent);
    outline: none;
}

input[type="file"]:hover::file-selector-button {
    background: var(--accent);
}

.receipt-upload-form {
    align-items: stretch;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.period-picker {
    margin-bottom: 14px;
    max-width: 320px;
}

.info-card {
    display: grid;
    gap: 10px;
    padding: 16px;
}

.info-card p {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
}

/* Tablas */

.table-wrap {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #465363;
    font-size: 12px;
    text-transform: uppercase;
}

.actions-cell {
    text-align: right;
}

.actions-cell.wide {
    white-space: nowrap;
}

.actions-cell.wide .button,
.actions-cell.wide details {
    margin-left: 6px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.table-toolbar {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    font-size: 13px;
    font-weight: 700;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-current {
    color: #465363;
    white-space: nowrap;
}

/* Lista desplegable de PDF por UF */

.uf-pdfs {
    display: inline-block;
    text-align: left;
    vertical-align: middle;
}

.uf-pdfs summary {
    cursor: pointer;
    list-style: none;
}

.uf-pdfs summary::-webkit-details-marker {
    display: none;
}

/* La lista se abre en linea (no flotante) para que el contenedor de la tabla no la recorte. */
.uf-pdfs-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    max-width: 260px;
    white-space: normal;
}

.uf-pdfs-list a {
    background: #eef2f6;
    border-radius: 999px;
    color: #465363;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 12px;
    text-decoration: none;
}

.uf-pdfs-list a:hover {
    background: #dff4f1;
    color: var(--accent-strong);
}

/* Tablas que se convierten en tarjetas en pantallas angostas (el script del pie agrega data-label) */

@media (max-width: 759px) {
    .table-wrap {
        overflow-x: visible;
    }

    table.stackable thead {
        height: 1px;
        overflow: hidden;
        position: absolute;
        width: 1px;
        clip-path: inset(50%);
    }

    table.stackable,
    table.stackable tbody {
        display: block;
    }

    table.stackable tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        display: block;
        margin-bottom: 12px;
        padding: 4px 12px;
    }

    table.stackable td {
        align-items: center;
        border-bottom: 1px dashed var(--line);
        display: flex;
        gap: 14px;
        justify-content: space-between;
        padding: 9px 0;
        text-align: right;
    }

    table.stackable td:last-child {
        border-bottom: 0;
    }

    table.stackable td::before {
        color: #465363;
        content: attr(data-label);
        flex: none;
        font-size: 12px;
        font-weight: 700;
        max-width: 42%;
        text-align: left;
        text-transform: uppercase;
    }

    table.stackable td:first-child {
        border-bottom: 1px solid var(--line);
        font-size: 16px;
        justify-content: flex-start;
        text-align: left;
    }

    table.stackable td:first-child::before,
    table.stackable td.actions-cell::before,
    table.stackable td:not([data-label])::before,
    table.stackable td[data-label=""]::before {
        display: none;
    }

    table.stackable td.actions-cell {
        display: block;
        text-align: left;
        white-space: normal;
    }

    table.stackable td.actions-cell .table-actions {
        justify-content: flex-start;
    }

    table.stackable td.actions-cell .button,
    table.stackable td.actions-cell .uf-pdfs {
        margin: 4px 6px 4px 0;
    }

    .uf-pdfs-list {
        max-width: none;
    }
}

/* ---------- Pantallas sin sesion (login, recuperar, crear contrasena) ---------- */

.auth-body {
    align-items: center;
    background:
        linear-gradient(rgb(10 18 30 / 52%), rgb(10 18 30 / 78%)),
        #17202b url("../img/fachada-chica.jpg") center / cover no-repeat;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
}

.auth-card {
    background: var(--panel);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgb(0 0 0 / 35%);
    max-width: 400px;
    padding: 26px;
    width: 100%;
}

.auth-card .brand {
    color: var(--ink);
    margin-bottom: 18px;
}

.auth-card .brand small {
    color: var(--muted);
}

.auth-card h1 {
    font-size: 22px;
    margin: 0 0 16px;
}

.auth-form {
    display: grid;
    gap: 14px;
}

.auth-links {
    font-size: 14px;
    margin: 16px 0 0;
    text-align: center;
}

/* ---------- Pantallas medianas y grandes ---------- */

@media (min-width: 760px) {
    :root {
        --gutter: 24px;
    }

    .app-shell {
        display: grid;
        grid-template-columns: 250px minmax(0, 1fr);
    }

    .sidebar {
        align-self: start;
        height: 100vh;
        overflow-y: auto;
        padding: 24px 16px;
    }

    .brand {
        margin-bottom: 26px;
    }

    .nav-toggle-label {
        display: none;
    }

    .main-nav {
        display: grid;
        padding: 0;
    }

    .content {
        padding: 28px var(--gutter) 48px;
    }

    .topbar {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
        margin-bottom: 22px;
    }

    .topbar h1 {
        font-size: 28px;
    }

    .panel {
        padding: 20px;
    }

    .section-heading {
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
    }

    .metrics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .attention-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }

    .edit-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    table {
        min-width: 640px;
    }

    .receipt-upload-form {
        align-items: center;
        flex-direction: row;
        min-width: 240px;
    }

    .receipt-upload-form input[type="file"] {
        flex: 1;
        font-size: 12px;
        min-height: 34px;
        min-width: 180px;
        padding: 4px;
    }

    .button {
        min-height: 40px;
    }

    .button.subtle {
        min-height: 34px;
    }

    input,
    select {
        font-size: 15px;
        min-height: 40px;
    }

    .actions-cell {
        width: 92px;
    }

    .actions-cell.wide {
        width: auto;
    }

    .auth-body {
        background:
            linear-gradient(rgb(10 18 30 / 45%), rgb(10 18 30 / 70%)),
            #17202b url("../img/fachada.jpg") center / cover no-repeat;
    }
}

@media (min-width: 1100px) {
    .split-layout {
        grid-template-columns: 320px minmax(0, 1fr);
    }

    .panel-grid {
        grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
    }

    .edit-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: no-preference) {
    .button,
    .main-nav a,
    .attention {
        transition: background-color 0.15s, border-color 0.15s;
    }
}
