/* ===== Button Tokens ===== */
:root {
    --button-primary-bg: #8B5CF6;
    --button-primary-bg-hover: #7C3AED;
    --button-primary-border: #C4B5FD;
    --button-primary-text: #FFFFFF;
    --button-secondary-bg: rgba(255, 255, 255, 0.04);
    --button-secondary-bg-hover: rgba(255, 255, 255, 0.08);
    --button-secondary-border: rgba(255, 255, 255, 0.10);
    --button-secondary-text: #F8FAFC;
    --button-ghost-bg-hover: rgba(255, 255, 255, 0.06);
    --button-ghost-border: rgba(255, 255, 255, 0.18);
    --button-danger-bg: #DC2626;
    --button-danger-bg-hover: #B91C1C;
    --button-danger-border: #F87171;
    --button-danger-subtle-bg: rgba(239, 68, 68, 0.13);
    --button-danger-subtle-bg-hover: rgba(239, 68, 68, 0.20);
    --button-danger-subtle-border: rgba(239, 68, 68, 0.25);
    --button-danger-subtle-text: #FECACA;
    --button-focus-ring: rgba(139, 92, 246, 0.45);
    --button-disabled-bg: rgba(148, 163, 184, 0.16);
    --button-disabled-border: rgba(148, 163, 184, 0.32);
    --button-disabled-text: #94A3B8;
    --button-radius: 8px;
}

[data-theme="light"] {
    --button-primary-bg: #4F46E5;
    --button-primary-bg-hover: #4338CA;
    --button-primary-border: #3730A3;
    --button-primary-text: #FFFFFF;
    --button-secondary-bg: #FFFFFF;
    --button-secondary-bg-hover: #F1F5F9;
    --button-secondary-border: #CBD5E1;
    --button-secondary-text: #334155;
    --button-ghost-bg-hover: #F8FAFC;
    --button-ghost-border: #CBD5E1;
    --button-danger-bg: #DC2626;
    --button-danger-bg-hover: #B91C1C;
    --button-danger-border: #991B1B;
    --button-danger-subtle-bg: #FEF2F2;
    --button-danger-subtle-bg-hover: #FEE2E2;
    --button-danger-subtle-border: #FECACA;
    --button-danger-subtle-text: #B91C1C;
    --button-focus-ring: rgba(79, 70, 229, 0.35);
    --button-disabled-bg: #CBD5E1;
    --button-disabled-border: #94A3B8;
    --button-disabled-text: #64748B;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    position: relative;
    overflow: visible;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    animation: slideUpCard 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) both;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.12);
}

.card:hover::before {
    opacity: 1;
}

.create-card {
    z-index: 10;
}

.card h2 {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Dashboard ===== */
.dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 1.25rem;
}

.dashboard-metric-card {
    --metric-color: var(--accent);
    --metric-bg: rgba(99, 102, 241, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 112px;
    padding: 1.25rem;
    border-left: 4px solid var(--metric-color);
}

.dashboard-metric-card--students {
    --metric-color: #10b981;
    --metric-bg: rgba(16, 185, 129, 0.1);
}

.dashboard-metric-card--teachers {
    --metric-color: #f59e0b;
    --metric-bg: rgba(245, 158, 11, 0.1);
}

.dashboard-metric-card--classrooms {
    --metric-color: #3b82f6;
    --metric-bg: rgba(59, 130, 246, 0.1);
}

.dashboard-metric-card .metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    color: var(--metric-color);
    background: var(--metric-bg);
    border-radius: 12px;
}

.dashboard-middle {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
    gap: 1.25rem;
    align-items: stretch;
}

.dashboard-monitor-card,
.dashboard-compact-card {
    display: flex;
    flex-direction: column;
}

.dashboard-monitor-card {
    min-height: 100%;
}

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

.dashboard-card-header h2 {
    margin: 0;
}

.dashboard-time-slot {
    flex: 0 0 auto;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    color: var(--accent-hover);
    background: var(--bg-hover);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.dashboard-monitor-table {
    flex: 1;
}

.dashboard-side-stack {
    display: grid;
    grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
    min-height: 100%;
}

.dashboard-compact-card {
    min-height: 0;
    padding: 1.25rem;
    gap: 0.75rem;
}

.dashboard-card-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dashboard-badge-list {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.dashboard-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-top: auto;
}

.dashboard-action-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 40px;
    padding: 0.6rem 0.85rem;
    text-align: center;
    text-decoration: none;
    font-size: 0.9rem;
}

.dashboard-action-link.btn-secondary {
    color: var(--button-secondary-text);
    background: var(--button-secondary-bg);
    border: 1px solid var(--button-secondary-border);
    border-radius: var(--button-radius);
    box-shadow: none;
}

.dashboard-action-link.btn-secondary:hover {
    color: var(--button-secondary-text);
    background: var(--button-secondary-bg-hover);
    border-color: var(--button-secondary-border);
}

.dashboard-check-state {
    --check-accent: var(--text-secondary);
    --check-surface: rgba(148, 163, 184, 0.08);
    --check-border: rgba(148, 163, 184, 0.22);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.9rem;
    align-items: start;
    padding: 1rem 1.1rem;
    color: var(--text-primary);
    background: linear-gradient(115deg, var(--check-surface), transparent 72%);
    border: 1px solid var(--check-border);
    border-left: 4px solid var(--check-accent);
    border-radius: var(--radius-sm);
}

.dashboard-check-state--success {
    --check-accent: var(--success);
    --check-surface: rgba(16, 185, 129, 0.1);
    --check-border: rgba(16, 185, 129, 0.24);
}

.dashboard-check-state--warning {
    --check-accent: var(--warning);
    --check-surface: rgba(245, 158, 11, 0.1);
    --check-border: rgba(245, 158, 11, 0.26);
}

.dashboard-check-state--error {
    --check-accent: var(--error);
    --check-surface: rgba(239, 68, 68, 0.1);
    --check-border: rgba(239, 68, 68, 0.26);
}

.dashboard-check-state__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: var(--check-accent);
    background: var(--check-surface);
    border: 1px solid var(--check-border);
    border-radius: var(--radius-sm);
}

.dashboard-check-state__body {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 0.2rem;
}

.dashboard-check-state__body strong {
    color: var(--check-accent);
    font-size: 0.95rem;
    line-height: 1.35;
}

.dashboard-check-state__body > span {
    color: var(--text-primary);
    font-size: 0.86rem;
    line-height: 1.5;
}

.dashboard-check-state__body small {
    margin-top: 0.25rem;
    color: var(--text-secondary);
    font-size: 0.76rem;
    line-height: 1.4;
}

.dashboard-conflict-card {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid rgba(229, 231, 235, 0.1);
    border-left: 4px solid var(--warning);
    border-radius: var(--radius-sm);
    background: rgba(245, 158, 11, 0.05);
}

