:root {
    --primary-color: #003366;
    --primary-hover: #002244;
    --accent-color: #00fcdf;
    --bg-light: #f4f6f9;
    --text-color: #333333;
    --border-color: #cccccc;
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-color);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Login Page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    background: linear-gradient(135deg, #003366 0%, #001122 100%);
}

.login-container {
    background: #ffffff;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header h2 { font-size: 1.2rem; color: var(--primary-color); }
.login-header h3 { font-size: 1rem; color: #555; margin-bottom: 0.5rem; }
.login-header p { font-size: 0.9rem; font-weight: bold; margin-bottom: 1.5rem; color: #777; }

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    background-color: var(--primary-hover);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.sidebar-header-text {
    flex: 1;
    min-width: 0;
    text-align: center;
}

.sidebar-collapse-btn {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.22);
}

.sidebar-collapse-btn .icon-expand {
    display: none;
}

.sidebar-menu {
    list-style: none;
    margin-top: 1rem;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    color: #ecf0f1;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.sidebar-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-label {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-menu li a:hover, .sidebar-menu li.active a {
    background-color: rgba(255, 255, 255, 0.15);
    border-left: 4px solid var(--accent-color);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.85rem;
}

.btn-logout {
    color: #ff6b6b;
    text-decoration: none;
    display: inline-block;
    margin-top: 0.5rem;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    cursor: pointer;
}

.menu-toggle:active {
    background: var(--primary-hover);
}

@media (min-width: 769px) {
    .sidebar {
        transition: width 0.25s ease;
        overflow: hidden;
    }

    /* El toggle del top-bar queda solo para móvil */
    .top-bar .menu-toggle {
        display: none;
    }

    body.sidebar-collapsed {
        --sidebar-width: 68px;
    }

    body.sidebar-collapsed .sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
    }

    body.sidebar-collapsed .sidebar-header {
        flex-direction: column;
        justify-content: center;
        padding: 0.75rem 0.35rem;
        gap: 0.35rem;
    }

    body.sidebar-collapsed .sidebar-header-text,
    body.sidebar-collapsed .sidebar-label,
    body.sidebar-collapsed .sidebar-footer-text {
        display: none;
    }

    body.sidebar-collapsed .sidebar-collapse-btn .icon-collapse {
        display: none;
    }

    body.sidebar-collapsed .sidebar-collapse-btn .icon-expand {
        display: block;
    }

    body.sidebar-collapsed .sidebar-menu li a {
        justify-content: center;
        padding: 0.9rem 0.4rem;
        border-left: none;
        gap: 0;
    }

    body.sidebar-collapsed .sidebar-menu li a:hover,
    body.sidebar-collapsed .sidebar-menu li.active a {
        border-left: none;
        background-color: rgba(255, 255, 255, 0.18);
    }

    body.sidebar-collapsed .sidebar-footer {
        padding: 0.75rem 0.35rem;
        text-align: center;
    }

    body.sidebar-collapsed .sidebar-footer .btn-logout {
        margin-top: 0;
        justify-content: center;
        width: 100%;
    }

    body.sidebar-collapsed .content-section {
        max-width: none;
    }

    body.sidebar-collapsed .grid-table-fixed {
        --aula-col: 4.8%;
    }
}

.sidebar-backdrop {
    display: none;
}

.top-bar {
    background: #ffffff;
    padding: clamp(0.5rem, 1.5vw, 1rem) clamp(0.75rem, 2vw, 2rem);
    border-bottom: 1px solid var(--border-color);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: 1rem;
}

.top-bar-start {
    justify-self: start;
    display: flex;
    align-items: center;
    min-width: 0;
}

.top-bar .menu-toggle {
    justify-self: start;
}

.top-bar-title {
    justify-self: center;
    text-align: center;
    min-width: 0;
    grid-column: 2;
}

.top-bar-title h2 {
    margin: 0;
    font-size: clamp(0.85rem, 1.4vw, 1.15rem);
    line-height: 1.25;
}

.top-bar-title p {
    margin: 0.15rem 0 0;
    color: #666;
    font-size: 0.9rem;
}

.top-bar-actions {
    justify-self: end;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    grid-column: 3;
    min-width: 0;
}

.content-section {
    padding: clamp(0.5rem, 1.5vw, 1.5rem);
    display: none;
}

.content-section.active {
    display: block;
}

/* Accordion & Matrix Grid */
.accordion-day {
    background: #ffffff;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.accordion-header {
    background: #e9ecef;
    padding: 0.8rem 1.2rem;
    cursor: pointer;
    font-weight: bold;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    display: flex;
    justify-content: space-between;
}

.accordion-body {
    display: none;
    overflow-x: hidden;
    padding: clamp(0.5rem, 1vw, 1rem);
}

.accordion-day.open .accordion-body {
    display: block;
}

/* Indicador +/? del acorde?n */
.accordion-chevron {
    min-width: 22px;
    text-align: center;
    font-size: 1.1rem;
    color: #555;
}

.accordion-chevron::before {
    content: '+';
}

.accordion-day.open .accordion-chevron::before {
    content: '?';
}

.grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-top: 1.5px solid #8a96a8;
    border-left: 1.5px solid #8a96a8;
}

