:root {
    color-scheme: light;
    --blue: #2188c9;
    --ink: #263b4d;
    --muted: #708394;
    --line: #e1eaf1;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: #f5f8fb;
    color: var(--ink);
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}
button, input, select, textarea {
    font: inherit;
}
button, a {
    -webkit-tap-highlight-color: transparent;
}
button {
    cursor: pointer;
}
a {
    color: var(--blue);
    text-decoration: none;
}
button:focus-visible, a:focus-visible {
    outline: 3px solid #96c9e8;
    outline-offset: 2px;
}
.top {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 68px;
    padding: 12px 28px;
    background: #2188c9;
    color: #ffffff;
}
.brand {
    color: white;
    font-size: 24px;
    font-weight: bold;
}
.brand span {
    font-weight: normal;
    opacity: 0.75;
}
.back {
    margin-left: auto;
    color: white;
    font-size: 12px;
}
.private-label {
    border: 1px solid #ffffff60;
    border-radius: 20px;
    padding: 3px 10px;
    font-size: 11px;
}
.workspace {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    max-width: 1450px;
    margin: auto;
}
aside {
    padding: 28px 18px;
}
.school {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}
.school small {
    display: block;
    color: var(--muted);
    font-size: 10px;
}
.school-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    background: #deeffa;
    border-radius: 10px;
    color: var(--blue);
    font-weight: bold;
}
nav {
    display: grid;
    gap: 5px;
}
nav button {
    border: 0;
    background: transparent;
    text-align: left;
    padding: 11px 14px;
    color: #64788a;
    border-radius: 7px;
}
nav button.active {
    background: #e1f0fa;
    color: #1875af;
    font-weight: bold;
}
.aside-note {
    margin: 30px 14px;
    font-size: 11px;
    color: #8b9aa7;
}
main {
    min-width: 0;
    padding: 24px 30px 50px;
}
.concept-note {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 11px;
}
.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 22px;
}
h1 {
    margin: 0;
    font-size: 28px;
    font-weight: normal;
}
h2 {
    margin: 0;
    font-size: 18px;
}
h3 {
    margin: 0;
    font-size: 15px;
}
.subtitle {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}
.primary, .secondary {
    border: 1px solid var(--blue);
    border-radius: 7px;
    padding: 8px 13px;
    background: var(--blue);
    color: white;
}
.secondary {
    background: white;
    border-color: #d4e2ec;
    color: #42647d;
}
.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat {
    background: white;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 18px;
}
.stat strong {
    display: block;
    font-size: 26px;
    font-weight: normal;
}
.stat small {
    color: var(--muted);
    font-size: 11px;
}
.panel {
    background: white;
    border: 1px solid var(--line);
    border-radius: 11px;
    margin-bottom: 16px;
    overflow: hidden;
}
.panel-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
}
.panel-body {
    padding: 18px;
}
.session-select {
    max-width: 100%;
    width: 100%;
}
.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.toolbar input {
    flex: 1 1 200px;
}
input, select, textarea {
    min-width: 0;
    width: 100%;
    border: 1px solid #ccdce8;
    border-radius: 6px;
    background: white;
    color: var(--ink);
    padding: 8px 10px;
}
textarea {
    min-height: 80px;
    resize: vertical;
}
label {
    display: block;
    margin: 10px 0;
    font-size: 12px;
}
label input, label select, label textarea {
    margin-top: 5px;
}
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--blue);
    margin: 0;
}
.student {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 13px 18px;
    border-bottom: 1px solid #edf2f6;
    align-items: center;
}
.student:last-child {
    border-bottom: 0;
}
.student-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
}
.avatar {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    background: #eef5fa;
    border-radius: 50%;
    color: #6486a0;
    font-size: 10px;
}
.student-meta {
    margin: 3px 0 0 36px;
    color: var(--muted);
    font-size: 11px;
}
.note {
    border: 0;
    padding: 0;
    margin: 4px 0 0 36px;
    background: transparent;
    color: #84663c;
    font-size: 11px;
    text-align: left;
}
.note.empty {
    color: #9aa9b4;
}
.badge {
    display: inline-block;
    padding: 2px 7px;
    background: #edf5fa;
    color: #527389;
    border-radius: 12px;
    font-size: 10px;
    font-weight: normal;
}
.badge.warning {
    background: #fff3df;
    color: #986b27;
}
.badge.good {
    background: #e8f5ec;
    color: #3e8157;
}
.attendance {
    display: flex;
    gap: 5px;
}
.attendance button {
    min-width: 38px;
    height: 38px;
    border: 1px solid #d6e3ed;
    border-radius: 7px;
    background: white;
    color: #8b9dac;
    font-size: 18px;
}
.attendance button.selected.present {
    background: #e1f4e8;
    border-color: #83c99b;
    color: #328350;
}
.attendance button.selected.absent {
    background: #fae9ed;
    border-color: #dda4af;
    color: #a85465;
}
.attendance button.selected.excused {
    background: #fff1d9;
    border-color: #e3c286;
    color: #a27b30;
}
.legend {
    color: var(--muted);
    font-size: 11px;
}
.cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
}
.card p {
    color: var(--muted);
    font-size: 12px;
}
.card-actions {
    display: flex;
    gap: 7px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.empty {
    color: var(--muted);
    padding: 18px;
}
.calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 7px;
}
.day {
    background: white;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px 8px;
    min-height: 150px;
}
.day strong {
    font-size: 11px;
    color: var(--muted);
}
.lesson {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    border: 0;
    border-radius: 6px;
    background: #edf6fc;
    color: #386984;
    text-align: left;
    font-size: 11px;
}
.lesson b {
    display: block;
}
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    margin: 0;
}
.check-row span {
    flex: 1;
}
.price {
    white-space: nowrap;
    font-size: 12px;
}
.total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    margin-top: 10px;
    border-top: 1px solid var(--line);
}
.total strong {
    font-size: 22px;
}
dialog {
    width: min(460px, calc(100% - 24px));
    border: 0;
    border-radius: 12px;
    padding: 20px;
    color: var(--ink);
}
dialog::backdrop {
    background: #163b5866;
}
.dialog-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.dialog-heading button {
    border: 0;
    background: transparent;
    font-size: 24px;
    color: var(--muted);
}
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}
#toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: #263b4d;
    color: white;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    max-width: calc(100% - 24px);
}
#toast.visible {
    opacity: 1;
}
@media (max-width: 800px) {
    .workspace {
    display: block;
}
    .top {
    min-height: 56px;
    padding: 10px 14px;
    gap: 10px;
}
    .brand {
    font-size: 20px;
}
    .private-label {
    display: none;
}
    aside {
    position: sticky;
    top: 0;
    padding: 8px 10px;
    background: #f5f8fb;
    z-index: 5;
    border-bottom: 1px solid var(--line);
}
    .school, .aside-note {
    display: none;
}
    nav {
    display: flex;
    overflow-x: auto;
    gap: 3px;
}
    nav button {
    flex-shrink: 0;
    padding: 9px 11px;
    font-size: 12px;
}
    main {
    padding: 16px 12px 30px;
}
    h1 {
    font-size: 24px;
}
    .page-heading {
    margin-bottom: 16px;
}
    .stats {
    gap: 7px;
}
    .stat {
    padding: 10px;
}
    .stat strong {
    font-size: 22px;
}
    .cards {
    grid-template-columns: 1fr;
}
    .student {
    padding: 11px 12px;
    gap: 6px;
}
    .student-meta, .note {
    margin-left: 0;
}
    .avatar {
    display: none;
}
    .student-name {
    font-size: 12px;
    flex-wrap: wrap;
    gap: 5px;
}
    .attendance {
    gap: 3px;
}
    .attendance button {
    min-width: 34px;
    height: 38px;
}
    .calendar {
    grid-template-columns: 1fr;
}
    .day {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
}
    .lesson {
    margin: 0;
}
    input, select, textarea {
    font-size: 16px;
}
}