.dashboard-conflict-card--error {
    border-left-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

.dashboard-conflict-card__icon {
    margin-top: 0.1rem;
}

.dashboard-conflict-card__body {
    flex: 1;
}

.dashboard-conflict-card__body h4 {
    margin: 0 0 0.25rem;
    color: #d97706;
    font-size: 0.95rem;
    font-weight: 600;
}

.dashboard-conflict-card--error h4 {
    color: var(--error);
}

.dashboard-conflict-card__body p {
    margin: 0;
    color: var(--text-main);
    font-size: 0.85rem;
    line-height: 1.4;
}

@media (max-width: 1200px) {
    .dashboard-metrics-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .dashboard-middle {
        grid-template-columns: 1fr;
    }

    .dashboard-side-stack {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-rows: auto;
    }
}

@media (max-width: 700px) {
    .dashboard-metrics-grid,
    .dashboard-side-stack {
        grid-template-columns: 1fr;
    }

    .dashboard-card-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

/* ===== Form Structure ===== */
.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 160px;
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input,
.filter-row input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition);
}

.form-group input::placeholder,
.filter-row input::placeholder {
    color: var(--text-placeholder);
    transition: opacity var(--transition);
}

.form-group input:focus,
.filter-row input:focus {
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    transform: translateY(-1px);
}

.form-group input:focus::placeholder,
.filter-row input:focus::placeholder {
    opacity: 0.5;
}

.form-group select,
.filter-row select,
.schedule-view-filter-grid select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition);
}

.form-group select:focus,
.filter-row select:focus,
.schedule-view-filter-grid select:focus {
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.stack-form textarea {
    width: 100%;
    min-height: 150px;
    resize: vertical;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition);
}

.stack-form textarea:focus {
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.schedule-view-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 1rem;
    align-items: end;
}

.department-workspace-control-card {
    display: grid;
    gap: 1rem;
}

.department-workspace-control-card .card-header-row {
    margin-bottom: 0;
}

.department-workspace-filter-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.35fr) repeat(2, minmax(180px, 0.65fr));
    gap: 1rem;
    align-items: end;
}

.schedule-view-metrics,
.department-workspace-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.department-workspace-grid {
    align-items: stretch;
}

.department-workspace-grid-wide {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: stretch;
}

.department-workspace-actions-grid {
    gap: 1rem;
}

.department-subject-import-card {
    grid-column: span 7;
    grid-row: span 2;
}

.department-teacher-assign-card {
    grid-column: span 5;
}

.department-teacher-request-card {
    grid-column: span 5;
}

.department-teachers-card {
    grid-column: 1 / -1;
}

.department-subject-import-card,
.department-teacher-assign-card,
.department-teacher-request-card,
.department-teachers-card,
.department-workspace-table-card {
    min-width: 0;
}

.department-subject-import-card,
.department-teacher-assign-card,
.department-teacher-request-card {
    display: flex;
    flex-direction: column;
}

.department-subject-import-card .stack-form,
.department-teacher-assign-card .stack-form,
.department-teacher-request-card .stack-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.department-subject-import-card .subject-import-slots-panel {
    flex: 1;
}

.department-subject-import-card .stack-form > .btn,
.department-teacher-assign-card .stack-form > .btn,
.department-teacher-request-card .stack-form > .btn {
    align-self: flex-start;
    margin-top: auto;
}

.teacher-request-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 180px;
}

.teacher-request-toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#teacher-requests-tbody input,
#teacher-requests-tbody select {
    min-width: 150px;
    width: 100%;
    padding: 0.5rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.85rem;
}

#teacher-requests-tbody input:focus,
#teacher-requests-tbody select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.department-teachers-card {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    min-height: 100%;
}

.department-teachers-card .card-header-row {
    margin-bottom: 0.85rem;
}

.department-teachers-card .metric-grid {
    margin-top: 0;
}

.metric-grid {
    display: grid;
    gap: 0.6rem;
}

.metric-card,
.department-comment-item {
    padding: 0.8rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
}

.metric-card strong,
.department-comment-item strong {
    display: block;
    margin-bottom: 0.28rem;
    color: var(--text-primary);
}

.metric-card span,
.metric-card small,
.department-comment-item span {
    display: block;
    color: var(--text-secondary);
}

.department-comment-list {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.department-comment-item p {
    margin-top: 0.5rem;
    color: var(--text-primary);
}

.schedule-section-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 1rem 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-group-select {
    max-width: 520px;
}

.schedule-group-select .select-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.schedule-group-checkboxes {
    max-height: 220px;
}

.schedule-hours-panel {
    margin-top: 1rem;
}

.schedule-hours-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 0.75rem;
}

.schedule-hours-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
    align-items: end;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
}

.schedule-hours-title {
    grid-column: 1 / -1;
    color: var(--text-primary);
    font-weight: 700;
}

.schedule-slots-panel {
    margin-top: 1rem;
    margin-bottom: 1.25rem;
    min-width: 0;
}

.schedule-slots-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    overflow: visible;
}

.schedule-slot-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(125px, 1fr)) auto;
    gap: 0.75rem;
    align-items: end;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
}

.schedule-slot-row:last-child {
    margin-bottom: 0;
}

.schedule-slot-row.has-subgroup {
    grid-template-columns: repeat(8, minmax(125px, 1fr)) auto;
}

.schedule-slot-remove {
    min-width: 125px;
    min-height: 44px;
    padding-inline: 1rem;
}

.schedule-conflict-modal {
    z-index: 1200;
    padding: 0.35rem;
    overflow-x: hidden;
    overflow-y: auto;
}

#schedule-conflict-modal .schedule-conflict-card {
    width: min(1760px, calc(100vw - 0.7rem));
    max-width: calc(100vw - 0.7rem);
    max-height: none;
    box-sizing: border-box;
    margin: auto;
    padding: 1rem;
    overflow: visible;
}

.schedule-conflict-head {
    display: grid;
    gap: 0.3rem;
    margin-right: 2rem;
    margin-bottom: 0.65rem;
}

.schedule-conflict-head h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.05rem;
    letter-spacing: 0;
    text-transform: none;
}

.schedule-conflict-head p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.35;
}

.schedule-conflict-kicker {
    width: max-content;
    padding: 0.2rem 0.55rem;
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-conflict-reasons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.15rem;
}

.schedule-conflict-reasons[hidden] {
    display: none;
}

.schedule-conflict-reasons span {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

.schedule-conflict-reasons strong {
    padding: 0.2rem 0.5rem;
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
    font-size: 0.76rem;
    font-weight: 800;
}

.schedule-conflict-rules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.schedule-conflict-rule-box {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.65rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.schedule-conflict-rule-box-active {
    border-color: rgba(245, 158, 11, 0.35);
    background: rgba(245, 158, 11, 0.08);
}

.schedule-conflict-rule-box span,
.schedule-conflict-slot-fixed span {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-conflict-rule-box strong,
.schedule-conflict-slot-fixed strong {
    min-width: 0;
    color: var(--text-primary);
    overflow-wrap: anywhere;
}

.schedule-conflict-rule-box small,
.schedule-conflict-slot-fixed small {
    color: var(--text-secondary);
    line-height: 1.4;
}

.schedule-conflict-form {
    display: grid;
    gap: 0.55rem;
}

.schedule-conflict-slots {
    display: grid;
    gap: 0.55rem;
    max-height: none;
    overflow: visible;
    padding-right: 0;
}

.schedule-conflict-slot-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.05fr) minmax(104px, 0.72fr) minmax(112px, 0.72fr) minmax(132px, 0.85fr) minmax(190px, 1.2fr) minmax(160px, 0.95fr);
    gap: 0.5rem;
    align-items: end;
    min-width: 0;
    max-width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-input) 88%, transparent);
}

