:root {
    --bg: #F7F8FA;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --border-strong: #D8DCE3;
    --text: #111827;
    --text-soft: #4B5563;
    --text-muted: #9CA3AF;
    --accent: #2563EB;
    --accent-hover: #1D4ED8;
    --accent-soft: #EFF4FF;
    --accent-border: #BFDBFE;
    --success: #15803D;
    --success-soft: #F0FDF4;
    --success-border: #BBF7D0;
    --danger: #DC2626;
    --danger-soft: #FEF2F2;
    --danger-border: #FECACA;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.07), 0 2px 4px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.10), 0 4px 10px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::selection { background: var(--accent-border); color: var(--text); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- shell layout ---------- */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 8px;
}

.brand-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.nav-group-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0 10px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-soft);
    font-weight: 600;
    font-size: 13.5px;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover { background: #F3F4F6; color: var(--text); }

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-item svg { flex-shrink: 0; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.acct-block {
    margin-top: auto;
    padding: 12px 10px 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.acct-row { display: flex; align-items: center; gap: 9px; min-width: 0; }

.acct-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.acct-details { min-width: 0; }
.acct-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-role { font-size: 10.5px; color: var(--text-muted); text-transform: capitalize; }

.main {
    flex: 1;
    min-width: 0;
    padding: 24px 28px 48px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.page-title {
    font-size: 19px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

/* ---------- buttons ---------- */

.btn {
    font-family: inherit;
    font-weight: 600;
    font-size: 13.5px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}

.btn:hover { background: #F9FAFB; border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 1px 2px rgba(37,99,235,0.25);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled {
    background: #C7D2FE;
    border-color: #C7D2FE;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger-border); }

/* ---------- pills / filters ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    box-shadow: var(--shadow-xs);
}

.pill-label { color: var(--text-muted); font-weight: 500; flex-shrink: 0; }

.pill select, .pill input {
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    cursor: pointer;
    min-width: 0;
}

/* ---------- cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-xs);
}

.card-pad { padding: 18px; }

.card-title {
    font-size: 13.5px;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.005em;
}

/* ---------- room grid ---------- */

.room-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.room-card {
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: inherit;
    transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}

.room-card:hover:not(:disabled) { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.room-card.selected {
    background: var(--accent-soft);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.room-card.full { opacity: 0.5; cursor: not-allowed; }
.room-card.full:hover { transform: none; box-shadow: none; }

.room-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.room-icon {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
}
.room-card.selected .room-icon { background: #DCE7FE; color: var(--accent); }

.room-code { font-weight: 700; font-size: 14.5px; }
.room-capacity {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
    color: var(--text-muted);
    font-size: 12.5px;
}

/* ---------- badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
    border: 1px solid;
}
.badge-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge-danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.badge-neutral { background: #F3F4F6; border-color: var(--border); color: var(--text-soft); }
.badge-accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

/* ---------- time slots ---------- */

.slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}

.slot-btn {
    padding: 9px 6px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: all 120ms ease;
}
.slot-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }

.slot-btn.occupied {
    background: #F3F4F6;
    color: var(--text-muted);
    text-decoration: line-through;
    cursor: not-allowed;
    opacity: 0.7;
}
.slot-btn.occupied:hover { border-color: var(--border); color: var(--text-muted); }

.slot-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.slot-btn.active:hover { color: #fff; }

.slot-btn:disabled { cursor: not-allowed; }

/* ---------- forms ---------- */

.field { display: block; margin-bottom: 0; }
.field-label { font-size: 12.5px; color: var(--text-soft); margin-bottom: 6px; font-weight: 600; display: block; }
.field input, .field select {
    width: 100%;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 520px;
}

/* ---------- messages ---------- */

.msg { display: flex; gap: 6px; align-items: flex-start; font-size: 13px; margin-bottom: 14px; line-height: 1.45; }
.msg-error { color: var(--danger); }
.msg-success { color: var(--success); }

/* ---------- reservation rows ---------- */

.res-row {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}
.res-row + .res-row { border-top: 1px solid var(--border); }

.res-info { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.res-icon {
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.res-title { font-weight: 700; font-size: 13.5px; }
.res-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- admin table (se convierte en tarjetas en móvil) ---------- */

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

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
table.admin-table thead th {
    text-align: left;
    padding: 10px 16px;
    background: #F9FAFB;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
table.admin-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.admin-table tbody tr:last-child td { border-bottom: none; }
table.admin-table tbody tr { transition: background 100ms ease; }
table.admin-table tbody tr:hover { background: #FAFBFC; }

/* ---------- stat cards ---------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px,1fr));
    gap: 12px;
    margin-bottom: 22px;
    max-width: 520px;
}
.stat-card { padding: 16px 18px; }
.stat-label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 27px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }

/* ---------- auth pages (login / registro) ---------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    background: var(--surface);
}

.auth-brandside {
    flex: 1 1 46%;
    background: linear-gradient(160deg, #17233F 0%, #1D3A7A 55%, var(--accent) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 48px 56px;
    position: relative;
    overflow: hidden;
}
.auth-brandside::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 15% 15%, rgba(255,255,255,0.10) 0, transparent 45%),
                       radial-gradient(circle at 85% 85%, rgba(255,255,255,0.08) 0, transparent 40%);
    pointer-events: none;
}
.auth-brand-top { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.auth-brand-icon {
    width: 34px; height: 34px; border-radius: 9px;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.auth-brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.auth-hero { position: relative; z-index: 1; max-width: 380px; }
.auth-hero h2 { font-family: inherit; font-size: 26px; font-weight: 700; line-height: 1.3; margin: 0 0 12px; letter-spacing: -0.01em; }
.auth-hero p { font-size: 13.5px; line-height: 1.6; color: rgba(255,255,255,0.82); margin: 0; }
.auth-hero-list { list-style: none; padding: 0; margin: 20px 0 0; display: flex; flex-direction: column; gap: 10px; }
.auth-hero-list li { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: rgba(255,255,255,0.9); }
.auth-hero-list svg { flex-shrink: 0; margin-top: 1px; }
.auth-foot { font-size: 11.5px; color: rgba(255,255,255,0.55); position: relative; z-index: 1; }

.auth-formside {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    background: var(--bg);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card-header { margin-bottom: 22px; }
.auth-card-title { font-size: 20px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.auth-card-subtitle { font-size: 13px; color: var(--text-muted); }
.auth-mobile-brand { display: none; }

/* ---------- empty state ---------- */

.empty {
    color: var(--text-muted);
    font-size: 13.5px;
    padding: 28px 16px;
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
}

/* ---------- spinner ---------- */

.spinner {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted); padding: 60px 0; justify-content: center; font-size: 13.5px;
}
.spin { animation: srb-spin 1s linear infinite; }
@keyframes srb-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
    .auth-shell { flex-direction: column; }
    .auth-brandside { display: none; }
    .auth-formside { padding: 28px 20px; background: var(--bg); }
    .auth-mobile-brand {
        display: flex; align-items: center; gap: 9px; justify-content: center; margin-bottom: 22px;
    }
}

@media (max-width: 720px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 10px 14px;
        align-items: center;
        gap: 14px;
    }
    .nav-group-label { display: none; }
    .sidebar-nav { flex-direction: row; gap: 4px; }
    .nav-item { padding: 8px 10px; white-space: nowrap; }
    .acct-block {
        margin-top: 0;
        margin-left: auto;
        padding: 0 0 0 12px;
        border-top: none;
        border-left: 1px solid var(--border);
        flex-direction: row;
        align-items: center;
        flex-shrink: 0;
    }
    .acct-details { display: none; }
    .main { padding: 16px; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .page-title { font-size: 17px; }

    /* tablas -> tarjetas apiladas */
    table.admin-table thead { display: none; }
    table.admin-table, table.admin-table tbody, table.admin-table tr, table.admin-table td { display: block; width: 100%; }
    table.admin-table tr {
        border: 1px solid var(--border);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 6px 4px;
    }
    table.admin-table tbody tr:hover { background: var(--surface); }
    table.admin-table td {
        border-bottom: none !important;
        padding: 6px 12px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: right;
    }
    table.admin-table td[data-label]::before {
        content: attr(data-label);
        font-size: 10.5px;
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        text-align: left;
    }
    table.admin-table td:last-child { justify-content: flex-end; }
}

@media (max-width: 480px) {
    .room-grid { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); }
    .slot-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
    .main { padding: 14px; }
    .card-pad { padding: 14px; }
}