.entry-selectors {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
}
#live-entry-frame {
    display: block;
    width: 100%;
    min-height: 900px;
    border: 0;
    background: #ffffff;
}
@media (max-width: 800px) {
    .entry-selectors {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}
.note {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Фильтры и массовый перенос не расширяют экран на телефоне. */
.student-filters {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) repeat(4, minmax(120px, 1fr));
    gap: 10px;
}

.student-filters input,
.student-filters select {
    width: 100%;
    min-width: 0;
}

.bulk-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.selectable-student {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 12px;
}

.student-select input,
.bulk-toolbar input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #2474bc;
    margin: 0;
}

@media (max-width: 1100px) {
    .student-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .student-filters > input {
        grid-column: 1 / -1;
    }
}

@media (max-width: 600px) {
    .selectable-student {
        grid-template-columns: 24px minmax(0, 1fr);
        gap: 8px;
    }

    .selectable-student > .card-actions {
        grid-column: 2;
        justify-content: flex-start;
    }

    .bulk-toolbar .check-row {
        margin: 0;
    }
}

/* Рабочий филиал и дополнительные операции CRM. */
.workspace-branch {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-bottom: 20px;
    padding: 14px 18px;
    border: 1px solid #dce8f4;
    border-radius: 14px;
    background: #edf5fc;
}