.schedule-conflict-slot-fixed {
    display: grid;
    gap: 0.25rem;
    align-self: stretch;
    align-content: center;
    min-width: 0;
}

.schedule-conflict-slot-fixed.schedule-conflict-field-hit {
    padding-left: 0.55rem;
    border-left: 3px solid rgba(245, 158, 11, 0.75);
}

.schedule-conflict-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 0;
}

.schedule-conflict-card .form-group,
.schedule-move-slot-card .form-group {
    min-width: 0;
}

.schedule-conflict-card .form-group label,
.schedule-move-slot-card .form-group label {
    margin-bottom: 0.28rem;
    font-size: 0.7rem;
}

.schedule-conflict-card .form-group select,
.schedule-move-slot-card .form-group select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0.55rem 0.65rem;
    font-size: 0.84rem;
}

.schedule-conflict-card .form-alert,
.schedule-move-slot-card .form-alert {
    margin-top: 0;
}

.schedule-conflict-field-hit label {
    color: var(--warning);
}

.schedule-conflict-field-hit select {
    border-color: rgba(245, 158, 11, 0.65);
    background: color-mix(in srgb, rgba(245, 158, 11, 0.15) 35%, var(--bg-input));
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.12);
}

.schedule-visual-context-menu {
    position: fixed;
    z-index: 1300;
    display: grid;
    min-width: 220px;
    padding: 0.35rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: rgba(10, 10, 15, 0.97);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.schedule-visual-context-menu[hidden] {
    display: none;
}

[data-theme="light"] .schedule-visual-context-menu {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
}

.schedule-visual-context-menu button {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
}

.schedule-visual-context-menu button:hover,
.schedule-visual-context-menu button:focus-visible {
    outline: none;
    background: var(--bg-hover);
}

.schedule-visual-context-menu button.danger {
    color: var(--error);
}

#schedule-move-slot-modal .schedule-move-slot-card {
    width: min(620px, calc(100vw - 2rem));
    box-sizing: border-box;
    margin: auto;
    max-height: none;
    padding: 1rem;
    overflow: visible;
}

.schedule-move-slot-form {
    display: grid;
    gap: 0.55rem;
}

@media (max-width: 980px) {
    .schedule-conflict-slot-row {
        grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(140px, 1fr));
    }
}

.subject-import-rows-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    overflow: visible;
}

.subject-import-row {
    display: grid;
    grid-template-columns: minmax(120px, 0.7fr) minmax(240px, 1.3fr) auto;
    column-gap: 0.65rem;
    row-gap: 0.75rem;
    align-items: end;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
}

.schedule-rule-actions {
    margin-top: 0.25rem;
    clear: both;
}

.schedule-rule-table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 188px;
}

.schedule-rule-table-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    min-height: 32px;
    padding: 0.38rem 0.72rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.1;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.schedule-rule-table-button:hover,
.schedule-rule-table-button:focus-visible {
    outline: none;
    transform: translateY(-1px);
}

.schedule-rule-table-button-edit {
    border-color: color-mix(in srgb, var(--accent) 34%, var(--bg-card-border));
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-input));
    color: var(--accent-hover);
}

.schedule-rule-table-button-edit:hover,
.schedule-rule-table-button-edit:focus-visible {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 22%, var(--bg-input));
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent-glow) 60%, transparent);
}

.schedule-rule-table-button-delete {
    border-color: color-mix(in srgb, var(--error) 34%, var(--bg-card-border));
    background: color-mix(in srgb, var(--error) 10%, var(--bg-input));
    color: var(--error);
}

.schedule-rule-table-button-delete:hover,
.schedule-rule-table-button-delete:focus-visible {
    border-color: var(--error);
    background: color-mix(in srgb, var(--error) 18%, var(--bg-input));
    box-shadow: 0 4px 14px rgba(248, 113, 113, 0.14);
}

.slot-subgroup-multi .select-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-subgroup-multi .dropdown-menu {
    min-width: 260px;
}

.schedule-slot-summary {
    margin-bottom: 0.35rem;
}

.academic-year-semesters {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 0.35rem;
    align-items: stretch;
}

.academic-years-table tbody td {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    vertical-align: middle;
}

.academic-years-table thead th:first-child,
.academic-years-table thead th:nth-child(2),
.academic-years-table thead th:last-child {
    text-align: center;
}

.academic-year-center-cell {
    text-align: center;
    font-weight: 700;
}

.academic-year-semesters-cell {
    min-width: 520px;
    vertical-align: middle;
}

.academic-year-actions-cell {
    text-align: center;
    vertical-align: middle;
}

.academic-year-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 100%;
    white-space: nowrap;
}

.academic-year-semester-item {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
}

.subject-import-code-field,
.subject-import-name-field {
    min-width: 0;
}

.subject-import-row .btn {
    min-height: 42px;
}

.subject-import-row .form-group label {
    margin-bottom: 0.45rem;
}

@media (max-width: 900px) {
    .department-workspace-grid-wide {
        grid-template-columns: 1fr;
    }

    .department-subject-import-card,
    .department-teacher-assign-card,
    .department-teacher-request-card,
    .department-teachers-card {
        grid-column: 1;
        grid-row: auto;
    }

    .academic-year-semesters {
        grid-template-columns: 1fr;
    }

    .academic-year-semesters-cell {
        min-width: 360px;
    }
}

