:root {
    --brand: #C8102E;
    --navy: #1a2b4a;
    --sidebar: #152238;
    --bg: #f4f6f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --success: #16a34a;
    --warning: #ca8a04;
    --danger: #dc2626;
    --radius: 10px;
    --font-sans: 'Source Sans 3', system-ui, sans-serif;
    --header-height: 56px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

body.sidebar-open { overflow: hidden; }

a { color: inherit; }

.admin-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 150;
}

.sidebar {
    background: var(--sidebar);
    color: #fff;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    z-index: 200;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0 0.75rem;
}

.sidebar-brand span { color: #ff6b7a; }

.sidebar-close {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.sidebar nav a {
    display: block;
    color: rgba(255, 255, 255, 0.85);
    padding: 0.8rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-footer {
    display: none;
    margin-top: 1rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-user {
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.7);
    word-break: break-all;
}

.admin-content {
    min-width: 0;
}

.mobile-header {
    display: none;
    align-items: center;
    gap: 0.75rem;
    height: var(--header-height);
    padding: 0 1rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 120;
}

.mobile-header-title {
    flex: 1;
    font-weight: 700;
    color: var(--navy);
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--navy);
    border-radius: 2px;
}

.mobile-logout-form { margin: 0; }

.main {
    padding: 1.5rem 2rem;
}

.main-guest {
    padding: 1rem;
}

.desktop-user-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-header h1 {
    margin: 0;
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    color: var(--navy);
}

.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.card h2 {
    margin-top: 0;
    font-size: 1.15rem;
    color: var(--navy);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card h3 {
    margin: 0;
    font-size: clamp(1.5rem, 5vw, 2rem);
    color: var(--navy);
}

.stat-card p {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

th, td {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: capitalize;
}

.badge-pendiente { background: #fef3c7; color: #92400e; }
.badge-confirmada { background: #dcfce7; color: #166534; }
.badge-cancelada { background: #fee2e2; color: #991b1b; }
.badge-completada { background: #e0e7ff; color: #3730a3; }

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

.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--navy);
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    min-height: 44px;
}

textarea { min-height: 110px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.1rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
    font-size: 0.95rem;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.5rem 0.85rem; min-height: 38px; font-size: 0.85rem; }

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.actions form { margin: 0; }

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.error { color: var(--danger); font-size: 0.85rem; }

.login-page {
    max-width: 420px;
    margin: 2rem auto;
    padding: 0 0.5rem;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 1rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    text-decoration: none;
    font-size: 0.9rem;
}

.pagination .active span {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

@media (max-width: 900px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 86vw);
        padding: 1rem;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-close,
    .sidebar-footer,
    .mobile-header {
        display: flex;
    }

    .desktop-user-bar {
        display: none;
    }

    .main {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header .btn,
    .page-header .actions {
        width: 100%;
    }

    .page-header .btn {
        justify-content: center;
    }

    .page-header .actions .btn {
        flex: 1;
    }

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

    .admin-table thead {
        display: none;
    }

    .admin-table tbody tr {
        display: block;
        margin-bottom: 0.85rem;
        padding: 0.85rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        background: #fff;
    }

    .admin-table tbody tr:last-child {
        margin-bottom: 0;
    }

    .admin-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
        padding: 0.45rem 0;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }

    .admin-table td:last-child {
        border-bottom: none;
        padding-top: 0.65rem;
    }

    .admin-table td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        color: var(--muted);
        text-align: left;
        flex-shrink: 0;
    }

    .admin-table td.actions {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-table td.actions::before {
        margin-bottom: 0.25rem;
    }

    .admin-table td.actions .btn {
        width: 100%;
    }

    .admin-table td[colspan] {
        display: block;
        text-align: center;
    }

    .admin-table td[colspan]::before {
        display: none;
    }

    .table-wrap:has(.admin-table) {
        overflow: visible;
    }
}