.workspace-branch label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    font-weight: 600;
}

.workspace-branch select {
    margin: 0;
    align-self: center;
    width: auto;
    min-width: 160px;
    max-width: 360px;
}

.workspace-branch > span {
    color: #54708d;
    font-size: 13px;
}

.bulk-toolbar select {
    width: auto;
    max-width: 100%;
}

.archive-heading {
    margin: 0;
    padding: 12px 16px;
    background: #f0f5fa;
    color: #3d5e7a;
    font-size: 15px;
    border-bottom: 1px solid #dce6ef;
}

.section-heading {
    margin: 24px 0 12px;
}

.schedule-rule {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid #e3eaf2;
}

.schedule-rule small {
    display: block;
    margin-top: 4px;
    color: #5f738a;
}

.weekday-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border: 1px solid #d9e4ef;
    border-radius: 12px;
    padding: 12px;
    margin: 0 0 16px;
}

.weekday-picker label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 8px;
    border-radius: 8px;
    background: #f1f6fc;
    cursor: pointer;
}

.weekday-picker input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #2474bc;
}

.calendar-viewport {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #dce6ef;
    border-radius: 14px;
    background: #fff;
    overscroll-behavior-x: contain;
}

.calendar-board {
    display: grid;
    grid-template-columns: repeat(7, minmax(180px, 1fr));
    min-width: 1260px;
}

.calendar-day {
    min-width: 0;
    border-right: 1px solid #e0e9f2;
}

.calendar-day h3 {
    position: sticky;
    top: 0;
    margin: 0;
    padding: 12px;
    background: #edf5fc;
    color: #315b80;
    font-size: 14px;
    border-bottom: 1px solid #dce6ef;
    z-index: 2;
}