@media (max-width: 1280px) and (min-width: 901px) {
    .department-workspace-grid-wide {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .department-subject-import-card,
    .department-teachers-card {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .department-teacher-assign-card,
    .department-teacher-request-card {
        grid-column: span 1;
    }
}

@media (max-width: 700px) {
    .department-workspace-filter-grid {
        grid-template-columns: 1fr;
    }

    .subject-import-row {
        grid-template-columns: 1fr;
    }

    .department-subject-import-card .stack-form > .btn,
    .department-teacher-assign-card .stack-form > .btn,
    .department-teacher-request-card .stack-form > .btn,
    .subject-import-row .btn {
        width: 100%;
    }

    #schedule-conflict-modal .schedule-conflict-card {
        padding: 1rem;
    }

    .schedule-conflict-rules,
    .schedule-conflict-slot-row {
        grid-template-columns: 1fr;
    }

    .schedule-conflict-actions {
        flex-direction: column-reverse;
    }

    .schedule-conflict-actions .btn {
        width: 100%;
    }
}

.academic-year-semester-meta {
    display: grid;
    gap: 0.2rem;
}

.academic-year-semester-type {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 700;
}

.academic-year-semester-period {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.schedule-inline-table {
    margin-top: 1rem;
}

.schedule-visual-handle {
    position: fixed;
    top: 50%;
    right: 0 !important;
    z-index: 905;
    width: 46px !important;
    height: 100px !important;
    border: 1px solid var(--bg-card-border) !important;
    border-left: 3px solid var(--accent) !important;
    border-right: 0 !important;
    border-radius: 8px 0 0 8px !important;
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-card)) !important;
    color: var(--text-primary) !important;
    box-shadow: -4px 4px 16px rgba(0, 0, 0, 0.25) !important;
    transform: translateY(-50%) !important;
    transition: right 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                width 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                background 0.25s ease,
                color 0.25s ease,
                box-shadow 0.3s ease,
                border-color 0.25s ease !important;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

.schedule-visual-handle:hover {
    background: color-mix(in srgb, var(--accent) 18%, var(--bg-card)) !important;
    color: var(--text-primary) !important;
    width: 62px !important;
    box-shadow: -8px 8px 24px rgba(0, 0, 0, 0.35) !important;
    transform: translateY(-50%) !important;
}

.schedule-visual-handle.open {
    right: min(92vw, 1180px) !important;
    border-color: var(--bg-card-border) !important;
    border-left: 3px solid var(--accent) !important;
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-card)) !important;
    color: var(--text-primary) !important;
}

.schedule-visual-handle.open:hover {
    transform: translateY(-50%) !important;
    width: 62px !important;
}

.schedule-visual-handle.open .schedule-visual-handle-icon {
    transform: rotate(180deg) !important;
}

.schedule-visual-handle-icon {
    width: 38px !important;
    height: 38px !important;
    stroke-width: 3px !important;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

.schedule-visual-backdrop {
    position: fixed;
    inset: 0;
    z-index: 880;
    background: rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(2px);
}

.schedule-visual-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 900;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(92vw, 1180px);
    height: 100vh;
    padding: 1rem;
    background: color-mix(in srgb, var(--bg-primary) 90%, var(--bg-card));
    border-left: 1px solid var(--bg-card-border);
    box-shadow: -22px 0 55px rgba(0, 0, 0, 0.34);
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.schedule-visual-drawer.open {
    transform: translateX(0);
}

.schedule-visual-header {
    display: grid;
    gap: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.schedule-visual-header-main,
.schedule-visual-filter-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.schedule-visual-header h2 {
    margin: 0 0 0.25rem;
    color: var(--text-primary);
    font-size: 1rem;
    text-transform: none;
    letter-spacing: 0;
}

.schedule-visual-toolbar {
    display: grid;
    gap: 0.55rem;
}

.schedule-visual-period-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 0.65rem;
    align-items: end;
}

.schedule-visual-period-grid .form-group {
    min-width: 0;
}

.schedule-visual-filter-head {
    align-items: center;
}

.schedule-visual-filter-head>span {
    color: var(--text-secondary);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.schedule-visual-filter-head div {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem;
}

.schedule-visual-group-filter {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
}

.schedule-visual-group-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 30px;
    padding: 0.25rem 0.58rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}

.schedule-visual-group-chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.schedule-visual-group-chip input {
    width: 0.9rem;
    height: 0.9rem;
    margin: 0;
    accent-color: var(--accent);
}

.schedule-visual-group-chip:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--bg-input));
    color: var(--text-primary);
}

.schedule-visual-stage {
    min-height: 0;
    padding-top: 0.85rem;
    overflow: hidden;
}

