    .schedule-page:has(#schedule-grid:not([style*="display: none"])) {
        max-width: none;
    }

    .schedule-page.is-managing-groups #manage-groups-bar,
    .schedule-page.is-teacher-schedule #manage-groups-bar {
        display: none;
    }
    
    .control-panel {
        background: var(--background);
        padding: var(--space-6);
        border-radius: 0.5rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .form-group > label {
        display: block;
        margin-bottom: 0.375rem;
        font-weight: 500;
        color: #333;
    }
    
    .form-group select,
    .form-group input[type="date"] {
        width: 100%;
        max-width: 400px;
        padding: var(--space-3) var(--space-4);
        border: 2px solid var(--gray-300);
        border-radius: var(--border-radius-md);
        font-size: 0.9375rem;
        font-family: var(--font-sans);
        transition: all var(--transition-fast);
        background: var(--background);
        color: var(--text-primary);
    }
    
    .form-group select {
        appearance: none;
        cursor: pointer;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right var(--space-3) center;
        padding-right: var(--space-10);
    }
    
    .form-group select:hover,
    .form-group input:hover {
        border-color: var(--primary-400);
    }
    
    .form-group select:focus,
    .form-group input:focus {
        outline: none;
        border-color: var(--primary-500);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    }
    
    .btn {
        padding: var(--space-3) var(--space-5);
        border: none;
        border-radius: var(--border-radius-full);
        font-weight: 600;
        cursor: pointer;
        transition: all var(--transition-base);
        text-decoration: none;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 160px;
        text-align: center;
        font-size: 1rem;
        box-shadow: var(--shadow-md);
        position: relative;
        z-index: 1;
    }
    
    .btn-primary {
        background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-500) 100%);
        color: white;
        position: relative;
        overflow: hidden;
    }
    
    .btn-primary::before {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-600) 100%);
        opacity: 0;
        transition: opacity var(--transition-base);
        z-index: -1;
    }
    
    .btn-primary:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-xl);
    }
    
    .btn-primary:hover::before {
        opacity: 1;
    }
    
    .btn-primary:active {
        transform: translateY(0);
    }

    .modal .btn-primary:not(.btn-add-with-plus):hover,
    .modal .btn-primary:not(.btn-add-with-plus):active,
    .modal .btn-secondary:hover,
    .modal .btn-secondary:active,
    .error-modal .btn-primary:hover,
    .error-modal .btn-primary:active {
        transform: none;
    }

    .modal .btn-primary:not(.btn-add-with-plus)::before,
    .error-modal .btn-primary::before {
        display: none;
    }

    .modal .btn.btn-primary.btn-add-with-plus:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-xl);
    }

    .modal .btn.btn-primary.btn-add-with-plus:active {
        transform: translateY(0);
    }
    
    .btn-secondary {
        padding: var(--space-3) var(--space-5);
        background: var(--background);
        color: var(--primary-600);
        border: 2px solid var(--primary-500);
        border-radius: var(--border-radius-md);
        font-weight: 500;
        cursor: pointer;
        transition: all var(--transition-base);
        box-shadow: var(--shadow-sm);
    }
    
    .btn-secondary:hover {
        background: var(--primary-50);
        border-color: var(--primary-600);
        transform: translateY(-1px);
        box-shadow: var(--shadow-md);
    }
    
    .btn-secondary:active {
        transform: translateY(0);
    }
    
    .schedule-grid {
        background: var(--background);
        border-radius: var(--border-radius-md);
        box-shadow: var(--shadow-md);
        overflow: visible;
        display: none;
    }
    
    .schedule-header-wrapper {
        padding: var(--space-4);
        background: var(--gray-50);
        border-bottom: 1px solid var(--gray-200);
    }
    
    .schedule-header-content {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-4);
    }
    
    .schedule-header-title {
        flex: 1;
    }

    #schedule-title {
        margin: 0;
    }
    
    .schedule-header-buttons {
        display: flex;
        gap: var(--space-3);
        flex-wrap: wrap;
    }

    .week-navigation {
        display: inline-grid;
        grid-template-columns: auto auto auto;
        align-items: center;
        column-gap: var(--space-2);
        margin-top: var(--space-2);
        max-width: 100%;
    }

    .week-navigation #btn-prev-week,
    .week-navigation #btn-next-week {
        flex: 0 0 auto;
        min-width: auto;
        padding: 0.375rem var(--space-3);
        font-size: 0.875rem;
    }

    .week-navigation #week-info {
        text-align: center;
        white-space: nowrap;
        color: var(--gray-600);
        min-width: 23ch;
    }
    
    #empty-week-message {
        text-align: center;
        padding: var(--space-12);
        margin: 0;
    }

    #empty-week-message h3 {
        margin-bottom: var(--space-4);
        color: var(--gray-700);
    }

    #empty-week-message p {
        color: var(--gray-500);
    }

    #empty-week-message .btn {
        margin-top: var(--space-6);
    }

    .table-wrapper {
        overflow: auto;
        max-height: calc(100vh - var(--space-8));
        max-height: calc(100dvh - var(--space-8));
        max-height: calc(100svh - var(--space-8));
        margin: 0;
        width: 100%;
        position: relative;
        -webkit-overflow-scrolling: touch;
    }
    
    .table-wrapper[style*="display: none"] {
        visibility: hidden;
        height: 0;
        max-height: 0;
        overflow: hidden;
    }
    
    .grid-table {
        border-collapse: separate;
        border-spacing: 0;
        table-layout: auto;
        width: max-content;
        min-width: 100%;
    }
    
    .grid-table th,
    .grid-table td {
        border: 1px solid var(--gray-200);
        padding: var(--space-1);
        text-align: center;
    }

    .grid-table th {
        background: var(--gray-100);
        font-weight: 600;
        position: -webkit-sticky;
        position: sticky;
        font-size: 0.75rem;
        line-height: 1.25;
        top: 0;
        z-index: 20;
        background-clip: padding-box;
        box-shadow: 0 1px 0 var(--gray-200);
    }
    
    .grid-table th.group-header {
        width: 135px;
        min-width: 135px;
        z-index: 20;
        overflow-wrap: anywhere;
        hyphens: auto;
    }

    .group-header-number,
    .group-header-name {
        display: block;
    }

    .group-header-number {
        white-space: nowrap;
    }
    
    .grid-table th.day-header {
        background: var(--primary-500);
        color: white;
        width: 96px !important;
        min-width: 96px !important;
        max-width: 96px !important;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        left: 0;
        background-clip: padding-box;
        border-right: 1px solid var(--gray-200);
        z-index: 31;
    }
    
    .grid-table td.day-header {
        width: 96px !important;
        min-width: 96px !important;
        max-width: 96px !important;
        background: var(--background);
        position: -webkit-sticky;
        position: sticky;
        left: 0;
        background-clip: padding-box;
        border-right: 1px solid var(--gray-200);
        font-size: 0.75rem;
        font-weight: 600;
        z-index: 11;
    }
    
    .grid-table th.time-header {
        background: var(--primary-600);
        color: white;
        width: 86px !important;
        min-width: 86px !important;
        max-width: 86px !important;
        position: -webkit-sticky;
        position: sticky;
        top: 0;
        left: 96px;
        background-clip: padding-box;
        border-right: 1px solid var(--gray-200);
        z-index: 30;
    }
    
    .grid-table td.time-header {
        width: 86px !important;
        min-width: 86px !important;
        max-width: 86px !important;
        background: var(--background);
        position: -webkit-sticky;
        position: sticky;
        left: 96px;
        background-clip: padding-box;
        border-right: 1px solid var(--gray-200);
        font-size: 0.75rem;
        z-index: 10;
    }

    /* Текущая пара по времени — только цвет текста, без фона и рамок */
    .grid-table td.time-header.is-current-slot,
    .grid-table td.time-header.is-current-slot strong,
    .grid-table td.time-header.is-current-slot .time-range-full,
    .grid-table td.time-header.is-current-slot .time-range-mobile {
        color: var(--primary-600);
    }

    .grid-table td.time-header.is-current-slot strong {
        font-weight: 800;
    }

    .day-name-short {
        display: none;
    }

    .time-range-mobile {
        display: none;
    }
    
    .grid-table td.cell {
        cursor: pointer;
        vertical-align: middle;
        height: 1px;
        position: relative;
        z-index: 1;
        padding: 0.12rem;
        width: 135px;
        min-width: 135px;
        overflow: visible;
    }

    .grid-table.teacher-view {
        table-layout: fixed;
        width: 100%;
    }

    .grid-table.teacher-view th.day-header,
    .grid-table.teacher-view td.day-header {
        width: 20% !important;
        min-width: 96px !important;
        max-width: 20% !important;
    }

    .grid-table.teacher-view th.time-header,
    .grid-table.teacher-view td.time-header {
        width: 20% !important;
        min-width: 86px !important;
        max-width: 20% !important;
        left: 20%;
    }

    .grid-table.teacher-view th.group-header,
    .grid-table.teacher-view td.cell {
        width: auto;
        min-width: 0;
        max-width: none;
    }

    .grid-table td.cell.cell-has-overlay {
        z-index: 5;
    }
    
    .grid-table tr.day-last-row td {
        border-bottom: 3px solid var(--gray-300);
    }

    .grid-table td.cell.empty-cell:hover::after {
        background: #f0fdf4;
    }
    
    .lesson-card {
        background: #dbeafe;
        border-left: 2px solid #3b82f6;
        padding: var(--space-1);
        border-radius: 0.2rem;
        font-size: 0.68rem;
        cursor: pointer;
        min-height: 52px;
        height: calc(100% - 0.2rem);
        width: calc(100% - 0.2rem);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        box-sizing: border-box;
        margin: 0.1rem;
    }
    
    .lesson-card:hover {
        opacity: 0.8;
    }

    .lesson-card.is-draggable {
        cursor: grab;
        user-select: none;
    }

    .lesson-card.is-dragging {
        opacity: 0.45;
    }

    .grid-table td.cell.empty-cell.drop-ready {
        background: rgba(16, 185, 129, 0.12);
        box-shadow: inset 0 0 0 2px var(--primary-500);
    }
    
    .lesson-card.lecture {
        background: #fef3c7;
        border-left-color: #f59e0b;
    }
    
    .lesson-card.lecture:hover {
        background: #fde68a;
    }
    
    .lesson-card.practice {
        background: #dbeafe;
        border-left-color: #3b82f6;
    }
    
    .lesson-card.practice:hover {
        background: #bfdbfe;
    }
    
    .lesson-card.lab {
        background: var(--primary-100);
        border-left-color: var(--primary-500);
    }
    
    .lesson-card.lab:hover {
        background: var(--primary-200);
    }

    .lesson-card.seminar {
        background: #ffe4e6;
        border-left-color: #f43f5e;
    }

    .lesson-card.seminar:hover {
        background: #fecdd3;
    }
    
    .lesson-card.other {
        background: #e9d5ff;
        border-left-color: #a855f7;
    }
    
    .lesson-card.other:hover {
        background: #ddd6fe;
    }

    /* Подгруппы с разными типами занятий */
    .lesson-card.mixed-types {
        background: #cffafe;
        border-left-color: #06b6d4;
    }

    .lesson-card.mixed-types:hover {
        background: #a5f3fc;
    }
    
    /* Стиль для занятий без преподавателя/аудитории (и после копирования с конфликтом) */
    .lesson-card.room-conflict {
        border: 2px solid #ef4444 !important;
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
        position: relative;
        z-index: 5;
    }

    .incomplete-lesson-flags {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0.125rem;
        margin-bottom: 0.15rem;
        z-index: 6;
        flex-shrink: 0;
        width: 100%;
    }
    
    .room-conflict-label {
        display: block;
        width: 100%;
        box-sizing: border-box;
        text-align: center;
        font-size: 0.5rem;
        color: #dc2626;
        font-weight: 600;
        background: #fee2e2;
        padding: 0.15rem;
        border-radius: 0.25rem;
        white-space: normal;
        line-height: 1.2;
        z-index: 6;
    }

    .grid-table td.cell.cell-has-overlay .lesson-card {
        z-index: 5;
    }

    .grid-table td.cell.cell-has-overlay .incomplete-lesson-flags,
    .grid-table td.cell.cell-has-overlay .room-conflict-label {
        z-index: 6;
    }
    
    .lesson-title {
        font-weight: 600;
        margin-bottom: 0.15rem;
        font-size: 0.7rem;
        line-height: 1.2;
        text-align: center;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
        overflow-wrap: break-word;
        word-break: normal;
        hyphens: auto;
        -webkit-hyphens: auto;
        -ms-hyphens: auto;
    }
    
    .subgroup-lesson-card {
        position: relative;
        background: var(--gray-50);
        padding: var(--space-4);
        border-radius: var(--border-radius-lg);
        margin-bottom: 0.875rem;
        border: 2px solid var(--primary-200);
    }
    
    .subgroup-lesson-card h4 {
        position: relative;
        padding-left: var(--space-3);
    }
    
    .subgroup-lesson-card h4::before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 1rem;
        background: var(--primary-500);
        border-radius: var(--border-radius-full);
    }
    
    /* Стили для мини-слотов в расписании */
    .lesson-card.has-subgroups {
        align-items: stretch;
        justify-content: center;
    }

    .lesson-card.has-subgroups:has(.subgroup-mini-slot.room-conflict) {
        border-left-width: 0;
    }

    .lesson-card.has-subgroups > .lesson-comment {
        margin-top: 0;
    }
    
    .subgroup-mini-slot {
        padding: 0.15rem;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        align-self: stretch;
    }

    .subgroup-mini-slot.room-conflict {
        border: 2px solid #ef4444 !important;
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
        border-radius: 0.375rem;
        position: relative;
        z-index: 5;
    }

    .subgroup-mini-slot .incomplete-lesson-flags {
        position: static;
        align-items: stretch;
        width: 100%;
    }
    
    .subgroup-mini-slot:not(:has(+ .subgroup-mini-slot)) {
        border-bottom: none;
    }
    
    .subgroup-mini-slot-title {
        font-size: 0.54rem;
        font-weight: 700;
        color: var(--primary-700);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        text-align: center;
        width: 100%;
    }
    
    .lesson-teacher {
        color: var(--text-primary);
        font-size: 0.66rem;
        line-height: 1.2;
        text-align: center;
        overflow-wrap: anywhere;
        margin-bottom: 0.15rem;
    }
    
    .lesson-teacher a.teacher-link {
        color: var(--text-primary);
        font-size: 0.66rem;
        text-decoration: none;
        transition: background-color 0.2s ease;
        padding: 0.1rem;
        border-radius: 0.2rem;
        display: inline;
    }
    
    .lesson-teacher a.teacher-link:hover {
        color: var(--text-primary);
        background-color: #93c5fd;
        box-shadow: none;
        transform: none;
    }

    .lesson-card.lecture .lesson-teacher a.teacher-link:hover {
        background-color: #fcd34d;
    }

    .lesson-card.lab .lesson-teacher a.teacher-link:hover {
        background-color: var(--primary-300);
    }

    .lesson-card.seminar .lesson-teacher a.teacher-link:hover {
        background-color: #fda4af;
    }

    .lesson-card.other .lesson-teacher a.teacher-link:hover {
        background-color: #c4b5fd;
    }

    .lesson-card.mixed-types .lesson-teacher a.teacher-link:hover {
        background-color: #67e8f9;
    }
    
    .lesson-room {
        font-size: 0.66rem;
        line-height: 1.2;
        text-align: center;
        margin-bottom: 0.15rem;
    }
    
    .lesson-address {
        color: #f97316;
        font-size: 0.66rem;
        line-height: 1.2;
        font-style: italic;
        text-align: center;
    }

    .grid-table.teacher-view .lesson-card {
        margin-bottom: var(--space-2);
    }

    .grid-table.teacher-view .lesson-title {
        font-size: 0.7rem;
        font-weight: 600;
    }

    .spec-mini-slot .lesson-teacher,
    .spec-mini-slot .lesson-teacher a.teacher-link,
    .spec-mini-slot .lesson-room,
    .spec-mini-slot .lesson-address {
        margin-bottom: 0;
    }

    .spec-mini-slot .lesson-teacher a.teacher-link,
    .spec-mini-slot .lesson-address {
        font-size: 0.64rem;
    }
    
    .lesson-comment {
        color: #dc2626;
        font-weight: 600;
        font-size: 0.66rem;
        line-height: 1.2;
        font-style: italic;
        margin-top: 0.15rem;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        padding-top: 0.15rem;
        text-align: center;
        width: 100%;
    }
    
    .lesson-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        flex: 1 1 auto;
        min-height: 0;
    }

    .lesson-card.has-subgroups .lesson-content {
        flex: 0 1 auto;
    }

    .slot-type-options {
        display: flex;
        flex-wrap: wrap;
        column-gap: var(--space-4);
        row-gap: var(--space-2);
        align-items: center;
    }

    .slot-type-options > label {
        display: flex;
        align-items: center;
        gap: var(--space-2);
        cursor: pointer;
    }

    .field-suggest {
        position: relative;
    }

    .form-hint {
        display: block;
        color: var(--gray-500);
        margin-top: var(--space-2);
    }

    .form-hint-sm {
        margin-top: var(--space-1);
    }

    .form-radio-stack {
        display: flex;
        flex-direction: column;
        gap: var(--space-3);
        margin-top: var(--space-2);
    }

    .form-radio-stack > label {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        cursor: pointer;
    }

    .form-radio-stack input {
        cursor: pointer;
    }

    .form-radio-stack .form-hint {
        margin-top: 0;
        margin-left: var(--space-6);
    }

    .subgroup-card-hint {
        margin: 0 0 var(--space-3);
        color: var(--gray-500);
        font-size: 0.875rem;
    }

    .form-empty-note {
        color: var(--gray-500);
        margin: var(--space-4) 0;
    }

    .form-empty-note-secondary {
        color: var(--text-secondary);
    }

    .form-empty-note-italic {
        font-style: italic;
    }

    .muted-note {
        color: var(--gray-500);
    }

    .muted-note-error {
        color: #dc2626;
    }

    .muted-note-italic {
        font-style: italic;
    }

    .default-address-mark {
        color: var(--primary-500);
        font-weight: 600;
    }

    #specialization-lessons-container {
        margin-top: var(--space-3);
    }

    .btn-add-with-plus {
        min-width: auto;
        width: auto;
        height: auto;
        flex: 0 0 auto;
        padding: var(--space-1) var(--space-3);
        border-radius: var(--border-radius-lg);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        line-height: 1.2;
        color: white;
        font-size: 0.875rem;
        white-space: nowrap;
    }

    .btn-add-with-plus::before {
        border-radius: inherit;
    }

    #specialization-lessons-fields > .form-hint {
        margin-top: 0;
    }

    #add-specialization-slot-btn {
        margin: 0 0 var(--space-2);
    }

    .btn-add-with-plus svg {
        display: block;
        flex-shrink: 0;
    }

    .spec-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        margin-bottom: var(--space-3);
    }

    .spec-card-header h4 {
        margin: 0;
        color: var(--primary-700);
        font-size: 1rem;
        font-weight: 600;
    }

    .subgroup-card-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-3);
        margin-bottom: var(--space-3);
        flex-wrap: wrap;
    }

    .subgroup-card-header h4 {
        margin: 0;
        color: var(--primary-700);
        font-size: 1rem;
        font-weight: 600;
    }

    .subgroup-shared-groups {
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem;
        margin: 0 0 var(--space-3);
        min-height: 0;
    }

    .subgroup-shared-group-chip {
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
        padding: var(--space-1) var(--space-2);
        border-radius: 999px;
        background: #e0f2fe;
        color: var(--primary-700);
        font-size: 0.75rem;
        line-height: 1.2;
        font-weight: 600;
    }

    .subgroup-shared-group-remove {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.25rem;
        height: 1.25rem;
        padding: 0;
        margin: 0;
        border: none;
        border-radius: 999px;
        background: transparent;
        color: inherit;
        cursor: pointer;
        font-size: 1.25rem;
        font-weight: 500;
        line-height: 1;
        flex-shrink: 0;
        transition: background var(--transition-fast), color var(--transition-fast);
    }

    .subgroup-shared-group-remove:hover,
    .subgroup-shared-group-remove:focus-visible {
        background: #fee2e2;
        color: #dc2626;
        outline: none;
    }

    .subgroup-shared-groups-hint {
        margin: 0 0 var(--space-3);
        color: var(--gray-600);
        font-size: 0.875rem;
    }

    #subgroup-shared-groups-list.checkbox-group {
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: var(--space-2);
    }

    #subgroup-shared-groups-list .checkbox-label {
        white-space: normal;
        word-break: break-word;
    }

    .spec-remove-btn {
        min-width: auto;
        padding: 0.2rem var(--space-2);
        font-size: 0.75rem;
        line-height: 1.2;
        box-shadow: var(--shadow-sm);
    }

    .lesson-card.has-specializations {
        justify-content: center;
        align-items: stretch;
    }

    .lesson-card.has-specializations:has(.spec-mini-slot.room-conflict) {
        border-left-width: 0;
    }

    .spec-mini-slot {
        font-size: 0.64rem;
        line-height: 1.2;
        padding: 0.15rem;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        text-align: center;
        box-sizing: border-box;
        overflow-wrap: break-word;
        word-break: normal;
        hyphens: auto;
        -webkit-hyphens: auto;
        -ms-hyphens: auto;
    }

    .spec-mini-slot.room-conflict {
        border: 2px solid #ef4444 !important;
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
        border-radius: 0.375rem;
        position: relative;
        z-index: 5;
    }

    .spec-mini-slot .incomplete-lesson-flags {
        position: static;
        align-items: stretch;
        width: 100%;
    }

    .grid-table td.cell.empty-cell {
        min-height: calc(52px + 0.3rem);
        cursor: pointer;
    }

    .grid-table td.cell.empty-cell::after {
        content: '';
        position: absolute;
        inset: 0.2rem;
        border-radius: 0.375rem;
        pointer-events: none;
        box-sizing: border-box;
    }

    #slot-preview-modal .modal-content {
        max-width: 28rem;
        width: calc(100vw - 1.25rem);
        padding: var(--space-4);
        max-height: min(92vh, 92dvh);
        box-sizing: border-box;
    }

    #slot-preview-modal .modal-header h2 {
        font-size: 1.15rem;
        line-height: 1.3;
    }

    .slot-preview-meta {
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
        margin: 0 0 var(--space-3);
        color: var(--text-secondary);
        font-size: 0.92rem;
        line-height: 1.3;
    }

    .slot-preview-groups-mode {
        display: block;
        font-weight: 700;
        color: var(--text-primary);
    }

    .slot-preview-group-line {
        display: block;
    }

    .slot-preview-common {
        font-weight: 700;
        font-size: 1rem;
        color: var(--primary-700);
        margin-bottom: var(--space-3);
    }

    .slot-preview-block {
        background: var(--gray-50);
        border-radius: 0.75rem;
        padding: var(--space-4);
        margin-bottom: var(--space-3);
        border-left: 3px solid #3b82f6;
    }

    .slot-preview-block.lecture { background: #fffbeb; border-left-color: #f59e0b; }
    .slot-preview-block.practice { background: #eff6ff; border-left-color: #3b82f6; }
    .slot-preview-block.lab { background: var(--primary-50); border-left-color: var(--primary-500); }
    .slot-preview-block.seminar { background: #fff1f2; border-left-color: #f43f5e; }
    .slot-preview-block.other { background: #f5f3ff; border-left-color: #a855f7; }

    .slot-preview-block-title {
        font-size: 0.8rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--primary-700);
        margin-bottom: 0.65rem;
    }

    .slot-preview-row {
        margin-bottom: var(--space-2);
    }

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

    .slot-preview-label {
        font-size: 0.72rem;
        color: var(--text-tertiary);
        margin-bottom: 0.12rem;
    }

    .slot-preview-value {
        font-size: 1.02rem;
        font-weight: 600;
        color: var(--text-primary);
        line-height: 1.35;
        overflow-wrap: anywhere;
    }

    .slot-preview-value a.teacher-link {
        font-size: inherit;
        padding: 0;
        display: inline;
    }

    .slot-preview-comment {
        color: #dc2626;
        font-weight: 600;
        font-size: 0.95rem;
    }

    .modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
        align-items: center;
        justify-content: center;
    }
    
    .modal.active {
        display: flex;
    }
    
    .modal-content {
        background: var(--background);
        padding: var(--space-6);
        border-radius: var(--border-radius-2xl);
        max-width: 850px;
        width: 90%;
        max-height: 95vh;
        overflow-y: auto;
        box-shadow: var(--shadow-2xl);
        border: 1px solid var(--gray-200);
    }

    #create-current-week-modal .modal-content,
    #create-room-modal .modal-content,
    #create-address-modal .modal-content {
        max-width: 500px;
    }

    #new-week-modal .modal-content {
        max-width: 550px;
    }

    #fill-next-week-modal .modal-content {
        max-width: 600px;
    }

    #slot-transfer-modal .modal-content,
    #slot-transfer-conflict-modal .modal-content,
    #slot-transfer-mismatch-modal .modal-content {
        max-width: 640px;
    }

    #subgroup-shared-groups-modal .modal-content {
        max-width: 720px;
    }

    #create-room-modal,
    #create-address-modal,
    #subgroup-shared-groups-modal {
        z-index: 1100;
    }

    .modal-lead {
        margin-bottom: var(--space-6);
    }

    .modal-lead p {
        color: var(--gray-600);
        line-height: 1.6;
    }

    #slot-transfer-conflict-hint {
        color: var(--gray-700);
        font-weight: 600;
        margin: var(--space-4) 0 0;
    }
    
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: var(--space-4);
    }
    
    .modal-header h2 {
        margin: 0;
    }
    
    .close-modal {
        font-size: 1.5rem;
        cursor: pointer;
        color: #999;
        background: none;
        border: none;
        padding: 0;
        width: 30px;
        height: 30px;
    }
    
    .close-modal:hover {
        color: #333;
    }
    
    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--space-4);
        margin-bottom: 0.875rem;
    }

    #lesson-groups-block,
    #lesson-slot-type-block {
        margin-bottom: 0.875rem;
    }
    
    .form-full {
        grid-column: 1 / -1;
    }

    .lesson-comment-group {
        margin-top: 0.875rem;
    }
    
    .checkbox-group {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2);
    }
    
    .checkbox-label {
        display: flex;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-2);
        border: 1px solid #ddd;
        border-radius: 0.25rem;
        cursor: pointer;
    }
    
    .checkbox-label:hover {
        background: var(--gray-50);
    }
    
    .checkbox-label input {
        width: auto;
    }
    
    .btn-danger {
        background: linear-gradient(135deg, #ef4444, #dc2626);
        color: white;
        position: relative;
        overflow: hidden;
    }
    
    .btn-danger::before {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, #dc2626, #b91c1c);
        opacity: 0;
        transition: opacity var(--transition-base);
        z-index: -1;
    }
    
    .btn-danger:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-xl);
    }
    
    .btn-danger:hover::before {
        opacity: 1;
    }
    
    .btn-danger:active {
        transform: translateY(0);
    }

    .btn-row {
        display: flex;
        gap: var(--space-3);
        margin-top: var(--space-4);
        flex-wrap: wrap;
        align-items: center;
    }

    .btn-row .btn-danger,
    .group-form-actions .btn-danger {
        margin-left: auto;
    }

    .btn-small {
        min-width: auto;
        padding: var(--space-1) var(--space-3);
        font-size: 0.875rem;
        box-shadow: var(--shadow-sm);
    }

    #subgroups-section {
        margin-top: var(--space-6);
        padding-top: var(--space-6);
        border-top: 2px solid var(--gray-200);
    }

    #subgroups-section h3 {
        font-size: 1.125rem;
        font-weight: 600;
        margin-bottom: var(--space-4);
        color: var(--primary-700);
    }

    #subgroups-list {
        margin-bottom: var(--space-4);
    }

    #subgroups-list .subgroup-item {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: var(--space-2) var(--space-3);
        background: var(--gray-50);
        border-radius: var(--border-radius-md);
        margin-bottom: var(--space-2);
    }

    #subgroups-list .subgroup-item-name {
        flex: 1;
        font-weight: 500;
        min-width: 0;
    }

    /* Стили для элементов формы в модальном окне */
    .modal-select,
    .modal-input,
    .modal-textarea {
        width: 100%;
        padding: var(--space-3) var(--space-4);
        border: 2px solid var(--gray-300);
        border-radius: var(--border-radius-md);
        font-size: 0.9375rem;
        font-family: var(--font-sans);
        transition: all var(--transition-fast);
        background: var(--background);
        color: var(--text-primary);
    }
    
    .modal-select {
        appearance: none;
        cursor: pointer;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23059669' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right var(--space-3) center;
        padding-right: var(--space-10);
    }
    
    .modal-select:hover,
    .modal-input:hover,
    .modal-textarea:hover {
        border-color: var(--primary-400);
    }
    
    .modal-select:focus,
    .modal-input:focus,
    .modal-textarea:focus {
        outline: none;
        border-color: var(--primary-500);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    }
    
    .modal-select.error,
    .modal-input.error {
        border-color: #ef4444;
        background-color: #fef2f2;
    }
    
    input[type="checkbox"].error {
        outline: 2px solid #ef4444;
        outline-offset: 2px;
    }
    
    .modal-select.error:focus,
    .modal-input.error:focus {
        border-color: #dc2626;
        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
    }
    
    .modal-input::placeholder {
        color: var(--text-tertiary);
    }
    
    .modal-textarea {
        resize: vertical;
        min-height: 80px;
    }
    
    /* Модальное окно ошибки */
    .error-modal {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.6);
        z-index: 1200;
        align-items: center;
        justify-content: center;
    }
    
    .error-modal.active {
        display: flex;
    }
    
    .error-modal-content {
        background: var(--background);
        padding: var(--space-8);
        border-radius: var(--border-radius-2xl);
        max-width: 600px;
        width: 90%;
        box-shadow: var(--shadow-2xl);
        border: 1px solid var(--gray-200);
    }
    
    .error-modal-header {
        display: flex;
        align-items: center;
        gap: var(--space-4);
        margin-bottom: var(--space-6);
        padding-bottom: var(--space-4);
        border-bottom: 2px solid #ef4444;
    }
    
    .error-modal-header.success {
        border-bottom-color: var(--primary-500);
    }
    
    .error-icon {
        font-size: 2.5rem;
        color: #ef4444;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 3rem;
        height: 3rem;
        border-radius: 50%;
        background: rgba(239, 68, 68, 0.1);
    }
    
    .error-icon.success {
        color: var(--primary-500);
        background: rgba(16, 185, 129, 0.1);
    }
    
    .error-modal-header h3 {
        margin: 0;
        font-size: 1.5rem;
        color: #dc2626;
    }
    
    .error-modal-header.success h3 {
        color: var(--primary-600);
    }
    
    .error-modal-body {
        margin-bottom: var(--space-6);
        color: var(--text-primary);
        line-height: 1.7;
        white-space: pre-line;
    }

    .error-modal-body strong {
        font-weight: 700;
    }

    #slot-transfer-conflict-message {
        white-space: normal;
    }

    .conflict-record {
        padding: 0.85rem 0;
        border-bottom: 1px solid var(--gray-300);
    }

    .conflict-record:first-child {
        padding-top: 0;
    }

    .conflict-record:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .conflict-record strong {
        font-weight: 700;
        color: var(--text-primary);
    }

    .slot-transfer-kind {
        color: var(--gray-600);
        font-size: 0.95rem;
        margin: 0 0 var(--space-4);
    }

    .slot-transfer-path {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: var(--space-3);
        align-items: stretch;
        margin-bottom: var(--space-6);
    }

    .slot-transfer-point {
        background: var(--gray-50);
        border: 1px solid var(--gray-200);
        border-radius: var(--border-radius-lg);
        padding: var(--space-4);
        min-width: 0;
    }

    .slot-transfer-point.is-target {
        background: var(--primary-50);
        border-color: var(--primary-200);
    }

    .slot-transfer-point-label {
        display: block;
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        color: var(--gray-500);
        margin-bottom: var(--space-2);
    }

    .slot-transfer-point.is-target .slot-transfer-point-label {
        color: var(--primary-700);
    }

    .slot-transfer-point-day {
        font-weight: 700;
        font-size: 1.05rem;
        color: var(--text-primary);
        margin-bottom: 0.15rem;
    }

    .slot-transfer-point-time,
    .slot-transfer-point-group {
        color: var(--gray-700);
        line-height: 1.4;
    }

    .slot-transfer-arrow {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
        font-weight: 700;
        color: var(--primary-600);
        padding-top: var(--space-2);
    }

    .form-group .slot-transfer-option {
        display: flex;
        align-items: flex-start;
        gap: var(--space-3);
        cursor: pointer;
        padding: var(--space-4);
        border: 2px solid var(--gray-200);
        border-radius: var(--border-radius-lg);
        background: var(--background);
        margin-bottom: 0;
        font-weight: 400;
        color: inherit;
    }

    .form-group .slot-transfer-option:has(input:checked) {
        border-color: var(--primary-500);
        background: var(--primary-50);
    }

    .form-group .slot-transfer-option input {
        margin: 0.15rem 0 0;
        cursor: pointer;
        flex-shrink: 0;
    }

    .slot-transfer-option-text {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-1);
        min-width: 0;
    }

    .slot-transfer-option-title {
        display: block;
        font-size: 1.15rem;
        font-weight: 700;
        color: var(--primary-700);
        line-height: 1.2;
    }

    .slot-transfer-option-note {
        display: block;
        color: var(--gray-600);
        font-size: 0.9rem;
        line-height: 1.45;
        font-weight: 400;
    }

    @media (max-width: 640px) {
        .slot-transfer-path {
            grid-template-columns: 1fr;
            gap: var(--space-2);
        }

        .slot-transfer-arrow {
            padding: 0;
            transform: rotate(90deg);
        }
    }
    
    .error-modal-footer {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        gap: var(--space-3);
        text-align: left;
    }
    
    /* Стили для нового интерфейса выбора */
    #selection-screen {
        display: flex;
        flex-direction: column;
        gap: var(--space-6);
    }

    #manage-groups-bar {
        margin-bottom: var(--space-6);
    }

    #btn-manage-groups {
        min-width: 200px;
    }

    #manage-groups-screen .control-panel {
        margin-bottom: var(--space-4);
    }
    
    .teacher-search-section {
        background: var(--background);
        padding: var(--space-8);
        border-radius: var(--border-radius-xl);
        box-shadow: var(--shadow-md);
        border: 1px solid var(--gray-200);
        position: relative;
        z-index: auto;
    }

    .teacher-search-section:focus-within,
    .teacher-search-section.has-teacher-suggestions {
        z-index: 100;
    }

    .teacher-search-input {
        width: 100%;
        padding: var(--space-3) var(--space-4);
        border: 2px solid var(--gray-300);
        border-radius: var(--border-radius-md);
        font-size: 1rem;
        font-family: var(--font-sans);
        transition: all var(--transition-fast);
    }
    
    .teacher-search-input:focus {
        outline: none;
        border-color: var(--primary-500);
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    }

    .teacher-search-section .form-group {
        max-width: 500px;
    }

    .teacher-search-field {
        position: relative;
    }
    
    .teacher-suggestions {
        position: absolute;
        top: calc(100% + 0.5rem);
        left: 0;
        right: 0;
        background: var(--background);
        border: 1px solid var(--gray-300);
        border-radius: var(--border-radius-md);
        max-height: 10.5rem;
        overflow-y: auto;
        display: none;
        box-shadow: var(--shadow-lg);
        z-index: 100;
    }
    
    .teacher-suggestions.active {
        display: block;
    }
    
    .teacher-suggestion-item {
        padding: var(--space-3) var(--space-4);
        cursor: pointer;
        transition: background var(--transition-fast);
        border-bottom: 1px solid var(--gray-200);
    }
    
    .teacher-suggestion-item:last-child {
        border-bottom: none;
    }
    
    .teacher-suggestion-item:hover {
        background: var(--gray-100);
    }
    
    .teacher-suggestion-item.selected {
        background: var(--primary-50);
        color: var(--primary-700);
    }
    
    .room-suggestions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        margin-top: var(--space-1);
        background: var(--background);
        border: 1px solid var(--gray-300);
        border-radius: var(--border-radius-md);
        max-height: 200px;
        overflow-y: auto;
        display: none;
        box-shadow: var(--shadow-lg);
        z-index: 100;
    }
    
    .room-suggestions.active {
        display: block;
    }
    
    .room-suggestion-item {
        padding: var(--space-3) var(--space-4);
        cursor: pointer;
        transition: background var(--transition-fast);
        border-bottom: 1px solid var(--gray-200);
    }
    
    .room-suggestion-item:last-child {
        border-bottom: none;
    }
    
    .room-suggestion-item:hover {
        background: var(--gray-100);
    }
    
    .room-suggestion-item.selected {
        background: var(--primary-50);
        color: var(--primary-700);
    }
    
    .study-mode-section {
        background: var(--background);
        padding: var(--space-8);
        border-radius: var(--border-radius-xl);
        box-shadow: var(--shadow-md);
        border: 1px solid var(--gray-200);
    }
    
    .section-title {
        text-align: left;
    }
    
    .course-buttons {
        display: flex;
        gap: var(--space-4);
        flex-wrap: wrap;
        align-items: center;
    }
    
    .course-btn {
        width: 60px;
        height: 60px;
        background: var(--background);
        border: 2px solid var(--primary-500);
        border-radius: var(--border-radius-xl);
        font-size: 1.75rem;
        font-weight: 700;
        color: var(--primary-700);
        cursor: pointer;
        transition: all var(--transition-base);
        box-shadow: var(--shadow-sm);
    }
    
    .course-btn:hover {
        background: var(--primary-50);
        border-color: var(--primary-600);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
    
    .course-btn:active {
        transform: translateY(0);
    }
    
    .action-buttons {
        display: flex;
        gap: var(--space-4);
        flex-wrap: wrap;
        align-items: center;
    }
    
    .action-btn {
        padding: var(--space-3) var(--space-5);
        background: var(--background);
        border: 2px solid var(--primary-500);
        border-radius: var(--border-radius-lg);
        font-size: 1rem;
        font-weight: 600;
        color: var(--primary-700);
        cursor: pointer;
        transition: all var(--transition-base);
        box-shadow: var(--shadow-sm);
        min-width: 180px;
        height: 60px;
    }
    
    .action-btn:hover {
        background: var(--primary-50);
        border-color: var(--primary-600);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
    
    .action-btn:active {
        transform: translateY(0);
    }

    .debt-liquidation-btn {
        padding: var(--space-3) var(--space-5);
        background: var(--background);
        border: 2px solid var(--primary-500);
        border-radius: var(--border-radius-lg);
        font-size: 1rem;
        font-weight: 600;
        color: var(--primary-700);
        cursor: pointer;
        transition: all var(--transition-base);
        box-shadow: var(--shadow-sm);
        min-width: 180px;
        height: 60px;
        margin-left: auto;
        flex-shrink: 0;
    }

    .debt-liquidation-btn:hover {
        background: var(--primary-50);
        border-color: var(--primary-600);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

    .debt-liquidation-btn:active {
        transform: translateY(0);
    }
    
    /* Стили для управления группами */
    .manage-groups-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-4);
        margin-bottom: var(--space-6);
    }

    .manage-groups-header h2 {
        margin: 0;
    }

    .manage-groups-actions,
    .manage-groups-filters,
    .manage-groups-filter-actions {
        display: flex;
        gap: var(--space-3);
    }

    .manage-groups-filters {
        gap: var(--space-4);
        flex-wrap: wrap;
        align-items: flex-end;
        width: 100%;
    }

    .manage-groups-filter {
        flex: 1 1 0;
        min-width: 0;
        margin-bottom: 0;
    }

    .manage-groups-filter select {
        width: 100%;
        max-width: none;
    }

    .manage-groups-filter-actions {
        align-items: flex-end;
        flex: 0 0 auto;
    }

    .subgroup-create-row,
    .group-form-actions {
        display: flex;
        gap: var(--space-3);
    }

    .subgroup-create-row {
        align-items: center;
    }

    .group-form-actions {
        justify-content: flex-start;
        margin-top: var(--space-6);
    }

    .groups-table-panel {
        overflow-x: auto;
    }

    .groups-table {
        width: 100%;
        border-collapse: collapse;
        background: var(--background);
    }
    
    .groups-table th,
    .groups-table td {
        padding: var(--space-3) var(--space-4);
        text-align: left;
        border-bottom: 1px solid var(--gray-200);
    }
    
    .groups-table th {
        background: var(--gray-100);
        font-weight: 600;
        color: var(--gray-700);
        position: sticky;
        top: 0;
    }
    
    .groups-table tbody tr:hover {
        background: var(--gray-50);
    }
    
    .groups-table .actions {
        vertical-align: middle;
        white-space: nowrap;
    }
    
    .groups-table .btn-small {
        padding: var(--space-1) var(--space-3);
        font-size: 0.875rem;
        min-width: auto;
    }

    .groups-table .groups-empty-row td {
        text-align: center;
        padding: var(--space-8);
        color: var(--gray-500);
    }
    
    /* Ссылка на карточку преподавателя в заголовке расписания */
    #schedule-title a.teacher-link {
        color: var(--primary);
        text-decoration: none;
        border-bottom: 2px solid var(--primary);
        transition: all 0.2s ease;
        padding: var(--space-1) var(--space-2);
        border-radius: 4px;
        background-color: rgba(0, 100, 200, 0.05);
    }
    
    #schedule-title a.teacher-link:hover {
        background-color: rgba(0, 100, 200, 0.1);
        border-bottom-color: var(--primary);
        transform: translateY(-1px);
    }

    /* Мобильная адаптация */
    @media (max-width: 768px) {
        /* Шапка и панель управления */
        .control-panel {
            padding: var(--space-4);
        }

        .schedule-header-content {
            flex-direction: column;
            align-items: flex-start;
        }
        
        .schedule-header-title {
            width: 100%;
        }
        
        .schedule-header-title h3 {
            font-size: 1.25rem;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .schedule-header-title h3.teacher-schedule-title {
            white-space: normal;
            overflow: visible;
            text-overflow: clip;
            line-height: 1.35;
        }

        .teacher-schedule-label {
            display: block;
        }

        .teacher-schedule-title .teacher-link {
            display: inline-block;
            max-width: 100%;
            margin-top: var(--space-2);
            font-size: 1.15rem;
            white-space: normal;
            overflow-wrap: anywhere;
            word-break: normal;
        }
        
        .schedule-header-buttons {
            width: 100%;
            flex-direction: column;
            align-items: stretch;
            gap: var(--space-3);
        }
        
        .schedule-header-buttons .btn {
            width: 100%;
            min-width: 0;
            padding: var(--space-3) var(--space-4);
            font-size: 0.9375rem;
            border-radius: var(--border-radius-lg);
            box-sizing: border-box;
        }

        #btn-back-from-schedule {
            display: none;
        }

        .schedule-header-buttons:not(:has(#btn-export-xlsx[style*="display: block"])):not(:has(#btn-fill-next-week[style*="display: block"])) {
            display: none;
        }

        .schedule-header-title > .week-navigation {
            display: grid;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            grid-template-columns: auto minmax(0, 1fr) auto;
            justify-content: stretch;
        }

        .schedule-header-title #week-info {
            min-width: 0;
            width: auto;
            max-width: none;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Сетка расписания: ширины колонок как были, шрифты/отступы от десктопа */
        .grid-table th.day-header,
        .grid-table td.day-header {
            width: 42px !important;
            min-width: 42px !important;
            max-width: 42px !important;
            padding: 0.15rem 0.08rem;
        }

        .grid-table th.day-header,
        .grid-table th.time-header {
            font-size: 0.68rem;
            font-weight: 700;
            line-height: 1.2;
        }

        .grid-table td.day-header {
            font-size: 0.68rem;
            font-weight: 600;
            line-height: 1.2;
        }

        .grid-table th.time-header,
        .grid-table td.time-header {
            left: 42px;
            width: 54px !important;
            min-width: 54px !important;
            max-width: 54px !important;
            padding: 0.15rem 0.08rem;
        }

        .grid-table td.time-header {
            font-size: 0.64rem;
            line-height: 1.2;
        }

        .grid-table th {
            font-size: 0.68rem;
            padding: 0.2rem 0.12rem;
            line-height: 1.2;
        }

        .grid-table th.group-header,
        .grid-table td.cell {
            width: 100px !important;
            min-width: 100px !important;
            max-width: 100px !important;
        }

        .grid-table td.cell {
            position: relative;
            z-index: 1;
            padding: 0.1rem;
            height: 1px;
            vertical-align: stretch;
            -webkit-tap-highlight-color: transparent;
        }

        .grid-table.teacher-view {
            table-layout: fixed;
            width: 100% !important;
            max-width: 100%;
            min-width: 0 !important;
        }

        .grid-table.teacher-view th.day-header,
        .grid-table.teacher-view td.day-header {
            width: 42px !important;
            min-width: 42px !important;
            max-width: 42px !important;
        }

        .grid-table.teacher-view th.time-header,
        .grid-table.teacher-view td.time-header {
            left: 42px;
            width: 54px !important;
            min-width: 54px !important;
            max-width: 54px !important;
        }

        .grid-table.teacher-view th.group-header,
        .grid-table.teacher-view td.cell {
            width: auto !important;
            min-width: 0 !important;
            max-width: none !important;
            overflow-wrap: break-word;
            word-break: break-word;
        }

        .grid-table.teacher-view .lesson-card,
        .grid-table.teacher-view .lesson-content {
            max-width: 100%;
            min-width: 0;
            box-sizing: border-box;
        }

        .table-wrapper {
            max-height: calc(100vh - var(--space-4));
            max-height: calc(100dvh - var(--space-4));
            max-height: calc(100svh - var(--space-4));
        }

        .table-wrapper:has(.grid-table.teacher-view) {
            overflow-x: hidden;
        }

        .grid-table th.group-header {
            position: -webkit-sticky;
            position: sticky;
            top: 0;
            z-index: 20;
            background: var(--gray-100);
            font-size: 0.68rem;
            font-weight: 600;
            line-height: 1.2;
            padding: 0.2rem 0.12rem;
            overflow-wrap: anywhere;
            hyphens: auto;
        }

        .lesson-card {
            padding: 0.2rem 0.15rem;
            font-size: 0.62rem;
            min-height: 52px;
            margin: 0.08rem;
            width: calc(100% - 0.16rem);
            height: calc(100% - 0.16rem);
            border-left-width: 2px;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }

        .grid-table .lesson-title {
            font-size: 0.64rem;
            line-height: 1.2;
            margin-bottom: 0.1rem;
        }

        .grid-table .lesson-teacher,
        .grid-table .lesson-teacher a.teacher-link,
        .grid-table .lesson-room,
        .grid-table .lesson-address,
        .grid-table .lesson-comment {
            font-size: 0.6rem;
            line-height: 1.2;
            margin-bottom: 0.1rem;
        }

        .grid-table .lesson-comment {
            margin-top: 0.1rem;
            padding-top: 0.1rem;
            white-space: normal;
            overflow-wrap: anywhere;
            word-break: break-word;
            hyphens: auto;
            -webkit-hyphens: auto;
            max-width: 100%;
            box-sizing: border-box;
        }

        .grid-table .subgroup-mini-slot-title {
            font-size: 0.5rem;
        }

        .grid-table .spec-mini-slot {
            font-size: 0.58rem;
            line-height: 1.2;
            padding: 0.1rem 0.08rem;
        }

        .grid-table .spec-mini-slot .lesson-teacher a.teacher-link,
        .grid-table .spec-mini-slot .lesson-address {
            font-size: 0.58rem;
        }

        .grid-table.teacher-view .lesson-card {
            padding: var(--space-1);
            font-size: 0.68rem;
        }

        .grid-table.teacher-view .lesson-title {
            font-size: 0.7rem;
            font-weight: 600;
            margin-bottom: 0.15rem;
        }

        .grid-table.teacher-view .lesson-teacher,
        .grid-table.teacher-view .lesson-teacher a.teacher-link,
        .grid-table.teacher-view .lesson-room,
        .grid-table.teacher-view .lesson-address,
        .grid-table.teacher-view .lesson-comment {
            font-size: 0.66rem;
            margin-bottom: 0.15rem;
        }

        .grid-table.teacher-view .lesson-comment {
            margin-top: 0.15rem;
            padding-top: 0.15rem;
        }

        .grid-table .incomplete-lesson-flags {
            gap: 0.1rem;
            margin-bottom: 0.1rem;
            max-width: 100%;
            box-sizing: border-box;
        }

        .grid-table .room-conflict-label {
            font-size: 0.46rem;
            font-weight: 600;
            padding: 0.1rem 0.12rem;
            width: 100%;
            max-width: 100%;
            box-sizing: border-box;
            overflow-wrap: break-word;
            word-break: normal;
            text-align: center;
            display: block;
            line-height: 1.2;
        }

        .grid-table .lesson-card.room-conflict,
        .grid-table .subgroup-mini-slot.room-conflict,
        .grid-table .spec-mini-slot.room-conflict {
            box-shadow: none;
            border-width: 1px !important;
        }

        .subgroup-mini-slot {
            padding: 0.08rem;
        }

        .grid-table td.cell.empty-cell {
            min-height: 52px;
        }

        .time-range-full {
            display: none;
        }

        .time-range-mobile {
            display: inline;
        }

        .day-name-full {
            display: none;
        }

        .day-name-short {
            display: inline;
        }

        .lesson-teacher a.teacher-link {
            padding: 0;
        }

        .grid-table a.teacher-link {
            pointer-events: none;
            color: var(--text-primary);
            border-bottom: none;
            background: none;
            box-shadow: none;
            transform: none;
            text-decoration: none;
            cursor: inherit;
        }

        .grid-table .lesson-card .lesson-teacher a.teacher-link:hover {
            color: var(--text-primary);
            background: none;
            background-color: transparent;
        }

        .lesson-card.is-readonly-preview {
            cursor: pointer;
        }

        /* Кнопки и формы */
        .form-row-stack {
            grid-template-columns: 1fr;
            gap: 0.875rem;
        }

        .form-row-stack .form-group {
            width: 100%;
            min-width: 0;
        }

        .form-group select,
        .modal-select {
            max-width: none;
        }

        .btn.btn-primary:not(.btn-small),
        .btn.btn-secondary:not(.btn-small),
        .btn.btn-danger:not(.btn-small) {
            width: 100%;
            min-width: 0;
            box-sizing: border-box;
            border-radius: var(--border-radius-lg);
            justify-content: center;
        }

        .btn-add-with-plus {
            width: 100%;
            min-width: 0;
            flex: 1 0 100%;
            padding: 0.35rem var(--space-3);
            font-size: 0.8125rem;
            border-radius: var(--border-radius-md);
            box-sizing: border-box;
            justify-content: center;
        }

        /* Стрелки навигации по неделям остаются компактными */
        #btn-prev-week.btn,
        #btn-next-week.btn {
            width: auto;
            min-width: auto;
            flex: 0 0 auto;
            padding: 0.375rem var(--space-3);
            font-size: 0.875rem;
        }

        .spec-remove-btn.btn {
            width: auto;
            min-width: auto;
            flex: 0 0 auto;
            padding: 0.2rem var(--space-2);
            font-size: 0.75rem;
            line-height: 1.2;
        }

        #subgroups-list .btn.btn-small {
            width: auto;
            min-width: auto;
            flex: 0 0 auto;
            padding: 0.35rem var(--space-3);
            font-size: 0.8125rem;
            border-radius: var(--border-radius-md);
            white-space: nowrap;
        }

        .btn-row,
        .error-modal-footer,
        .group-form-actions,
        .subgroup-create-row,
        .manage-groups-actions,
        .manage-groups-filter-actions {
            flex-direction: column;
            align-items: stretch;
            width: 100%;
        }

        /* Мобильный порядок: Сохранить → Удалить → Отменить */
        .btn-row .btn-primary,
        .group-form-actions .btn-primary {
            order: 1;
        }

        .btn-row .btn-danger,
        .group-form-actions .btn-danger {
            order: 2;
        }

        .btn-row .btn-secondary,
        .group-form-actions .btn-secondary {
            order: 3;
        }

        .btn-row .btn,
        .error-modal-footer .btn,
        .group-form-actions .btn,
        .manage-groups-actions .btn,
        .manage-groups-filter-actions .btn {
            width: 100%;
            min-width: 0;
            margin-left: 0 !important;
            margin-right: 0 !important;
        }

        #btn-manage-groups {
            width: 100%;
            min-width: 0 !important;
        }

        /* Выбор режима обучения и управление группами */
        .study-mode-section,
        .teacher-search-section {
            padding: var(--space-4);
        }

        .teacher-search-section {
            overflow: visible;
        }

        .teacher-search-section .form-group {
            max-width: none;
            width: 100%;
        }

        .teacher-suggestions {
            position: absolute;
            width: 100%;
            max-height: 10.5rem;
            z-index: 100;
        }

        .course-buttons {
            justify-content: space-between;
        }

        .course-buttons .course-btn {
            width: 50px;
            height: 50px;
            font-size: 1.5rem;
        }
        
        .action-btn,
        .debt-liquidation-btn {
            min-width: 100%;
            margin-left: 0;
            height: auto;
        }
        
        .section-title {
            font-size: 1.25rem;
            margin-bottom: var(--space-4);
        }
        
        .groups-table {
            font-size: 0.875rem;
        }
        
        .groups-table th,
        .groups-table td {
            padding: var(--space-2) var(--space-3);
        }

        .manage-groups-header {
            flex-direction: column;
            align-items: stretch;
            gap: var(--space-4);
        }

        .manage-groups-header h2 {
            font-size: 1.5rem;
            line-height: 1.3;
        }

        .manage-groups-actions,
        .manage-groups-filters,
        .manage-groups-filter-actions {
            flex-direction: column;
            width: 100%;
        }

        .manage-groups-actions .btn,
        .manage-groups-filter-actions .btn,
        .manage-groups-filter,
        .manage-groups-filter select {
            width: 100%;
            max-width: none;
            flex: none;
        }

        .groups-table-panel {
            overflow-x: visible;
        }

        .groups-table,
        .groups-table thead,
        .groups-table tbody,
        .groups-table tr,
        .groups-table td {
            display: block;
            width: 100%;
        }

        .groups-table thead {
            display: none;
        }

        .groups-table tr {
            padding: var(--space-4);
            border: 1px solid var(--gray-200);
            border-radius: var(--border-radius-lg);
            box-shadow: var(--shadow-sm);
            margin-bottom: var(--space-3);
            background: var(--background);
        }

        .groups-table tbody tr:hover {
            background: var(--background);
        }

        .groups-table td {
            display: flex;
            justify-content: space-between;
            align-items: flex-start;
            gap: var(--space-4);
            padding: var(--space-2) 0;
            border-bottom: 1px solid var(--gray-100);
            text-align: right;
        }

        .groups-table td::before {
            content: attr(data-label);
            flex: 0 0 45%;
            color: var(--gray-600);
            font-weight: 600;
            text-align: left;
        }

        .groups-table td:last-child {
            border-bottom: none;
            padding-bottom: 0;
        }

        .groups-table .actions {
            flex-direction: column;
            align-items: stretch;
            flex: 1;
            min-width: 0;
            width: auto;
        }

        .groups-table .actions .btn {
            width: 100%;
            flex: none;
            min-width: 0;
            justify-content: center;
        }

        .groups-table .groups-empty-row {
            padding: 0;
        }

        .groups-table .groups-empty-row td {
            display: block;
            padding: var(--space-6);
            text-align: center;
            border-bottom: none;
        }

        .groups-table .groups-empty-row td::before {
            content: none;
        }

        #group-modal .modal-content {
            width: calc(100% - var(--space-4));
            padding: var(--space-4);
            max-height: 92vh;
        }
    }

    /* Firefox: height:100% от td { height:1px } схлопывает карточку.
       Высота auto — ряд растёт по тексту; растягивание на ячейку — stretchFirefoxLessonCards(). */
    @supports (-moz-appearance: none) {
        .grid-table td.cell {
            height: auto;
        }

        .lesson-card {
            height: auto;
            width: calc(100% - 0.2rem);
        }

        .grid-table td.cell.empty-cell::before {
            content: '';
            display: block;
            height: 52px;
            pointer-events: none;
        }
    }