.grid-table th, .grid-table td {
    border-bottom: 1.5px solid #8a96a8;
    border-right: 1.5px solid #8a96a8;
    text-align: left;
    padding: 8px 10px;
    font-size: clamp(0.72rem, 1.15vw, 0.92rem);
}

.grid-table th:first-child,
.grid-table td:first-child {
    font-weight: 600;
    font-size: clamp(0.7rem, 1vw, 0.88rem);
    text-align: center;
    background-color: #eef2f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-table th { background: #e4e9ef; color: #1f2a37; }

/* Estilos de interactividad en casillas de la grilla */
.grid-table td.cell-slot { 
    cursor: pointer; 
    min-height: 44px;
    height: auto;
    vertical-align: middle;
    transition: background-color 0.1s ease-in-out;
    touch-action: manipulation;
}

/* Columna de aula anclada al scrollear horizontalmente la grilla */
.accordion-body .grid-table th:first-child,
.accordion-body .grid-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
}

.grid-table td.cell-slot:not(.occupied):hover { 
    background-color: #d0ebff !important; 
}

.grid-table td.cell-slot.selected { 
    background-color: #74c0fc !important; 
    border: 1px solid #1c7ed6 !important; 
}

.grid-table td.cell-slot.occupied { 
    color: #111111; 
    font-weight: 400; 
    cursor: pointer; 
    text-align: center;
    user-select: none;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    line-height: 1.25;
    padding: 8px 8px;
}

.grid-table td.cell-slot.occupied .cell-reserva-titulo {
    display: block;
    color: inherit;
    font-weight: 400;
    font-size: clamp(0.72rem, 1.05vw, 1.1rem);
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-height: 4.6em;
    overflow: hidden;
}

.grid-table td.cell-slot.occupied.multi-selected {
    box-shadow: inset 0 0 0 3px #fff, 0 0 0 2px #1c7ed6;
    filter: brightness(1.12);
}

#loteAccionesBar {
    position: fixed;
    left: 50%;
    bottom: 1.25rem;
    transform: translateX(-50%);
    z-index: 1004;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    flex-wrap: wrap;
    background: #1b2a32;
    color: #fff;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    max-width: calc(100% - 2rem);
}

#loteAccionesBar[hidden] {
    display: none !important;
}

#loteAccionesBar .lote-bar-text {
    font-size: 0.9rem;
}

#loteAccionesBar .lote-bar-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

#loteAccionesBar .lote-bar-actions .btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.grid-table td.cell-slot.occupied:hover {
    filter: brightness(1.2);
}