.schedule-visual-state {
    height: 100%;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.schedule-visual-table-wrap {
    width: 100%;
    height: 100%;
    overflow: auto;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.schedule-visual-table {
    min-width: 760px;
    border-collapse: collapse;
    table-layout: fixed;
}

.schedule-visual-table th,
.schedule-visual-table td {
    border: 1px solid var(--bg-card-border);
}

.schedule-visual-table th {
    position: sticky;
    top: 0;
    z-index: 6;
    min-width: 168px;
    padding: 0.52rem;
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: center;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: none;
    letter-spacing: 0;
}

.schedule-visual-table .schedule-visual-day-head,
.schedule-visual-table .schedule-visual-time-head {
    z-index: 8;
    min-width: 96px;
    width: 96px;
}

.schedule-visual-table .schedule-visual-day-head {
    left: 0;
}

.schedule-visual-table .schedule-visual-time-head {
    left: 96px;
}

.schedule-visual-day-cell,
.schedule-visual-time-cell {
    position: sticky;
    background: var(--bg-input);
    color: var(--text-primary);
    box-shadow: 1px 0 0 var(--bg-card-border);
}

.schedule-visual-day-cell {
    left: 0;
    z-index: 4;
    width: 96px;
    min-width: 96px;
    padding: 0.52rem;
    vertical-align: top;
    font-weight: 800;
    font-size: 0.74rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

.schedule-visual-time-cell {
    left: 96px;
    z-index: 4;
    width: 96px;
    min-width: 96px;
    padding: 0.48rem;
    vertical-align: middle;
}

.schedule-visual-time-cell strong,
.schedule-visual-time-cell span {
    display: block;
    line-height: 1.15;
}

.schedule-visual-time-cell span {
    margin-top: 0.2rem;
    color: var(--text-secondary);
    font-size: 0.66rem;
}

.schedule-visual-lesson-cell {
    height: 1px;
    min-width: 168px;
    padding: 0 !important;
    vertical-align: stretch;
    background: var(--bg-primary);
}

.schedule-visual-lesson-cell-empty {
    background: color-mix(in srgb, var(--bg-input) 42%, var(--bg-primary));
}

.schedule-visual-unified {
    min-height: 96px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    padding: 0.34rem;
}

.schedule-visual-unified {
    justify-content: flex-start;
    background: color-mix(in srgb, var(--accent) 5%, var(--bg-primary));
}

.schedule-visual-half {
    position: relative;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    padding: 1.28rem 0.34rem 0.34rem;
    background: color-mix(in srgb, var(--accent) 13%, var(--bg-primary));
}

.schedule-visual-half+.schedule-visual-half {
    border-top: 1px solid var(--bg-card-border);
}

.schedule-visual-half-even {
    background: color-mix(in srgb, var(--success) 8%, var(--bg-primary));
}

.schedule-visual-half-label {
    position: absolute;
    top: 0.35rem;
    left: 0.45rem;
    max-width: calc(100% - 0.9rem);
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.58rem;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
}

.schedule-visual-half-odd .schedule-visual-half-label {
    color: var(--accent-hover);
}

.schedule-visual-half-even .schedule-visual-half-label {
    color: var(--success);
}

.schedule-visual-lesson {
    position: relative;
    display: grid;
    gap: 0.12rem;
    padding: 0.34rem 1.65rem 0.34rem 0.34rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.schedule-visual-lesson strong {
    color: var(--text-primary);
    font-size: 0.7rem;
    line-height: 1.18;
}

.schedule-visual-lesson strong span {
    color: var(--accent-hover);
    font-weight: 800;
}

.schedule-visual-lesson small {
    color: var(--text-secondary);
    font-size: 0.6rem;
    line-height: 1.14;
}

.schedule-visual-edit-rule {
    position: absolute;
    top: 0.18rem;
    right: 0.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1.25rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: none;
    transition: color var(--transition), transform var(--transition);
}

.schedule-visual-edit-rule:hover,
.schedule-visual-edit-rule:focus-visible {
    background: transparent;
    color: var(--accent-hover);
    outline: none;
    transform: translateY(-1px);
}

.schedule-visual-free {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

@media (max-width: 640px) {
    .schedule-visual-drawer {
        width: 100vw;
        padding: 0.75rem;
    }

    .schedule-visual-handle.open {
        right: calc(100vw - 46px) !important;
    }

    .schedule-visual-header {
        display: grid;
        grid-template-columns: 1fr;
    }

    .schedule-visual-header-main,
    .schedule-visual-filter-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .schedule-visual-period-grid {
        grid-template-columns: 1fr;
    }
}

.academic-calendar-tabs,
.university-structure-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.academic-calendar-tab,
.university-structure-tab {
    min-height: 40px;
    padding: 0.55rem 0.9rem;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.academic-calendar-tab:hover,
.academic-calendar-tab:focus-visible,
.university-structure-tab:hover,
.university-structure-tab:focus-visible {
    color: var(--text-primary);
    background: var(--bg-hover);
    outline: none;
}

.academic-calendar-tab.active,
.university-structure-tab.active {
    color: var(--accent-hover);
    background: var(--bg-card);
    border-color: var(--bg-card-border);
}

.academic-calendar-tab-panel,
.university-structure-tab-panel {
    display: grid;
    gap: 1rem;
}

.academic-calendar-tab-panel[hidden],
.university-structure-tab-panel[hidden] {
    display: none;
}

.calendar-subject-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0.75rem;
}

.calendar-subject-semester {
    min-height: 104px;
    padding: 0.8rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-input) 84%, var(--bg-card));
}

.calendar-subject-semester-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.calendar-subject-semester-head strong {
    color: var(--text-primary);
    font-size: 0.92rem;
}

.calendar-subject-semester-head span,
.calendar-subject-empty {
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.calendar-subject-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.calendar-subject-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    min-height: 30px;
    padding: 0.25rem 0.28rem 0.25rem 0.55rem;
    gap: 0.35rem;
    border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--bg-card-border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 9%, var(--bg-card));
    color: var(--text-primary);
    font-size: 0.84rem;
}

.calendar-subject-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-subject-remove {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
    border: none;
    border-radius: 50%;
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.calendar-subject-remove:hover,
.calendar-subject-remove:focus-visible {
    background: var(--danger);
    color: white;
    outline: none;
}

.assignment-subjects {
    display: grid;
    gap: 0.45rem;
    min-width: 220px;
}

.assignment-subject-semester {
    display: grid;
    gap: 0.15rem;
}

.assignment-subject-semester strong {
    color: var(--accent-hover);
    font-size: 0.78rem;
}

.assignment-subject-semester span {
    color: var(--text-primary);
    font-size: 0.86rem;
    line-height: 1.35;
}

.calendar-fill-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
    gap: 0.75rem;
    align-items: end;
    margin: 1rem 0;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
}

.academic-calendar-grid {
    display: grid;
    gap: 0.65rem;
    margin-top: 1rem;
}

.calendar-course-block {
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-input) 82%, var(--bg-card));
    overflow: hidden;
}

.calendar-course-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 44px;
    padding: 0.6rem 0.85rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background var(--transition);
}

.calendar-course-header::-webkit-details-marker {
    display: none;
}

.calendar-course-header:hover {
    background: var(--bg-hover);
}

.calendar-course-block[open] .calendar-course-header {
    border-bottom: 1px solid var(--bg-card-border);
}

.calendar-course-title {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.96rem;
    font-weight: 800;
}

.calendar-course-chevron {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(-45deg);
    transition: transform var(--transition), border-color var(--transition);
}

.calendar-course-block[open] .calendar-course-chevron {
    transform: rotate(45deg);
    border-color: var(--accent-hover);
}

.calendar-course-meta {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

.calendar-semesters-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
    align-items: stretch;
    gap: 0.65rem;
    padding: 0.65rem;
    overflow-x: hidden;
    overflow-y: hidden;
}

.calendar-semester-block {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 0;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    overflow: hidden;
}

.calendar-semester-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 32px;
    padding: 0.38rem 0.55rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.calendar-semester-header h4 {
    margin: 0;
    font-size: 0.86rem;
}

.calendar-semester-header span {
    color: var(--text-secondary);
    font-size: 0.72rem;
    white-space: nowrap;
}

.calendar-semester-table-wrap {
    flex: 1 1 auto;
    display: flex;
    min-height: 151px;
    overflow-x: auto;
    overflow-y: visible;
    background: var(--bg-primary);
    scrollbar-width: none;
}

.calendar-semester-table-wrap::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.calendar-semester-table {
    --calendar-day-head-width: 32px;
    --calendar-day-cell-size: 22px;
    --calendar-min-table-width: 538px;
    width: 100%;
    min-width: var(--calendar-min-table-width);
    max-width: none;
    min-height: 100%;
    flex: 1 1 auto;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.62rem;
    user-select: none;
}

.calendar-semester-table th,
.calendar-semester-table td {
    box-sizing: border-box;
    border: 1px solid var(--bg-card-border);
}

.calendar-semester-table tbody tr {
    height: var(--calendar-day-cell-size);
}

.calendar-day-head-col {
    width: var(--calendar-day-head-width);
}

.calendar-week-col {
    width: 22px;
}

.calendar-semester-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    height: var(--calendar-day-cell-size);
    padding: 0;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 700;
    text-align: center;
    line-height: 1;
    white-space: nowrap;
}

.calendar-semester-table .calendar-day-head {
    position: sticky;
    left: 0;
    z-index: 2;
    width: var(--calendar-day-head-width);
    min-width: var(--calendar-day-head-width);
    max-width: var(--calendar-day-head-width);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-weight: 700;
    text-align: center;
}

.calendar-day {
    position: relative;
    height: var(--calendar-day-cell-size);
    min-height: var(--calendar-day-cell-size);
    padding: 0;
    background: color-mix(in srgb, var(--activity-color, var(--accent)) 12%, var(--bg-card));
    border-color: color-mix(in srgb, var(--activity-color, var(--accent)) 28%, var(--bg-card-border));
    cursor: pointer;
    outline: none;
    box-shadow: none;
    text-align: center;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), filter var(--transition);
}

