:root {
    --brand: #0b3d5c;
    --brand-soft: #e8f1f6;
    --accent: #c45c26;
    --ink: #1a2b36;
    --line: rgba(11, 61, 92, 0.12);
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(196, 92, 38, 0.12), transparent 40%),
        linear-gradient(160deg, #f7fafc 0%, #eef3f7 45%, #f8f5f1 100%);
    color: var(--ink);
}

/* App sidebar */
.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    z-index: 1040;
    background: rgba(255, 255, 255, 0.96);
    border-right: 1px solid var(--line);
    box-shadow: 4px 0 24px rgba(11, 61, 92, 0.06);
    transform: translateX(0);
    transition: transform 0.2s ease;
}

.app-sidebar-inner {
    min-height: 100vh;
}

.app-sidebar-brand .brand-mark {
    color: var(--accent);
}

.app-sidebar-user {
    color: #6c7a84;
}

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

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.85rem;
    border-radius: 0.65rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    background: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar-link:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.app-sidebar-link.is-active {
    background: var(--brand-soft);
    color: var(--brand);
    box-shadow: inset 3px 0 0 var(--brand);
}

.app-sidebar-logout {
    color: #6c7a84;
    cursor: pointer;
}

.app-sidebar-logout:hover {
    color: var(--accent);
    background: rgba(196, 92, 38, 0.08);
}

.app-sidebar-toggle {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1050;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    box-shadow: 0 4px 12px rgba(11, 61, 92, 0.1);
}

.app-sidebar-toggle span {
    display: block;
    width: 1.1rem;
    height: 2px;
    background: var(--brand);
    border-radius: 1px;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(26, 43, 54, 0.35);
}

.app-content {
    margin-left: 240px;
    min-height: 100vh;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

    .app-sidebar-toggle {
        display: flex;
    }

    .app-content {
        margin-left: 0;
        padding-top: 3.25rem;
    }

    body.sidebar-open {
        overflow: hidden;
    }
}

.page-shell {
    max-width: 960px;
}

.brand-mark {
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
}

.page-title {
    font-weight: 700;
    color: var(--brand);
}

.ies-card {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.ies-card:hover {
    border-color: rgba(11, 61, 92, 0.35);
    box-shadow: 0 10px 24px rgba(11, 61, 92, 0.08);
    transform: translateY(-2px);
}

.ies-card.is-active {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: 0 0 0 1px var(--brand);
}

.ies-sigla {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--brand);
}

.uo-block {
    border: 1px solid rgba(11, 61, 92, 0.1);
    background: #fff;
    box-shadow: 0 4px 14px rgba(11, 61, 92, 0.05);
}

.uo-title {
    background: var(--brand);
    color: #fff;
}

.uo-toggle {
    color: inherit;
    cursor: pointer;
}

.uo-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.department-toggle {
    cursor: pointer;
    transition: background 0.15s ease;
}

.department-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.75rem;
    opacity: 0.85;
    flex-shrink: 0;
}

.uo-block.is-open .department-chevron {
    transform: rotate(180deg);
}

.uo-courses {
    border-top: 1px solid rgba(11, 61, 92, 0.1);
}

.catalog-search {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.95);
}

.catalog-search:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(11, 61, 92, 0.12);
}

.course-item {
    border-bottom: 1px solid rgba(11, 61, 92, 0.08);
    color: inherit;
    transition: background 0.15s ease;
}

.course-item:last-child {
    border-bottom: 0;
}

.course-item:hover {
    background: var(--brand-soft);
}

.course-name {
    color: var(--ink);
    font-weight: 500;
}

.course-action {
    font-size: 0.8rem;
    color: var(--accent);
    white-space: nowrap;
}

.empty-state {
    border: 1px dashed rgba(11, 61, 92, 0.25);
    background: rgba(255, 255, 255, 0.7);
}

.btn-brand {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn-brand:hover {
    background: #082d44;
    border-color: #082d44;
    color: #fff;
}

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

.btn-accent:hover {
    background: #a84c1f;
    border-color: #a84c1f;
    color: #fff;
}

/* Login */
.login-shell {
    min-height: 100vh;
}

.login-panel {
    max-width: 440px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 12px 32px rgba(11, 61, 92, 0.1);
}

.login-link {
    color: var(--brand);
    text-decoration: none;
}

.login-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}

.form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(11, 61, 92, 0.12);
}

/* Profile */
.profile-panel {
    max-width: none;
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 24px rgba(11, 61, 92, 0.07);
}

.profile-panel-danger {
    border-color: rgba(196, 92, 38, 0.28);
    background:
        linear-gradient(90deg, rgba(196, 92, 38, 0.06), rgba(255, 255, 255, 0.92) 35%);
}

/* Admin */
.admin-table-wrap {
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fff;
}

.admin-table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ink);
    margin-bottom: 0;
}

.admin-table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
    background: var(--brand-soft);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 1rem;
}

.admin-table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(11, 61, 92, 0.08);
    vertical-align: middle;
}

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

.admin-table tbody tr:hover td {
    background: rgba(232, 241, 246, 0.45);
}

.admin-btn-edit {
    background: var(--brand-soft);
    border: 1px solid transparent;
    color: var(--brand);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.35rem 0.75rem;
}

.admin-btn-edit:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.admin-btn-delete {
    background: rgba(196, 92, 38, 0.1);
    border: 1px solid transparent;
    color: var(--accent);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.35rem 0.75rem;
}

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