.calendar-day-grid {
    position: relative;
    background: repeating-linear-gradient(to bottom, transparent 0, transparent 71px, #e7edf4 71px, #e7edf4 72px);
}

.calendar-day-grid.is-drop-target {
    background-color: #eaf5ff;
    box-shadow: inset 0 0 0 2px #579bd5;
}

.calendar-hour {
    position: absolute;
    left: 3px;
    font-size: 9px;
    line-height: 14px;
    color: #718399;
    pointer-events: none;
}

.calendar-lesson {
    position: absolute;
    border: 1px solid #a9cdec;
    border-radius: 9px;
    background: #e8f3ff;
    color: #254f76;
    overflow: hidden;
    box-sizing: border-box;
}

.calendar-lesson-open {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 100%;
    height: 100%;
    padding: 7px 6px 26px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    font-size: 12px;
    cursor: pointer;
}

.calendar-lesson-open strong {
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.calendar-lesson-open small {
    font-size: 11px;
}

.calendar-lesson.is-cancelled {
    background: #fae9eb;
    border-color: #ddafb7;
    color: #874350;
    opacity: 0.8;
}

.lesson-drag {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 30px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: #fff9;
    color: #376d9c;
    font-size: 20px;
    line-height: 24px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.calendar-lesson.is-dragging {
    opacity: 0.3;
}

.calendar-drag-ghost {
    position: fixed !important;
    z-index: 10000;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: 0 8px 30px #193b6240;
}

@media (max-width: 600px) {
    .workspace-branch {
        padding: 10px 12px;
        margin-bottom: 14px;
        gap: 8px;
    }

    .workspace-branch label {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        width: 100%;
        font-size: 13px;
    }

    .workspace-branch select {
        min-width: 0;
        width: 100%;
        max-width: none;
    }

    .workspace-branch > span {
        font-size: 11px;
    }

    .bulk-toolbar {
        gap: 8px;
    }

    .bulk-toolbar select {
        flex: 1;
        min-width: 0;
        font-size: 14px;
    }

    .calendar-board {
        grid-template-columns: repeat(7, 240px);
        min-width: 1680px;
    }

    .lesson-drag {
        width: 38px;
        height: 28px;
        line-height: 28px;
    }
}

.check-row input[type="radio"] {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    padding: 0;
    margin: 0;
    accent-color: #2474bc;
}

/* Видимая привязка к пятнадцатиминутной сетке. */
.calendar-day-grid {
    background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 17px, #edf2f7 17px, #edf2f7 18px),
        repeating-linear-gradient(to bottom, transparent 0, transparent 71px, #cad8e7 71px, #cad8e7 72px);
}

.calendar-drop-preview {
    position: absolute;
    left: 28px;
    right: 3px;
    z-index: 4;
    box-sizing: border-box;
    border: 2px solid #2474bc;
    border-radius: 9px;
    background: #2484d126;
    pointer-events: none;
}

.calendar-drop-preview > span {
    position: absolute;
    top: -26px;
    left: 0;
    padding: 4px 6px;
    border-radius: 6px;
    background: #185788;
    color: #fff;
    font-size: 11px;
    white-space: nowrap;
}

.crm-date-field {
    position: relative;
    display: block;
}

.crm-date-field > [data-crm-date] {
    padding-right: 40px;
}

.crm-date-icon {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    color: #376d9c;
    font-size: 21px;
    pointer-events: none;
}

.crm-date-field > .crm-date-picker {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    width: 38px;
    height: 100%;
    margin: 0;
    opacity: 0;
    padding: 0;
    cursor: pointer;
}

.crm-date-picker::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Блоки оплаты: длинные подписи не расширяют строку ученика. */
.payment-student {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
    align-items: start;
    gap: 18px;
}
.payment-student-details,
.payment-student-actions {
    min-width: 0;
    overflow-wrap: anywhere;
}
.payment-student-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.payment-student-actions button {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
    padding: 9px 12px;
    text-align: center;
}
.payment-tariff-action {
    padding-bottom: 10px;
    border-bottom: 1px solid #edf2f6;
}
.payment-assigned {
    margin: 10px 0 6px;
    font-size: 12px;
    line-height: 1.5;
    color: #405b70;
}
.payment-receipt {
    margin: 5px 0;
    padding: 7px 10px;
    border-radius: 8px;
    background: #edf6f2;
    color: #446c5b;
    font-size: 11px;
    line-height: 1.45;
}
.payment-receipt-old {
    background: #f5f3ed;
    color: #786c52;
}
.payment-renewal {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px;
    border: 1px solid #e5edf4;
    border-radius: 10px;
    background: #f5f9fc;
    min-width: 0;
}
.payment-renewal-caption {
    font-size: 11px;
    line-height: 1.45;
    color: #61798c;
    overflow-wrap: anywhere;
}
@media (max-width: 640px) {
    .payment-student {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        padding: 12px;
    }
    .payment-student-actions {
        gap: 9px;
    }
    .payment-tariff-action {
        padding-bottom: 9px;
    }
    .payment-student-actions button {
        padding: 10px 12px;
    }
}

/* Keep the registration status readable on narrow screens. */
.feis-student > div {
    min-width: 0;
}
.feis-student > .badge {
    justify-self: start;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
}
@media (max-width: 600px) {
    .feis-student {
        align-items: center;
        gap: 6px 8px;
    }
    .feis-student > .badge {
        grid-column: 2;
        grid-row: 2;
        margin: 0;
        font-size: 10px;
    }
}

.attendance-date-navigation { display:flex; align-items:center; gap:8px; }
.attendance-date-navigation input { min-width:0; }
.attendance-date-navigation button { flex:0 0 38px; min-height:38px; padding:4px; font-size:22px; line-height:1; }
