:root {
    --bg: #f6f1eb;
    --surface: #ffffff;
    --text: #2d2926;
    --muted: #6f675f;
    --line: #e7ddd3;
    --primary: #b89477;
    --primary-dark: #8c6d53;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.table-loading {
    text-align: center;
    padding: 30px 0;
    font-size: 14px;
    color: #888;
}

.panel-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto 48px;
}

.stat-value.loading {
    opacity: 0.6;
    letter-spacing: 2px;
    animation: dotsPulse 1.2s ease-in-out infinite;
}

@keyframes dotsPulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.card-center {
    max-width: 520px;
    margin: 64px auto;
}

.grid {
    display: grid;
    gap: 20px;
    margin-bottom: 20px;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.eyebrow {
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 8px;
}

h1,
h2 {
    margin-top: 0;
}

.muted {
    color: var(--muted);
}

.stack>*+* {
    margin-top: 15px;
}

.stack-sm>*+* {
    margin-top: 8px;
}

#guestForm label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#guestForm input,
#guestForm textarea,
#guestForm select {
    margin-top: 0;
}

#guestForm>*+* {
    margin-top: 20px;
}

input,
textarea,
select {
    width: 100%;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid transparent;
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn-secondary {
    background: white;
    color: var(--text);
    border-color: var(--line);
}

.hidden {
    display: none;
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    font-size: 14px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
    background: #fff;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

.event-link {
    display: block;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    background: #fff;
}

@media (max-width: 900px) {

    .grid-2,
    .stats {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
    }
}

input[readonly] {
    background: #f7f5f2;
    border: 1px solid rgba(53, 47, 43, 0.12);
    color: rgba(53, 47, 43, 0.75);
    cursor: default;
}

input[readonly]:focus {
    outline: none;
    box-shadow: none;
}

input[readonly]::placeholder {
    color: rgba(53, 47, 43, 0.4);
}

#totalInvitados {
    font-weight: 600;
    letter-spacing: 0.5px;
}

#statsBox .stat {
    text-align: center;
}

#statsBox .stat-label,
#statsBox .stat-value {
    text-align: center;
}

#statsBox {
    margin-top: 4px;
}

main.panel-shell>section+section {
    margin-top: 24px;
}

#statsBox .stat-value {
    display: block;
    width: 100%;
    text-align: center;
}

/* Mejor spacing general entre secciones */
main.panel-shell>section+section {
    margin-top: 32px;
}

/* Mejor comportamiento de stats en pantallas medianas */
@media (max-width: 900px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* En móvil pequeño: 1 columna pero con mejor proporción */
@media (max-width: 520px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat {
        padding: 16px;
    }

    .stat-value {
        font-size: 24px;
    }
}

/* Refinamiento visual RSVP */
#statsBox .stat {
    padding: 14px 10px;
}

#statsBox .stat-label {
    font-size: 11px;
    margin-bottom: 4px;
}

#statsBox .stat-value {
    font-size: 22px;
    line-height: 1;
}

@media (max-width: 520px) {
    .panel-shell {
        width: calc(100% - 24px);
        margin: 20px auto 36px;
    }

    .card {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        padding: 18px;
    }

    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
    }
}

/* Scroll horizontal visible y más elegante en tablas */
.table-wrap {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #eee6dd;
}

.table-wrap::-webkit-scrollbar {
    height: 8px;
}

.table-wrap::-webkit-scrollbar-track {
    background: #eee6dd;
    border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

.scroll-hint {
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 12px;
    color: var(--muted);
    opacity: 0.8;
    pointer-events: none;
}

@media (min-width: 768px) {
    .scroll-hint {
        display: none;
    }
}

.table-scroll-area {
    position: relative;
}

.scroll-hint {
    position: absolute;
    right: 12px;
    bottom: -18px;
    font-size: 12px;
    color: var(--muted);
    opacity: 0.8;
    pointer-events: none;
}

@media (min-width: 768px) {
    .scroll-hint {
        display: none;
    }
}