.calendar-day:hover,
.calendar-day:focus-visible {
    background: color-mix(in srgb, var(--activity-color, var(--accent)) 24%, var(--bg-card));
    border-color: color-mix(in srgb, var(--activity-color, var(--accent)) 50%, var(--bg-card-border));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--activity-color, var(--accent)) 30%, transparent);
    z-index: 3;
}

.calendar-day.is-selected {
    background: color-mix(in srgb, var(--activity-color, var(--accent)) 34%, var(--bg-card));
    border-color: color-mix(in srgb, var(--activity-color, var(--accent)) 64%, var(--bg-card-border));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--activity-color, var(--accent)) 44%, transparent);
    filter: saturate(1.08);
    z-index: 4;
}

.calendar-day-code {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 2px;
    color: var(--text-primary);
    font-size: 0.6rem;
    line-height: 1;
    font-weight: 800;
    text-shadow: 0 1px 0 color-mix(in srgb, var(--bg-primary) 70%, transparent);
}

.calendar-day-time-marker {
    position: absolute;
    right: 0;
    bottom: 0;
    padding: 0 1px;
    border-radius: 3px;
    background: var(--accent);
    color: #fff;
    font-size: 0.4rem;
    font-weight: 800;
    line-height: 1.15;
}

.calendar-day-activity {
    display: none !important;
}

.calendar-day-tooltip {
    position: fixed;
    z-index: 1200;
    width: min(280px, calc(100vw - 24px));
    padding: 0.75rem;
    border: 1px solid color-mix(in srgb, var(--activity-color, var(--accent)) 26%, var(--bg-card-border));
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-primary) 88%, var(--bg-card));
    color: var(--text-primary);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px) scale(0.98);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
    left: 0;
    top: 0;
}

.calendar-day-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.calendar-day-tooltip-head {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--bg-card-border);
}

.calendar-day-tooltip-head strong,
.calendar-day-tooltip-body strong {
    display: block;
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.25;
}

.calendar-day-tooltip-head span,
.calendar-day-tooltip-body span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.68rem;
    line-height: 1.2;
}

.calendar-day-tooltip-code {
    width: 34px;
    min-width: 34px;
    height: 34px;
    box-sizing: border-box;
    border-radius: 8px;
    background: color-mix(in srgb, var(--activity-color, var(--accent)) 24%, transparent);
    border: 1px solid color-mix(in srgb, var(--activity-color, var(--accent)) 56%, transparent);
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1;
    padding: 0;
    text-align: center;
}

.calendar-day-tooltip-head .calendar-day-tooltip-code {
    display: inline-grid;
    place-items: center;
}

.calendar-day-tooltip-code span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: inherit;
    font: inherit;
    line-height: 1;
    transform: none;
}

.calendar-day-tooltip-body {
    display: grid;
    gap: 0.45rem;
    padding-top: 0.65rem;
}

.calendar-empty-day {
    height: var(--calendar-day-cell-size);
    background: color-mix(in srgb, var(--bg-input) 65%, transparent);
}

.calendar-week-placeholder {
    color: transparent;
}

.calendar-empty-semester {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.calendar-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.calendar-total-chip {
    --chip-color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 28px;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--chip-color) 18%, transparent);
    border: 1px solid color-mix(in srgb, var(--chip-color) 52%, transparent);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
}

.calendar-total-chip.is-selected {
    background: color-mix(in srgb, var(--chip-color) 30%, var(--bg-card));
    border-color: color-mix(in srgb, var(--chip-color) 72%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--chip-color) 22%, transparent);
}

.calendar-total-selected {
    padding: 0.08rem 0.32rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--chip-color) 18%, var(--bg-primary));
    color: var(--text-secondary);
    font-size: 0.62rem;
    font-weight: 800;
    text-transform: uppercase;
}

#calendar-day-dialog.modal-overlay {
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(3px);
}

#calendar-day-dialog .calendar-day-dialog-card {
    width: min(470px, 100%);
    max-height: none;
    padding: 1rem 1rem 0.85rem;
    overflow: visible;
    background: color-mix(in srgb, var(--bg-primary) 88%, var(--bg-card));
    border-radius: 18px;
}

.calendar-day-dialog-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
    margin: 0.45rem 0;
}

.calendar-day-dialog-grid div {
    padding: 0.58rem 0.65rem;
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
}

.calendar-day-dialog-grid span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-bottom: 0.25rem;
}

.calendar-day-dialog-grid strong {
    font-size: 0.9rem;
}

.calendar-day-dialog-activity {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    margin: 0.55rem 0 0.65rem;
    padding: 0.6rem;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
}

.calendar-day-dialog-code {
    width: 40px;
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: color-mix(in srgb, var(--activity-color, var(--accent)) 20%, transparent);
    border: 1px solid color-mix(in srgb, var(--activity-color, var(--accent)) 55%, transparent);
    font-weight: 800;
}

.calendar-day-dialog-activity p {
    margin: 0.2rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.calendar-day-dialog-time-grid {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--bg-card-border);
}

.calendar-day-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.6rem;
    margin-bottom: 0;
}

#calendar-day-dialog-time-alert {
    margin: 0;
    padding: 0;
}

#calendar-day-dialog-time-alert.error,
#calendar-day-dialog-time-alert.success {
    margin-top: 0.55rem;
    padding: 0.5rem 0.75rem;
}

.profiles-context {
    color: var(--text-secondary);
    font-weight: 600;
    margin: -0.25rem 0 0.75rem;
}

.muted {
    color: var(--text-secondary);
}

@media (max-width: 1350px) {
    .schedule-view-filter-grid,
    .schedule-view-metrics,
    .department-workspace-grid:not(.department-workspace-grid-wide) {
        grid-template-columns: 1fr;
    }

    .schedule-hours-grid {
        grid-template-columns: 1fr;
    }

    .schedule-slot-row,
    .schedule-slot-row.has-subgroup {
        grid-template-columns: repeat(4, 1fr);
    }

    .schedule-slot-remove {
        grid-column: 4;
        justify-self: end;
        width: auto;
    }
}

@media (max-width: 1024px) {
    .calendar-fill-panel {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .calendar-subject-summary {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }

    .calendar-semesters-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .calendar-semester-block {
        height: auto;
        min-height: 0;
    }

    .calendar-semester-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.2rem;
    }

    .schedule-slot-row,
    .schedule-slot-row.has-subgroup {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }

    .schedule-slot-remove {
        grid-column: 2;
        justify-self: end;
        width: auto;
    }
}

@media (max-width: 640px) {
    .schedule-hours-row {
        grid-template-columns: 1fr;
    }

    .schedule-slot-row,
    .schedule-slot-row.has-subgroup {
        grid-template-columns: 1fr;
    }

    .schedule-slot-remove {
        grid-column: 1;
        justify-self: stretch;
        width: 100%;
    }

    .subject-import-row {
        grid-template-columns: 1fr;
    }

    .calendar-fill-panel {
        grid-template-columns: 1fr;
    }

    .academic-calendar-tab,
    .university-structure-tab {
        flex: 1 1 100%;
        border-radius: var(--radius-sm);
        border: 1px solid var(--bg-card-border);
    }

    .calendar-subject-summary {
        grid-template-columns: 1fr;
    }

    .calendar-day-dialog-grid {
        grid-template-columns: 1fr;
    }

    #calendar-day-dialog .calendar-day-dialog-card {
        max-height: calc(100vh - 2rem);
        overflow-y: auto;
    }
}

