/* Общие поля и компактные списки CRM. */
main, #screen, .panel, .card, .student > div, .dialog-heading h2 {
    min-width: 0;
}
input, select, textarea {
    min-height: 38px;
    line-height: 1.4;
}
input[type="checkbox"], input[type="radio"] {
    min-height: 0;
    flex-shrink: 0;
}
label {
    overflow-wrap: anywhere;
}
.panel > .legend, .panel > .empty {
    margin: 0;
    padding: 12px 16px;
}
.panel-body > label:first-child {
    margin-top: 0;
}
.panel-body > label:last-child {
    margin-bottom: 0;
}
.card, .student, .panel-heading, .workspace-branch, .dialog-actions {
    overflow-wrap: anywhere;
}
.card-actions, .panel-heading {
    flex-wrap: wrap;
}
.student-list .student {
    padding: 9px 14px;
    gap: 8px 12px;
}
.student-list .student-meta, .student-list .subtitle {
    margin: 3px 0;
    line-height: 1.35;
}
.student-list .student-name {
    font-size: 14px;
}
.student-list .card-actions {
    gap: 5px;
    justify-content: flex-end;
}
.student-list .card-actions button {
    padding: 5px 8px;
    font-size: 12px;
}
.student-list .note {
    margin-top: 2px;
}
.history-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: end;
    gap: 10px;
    margin-bottom: 14px;
}
.history-controls label {
    margin: 0;
}
.history-controls button {
    min-height: 38px;
}
.history-controls .crm-date-field input {
    margin-top: 5px;
}
.history-controls .crm-date-picker {
    margin-top: 0;
}
.history-scroll {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    max-height: 70vh;
}
.attendance-history {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    font-size: 12px;
}
.attendance-history th, .attendance-history td {
    padding: 9px 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    text-align: center;
    min-width: 100px;
}
.attendance-history thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #eef5fb;
}
.attendance-history th:first-child {
    position: sticky;
    left: 0;
    text-align: left;
    min-width: 160px;
    max-width: 220px;
    background: #fff;
    z-index: 1;
    overflow-wrap: anywhere;
}
.attendance-history thead th:first-child {
    z-index: 3;
    background: #eef5fb;
}
.history-present {
    color: #17794e;
    background: #e7f6ed;
    font-weight: bold;
}
.history-absent {
    color: #a14f57;
    background: #fff0f0;
}
.history-unmarked {
    color: #9b7b25;
    background: #fff8e1;
}
.history-cancelled {
    color: #8c8f99;
    background: #f1f2f5;
}
.history-pages {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    padding-top: 14px;
}
.history-payment {
    padding-left: 0;
    padding-right: 0;
}
.history-result .legend {
    margin: 12px 0;
}
.feis-bulk-heading label {
    margin: 0;
}
.feis-student .subtitle {
    margin: 2px 0;
}
.feis-student input:disabled {
    opacity: 0.6;
}
.tariff-group + .tariff-group {
    margin-top: 20px;
}
@media (max-width: 700px) {
    .history-controls {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
    .history-controls > label:first-child {
        grid-column: 1 / -1;
    }
    .history-controls > button {
        grid-column: 1 / -1;
    }
    .student-list .student {
        padding: 8px 10px;
    }
    .student-list .card-actions {
        grid-column: 2 / -1;
        justify-content: flex-start;
    }
    .history-payment > div:last-child {
        grid-column: 1 / -1;
    }
    .history-controls .crm-date-field > [data-crm-date] {
        padding-left: 8px;
        padding-right: 32px;
        font-size: 13px;
    }
    .history-controls .crm-date-picker {
        width: 30px;
    }
}

.student-list .card-actions {
    max-width: 300px;
}

/* Кнопка добавления комментария занимает только ширину подписи. */
.note.empty[data-action="comment"] {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: auto;
    max-width: 100%;
    min-height: 24px;
    margin: 3px 0 0;
    padding: 3px 6px;
    font-size: 12px;
    line-height: 1.3;
    color: #708394;
    border-radius: 4px;
    -webkit-line-clamp: unset;
}

.absence-reason {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    max-width: 132px;
    margin: 5px 0;
    color: #84663c;
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.history-excused {
    background: #fff6df;
}
.history-reason {
    padding: 3px 7px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
}
.history-reason-detail {
    padding: 10px 12px;
    border-radius: 6px;
    background: #fff6df;
    overflow-wrap: anywhere;
}

.crm-admin-link {
    color: #fff;
    padding: 5px 8px;
    border: 1px solid #ffffff70;
    border-radius: 6px;
    font-size: 12px;
}
.top:has(.crm-admin-link) {
    flex-wrap: wrap;
}

/* One calendar selects both ends of the reporting period. */
.history-range-field {
    min-width: 0;
}
.history-range-field > span {
    display: block;
    margin-bottom: 5px;
}
[data-history-range] {
    position: relative;
}
.crm-range-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    white-space: nowrap;
    font-size: 12px;
}
.crm-range-calendar {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    z-index: 20;
    width: 294px;
    max-width: calc(100vw - 40px);
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 10px 30px rgba(24, 51, 76, 0.16);
}
.crm-range-calendar[hidden] {
    display: none;
}
.crm-range-navigation,
.crm-range-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.crm-range-navigation strong {
    font-size: 13px;
}
.crm-range-hint {
    margin: 8px 0;
    color: #63788b;
    font-size: 12px;
}
.crm-range-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 3px;
}
.crm-range-grid > span {
    text-align: center;
    padding: 3px 0;
    font-size: 11px;
    color: #63788b;
}
.crm-range-grid > button {
    min-width: 0;
    min-height: 32px;
    padding: 4px 0;
    font-size: 12px;
}
.crm-range-grid .is-in-range {
    background: #e5f2fb;
}
.crm-range-grid .is-endpoint {
    color: #fff;
    background: #2188c9;
    border-color: #2188c9;
}
.crm-range-footer {
    margin-top: 10px;
}
.history-controls {
    grid-template-columns: minmax(160px, 1fr) minmax(245px, 1fr) auto;
}
.attendance-history th,
.attendance-history td {
    min-width: 42px;
    padding: 5px 7px;
}
.attendance-history .history-group-row th {
    position: static;
    max-width: none;
    background: var(--group-tint, #eff7fc);
    border-left: 4px solid var(--group-color, #2188c9);
}
.attendance-history .history-student-row > th {
    border-left: 4px solid var(--group-color, #2188c9);
    background: linear-gradient(var(--group-tint, #eff7fc), var(--group-tint, #eff7fc)), #fff;
}
.history-cell-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 26px;
    min-height: 28px;
    padding: 1px 3px;
    border-radius: 5px;
}
.history-date-cell .history-cell-mark + .history-cell-mark {
    margin-left: 3px;
}
.history-cell-mark small {
    font-size: 9px;
}
@media (max-width: 720px) {
    .history-controls {
        grid-template-columns: minmax(0, 1fr);
    }
    .history-controls > label:first-child,
    .history-controls > button {
        grid-column: auto;
    }
    .history-range-field {
        width: 100%;
    }
    .attendance-history th,
    .attendance-history td {
        min-width: 33px;
        padding: 3px 4px;
        font-size: 10px;
    }
    .attendance-history th:first-child {
        min-width: 125px;
        max-width: 165px;
    }
}

.attendance-history .history-group-row .history-lesson-filter {
    max-width: none;
    white-space: normal;
    text-align: left;
    font-size: 11px;
}
.attendance-history .history-group-row > th {
    max-width: none;
}

/* Floating date range stays outside clipping panels, within the visible screen. */
.crm-range-calendar {
    position: fixed;
    inset: auto;
    margin: 0;
    box-sizing: border-box;
    overflow: auto;
    overscroll-behavior: contain;
    z-index: 1000;
}

/* Editable marks retain their original compact symbol appearance. */
.history-cell-mark[role="button"]{cursor:pointer}
.history-cell-mark[role="button"]:focus-visible{outline:2px solid #009eff;outline-offset:2px}

.attendance-history td.history-perfect{background:#e0f4e7;color:#17794e;font-weight:600}
