:root {
    --wine: #741f2b;
    --wine-dark: #4f121c;
    --red: #c92f3e;
    --rose: #f7eceb;
    --paper: #fffdf9;
    --ink: #251f20;
    --muted: #6d6264;
    --line: #e6d9d7;
    --success: #216e4e;
    --danger: #aa2433;
    --shadow: 0 16px 45px rgba(76, 27, 34, .11);
}

* { box-sizing: border-box; }

html {
    min-width: 0;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 0;
    margin: 0;
    overflow-x: hidden;
    color: var(--ink);
    background:
        radial-gradient(circle at 9% 4%, rgba(201, 47, 62, .09), transparent 26rem),
        linear-gradient(180deg, #f8f0ee 0, #f5f1ed 100%);
    font-family: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

button, input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

.login-page {
    min-height: 100vh;
    background-image:
        linear-gradient(rgba(38, 12, 18, .68), rgba(38, 12, 18, .78)),
        url("../images/museo-fachada-parallax.jpg");
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

.login-page .page {
    min-height: calc(100vh - 150px);
    display: grid;
    align-content: center;
}

.login-page .card { border-color: rgba(255, 255, 255, .38); }

.registration-page,
.profile-page,
.admin-page {
    min-height: 100vh;
    background-image:
        linear-gradient(rgba(248, 240, 238, .78), rgba(245, 241, 237, .86)),
        url("../images/museo-fachada-parallax.jpg");
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

.registration-page .card,
.profile-page .card,
.admin-page .card {
    background: rgba(255, 253, 249, .93);
    backdrop-filter: blur(5px);
}

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

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(79, 18, 28, .97);
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    backdrop-filter: blur(14px);
}

.nav {
    width: min(1120px, calc(100% - 32px));
    min-height: 108px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

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

.brand-logo { display: block; width: auto; height: 88px; object-fit: contain; }

.site-header .button.secondary,
.site-header .button.ghost {
    color: white;
    border-color: rgba(255, 255, 255, .66);
}

.site-header .button.secondary:hover,
.site-header .button.ghost:hover {
    color: var(--wine-dark);
    background: white;
}

.nav-actions { display: flex; align-items: center; gap: 12px; }
.nav-actions form { margin: 0; }

.page {
    width: min(960px, calc(100% - 32px));
    margin: 42px auto 80px;
}

.page.narrow { width: min(520px, calc(100% - 32px)); }

.hero {
    overflow: hidden;
    position: relative;
    padding: clamp(30px, 6vw, 58px);
    color: white;
    background: linear-gradient(135deg, var(--wine-dark), var(--wine) 55%, var(--red));
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.hero::after {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    right: -80px;
    top: -110px;
    border: 35px solid rgba(255, 255, 255, .1);
    transform: rotate(35deg);
}

.hero > * { position: relative; z-index: 1; }

.eyebrow {
    margin: 0 0 8px;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.hero h1 { max-width: 720px; margin: 0; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.05; }
.hero p { max-width: 680px; margin: 18px 0 0; color: rgba(255,255,255,.88); }

.card {
    margin-top: 22px;
    padding: clamp(22px, 4vw, 38px);
    background: var(--paper);
    border: 1px solid rgba(116, 31, 43, .1);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.card h1, .card h2, .card h3 { line-height: 1.2; }
.card h1 { margin-top: 0; }

.section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0 22px;
    padding-bottom: 13px;
    border-bottom: 1px solid var(--line);
}

.section-number {
    display: grid;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    place-items: center;
    color: white;
    background: var(--wine);
    border-radius: 50%;
    font-weight: 800;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }

label, legend { display: block; margin-bottom: 8px; font-size: .92rem; font-weight: 750; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.required { color: var(--red); }
.help { margin: 7px 0 0; color: var(--muted); font-size: .82rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="tel"], select {
    width: 100%;
    min-height: 47px;
    padding: 10px 13px;
    color: var(--ink);
    background: white;
    border: 1px solid #cfc3c1;
    border-radius: 10px;
    font: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

input[type="file"] {
    max-width: 100%;
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px dashed #bca9a7;
    border-radius: 10px;
}

input:focus, select:focus {
    border-color: var(--wine);
    box-shadow: 0 0 0 3px rgba(116, 31, 43, .12);
}

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 14px; }
.choice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0;
    padding: 10px 11px;
    font-weight: 500;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
}

.choice input { margin-top: 4px; accent-color: var(--wine); }

.error { margin-top: 6px; color: var(--danger); font-size: .84rem; font-weight: 650; }
.invalid { border-color: var(--danger) !important; }

.alert {
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 10px;
}
.alert-success { color: #15573d; background: #e7f6ee; border: 1px solid #b8dfca; }
.alert-error { color: #7f1623; background: #fff0f1; border: 1px solid #efc5ca; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }

.button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    color: white;
    background: var(--wine);
    border: 1px solid var(--wine);
    border-radius: 10px;
    font: inherit;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}
.button:hover { background: var(--wine-dark); }
.button.secondary { color: var(--wine); background: transparent; }
.button.ghost { min-height: auto; padding: 7px 11px; color: var(--wine); background: transparent; }

.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }
.auth-footer { margin: 24px 0 0; text-align: center; color: var(--muted); }

.register-callout {
    margin-top: 20px;
    padding: 26px;
    text-align: center;
    background: #f4e0df;
    border: 2px solid rgba(116, 31, 43, .2);
    border-radius: 18px;
}

.register-callout .eyebrow { color: var(--wine); }
.register-callout h2 { margin: 4px 0 8px; }
.register-callout p:not(.eyebrow) { margin: 0 auto 18px; color: var(--muted); }

.profile-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border-radius: 999px;
    font-size: .84rem;
    font-weight: 800;
}
.status.active { color: #15573d; background: #e1f4e9; }
.status.inactive { color: #84202c; background: #fde9eb; }
.status::before { content: ""; width: 8px; height: 8px; background: currentColor; border-radius: 50%; }

.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin: 0; }
.detail { padding: 15px 0; border-bottom: 1px solid var(--line); }
.detail dt { color: var(--muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.detail dd { margin: 5px 0 0; font-weight: 620; overflow-wrap: anywhere; }
.document-list { display: grid; gap: 10px; }
.document { display: flex; justify-content: space-between; gap: 15px; padding: 13px; background: #faf5f3; border-radius: 10px; }
.document > * { min-width: 0; overflow-wrap: anywhere; }

.admin-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.admin-identity { position: relative; z-index: 1; flex: 0 0 auto; padding: 15px 18px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); border-radius: 12px; }
.admin-identity span, .admin-identity strong { display: block; }
.admin-identity span { color: rgba(255,255,255,.7); font-size: .78rem; }
.metrics-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 22px; }
.metric-card { padding: 22px; background: rgba(255,253,249,.94); border-left: 5px solid var(--wine); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(5px); }
.metric-card span, .metric-card strong { display: block; }
.metric-card span { color: var(--muted); font-size: .85rem; font-weight: 700; }
.metric-card strong { margin-top: 5px; color: var(--wine); font-size: 2rem; line-height: 1; }
.metric-card.success { border-left-color: var(--success); }
.metric-card.success strong { color: var(--success); }
.metric-card.danger { border-left-color: var(--danger); }
.metric-card.danger strong { color: var(--danger); }
.metric-card.warning { border-left-color: #bd7313; }
.metric-card.warning strong { color: #8c550e; }
.admin-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.dashboard-card { min-width: 0; }
.dashboard-card h2 { margin: 0; }
.bar-chart { display: grid; gap: 15px; margin-top: 22px; }
.bar-label { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 5px; font-size: .86rem; }
.bar-track { height: 9px; overflow: hidden; background: #eadfdd; border-radius: 999px; }
.bar-track span { display: block; height: 100%; background: linear-gradient(90deg, var(--wine), var(--red)); border-radius: inherit; }
.dashboard-section-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.export-button { flex: 0 0 auto; align-self: flex-start; }
.admin-filters { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 14px; align-items: end; padding: 18px; background: #f8efed; border-radius: 13px; }
.filter-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
.table-wrap { margin-top: 22px; overflow-x: auto; }
.admin-table { width: 100%; min-width: 980px; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 14px 11px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--muted); font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; }
.admin-table td { font-size: .87rem; }
.table-subtext { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; }
.table-action { min-height: 35px; padding: 6px 10px; font-size: .78rem; white-space: nowrap; }
.table-actions-cell { min-width: 150px; }
.document-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.empty-state { padding: 25px !important; color: var(--muted); text-align: center !important; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; }
.pagination .disabled { opacity: .45; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 860px) and (min-width: 681px) {
    .admin-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-search { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
    .nav {
        width: min(100% - 24px, 1120px);
        min-height: 74px;
        gap: 8px;
    }
    .brand { min-width: 0; }
    .brand-logo { height: 56px; }
    .nav-actions { flex: 0 0 auto; gap: 6px; }
    .nav-actions .button { min-height: 38px; padding: 7px 10px; font-size: .78rem; }
    .page, .page.narrow {
        width: min(100% - 20px, 960px);
        margin-top: 16px;
        margin-bottom: 48px;
    }
    .login-page .page { min-height: calc(100vh - 106px); }
    .hero { padding: 26px 20px; border-radius: 17px; }
    .hero h1 { font-size: clamp(1.75rem, 9vw, 2.35rem); overflow-wrap: anywhere; }
    .hero p { margin-top: 13px; }
    .hero::after { right: -150px; opacity: .7; }
    .card { margin-top: 14px; padding: 21px 16px; border-radius: 16px; }
    .card h1 { font-size: 1.75rem; }
    .card h2 { font-size: 1.3rem; overflow-wrap: anywhere; }
    .section-heading { align-items: flex-start; gap: 10px; margin-top: 4px; margin-bottom: 18px; }
    .section-heading h2 { margin: 3px 0 0; }
    .section-number { width: 29px; height: 29px; }
    .form-grid, .details, .choices { grid-template-columns: 1fr; }
    .form-grid { gap: 17px; }
    input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="tel"], select {
        min-width: 0;
        font-size: 16px;
    }
    input[type="file"] { padding: 10px; font-size: .8rem; }
    .choice { min-width: 0; overflow-wrap: anywhere; }
    .profile-header { align-items: flex-start; flex-direction: column; }
    .form-actions { align-items: stretch; flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
    .register-callout { margin-top: 14px; padding: 22px 16px; }
    .document { align-items: flex-start; flex-direction: column; gap: 5px; }
    .login-page, .registration-page, .profile-page, .admin-page { background-attachment: scroll; }
    .registration-page, .profile-page, .admin-page { background-position: 58% center; }
    .admin-hero { align-items: flex-start; flex-direction: column; }
    .admin-identity { width: 100%; }
    .metrics-grid, .admin-chart-grid { grid-template-columns: 1fr; }
    .metrics-grid { gap: 10px; margin-top: 14px; }
    .metric-card { padding: 17px; }
    .metric-card strong { font-size: 1.7rem; }
    .admin-chart-grid { gap: 0; }
    .bar-label { align-items: flex-start; }
    .bar-label span { min-width: 0; overflow-wrap: anywhere; }
    .dashboard-section-heading { align-items: stretch; flex-direction: column; }
    .export-button { width: 100%; }
    .admin-filters { grid-template-columns: 1fr; }
    .filter-actions { grid-column: auto; align-items: stretch; flex-direction: column-reverse; }
    .filter-actions .button { width: 100%; }
    .table-wrap { overflow: visible; }
    .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
    .admin-table { min-width: 0; }
    .admin-table thead { display: none; }
    .admin-table tr {
        margin-top: 14px;
        padding: 10px 13px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
    }
    .admin-table td {
        display: grid;
        grid-template-columns: minmax(88px, .75fr) minmax(0, 1.25fr);
        gap: 12px;
        padding: 9px 0;
        overflow-wrap: anywhere;
        border-bottom: 1px solid var(--line);
    }
    .admin-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .68rem;
        font-weight: 800;
        letter-spacing: .04em;
        text-transform: uppercase;
    }
    .admin-table .table-actions-cell { display: block; padding-top: 13px; border-bottom: 0; }
    .admin-table .table-actions-cell::before { display: none; }
    .admin-table .table-action { width: 100%; }
    .admin-table .document-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-table .empty-row { padding: 0; }
    .admin-table .empty-state { display: block; border: 0; }
    .admin-table .empty-state::before { display: none; }
    .pagination { flex-wrap: wrap; gap: 8px; font-size: .82rem; }
    .pagination > span:not(.button) { width: 100%; text-align: center; order: -1; }
}

@media (max-width: 380px) {
    .nav { width: calc(100% - 16px); }
    .brand-logo { height: 48px; }
    .nav-actions .button { padding-inline: 8px; font-size: .72rem; }
    .hero { padding-inline: 17px; }
    .card { padding-inline: 14px; }
    .admin-table td { grid-template-columns: 80px minmax(0, 1fr); gap: 9px; }
}

@media (prefers-reduced-motion: reduce) {
    .login-page, .registration-page, .profile-page, .admin-page { background-attachment: scroll; }
}