/* Hide Number Arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ===== Premium Custom Dropdown Styles ===== */
.custom-select-wrapper {
    position: relative;
    width: 100%;
    user-select: none;
    font-family: inherit;
}

.select-layer-active {
    position: relative !important;
    z-index: 10001 !important;
}

.custom-select-wrapper.open {
    z-index: 10002 !important;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    outline: none;
    transition: all var(--transition);
}

.filter-row .custom-select-trigger {
    height: 38px;
    box-sizing: border-box;
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    border-color: var(--bg-card-border);
}

.custom-select-trigger:hover {
    background: var(--bg-hover);
}

.custom-select-trigger:focus,
.custom-select-wrapper.open .custom-select-trigger {
    background: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    transform: translateY(-1px);
}

.filter-row .custom-select-wrapper.open .custom-select-trigger,
.filter-row .custom-select-trigger:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.custom-select-trigger.placeholder-active .custom-select-text {
    color: var(--text-placeholder);
}

.custom-select-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-icon {
    margin-left: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-select-wrapper.open .custom-select-icon {
    transform: rotate(180deg);
    color: var(--accent);
}

.custom-select-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    padding: 0.5rem;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top center;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
    list-style: none;
    margin: 0;
}

.custom-select-wrapper.open .custom-select-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.custom-select-search-container {
    padding: 0.25rem 0.5rem 0.5rem 0.5rem;
    border-bottom: 1px solid var(--bg-card-border);
    margin-bottom: 0.35rem;
}

.custom-select-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition);
}

.custom-select-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

/* Custom Scrollbar for Dropdown */
.custom-select-menu::-webkit-scrollbar {
    width: 6px;
}

.custom-select-menu::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 8px;
}

.custom-select-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.custom-select-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.custom-select-item {
    padding: 0.6rem 0.8rem;
    margin-bottom: 0.15rem;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, padding-left 0.2s ease;
}

.custom-select-item:last-child {
    margin-bottom: 0;
}

.custom-select-item:hover:not(.disabled) {
    background: var(--bg-hover);
    padding-left: 1.1rem;
}

.custom-select-item.selected {
    background: var(--accent-glow);
    color: #fff;
    font-weight: 500;
}

.custom-select-item.selected:hover {
    background: var(--accent-glow);
    padding-left: 0.8rem;
}

.custom-select-item.disabled {
    color: var(--text-secondary);
    opacity: 0.6;
    cursor: not-allowed;
}

.custom-select-item.placeholder-item {
    display: none;
    /* Hide placeholder options in the actual dropdown list naturally */
}

/* Light theme selects */
[data-theme="light"] .form-group input,
[data-theme="light"] .filter-row input,
[data-theme="light"] .custom-select-trigger {
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .custom-select-menu {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}

[data-theme="light"] .custom-select-menu::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .custom-select-menu::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .custom-select-item.selected {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-hover);
}

/* Filter Row */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.card-header-row h2 {
    margin-bottom: 0;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-row label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.filter-row input {
    height: 38px;
    box-sizing: border-box;
    padding: 0.45rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.filter-row input:focus {
    background-color: var(--bg-input-focus);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-row .custom-multi-select {
    width: min(240px, 100%);
    min-width: 220px;
}

.filter-row .select-box {
    min-height: 38px;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
}

.filter-row .select-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subgroup-config-grid {
    display: grid;
    grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
    grid-template-areas:
        "count capacities"
        "actions actions";
    gap: 1rem 0.75rem;
    align-items: end;
}

.subgroup-count-field {
    grid-area: count;
    min-width: 0;
    margin-bottom: 0;
}

.subgroup-capacity-fields {
    grid-area: capacities;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    min-width: 0;
}

.subgroup-capacity-fields:empty {
    display: none;
}

.subgroup-capacity-fields-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.subgroup-capacity-fields-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.subgroup-capacity-field {
    min-width: 0;
    margin-bottom: 0;
}

.subgroup-actions {
    grid-area: actions;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0;
}

@media (max-width: 720px) {
    .subgroup-config-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "count"
            "capacities"
            "actions";
    }

    .subgroup-capacity-fields {
        grid-template-columns: 1fr;
    }
}


/* ===== Custom Multi-Select ===== */
.custom-multi-select {
    position: relative;
    user-select: none;
    width: 100%;
}

.select-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
}

.select-box:hover {
    background: var(--bg-hover);
}

.select-box.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.dropdown-icon {
    transition: transform var(--transition);
}

.select-box.active .dropdown-icon {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    width: 100%;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    padding: 0.5rem;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.98);
    transform-origin: top center;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s ease;
}

[data-theme="light"] .custom-multi-select .dropdown-menu {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05) inset;
}

.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-menu.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.checkbox-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.checkbox-group-vertical::-webkit-scrollbar {
    width: 6px;
}

.checkbox-group-vertical::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 8px;
}

.checkbox-group-vertical::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.checkbox-group-vertical::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

[data-theme="light"] .checkbox-group-vertical::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .checkbox-group-vertical::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

.checkbox-item {
    display: flex;
    align-items: center;
    position: relative;
    padding: 0.5rem 0.5rem 0.5rem 2.25rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    user-select: none;
    transition: background 0.2s ease;
}

.form-group .checkbox-group-vertical .checkbox-item,
.filter-row .checkbox-group-vertical .checkbox-item {
    display: flex;
    align-items: center;
    margin-bottom: 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-transform: none;
    letter-spacing: 0;
}

.checkbox-item:hover {
    background: var(--bg-hover);
}

