:root {
    --bg: #f2ecdf;
    --ink: #2c1b12;
    --muted: #8b7763;
    --red: #9a1714;
    --red-dark: #5c0c0a;
    --gold: #c28a3c;
    --gold-soft: #ecc985;
    --paper: #fffdf8;
    --line: #e8dcc4;
    --line-soft: #f0e7d5;
    --ok: #1c6b34;
    --ok-bg: #e8f5ec;
    --warn: #9a6a00;
    --warn-bg: #fdf3df;
    --err: #b32d2e;
    --err-bg: #fcebeb;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(44,27,18,.06);
    --shadow: 0 10px 30px rgba(44,27,18,.10);
    --shadow-lg: 0 22px 60px rgba(44,27,18,.18);
    --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, system-ui, sans-serif;
    --serif: "Georgia", "Times New Roman", serif;
}

* { box-sizing: border-box; }

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

body {
    background:
        radial-gradient(900px 460px at 100% -8%, rgba(194,138,60,.16), transparent 60%),
        radial-gradient(760px 420px at -5% 0%, rgba(154,23,20,.10), transparent 55%),
        var(--bg);
    color: var(--ink);
    display: flex;
    flex-direction: column;
    font-family: var(--sans);
    font-size: 15.5px;
    line-height: 1.55;
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; }
a { color: var(--red); text-underline-offset: 2px; }
img { max-width: 100%; }