/* La grilla siempre ocupa el 100% y reparte las franjas sin scroll horizontal */
.grid-table-fixed {
    table-layout: fixed;
    width: 100%;
    max-width: 100%;
    --aula-col: 5.5%;
    --hour-count: 13;
    --hour-col: calc((100% - var(--aula-col)) / var(--hour-count));
}

.grid-table-fixed > colgroup > col.col-aula {
    width: var(--aula-col);
}

.grid-table-fixed > colgroup > col.col-hora {
    width: var(--hour-col);
}

.grid-table-fixed th:first-child,
.grid-table-fixed td:first-child {
    width: var(--aula-col) !important;
    min-width: 0 !important;
    max-width: none !important;
}

.grid-table-fixed th:not(:first-child),
.grid-table-fixed td.cell-slot:not(.occupied) {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.grid-table-fixed td.cell-slot.occupied {
    overflow: hidden;
    white-space: normal;
}

.grid-table-fixed th {
    font-size: clamp(0.62rem, 0.95vw, 0.85rem);
    padding: 6px 2px;
    text-align: center;
}

/* Etiquetas de aulas seleccionadas en el modal de reserva */
.aulas-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.aula-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #e7f5ff;
    border: 1px solid #74c0fc;
    color: #1864ab;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.aula-chip-x {
    border: none;
    background: transparent;
    color: #1864ab;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.1rem;
    font-weight: 700;
}

.aula-chip-x:hover {
    color: #c92a2a;
}

.aula-chip-empty {
    color: #999;
    font-size: 0.8rem;
}

.grilla-toolbar {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.grilla-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.fecha-ar-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}
.fecha-ar-parts {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.2rem 0.35rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #fff;
}
.fecha-ar-parts.fecha-ar-invalid {
    border-color: #dc3545;
    background: #fff5f5;
}
.fecha-ar-part {
    border: none;
    outline: none;
    background: transparent;
    text-align: center;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    padding: 0.2rem 0;
}
.fecha-ar-day,
.fecha-ar-month {
    width: 1.7rem;
}
.fecha-ar-year {
    width: 3.1rem;
}
.fecha-ar-sep {
    color: #888;
    user-select: none;
    font-size: 0.9rem;
}
.fecha-ar-native {
    width: 2.4rem;
    min-width: 2.4rem;
    padding: 0.2rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
.fecha-ar-native::-webkit-calendar-picker-indicator {
    margin: 0;
    cursor: pointer;
}
.grilla-toolbar-group[hidden] {
    display: none !important;
}
.grilla-day-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.92rem;
}
.modal-carrera-combo {
    margin-bottom: 6px;
}

.modal-aulas-combo {
    z-index: 2;
}

body.role-consultor .grid-table td.cell-slot,
body.role-consultor .grid-table td.cell-slot.occupied,
body.role-consultor td.cell-slot.occupied {
    cursor: default;
}

body.role-consultor .grid-table td.cell-slot:not(.occupied):hover {
    background-color: transparent !important;
}

body.role-guest .grid-table td.cell-slot,
body.role-guest .grid-table td.cell-slot.occupied,
body.role-guest td.cell-slot.occupied {
    cursor: default;
}

body.role-guest .grid-table td.cell-slot:not(.occupied):hover {
    background-color: transparent !important;
}

/* Estilo Google Calendar para Ocupaci?n Anual */
.calendar-wrapper {
    background: #ffffff;
    border: 1px solid #dadce0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(60,64,67,0.12);
    margin-top: 10px;
}

.calendar-header-days {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    background: #f8f9fa;
    border-bottom: 1px solid #dadce0;
    font-weight: 600;
    text-align: center;
    padding: 10px 0;
    color: #5f6368;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.calendar-grid-body {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    background: #ffffff;
    min-height: 520px;
}

.calendar-day-cell {
    border-right: 1px solid #dadce0;
    border-bottom: 1px solid #dadce0;
    padding: 6px;
    height: 112px;
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    position: relative;
    transition: background-color 0.15s;
    cursor: context-menu;
}