.checkbox-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkbox-item .checkmark {
    position: absolute;
    top: 50%;
    left: 0.6rem;
    transform: translateY(-50%);
    height: 1.15rem;
    width: 1.15rem;
    background-color: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: 4px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox-item:hover input~.checkmark {
    border-color: var(--accent);
}

.checkbox-item input:focus~.checkmark {
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.checkbox-item input:checked~.checkmark {
    background-color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

.checkmark::after {
    content: "";
    display: none;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.checkbox-item input:checked~.checkmark::after {
    display: block;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-width: 0;
    border: 1px solid var(--button-secondary-border);
    border-radius: var(--button-radius);
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        box-shadow var(--transition),
        transform var(--transition);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--button-focus-ring);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    background: var(--button-disabled-bg);
    border-color: var(--button-disabled-border);
    color: var(--button-disabled-text);
    cursor: not-allowed;
    opacity: 0.75;
    transform: none;
}

.btn-sm {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
}

.btn-md {
    min-height: 40px;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 600;
}

.btn-lg {
    min-height: 48px;
    padding: 0 20px;
    font-size: 15px;
    font-weight: 700;
}

.btn-icon-sm,
.btn-icon-md {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    border-radius: var(--button-radius);
    line-height: 1;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
}

.btn-icon-md {
    width: 40px;
    height: 40px;
}

.btn-icon-sm svg {
    width: 18px;
    height: 18px;
}

.btn-icon-md svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: var(--button-primary-bg);
    border-color: var(--button-primary-border);
    color: var(--button-primary-text);
    box-shadow: none;
}

.btn-primary:hover:not(:disabled) {
    background: var(--button-primary-bg-hover);
    color: var(--button-primary-text);
}

.btn-secondary {
    background: var(--button-secondary-bg);
    border-color: var(--button-secondary-border);
    color: var(--button-secondary-text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--button-secondary-bg-hover);
    border-color: var(--button-secondary-border);
    color: var(--button-secondary-text);
}

.btn-ghost {
    background: transparent;
    border-color: var(--button-ghost-border);
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--button-ghost-bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--button-danger-bg);
    border-color: var(--button-danger-border);
    color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
    background: var(--button-danger-bg-hover);
    color: #FFFFFF;
}

.btn-danger-subtle {
    background: var(--button-danger-subtle-bg);
    border-color: var(--button-danger-subtle-border);
    color: var(--button-danger-subtle-text);
}

.btn-danger-subtle:hover:not(:disabled) {
    background: var(--button-danger-subtle-bg-hover);
    border-color: var(--button-danger-subtle-border);
    color: var(--button-danger-subtle-text);
}

.group-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.group-actions {
    display: grid;
    grid-template-columns: 88px 104px 104px 116px;
    gap: 0.35rem;
    justify-content: end;
    align-items: center;
}

.group-action-btn {
    width: 100%;
}

.btn-restore-group {
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--button-radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    position: relative;
    overflow: hidden;
}

.btn-restore-group {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.24);
    color: var(--warning);
}

.btn-restore-group:hover {
    background: rgba(245, 158, 11, 0.2);
    transform: scale(1.05);
}

.btn-icon-toggle {
    width: 32px;
    height: 32px;
}

.btn-icon-toggle:hover {
    transform: translateY(-1px);
}

.group-actions .group-action-btn {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

/* ===== Alerts ===== */
.form-alert {
    display: none;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.form-alert.error {
    display: block;
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--error);
    animation: slideDownAlert 0.3s ease-out both;
}

.form-alert.success {
    display: block;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.2);
    color: var(--success);
    animation: slideDownAlert 0.3s ease-out both;
}

/* ===== Table ===== */
.table-wrap {
    overflow-x: auto;
}

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

thead th {
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--bg-card-border);
}

/* Sortable columns */
thead th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

thead th.sortable:hover {
    color: var(--accent);
}

thead th.sortable.sort-active {
    color: var(--accent);
}

.sort-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid currentColor;
    opacity: 0.3;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

thead th.sortable:hover .sort-arrow {
    opacity: 0.6;
}

thead th.sortable.sort-asc .sort-arrow {
    opacity: 1;
    border-bottom: 5px solid var(--accent);
    transform: rotate(0deg);
}

thead th.sortable.sort-desc .sort-arrow {
    opacity: 1;
    border-bottom: 5px solid var(--accent);
    transform: rotate(180deg);
}

/* ===== Filter Icon & Popup ===== */
thead th.filterable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.2s ease;
}

thead th.filterable:hover {
    color: var(--accent);
}

.filter-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 0.65rem;
    opacity: 0.4;
    cursor: pointer;
    transition: opacity 0.2s ease, color 0.2s ease;
    vertical-align: middle;
}

thead th.filterable:hover .filter-icon {
    opacity: 0.8;
}

thead th.filter-active .filter-icon {
    opacity: 1;
    color: var(--accent);
}

thead th.filter-active {
    color: var(--accent);
}

.filter-popup {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    max-width: 280px;
    background: rgba(15, 23, 42, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    padding: 0.75rem;
    z-index: 200;
    animation: filterPopupIn 0.2s ease-out both;
    text-transform: none;
}

[data-theme="light"] .filter-popup {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

@keyframes filterPopupIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-search {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 0.5rem;
}

.filter-search::placeholder {
    color: var(--text-placeholder);
}

.filter-search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.filter-btn-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.filter-btn-action {
    flex: 1;
    padding: 0.3rem 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.filter-list {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-card-border) transparent;
}

.filter-list::-webkit-scrollbar {
    width: 4px;
}

.filter-list::-webkit-scrollbar-thumb {
    background: var(--bg-card-border);
    border-radius: 2px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.filter-item:hover {
    background: var(--bg-hover);
}

.filter-item input[type="checkbox"] {
    cursor: pointer;
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    flex-shrink: 0;
}

.filter-btn-apply {
    width: 100%;
    padding: 0.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 3px 10px var(--accent-glow);
}

.filter-btn-apply:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px var(--accent-glow);
}

tbody td {
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--bg-card-border);
    transition: background var(--transition);
}

[data-theme="light"] tbody td {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

tbody tr {
    transition: background var(--transition);
    animation: slideInRow 0.3s ease-out both;
}

/* Animation delays */
tbody tr:nth-child(1) {
    animation-delay: 0.05s;
}

tbody tr:nth-child(2) {
    animation-delay: 0.1s;
}

tbody tr:nth-child(3) {
    animation-delay: 0.15s;
}

tbody tr:nth-child(4) {
    animation-delay: 0.2s;
}

tbody tr:nth-child(5) {
    animation-delay: 0.25s;
}

tbody tr:nth-child(n+6) {
    animation-delay: 0.3s;
}

tbody tr:hover {
    background: var(--bg-hover);
}

.loading-row {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem !important;
}

/* ===== Badges ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-admin {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
}

.badge-teacher {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.badge-student {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
}

.badge-ef {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-hover);
}

/* Classroom Status */
.badge-available {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.badge-unavailable {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
}

.status-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Theme Toggle Button ===== */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: var(--button-radius);
    background: var(--button-secondary-bg);
    border: 1px solid var(--button-secondary-border);
    color: var(--button-secondary-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0;
    transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
    z-index: 100;
    flex-shrink: 0;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform 0.4s ease;
}

.theme-toggle-icon-enter {
    animation: theme-toggle-icon-enter 0.4s ease;
}

@keyframes theme-toggle-icon-enter {
    from { opacity: 0; transform: rotate(-90deg) scale(0.5); }
    to { opacity: 1; transform: rotate(0deg) scale(1); }
}

.theme-toggle:hover {
    background: var(--button-secondary-bg-hover);
    border-color: var(--button-secondary-border);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--button-focus-ring);
}

.theme-toggle--fixed {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
}

.lesson-weeks-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-input);
    border: 1px solid var(--bg-card-border);
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    white-space: nowrap;
    line-height: 1.2;
}