/* ===== Topbar ===== */
.topbar {
    background:
        radial-gradient(640px 150px at 12% -20%, rgba(154,23,20,.55), transparent 62%),
        linear-gradient(135deg, #050d14, #0d1c28);
    border-bottom: 1px solid rgba(194,138,60,.5);
    box-shadow: 0 6px 24px rgba(0,0,0,.18);
    position: sticky;
    top: 0;
    z-index: 30;
}
.topbar-inner {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: space-between;
    margin: 0 auto;
    max-width: 1120px;
    padding: 12px 22px;
}
.brand { align-items: center; color: var(--gold-soft); display: flex; gap: 12px; text-decoration: none; }
.brand img { height: 46px; width: auto; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.brand span { font-family: var(--serif); font-size: 1.18rem; letter-spacing: .04em; text-transform: uppercase; }
.topnav { align-items: center; display: flex; flex-wrap: wrap; gap: 6px; }
.topnav a, .logout-form button {
    align-items: center;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(236,201,133,.28);
    border-radius: 999px;
    color: var(--gold-soft);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: .92rem;
    font-weight: 600;
    gap: 7px;
    padding: 8px 15px;
    text-decoration: none;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.topnav a:hover, .logout-form button:hover { background: rgba(236,201,133,.18); border-color: rgba(236,201,133,.55); transform: translateY(-1px); }
.logout-form { margin: 0; }

/* ===== Layout ===== */
.container { flex: 1; margin: 0 auto; max-width: 1120px; padding: 34px 22px 60px; width: 100%; }
.page-head { margin-bottom: 24px; }
.page-head h1 { color: var(--red-dark); font-size: 1.9rem; margin: 0 0 4px; }
.muted { color: var(--muted); }
.row-between { align-items: center; display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; }
.section-title { color: var(--red-dark); font-size: 1.3rem; margin: 30px 0 16px; position: relative; padding-left: 14px; }
.section-title::before { background: linear-gradient(var(--gold), var(--red)); border-radius: 3px; content: ""; height: 100%; left: 0; position: absolute; top: 0; width: 5px; }

/* ===== Alerts ===== */
.alert { align-items: center; border-radius: var(--radius-sm); display: flex; font-weight: 600; gap: 10px; margin-bottom: 20px; padding: 13px 16px; box-shadow: var(--shadow-sm); }
.alert-ok { background: var(--ok-bg); border: 1px solid #abdcb9; color: var(--ok); }
.alert-error { background: var(--err-bg); border: 1px solid #e7adad; color: var(--err); }

/* ===== Cards / forms ===== */
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.card-title { color: var(--red-dark); font-size: 1.5rem; margin: 0 0 20px; }
.auth-wrap { display: flex; justify-content: center; padding-top: 24px; }
.auth-card { max-width: 430px; width: 100%; }
.auth-card::before {
    background: linear-gradient(90deg, var(--red), var(--gold));
    border-radius: var(--radius) var(--radius) 0 0;
    content: "";
    display: block;
    height: 5px;
    margin: -28px -28px 22px;
}
.auth-alt { margin-top: 18px; }
.auth-note { color: var(--muted); font-size: .9rem; margin-top: 12px; }
.form-card { max-width: 760px; }

.field { display: block; margin-bottom: 16px; }
.field > span { color: #4a3527; display: block; font-size: .9rem; font-weight: 700; margin-bottom: 7px; }
.field input, .field select, .toolbar input, .toolbar select {
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font: inherit;
    padding: 12px 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
    width: 100%;
}
.field input::placeholder { color: #c3b393; }
.field input:focus, .field select:focus, .toolbar input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(194,138,60,.16);
    outline: none;
}
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.check { align-items: center; display: flex; gap: 8px; margin: 4px 0 16px; }
.check input { width: 17px; height: 17px; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; }

/* ===== Buttons ===== */
.btn {
    align-items: center;
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    color: #5a4030;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 600;
    gap: 8px;
    justify-content: center;
    padding: 11px 18px;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
    white-space: nowrap;
}
.btn:hover { border-color: #dcc9a3; box-shadow: 0 8px 20px rgba(44,27,18,.12); transform: translateY(-1px); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-sm { padding: 7px 12px; font-size: .86rem; gap: 6px; }
.btn-primary { background: linear-gradient(180deg, #b21f1c, #861210); border: 1.5px solid #c9532f; color: #fff; box-shadow: 0 8px 20px rgba(154,23,20,.30); }
.btn-primary:hover { box-shadow: 0 12px 28px rgba(154,23,20,.40); border-color: #d9683f; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { background: rgba(44,27,18,.05); border-color: var(--line); box-shadow: none; }
.btn-danger { background: #fff; border-color: #e7adad; color: var(--err); }
.btn-danger:hover { background: #fdf1f1; border-color: #dd9595; }

/* ===== Estado banner ===== */
.estado { align-items: center; border-radius: var(--radius); display: flex; font-size: 1.02rem; font-weight: 700; gap: 12px; justify-content: center; margin-bottom: 24px; padding: 16px 22px; text-align: center; box-shadow: var(--shadow-sm); }
.estado.is-aldia { background: var(--ok-bg); border: 1px solid #abdcb9; color: var(--ok); }
.estado.is-deuda { background: var(--err-bg); border: 1px solid #e7adad; color: var(--err); }
.estado.is-revision { background: var(--warn-bg); border: 1px solid var(--gold-soft); color: var(--warn); }

/* ===== Cuotas (socio) ===== */
.cuotas { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.cuota {
    background: var(--paper);
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    transition: transform .16s ease, box-shadow .16s ease;
}
.cuota:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.cuota.estado-pagado { border-left-color: var(--ok); }
.cuota.estado-vencido { border-left-color: var(--err); }
.cuota.estado-en_revision { border-left-color: var(--warn); }
.cuota-top { align-items: center; display: flex; gap: 10px; justify-content: space-between; margin-bottom: 12px; }
.cuota-top strong { font-family: var(--serif); font-size: 1.12rem; }
.cuota-info { color: #6b4a37; display: flex; flex-wrap: wrap; font-size: .92rem; gap: 14px; margin-bottom: 12px; }
.comp-ok { color: var(--ok); font-weight: 600; margin: 8px 0; }
.upload { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.file { display: block; margin-bottom: 12px; }
.file span { color: #4a3527; display: block; font-size: .84rem; font-weight: 700; margin-bottom: 7px; }
.file input[type="file"] { font-size: .9rem; }

/* ===== Badges ===== */
.badge { border-radius: 999px; color: #fff; display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .05em; padding: 5px 11px; text-transform: uppercase; white-space: nowrap; }
.badge-pendiente { background: #94733f; }
.badge-en_revision { background: var(--warn); }
.badge-pagado { background: var(--ok); }
.badge-vencido { background: var(--err); }

/* ===== Tablas (admin) ===== */
.toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.toolbar input, .toolbar select { width: auto; min-width: 240px; }
.table-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; overflow-x: auto; }
.table { border-collapse: collapse; width: 100%; }
.table th, .table td { border-bottom: 1px solid var(--line-soft); padding: 13px 16px; text-align: left; vertical-align: middle; }
.table th { background: #fbf5ea; color: var(--red-dark); font-family: var(--sans); font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #fffaf0; }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; align-items: center; }
.actions form { margin: 0; }
.pager { align-items: center; display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* ===== Footer ===== */
.site-footer { background: linear-gradient(135deg, #050d14, #0d1c28); border-top: 1px solid rgba(194,138,60,.4); color: #e8d4b6; font-family: var(--serif); font-size: .85rem; padding: 18px 20px; text-align: center; }
.site-footer p { margin: 0; }

/* ===== Avatares / fotos de socio (circulares) ===== */
.head-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }
.avatar {
    aspect-ratio: 1 / 1;
    background: #f3e7cf;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(44,27,18,.18);
    flex: 0 0 auto;
    height: 84px;
    object-fit: cover;
    object-position: center 30%;
    width: 84px;
}
.avatar-sm { border-width: 2px; box-shadow: 0 2px 7px rgba(44,27,18,.2); cursor: zoom-in; height: 42px; width: 42px; }
.avatar-empty { align-items: center; color: #c3a468; display: flex; font-size: 1.5rem; justify-content: center; }
.avatar-sm.avatar-empty { font-size: 1rem; cursor: default; }
.avatar-field { align-items: center; display: flex; gap: 20px; margin-bottom: 6px; }
.dash-head { align-items: center; display: flex; gap: 20px; }
.dash-head h1 { margin: 0 0 2px; }
.avatar-controls { display: grid; gap: 8px; }
.avatar-cell { align-items: center; display: flex; gap: 12px; }
.avatar-cell-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-upload { display: inline; margin: 0; }
.avatar-upload input[type="file"] { display: none; }

/* ===== Datos de transferencia ===== */
.datos-banco { border-top: 4px solid transparent; border-image: linear-gradient(90deg, var(--red), var(--gold)) 1; margin-bottom: 26px; }
.db-head { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-bottom: 18px; }
.db-head h2 { align-items: center; color: var(--red-dark); display: flex; font-size: 1.2rem; gap: 10px; margin: 0; }
.db-grid { display: grid; gap: 10px; }
.db-row {
    align-items: center;
    background: linear-gradient(#fff, #fffdf8);
    border: 1px solid var(--line);
    border-radius: 12px;
    display: grid;
    gap: 12px;
    grid-template-columns: 140px 1fr auto;
    padding: 11px 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.db-row:hover { border-color: var(--gold-soft); box-shadow: var(--shadow-sm); }
.db-label { color: var(--muted); font-size: .74rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.db-value { font-family: var(--serif); font-size: 1.1rem; font-weight: 700; word-break: break-word; }
.db-nota { align-items: center; color: #6b4a37; display: flex; gap: 8px; margin: 16px 0 0; }
.db-copy.is-copied { background: var(--ok-bg) !important; border-color: #abdcb9 !important; color: var(--ok) !important; }

/* ===== Recortador de foto (cropper) ===== */
.crop-modal { align-items: center; background: rgba(8,5,3,.72); display: none; inset: 0; justify-content: center; padding: 20px; position: fixed; z-index: 90; }
.crop-modal.is-open { display: flex; }
.crop-box { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-width: 440px; padding: 22px; width: 100%; }
.crop-box h3 { color: var(--red-dark); margin: 0 0 4px; }
.crop-area { background: #1b1410; border-radius: 12px; margin: 14px 0; overflow: hidden; }
.crop-area img { display: block; max-width: 100%; }
.crop-area .cropper-view-box, .crop-area .cropper-face { border-radius: 50%; }
.crop-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Lightbox ===== */
.js-zoom { cursor: zoom-in; }
.lightbox { align-items: center; background: rgba(8,5,3,.86); display: none; inset: 0; justify-content: center; padding: 30px; position: fixed; z-index: 80; }
.lightbox.is-open { display: flex; animation: lb-in .18s ease; }
.lightbox img { border: 4px solid #fff; border-radius: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.6); max-height: 88vh; max-width: 88vw; object-fit: contain; }
.lightbox-close { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.4); border-radius: 50%; color: #fff; cursor: pointer; font-size: 1.3rem; height: 44px; line-height: 1; position: absolute; right: 22px; top: 22px; width: 44px; }
.lightbox-close:hover { background: rgba(255,255,255,.25); }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 720px) {
    body { font-size: 15px; }
    .grid-2 { grid-template-columns: 1fr; }
    .cuotas { grid-template-columns: 1fr; }
    .brand span { display: none; }
    .page-head h1 { font-size: 1.6rem; }
    .avatar-cell { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
    .db-row { grid-template-columns: 1fr auto; }
    .db-label { grid-column: 1 / -1; }
}

/* ===== Tablas en móvil: tarjetas apiladas (sin scroll lateral) ===== */
@media (max-width: 640px) {
    .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table thead { display: none; }
    .table tr {
        background: var(--paper);
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
        margin-bottom: 14px;
        overflow: hidden;
        padding: 4px 2px;
    }
    .table tbody tr:hover { background: var(--paper); }
    .table td {
        align-items: center;
        border: 0 !important;
        display: flex;
        gap: 14px;
        justify-content: space-between;
        padding: 10px 14px;
        text-align: right;
    }
    .table td + td { border-top: 1px solid var(--line-soft) !important; }
    .table td::before {
        color: var(--muted);
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: .72rem;
        font-weight: 800;
        letter-spacing: .05em;
        text-align: left;
        text-transform: uppercase;
        white-space: nowrap;
    }
    .table td.actions { flex-wrap: wrap; justify-content: flex-end; }
    .table td .avatar-cell { flex-direction: row; justify-content: flex-end; }
    .table td[colspan]::before { content: ""; }
}