.calendar-day-cell:nth-child(6n) {
    border-right: none;
}

.calendar-day-empty {
    background: #fafafa;
}

.calendar-events-list {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
}

/* Con filtro "Todas las aulas": las celdas crecen hacia abajo, sin scroll */
.calendar-grid-body.todas-aulas .calendar-day-cell {
    height: auto;
    min-height: 112px;
    overflow: visible;
}

.calendar-grid-body.todas-aulas .calendar-events-list {
    overflow-y: visible;
}

.calendar-day-cell:hover {
    background-color: #f8f9fa;
}

.calendar-day-number {
    font-size: 0.8rem;
    font-weight: 600;
    color: #3c4043;
    margin-bottom: 4px;
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
}

.calendar-day-cell.is-today .calendar-day-number {
    background-color: var(--primary-color);
    color: #ffffff;
}

.calendar-event-pill {
    background-color: #e8f0fe;
    color: #1a73e8;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.72rem;
    margin-bottom: 3px;
    border-left: 3px solid #1a73e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center; justify-content: center;
    z-index: 1000;
}

.modal.active { display: flex; }

.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Modal de reserva apaisado (3 pasos) */
.reserva-modal-content {
    max-width: min(1320px, 98vw);
    width: 98vw;
    min-height: min(640px, 88vh);
    padding: 1.5rem 1.6rem 1.15rem;
    max-height: 94vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.reserva-modal-content > h3 {
    margin: 0 0 1rem;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.reserva-modal-content #reservaForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 1.1rem;
}

.reserva-modal-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
    flex: 1;
    min-height: 0;
    align-items: stretch;
}