.admin-btn-perms {
    background: rgb(0 0 0 / 0.1);
    border: 1px solid transparent;
    color: var(--accent);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.35rem 0.75rem;
}

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

.admin-modal {
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    overflow: hidden;
    box-shadow: 0 16px 40px rgba(11, 61, 92, 0.14);
}

.admin-modal .modal-header {
    border-bottom: 1px solid var(--line);
    background: var(--brand-soft);
}

.admin-modal .modal-title {
    color: var(--brand);
    font-weight: 700;
}

.admin-modal .modal-footer {
    border-top: 1px solid var(--line);
    background: rgba(247, 250, 252, 0.9);
}

.admin-modal-danger .modal-header {
    background: rgba(196, 92, 38, 0.1);
}

.admin-modal-danger .modal-title {
    color: var(--accent);
}

/* Editor */
.editor-shell {
    max-width: 1400px;
}

.catalog-panel,
.canvas-panel {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    min-height: 70vh;
}

@media (min-width: 992px) {
    .catalog-panel {
        position: sticky;
        top: 1.5rem;
        max-height: calc(100vh - 3rem);
        overflow-y: auto;
    }
}

.catalog-category-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
}

.catalog-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    margin-bottom: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 0.65rem;
    background: #fff;
    cursor: grab;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.catalog-item:hover {
    border-color: rgba(196, 92, 38, 0.45);
    box-shadow: 0 6px 16px rgba(11, 61, 92, 0.08);
    transform: translateY(-1px);
}

.catalog-item.is-dragging,
.calendar-item.is-dragging {
    opacity: 0.45;
}

.catalog-item-name {
    font-size: 0.92rem;
    font-weight: 600;
}

.catalog-item-hint {
    font-size: 0.7rem;
    color: #6c7a84;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.drop-zone {
    min-height: 88px;
    border: 1.5px dashed rgba(11, 61, 92, 0.22);
    border-radius: 0.85rem;
    padding: 0.75rem;
    background:
        linear-gradient(180deg, rgba(232, 241, 246, 0.45), rgba(255, 255, 255, 0.8));
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.drop-zone.is-over {
    border-color: var(--accent);
    background: rgba(196, 92, 38, 0.08);
    box-shadow: inset 0 0 0 1px rgba(196, 92, 38, 0.25);
}

.drop-placeholder {
    color: #6c7a84;
    font-size: 0.9rem;
    text-align: center;
    padding: 1.1rem 0.5rem;
}

.calendar-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: #fff;
    cursor: grab;
}

.calendar-item.is-global {
    border-color: rgba(196, 92, 38, 0.35);
    background: linear-gradient(90deg, rgba(196, 92, 38, 0.08), #fff 40%);
}

.calendar-item-title {
    display: block;
    color: var(--brand);
}

.calendar-item-meta {
    display: block;
    font-size: 0.75rem;
    color: #6c7a84;
}

.calendar-item-dates {
    font-size: 0.82rem;
    color: var(--ink);
    white-space: nowrap;
}

.calendar-item-edit, .calendar-item-delete {
    border: 0;
    background: var(--brand-soft);
    color: var(--brand);
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    line-height: 1;
}

.calendar-item-edit:hover, .calendar-item-delete:hover {
    background: var(--brand);
    color: #fff;
}

.scope-badge {
    background: rgba(196, 92, 38, 0.12);
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 991.98px) {
    .catalog-panel,
    .canvas-panel {
        min-height: auto;
    }

    .calendar-item {
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
    }

    .calendar-item-dates {
        grid-column: 1 / 2;
    }

    .calendar-item-edit, .calendar-item-delete {
        grid-row: 1 / 3;
        grid-column: 2;
    }
}

.editor-tabs .nav-link {
    color: var(--ink);
    font-weight: 500;
}

.editor-tabs .nav-link.active {
    color: var(--brand);
    border-color: var(--line) var(--line) #fff;
    font-weight: 700;
}

.preview-zone {
    min-height: 64px;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.85);
}

.calendar-item.preview-item {
    cursor: default;
}

.calendar-item.is-exception {
    border-color: rgba(196, 92, 38, 0.35);
    background: linear-gradient(90deg, rgba(196, 92, 38, 0.08), #fff 40%);
}

.calendar-item.is-inherited {
    cursor: default;
    background: rgba(11, 61, 92, 0.03);
    border-style: dashed;
}

.calendar-item.is-inherited .scope-badge {
    background: rgba(11, 61, 92, 0.08);
    color: var(--brand);
}

.course-picker-list {
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
}

.course-picker-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid rgba(11, 61, 92, 0.08);
    cursor: pointer;
    margin: 0;
}

.course-picker-item:last-child {
    border-bottom: 0;
}

.course-picker-item:hover,
.course-picker-item.is-selected {
    background: var(--brand-soft);
}

.course-picker-item .course-code {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
}

.exception-course-card {
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.85rem 1rem;
}

.exception-course-card .course-title {
    font-weight: 600;
    margin-bottom: 0.65rem;
}

#periodDivisionSelectedCourses .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
    color: var(--ink);
    padding: 0.45rem 0.65rem;
}

#periodDivisionSelectedCourses .badge button {
    border: 0;
    background: transparent;
    color: var(--muted);
    line-height: 1;
    padding: 0;
    font-size: 1rem;
    cursor: pointer;
}

.exception-card {
    border: 1px solid var(--line);
    background: #fff;
}

