/* Staff workspaces: readable controls and phone layouts for real data.
   Load after the shared responsive stylesheet. */
.staff-portal :is(.main, .panel, .group-card, .course-main, .teacher-chip, .mobile-cell-value, .program-module-body, .checking-step-card, .admin-form-dialog-body) {
  min-width: 0;
}
.staff-portal :is(h1, h2, h3, .lead, .group-card p, .notice, .checking-answer-block, .teacher-submission-body, .file-card strong, .file-row strong, .teacher-chip strong) {
  overflow-wrap: anywhere;
}
.staff-portal :is(.button-small, .icon-btn, .sidebar-collapse, .sidebar-open, .sidebar-close) {
  min-width: 44px;
  min-height: 44px;
}
.staff-portal :is(.v38-program-module-head h3, .v38-program-title strong, .lesson-admin-row strong) {
  font-size: 14px;
  line-height: 1.5;
}
.staff-portal :is(.v38-program-module-head small, .v38-program-title small, .v38-program-schedule label span, .v38-program-schedule small, .weekday-time-input span, .weekday-summary, .schedule-example, .course-editor-group-facts span, .course-editor-group-head small, .checking-group-card dt) {
  font-size: 12px;
  line-height: 1.5;
}
.staff-portal :is(.v38-program-number, .lesson-admin-row > span) { font-size: 12px; }
.staff-portal :is(.course-editor-group-facts strong, .checking-card-action, .lesson-admin-row time, .lesson-admin-row em) { font-size: 13px; line-height: 1.5; }
.staff-portal :is(.v38-program-schedule input, .live-url-input, .weekday-time-input input, .program-lesson-form select) {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  font-size: 14px;
}
.staff-portal :is(.content-editor-fields textarea, .content-editor-fields input, .module-editor-row input, .program-lesson-form input, .program-lesson-form select) {
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
}
.staff-portal .weekday-time-toggle span { min-height: 44px; font-size: 14px; }
.staff-portal .weekday-time-toggle input:focus-visible + span {
  outline: 3px solid var(--accent-dark);
  outline-offset: 3px;
}
.staff-portal .mobile-cell-label { display: none; }
.staff-portal .mobile-cell-value { overflow-wrap: anywhere; }
.staff-portal .table-actions { flex-wrap: wrap; }
/* The two-column attendance form does not need the generic 920px table floor. */
.staff-portal #lesson-attendance .data-table { width: 100%; min-width: 0; }
.staff-portal .live-url-control { width: 100%; min-width: 0; }
.staff-portal .live-url-status { display: block; min-height: 1.5em; font-size: 12px; }
.staff-portal .checking-technical-body pre { overflow-wrap: anywhere; }
.staff-portal .checking-history-panel .section-head > form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.staff-portal .conduit-scroll-hint { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.staff-portal .conduit-table-wrap { max-width: 100%; border: 1px solid var(--line); border-radius: 10px; }
.staff-portal .conduit-table .score-link { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
/* The lesson editor is shared by both roles, so its disclosures must not
   depend on the teacher-only legacy stylesheet. */
.staff-portal .teacher-submission { display: block; padding: 0; overflow: hidden; }
.staff-portal .teacher-submission summary { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 16px; cursor: pointer; list-style: none; }
.staff-portal .teacher-submission summary::-webkit-details-marker { display: none; }
.staff-portal .teacher-submission summary div :is(strong, small) { display: block; }
.staff-portal .teacher-submission-body { display: grid; gap: 16px; padding: 18px; border-top: 1px solid var(--line); background: var(--surface); }
.staff-portal .homework-editor-files { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.staff-portal .homework-editor-file { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.staff-portal .teacher-submission .submission-hide { display: none; }
.staff-portal .teacher-submission[open] .submission-show { display: none; }
.staff-portal .teacher-submission[open] .submission-hide { display: inline; }
.staff-portal .teacher-submission[open] .submission-toggle { font-size: 13px; }
.staff-portal .teacher-submission[open] .submission-toggle::after { content: none; }
.staff-portal .teacher-submission summary .submission-toggle { color: var(--accent-dark); font-size: 13px; }
.staff-portal .admin-form-dialog {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.staff-portal .admin-form-dialog-head { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.staff-portal .admin-form-dialog-foot { position: sticky; bottom: 0; z-index: 1; }
.staff-portal .admin-form-dialog-shell { overflow: visible; }
.staff-portal :is(.checking-add-step summary, .technical-details-inline summary) { padding-block: 10px; min-height: 44px; }

@media (max-width: 1100px) {
  .staff-portal :is(.editor-grid, .checking-result-layout, .student-profile-grid) { grid-template-columns: minmax(0, 1fr); }
  .staff-portal .v38-program-lesson { grid-template-columns: 38px minmax(0, 1fr); }
  .staff-portal :is(.v38-program-schedule, .v38-program-actions) { grid-column: 2; }
  .staff-portal .v38-program-schedule { grid-template-columns: minmax(0, 1fr) minmax(100px, .65fr); }
  .staff-portal .v38-program-actions { justify-self: start; }
}
@media (max-width: 900px) {
  /* Match the specificity of the legacy field selectors. A broad input rule
     alone loses at 681–900 px and lets iOS zoom into 14 px form controls. */
  .staff-portal :is(.field, .auth-field) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  .staff-portal :is(.v38-program-schedule, .weekday-time-input, .content-editor-fields, .module-editor-row, .program-lesson-form, .toolbar) :is(input, select, textarea),
  .staff-portal input.live-url-input,
  .staff-portal select.select { font-size: 16px; }
  .staff-portal .sidebar { height: 100dvh; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .staff-portal :is(.sidebar-open, .sidebar-close) { width: 44px; height: 44px; flex-basis: 44px; }
  .staff-portal .sidebar .brand { padding-right: 42px; }
  .staff-portal .sidebar .brand-mark { flex-shrink: 0; }
  .staff-portal .sidebar .brand > span:nth-child(2) { min-width: 0; }
  .staff-portal .sidebar .brand strong { font-size: 14px; }
  .staff-portal .sidebar .sidebar-close { position: absolute; top: 14px; right: 10px; }
  .staff-portal :is(.form-grid, .field-grid, .field-grid.three, .homework-editor-files) { grid-template-columns: minmax(0, 1fr); }
  .staff-portal .lesson-heading-card { flex-direction: column; align-items: stretch; }
  .staff-portal .lesson-admin-row { grid-template-columns: 38px minmax(0, 1fr); gap: 6px 12px; }
  .staff-portal .lesson-admin-row > span { grid-row: 1 / 4; align-self: start; }
  .staff-portal .lesson-admin-row :is(time, em) { grid-column: 2; }
  .staff-portal .lesson-admin-row strong { font-size: 15px; }
  .staff-portal .page-head { align-items: stretch; flex-direction: column; }
  .staff-portal .page-actions { width: 100%; }
  .staff-portal .page-actions .button { flex: 1 1 160px; }
}
@media (max-width: 720px) {
  .staff-portal .main { width: calc(100% - 24px); padding-bottom: max(32px, env(safe-area-inset-bottom)); }
  .staff-portal :is(.panel-pad, .group-card, .lesson-heading-card, .student-card, .course-editor-group-card) { padding: 16px; }
  .staff-portal :is(.page-head, .page-heading) { gap: 16px; }
  .staff-portal :is(.page-head, .page-heading, .lesson-heading-card, .group-hero) h1 { font-size: clamp(26px, 7vw, 32px); line-height: 1.2; }
  .staff-portal .section-head { align-items: stretch; flex-direction: column; gap: 12px; }
  .staff-portal .section-head h2 { font-size: 19px; line-height: 1.3; }
  .staff-portal .tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px; }
  .staff-portal .tabs > button { width: auto; flex: 1 1 125px; min-width: 0; padding: 10px; }
  .staff-portal .tabs > button:only-child { flex-grow: 0; }
  .staff-portal .teacher-submission summary { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; }
  .staff-portal .teacher-submission summary :is(.badge, .score-badge) { justify-self: start; }
  .staff-portal .teacher-submission summary .submission-toggle { grid-column: 1; }
  .staff-portal .teacher-submission-body { padding: 14px; }
  .staff-portal :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea) { font-size: 16px; }
  .staff-portal input[type="file"] { width: 100%; min-width: 0; padding: 8px; overflow: hidden; }
  .staff-portal .field-full { min-width: 0; }
  .staff-portal .section-actions { width: 100%; }
  .staff-portal .section-actions > form { flex: 1 1 100%; }
  .staff-portal .section-actions > form .button { width: 100%; }
  .staff-portal .section-actions > .button { flex: 1 1 160px; }
  .staff-portal :is(.file-card, .file-row) { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .staff-portal .file-card-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
  .staff-portal .file-card-actions > :is(a, form) { flex: 1 1 100px; }
  .staff-portal .file-card-actions form .button { width: 100%; }
  .staff-portal .homework-editor-file { padding: 12px; }
  .staff-portal .checking-group-grid { grid-template-columns: minmax(0, 1fr); }
  .staff-portal .checking-group-card { padding: 16px; }
  .staff-portal .checking-group-card dl { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .staff-portal .checking-group-card dl > div { padding: 8px; min-width: 0; }
  .staff-portal .checking-group-card dt { overflow-wrap: anywhere; }
  .staff-portal .checking-summary-strip { grid-template-columns: minmax(0, 1fr); }
  .staff-portal .checking-summary-strip > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .staff-portal .checking-summary-strip > div:last-child { border-bottom: 0; }
  .staff-portal .checking-step-card { padding: 12px; }
  .staff-portal .checking-approval-rule { flex-direction: column; align-items: stretch; padding: 12px; }
  .staff-portal .checking-approval-rule .check { align-items: flex-start; }
  .staff-portal .checking-approval-rule .check input { flex-shrink: 0; }
  .staff-portal .checking-history-panel .section-head > form { display: grid; grid-template-columns: minmax(0, 1fr); }
  .staff-portal :is(.checking-history-panel .select, .checking-history-panel .section-head > form .button) { width: 100%; }
  .staff-portal .danger-zone-final { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  .staff-portal .danger-zone-final form { width: 100%; min-width: 0; }
  .staff-portal .danger-zone-final .button { width: 100%; }
  .staff-portal .admin-form-dialog-head, .staff-portal .admin-form-dialog-body, .staff-portal .admin-form-dialog-foot { padding: 14px; }
  .staff-portal .admin-form-dialog-foot { flex-wrap: wrap; }
  .staff-portal .admin-form-dialog-foot .button { flex: 1 1 110px; }

  /* A record becomes a labeled card. Explicit table roles in the templates
     preserve table semantics when CSS changes its visual display. */
  .staff-portal .mobile-stack-table { display: block; width: 100%; min-width: 0 !important; border-spacing: 0; }
  .staff-portal .mobile-stack-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .staff-portal .mobile-stack-table tbody { display: grid; gap: 0; width: 100%; }
  .staff-portal .mobile-stack-table tbody tr { display: block; min-width: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .staff-portal .mobile-stack-table tbody tr:last-child { border-bottom: 0; }
  .staff-portal .mobile-stack-table tbody td {
    display: grid;
    grid-template-columns: minmax(78px, .75fr) minmax(0, 1.65fr);
    align-items: start;
    gap: 12px;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 7px 0;
    border: 0;
    white-space: normal;
    text-align: left;
  }
  .staff-portal .mobile-stack-table .mobile-cell-label { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; }
  .staff-portal .mobile-stack-table td[data-label="Действия"] { display: block; padding-top: 12px; }
  .staff-portal .mobile-stack-table td[data-label="Действия"] .mobile-cell-label { display: none; }
  .staff-portal .mobile-stack-table td[colspan] { display: block; }
  .staff-portal .mobile-stack-table .table-actions { justify-content: stretch; }
  .staff-portal .mobile-stack-table td[data-label="Действия"] :is(.button, .table-actions > a) { width: 100%; flex: 1 1 110px; }
  .staff-portal .mobile-stack-table :is(.select, input[type="url"]) { width: 100%; min-width: 0; }
  .staff-portal .mobile-stack-table .enrollment-live-url-cell { display: block; }
  .staff-portal .mobile-stack-table .enrollment-live-url-cell .mobile-cell-label { margin-bottom: 6px; }
  .staff-portal .mobile-stack-table .teacher-chip { align-items: start; }
  .staff-portal .mobile-stack-table .teacher-chip img { width: 36px; height: 36px; flex: 0 0 36px; }
  .staff-portal .mobile-stack-table .checking-status-reason { max-width: 100%; }
  .staff-portal #lesson-attendance .mobile-stack-table td { display: block; }
  .staff-portal #lesson-attendance .mobile-stack-table td:first-child .mobile-cell-label { display: none; }
  .staff-portal #lesson-attendance .mobile-stack-table td:last-child .mobile-cell-label { margin-bottom: 6px; }
  .staff-portal #lesson-attendance .button[type="submit"] { width: 100%; margin-top: 14px; }

  .staff-portal .conduit-table .conduit-student-column { width: 124px; min-width: 124px; max-width: 124px; padding: 10px 8px; }
  .staff-portal .conduit-table .conduit-student-column strong { white-space: normal; overflow: visible; text-overflow: clip; font-size: 12px; line-height: 1.4; }
  .staff-portal .conduit-table :is(.conduit-attendance-column, .conduit-score-column) { padding: 8px 5px; }
  .staff-portal .conduit-table .conduit-lesson-title { white-space: normal; overflow: visible; text-overflow: clip; font-size: 12px; line-height: 1.4; }
}
@media (max-width: 420px) {
  .staff-portal .topbar { gap: 8px; padding-inline: 12px; }
  .staff-portal .profile-link { min-width: 44px; }
  .staff-portal .profile-link > span:last-child { display: none; }
  .staff-portal .v38-program-lesson { padding: 12px; }
  .staff-portal :is(.v38-program-schedule, .v38-program-actions) { grid-column: 1 / -1; }
  .staff-portal .v38-program-actions { width: 100%; }
  .staff-portal .v38-program-actions .button { width: 100%; }
  .staff-portal .v38-program-schedule { grid-template-columns: minmax(0, 1fr); }
  .staff-portal .content-editor-actions { display: flex; flex-wrap: wrap; }
  .staff-portal .content-editor-actions .button { flex: 1 1 72px; }
  .staff-portal .page-actions .button { flex-basis: 100%; }
  .staff-portal .mobile-stack-table tbody tr { padding-inline: 12px; }
  .staff-portal .mobile-stack-table tbody td { gap: 10px; }
}