.reserva-step {
    border: 1px solid #d5dce5;
    border-radius: 10px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.reserva-step-head {
    display: flex;
    align-items: baseline;
    gap: 0.55rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid #dde3ea;
    background: #fff;
    flex-shrink: 0;
}

.reserva-step-num {
    color: var(--primary-color, #003366);
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.1;
    flex-shrink: 0;
    min-width: 1.4rem;
    text-align: left;
    font-variant-numeric: tabular-nums;
}

.reserva-step-head strong {
    display: block;
    font-size: 1rem;
    color: #1f2a37;
    line-height: 1.25;
}

.reserva-step-head span {
    display: block;
    font-size: 0.8rem;
    color: #6b7785;
    margin-top: 0.2rem;
}

.reserva-step-body {
    padding: 1rem 1.05rem 1.1rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.reserva-modal-content .form-group {
    margin-bottom: 0.85rem;
}

.reserva-modal-content .form-group:last-child {
    margin-bottom: 0;
}

.reserva-hora-row {
    display: flex;
    gap: 0.85rem;
}

.reserva-hora-row .form-group {
    flex: 1;
    min-width: 0;
}

.form-hint {
    color: #666;
    display: block;
    margin-top: 0.3rem;
    font-size: 0.8rem;
    line-height: 1.4;
}

.reserva-step-idle {
    margin: 0.5rem 0 0;
    padding: 0.85rem 0.95rem;
    background: #eef2f6;
    border-radius: 6px;
    color: #556070;
    font-size: 0.86rem;
    line-height: 1.45;
}

.reserva-carreras-box {
    max-height: 13rem;
    overflow-y: auto;
    padding-right: 0.2rem;
}

.reserva-modal-content .evento-area-opciones {
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.reserva-evento-nombre-row {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    flex-wrap: nowrap;
}

.reserva-evento-nombre-campo {
    flex: 1 1 auto;
    min-width: 0;
}

.reserva-evento-nombre-campo label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    font-weight: bold;
}

.reserva-evento-nombre-campo input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
}

.reserva-fijar-check {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    flex: 0 0 auto;
    margin: 0 0 0.05rem;
    padding: 0.48rem 0.65rem;
    border: 1px solid #cfd6df;
    border-radius: 6px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1f2a37;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    line-height: 1.2;
    box-sizing: border-box;
    max-width: none;
}

.form-group.reserva-evento-nombre-row .reserva-fijar-check input[type="checkbox"],
.reserva-fijar-check input[type="checkbox"] {
    width: 1rem !important;
    height: 1rem !important;
    min-width: 1rem;
    max-width: 1rem;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    flex: 0 0 auto;
    accent-color: var(--primary-color, #003366);
    cursor: pointer;
}

.reserva-fijar-check span {
    display: inline;
    white-space: nowrap;
}

.reserva-modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.85rem;
    flex-shrink: 0;
    padding-top: 0.55rem;
    border-top: 1px solid #e4e9ef;
    margin-top: 0;
}

.reserva-modal-actions-left,
.reserva-modal-actions-right {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

@media (max-width: 960px) {
    .reserva-modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 96vh;
        overflow-y: auto;
        margin: 0.4rem;
        padding: 1rem;
    }

    .reserva-modal-steps {
        grid-template-columns: 1fr;
    }

    .reserva-step-body {
        overflow: visible;
    }

    .reserva-carreras-box {
        max-height: none;
    }
}

/* Floating Filter Bubble */
.floating-bubble {
    position: fixed;
    bottom: 2rem; right: 2rem;
    background: var(--primary-color);
    color: white;
    width: 55px; height: 55px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 900;
}

.floating-bubble.active {
    background: var(--accent-color);
    color: var(--primary-color);
}

.floating-panel {
    display: none;
    position: fixed;
    bottom: 5rem; right: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    width: 320px;
    z-index: 901;
}

.floating-panel.active { display: block; }

/* Forms & UI Elements */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; font-weight: bold; }
.form-group input, .form-group select { width: 100%; padding: 0.5rem; border: 1px solid var(--border-color); border-radius: 4px; }

.evento-area-opciones {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem 1rem;
    margin-top: 0.35rem;
}

.evento-area-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.evento-area-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.evento-area-box {
    width: 18px;
    height: 18px;
    border: 2px solid #8a94a6;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}

.evento-area-option input:checked + .evento-area-box {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.evento-area-option input:checked + .evento-area-box::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    line-height: 1;
    font-weight: 700;
}

.evento-area-option input:focus-visible + .evento-area-box {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.searchable-combo,
.searchable-combo {
    position: relative;
}
.searchable-combo-list,
.searchable-combo-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    z-index: 1200;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.searchable-combo-item,
.searchable-combo-item {
    padding: 0.45rem 0.65rem;
    cursor: pointer;
    font-size: 0.88rem;
}
.searchable-combo-item:hover,
.searchable-combo-item.active,
.searchable-combo-item:hover,
.searchable-combo-item.active {
    background: #e8f0fe;
}
.searchable-combo-empty,
.searchable-combo-empty {
    padding: 0.5rem 0.65rem;
    color: #888;
    font-size: 0.85rem;
}
.annual-carrera-combo,
.annual-carrera-combo {
    min-width: 260px;
}
.annual-carrera-combo input,
.annual-carrera-combo input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #fff;
}
.calendar-grid-body.is-loading {
    opacity: 0.6;
    pointer-events: none;
}
.floating-panel {
    overflow: visible;
}
.btn { padding: 0.5rem 1rem; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
.btn-undo {
    background: #e6b800;
    color: #1a1a1a;
    font-weight: 600;
    padding: 0.5rem 0.7rem;
    white-space: nowrap;
    min-width: 0;
}
.btn-undo:hover:not(:disabled) {
    background: #d4a800;
}
.btn-undo:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.btn-primary { background: var(--primary-color); color: white; }
.btn-success { background: #28a745; color: white; }
.btn-secondary { background: #6c757d; color: white; }
.btn-danger { background: #dc3545; color: white; }
.btn-block { width: 100%; }

/* Tabs & Paleta de Colores de Departamentos */
.dept-tabs { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 6px; 
    margin-bottom: 1rem; 
    border-bottom: 2px solid #ddd; 
    padding-bottom: 0.5rem; 
}

.dept-badge, .dept-tab {
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 6px;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s ease;
    text-decoration: none;
}

.dept-badge:hover, .dept-tab:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.dept-tab.active {
    box-shadow: 0 0 0 3px rgba(0,0,0,0.3);
    font-weight: 800;
}

/* Colores espec?ficos seg?n departamento */
.dept-00, .dept-default { background-color: #6c757d; color: #fff; }
.dept-01 { background-color: #ab0c0c; color: #fff; }
.dept-02 { background-color: #032aa8; color: #fff; }
.dept-03 { background-color: #855c29; color: #fff; }
.dept-04 { background-color: #0e6909; color: #fff; }
.dept-05 { background-color: #ed6894; color: #fff; }
.dept-06 { background-color: #5a2080; color: #fff; }
.dept-07 { background-color: #f54c0e; color: #fff; }
.dept-08 { background-color: #006d77; color: #fff; }
.dept-09 { background-color: #5C6BC0; color: #fff; }
.dept-cppu { background-color: #ab2c63; color: #fff; }
.dept-14 { background-color: #ecf23d; color: #000; }
.dept-15 { background-color: #00fcdf; color: #000; }
.dept-arq { background-color: #6c757d; color: #fff; }

/* Wrapper y bot?n para toggle de visibilidad de contrase?a (ojo) */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    width: 100%;
    padding-right: 2.5rem;
}

.btn-toggle-eye {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    transition: color 0.2s ease;
}

.btn-toggle-eye:hover {
    color: var(--primary-color, #ab0c0c);
}

.forgot-link {
    font-size: 0.85rem;
    color: var(--primary-color, #ab0c0c);
    text-decoration: none;
    transition: text-decoration 0.2s ease;
}

.forgot-link:hover {
    text-decoration: underline;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* ============================================================
   RESPONSIVE / MEDIUM SCREENS (769px ? 1200px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1200px) {
    .grid-table-fixed {
        --aula-col: 6.2%;
    }
}

/* ============================================================
   RESPONSIVE / WIDE SCREENS (> 1600px)
   ============================================================ */
@media (min-width: 1601px) {
    .grid-table-fixed {
        --aula-col: 4.5%;
    }
}

/* ============================================================
   RESPONSIVE / M?VIL
   ============================================================ */

@media (max-width: 768px) {

    body {
        flex-direction: column;
    }

    /* En móvil el colapso icon-rail no aplica; el botón cierra el drawer */
    .sidebar-collapse-btn .icon-expand {
        display: none !important;
    }

    .sidebar-collapse-btn .icon-collapse {
        display: block;
    }

    /* ---- Men? lateral como drawer ---- */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 270px;
        height: 100%;
        z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.45);
    }

    .sidebar > div:first-child {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar-header {
        flex: 0 0 auto;
        padding: 0.9rem 1rem;
        text-align: center;
    }

    .sidebar-header h3 {
        font-size: 1rem;
        white-space: nowrap;
    }

    .sidebar-header small {
        display: block;
        font-size: 0.75rem;
    }

    .sidebar-menu {
        flex: 1;
        display: flex;
        flex-direction: column;
        margin: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-menu li a {
        padding: 0.9rem 1.25rem;
        font-size: 0.95rem;
        white-space: nowrap;
        border-left: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sidebar-menu li a:hover,
    .sidebar-menu li.active a {
        border-left: 4px solid var(--accent-color);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sidebar-footer {
        display: block;
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }

    .sidebar-footer .btn-logout {
        margin-top: 0.35rem;
        display: inline-block;
    }

    /* ---- Fondo oscuro del drawer ---- */
    .sidebar-backdrop {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 1050;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }

    .sidebar-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        min-height: 0;
    }

    .top-bar {
        grid-template-columns: auto 1fr;
        gap: 0.5rem;
        padding: 0.6rem 0.75rem;
    }

    .top-bar-start {
        grid-column: 1;
    }

    .top-bar-title {
        grid-column: 2;
        justify-self: stretch;
        text-align: left;
    }

    .top-bar-actions {
        grid-column: 1 / -1;
        justify-self: stretch;
        justify-content: flex-start;
    }

    .top-bar h2,
    .top-bar-title h2 {
        font-size: 0.9rem;
    }

    .top-bar p,
    .top-bar-title p {
        font-size: 0.72rem;
    }

    #header-admin-actions {
        flex-wrap: wrap;
    }

    .content-section {
        padding: 0.75rem;
        overflow-x: auto;
    }

    /* ---- D?as compactos ---- */
    .accordion-day {
        margin-bottom: 0.5rem;
    }

    .accordion-header {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .accordion-body {
        padding: 0.5rem;
    }

    .grid-table th,
    .grid-table td {
        padding: 6px 8px;
        font-size: 0.75rem;
    }

    .grid-table td.cell-slot {
        min-height: 36px;
        height: auto;
        padding: 6px 4px;
    }

    .grid-table-fixed {
        --aula-col: 8%;
    }

    .grid-table td.cell-slot.occupied .cell-reserva-titulo {
        font-size: clamp(0.72rem, 2.4vw, 0.95rem);
    }

    .modal .modal-content {
        max-width: 100% !important;
        margin: 0.5rem;
        padding: 1.25rem;
        max-height: 94vh;
    }

    .modal .reserva-modal-content {
        width: calc(100% - 1rem);
        margin: 0.5rem;
        padding: 1rem;
        overflow-y: auto;
    }

    .form-group input,
    .form-group select {
        font-size: 16px; /* evita zoom autom?tico en iOS */
    }

    .modal-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .modal-actions > div {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .modal-actions .btn {
        flex: 1;
    }

    .floating-bubble {
        bottom: 1rem;
        right: 1rem;
        width: 48px;
        height: 48px;
    }

    .floating-panel {
        bottom: 4.2rem;
        right: 1rem;
        left: 1rem;
        width: auto;
        max-width: 340px;
    }

    .calendar-day-cell {
        height: 85px;
        padding: 3px;
    }

    .calendar-grid-body.todas-aulas .calendar-day-cell {
        height: auto;
        min-height: 85px;
    }

    .calendar-event-pill {
        font-size: 0.65rem;
    }

    #sec-departamentos > div[style] {
        flex-wrap: wrap;
    }

    #sec-departamentos input[type="text"] {
        min-width: 100%;
    }
}
/* ============================================================
   TOOLTIP DE AULA (Ocupaci?n Anual)
   ============================================================ */

.cal-tooltip {
    position: fixed;
    z-index: 2000;
    pointer-events: none;
    background: rgba(20, 20, 20, 0.92);
    color: #fff;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.45;
    max-width: 320px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
    white-space: normal;
}

.cal-tooltip-aula {
    margin-bottom: 2px;
}

.cal-tooltip-aula strong {
    color: #ffd166;
}

.cal-tooltip-texto {
    color: #e6e6e6;
}

.cal-tooltip-referencia {
    font-style: italic;
    color: #d4d4d4;
}

/* ============================================================
   MEN? CONTEXTUAL (clic derecho en espacio vac?o)
   ============================================================ */

.cal-context-menu {
    position: fixed;
    z-index: 2001;
    background: #fff;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    padding: 4px;
    min-width: 190px;
}

.cal-context-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #222;
    border-radius: 5px;
    cursor: pointer;
}

.cal-context-item:hover {
    background: #eef4ff;
}

.cal-context-item:last-child {
    color: #a02418;
}

td.cell-slot.occupied {
    cursor: pointer;
}

/* ============================================================
   TOOLTIP DE INFORMACIÓN DEL AULA (hover sobre nombre)
   ============================================================ */

.aula-info-tooltip {
    position: fixed;
    z-index: 2000;
    background: #ffffff;
    color: #333;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.5;
    max-width: 420px;
    min-width: 280px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    border: 1px solid #ddd;
}

.aula-info-tooltip h4 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    color: #003366;
}

.aula-info-tooltip img {
    width: 100%;
    max-height: 260px;
    border-radius: 4px;
    margin-bottom: 8px;
    display: block;
    object-fit: contain;
    background: #f0f3f7;
}

.aula-info-tooltip .aula-info-row {
    margin-bottom: 4px;
}

.aula-info-tooltip .aula-info-row strong {
    color: #555;
}

.aula-name-cell {
    cursor: help;
}

/* ============================================================
   PANEL DE AULAS (gestión por piso)
   ============================================================ */

.aulas-panel-header {
    margin-bottom: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.aulas-panel-header h3 {
    margin-bottom: 0.25rem;
}

.aulas-panel-header p {
    color: #666;
    font-size: 0.92rem;
}

.aulas-panel-loading {
    padding: 2rem;
    text-align: center;
    color: #777;
}

.aulas-piso-block {
    background: #fff;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    margin-bottom: 1.1rem;
    overflow: hidden;
}

.aulas-piso-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #003366;
    color: #fff;
}

.aulas-piso-header h4 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.aulas-piso-header span {
    font-size: 0.82rem;
    opacity: 0.85;
}

.aulas-piso-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.aula-card {
    border: 1px solid #d5dce5;
    border-radius: 8px;
    background: #f8fafc;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
}

.aula-card-delete {
    position: absolute;
    top: 0.45rem;
    right: 0.45rem;
    z-index: 2;
    width: 30px;
    height: 30px;
    border: 1px solid #e2b4b4;
    border-radius: 6px;
    background: #fff5f5;
    color: #b42318;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.aula-card-delete:hover {
    background: #fee4e2;
    border-color: #f04438;
}

.aula-card-top h5,
.aula-card-title {
    margin: 0 0 0.5rem;
    color: #003366;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-right: 2rem;
}

.aula-card-nombre {
    min-width: 0;
}

.aula-card-rename {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border: 1px solid #c9d4e0;
    border-radius: 6px;
    background: #fff;
    color: #003366;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.aula-card-rename:hover {
    background: #e8eef5;
    border-color: #003366;
}

.aula-card-foto {
    width: 100%;
    height: 240px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #d0d7de;
    background: #eef2f6;
}

.aula-card-foto-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8a94a6;
    font-size: 0.85rem;
}

.aula-card-form .form-group {
    margin-bottom: 0.65rem;
}

.aula-card-form label {
    font-size: 0.8rem;
}

.aula-comps-row {
    display: flex;
    gap: 1rem;
}

.aula-mobiliario-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.35rem;
    max-height: 180px;
    overflow-y: auto;
    padding: 0.45rem 0.55rem;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    background: #fff;
}

.aula-check {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    line-height: 1.3;
}

.aula-check input {
    width: auto;
    margin-top: 0.15rem;
}

.aula-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
    cursor: pointer;
}

.aula-radio input {
    width: auto;
}

.aula-cantidad-wrap[hidden] {
    display: none !important;
}

.aula-card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.aula-card-status {
    font-size: 0.8rem;
    color: #666;
}

.aula-card-status.ok {
    color: #0a7a3e;
    font-weight: 600;
}

.aula-card-view {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: #333;
}

.aula-card-view .aula-info-row strong {
    color: #555;
}

.aula-card-readonly {
    background: #fff;
}

.guest-nav {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.guest-top-actions {
    align-items: center;
    gap: 0.75rem;
}

.guest-nav-btn {
    border: 1px solid #c5ced9;
    background: #fff;
    color: #003366;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.guest-nav-btn.active {
    background: #003366;
    border-color: #003366;
    color: #fff;
}
