/* Shared phone layout for CRM, LMS, records and the schedule board. */
.portal-switcher{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:0 0 16px}.portal-switcher>a{display:flex;align-items:center;gap:11px;min-width:0;padding:14px;border:1px solid #dfe4dd;border-radius:16px;background:#fff;color:#59605a;text-decoration:none}.portal-switcher>a.active{border-color:#bfe9c2;background:#e7f8e7;color:#1e6328}.portal-switcher i{display:grid;flex:0 0 34px;height:34px;place-items:center;border-radius:10px;background:#f0f3ef;font-style:normal}.portal-switcher span,.portal-switcher b,.portal-switcher small{display:block;min-width:0}.portal-switcher b{font-size:12px}.portal-switcher small{margin-top:3px;color:#818882;font-size:9px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media (max-width: 760px) {
  html { overflow-x: clip; }
  body { min-width: 0; overflow-x: clip; }
  body[data-role="admin"] .notify-button,
  body[data-role="moderator"] .notify-button,
  body[data-role="teacher"] .notify-button { display: grid !important; top: calc(10px + env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; }
  body[data-role="admin"] .crm-top,
  body[data-role="moderator"] .staff-head,
  body[data-role="teacher"] .staff-head { padding-right: 48px; }
  body.has-mobile-tabs .crm-side,
  body.has-mobile-tabs .staff-side,
  body.has-mobile-tabs .workspace-nav { display: none !important; }
  body.has-mobile-tabs .crm-layout,
  body.has-mobile-tabs .staff-layout,
  body.has-mobile-tabs .workspace-layout { display: block; }

  .crm-main,.staff-main { width: 100%; min-width: 0; padding: calc(20px + env(safe-area-inset-top)) 12px calc(104px + env(safe-area-inset-bottom)); }
  .portal-switcher{display:flex;gap:7px;margin:0 0 14px;padding-bottom:2px;overflow-x:auto;scrollbar-width:none}.portal-switcher::-webkit-scrollbar{display:none}.portal-switcher>a{flex:0 0 min(78vw,260px);padding:12px}.portal-switcher b{font-size:13px}.portal-switcher small{font-size:10px}
  .crm-top,.staff-head,.workspace-head { align-items: flex-start; flex-direction: column; gap: 12px; margin-bottom: 22px; }
  .crm-top h1,.staff-head h1,.workspace-head h1 { overflow-wrap: anywhere; font-size: clamp(31px,10vw,40px); line-height: .98; }
  .staff-head p,.workspace-head p { font-size: 14px; line-height: 1.45; }
  .crm-card,.staff-panel,.panel { min-width: 0; padding: 16px; border-radius: 17px; }
  .card-head,.panel-title,.panel-head { gap: 10px; margin-bottom: 14px; }
  .card-head h2,.panel-title h2,.panel-head h2 { font-size: 20px; }
  .crm-metrics,.staff-stats,.metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .crm-metrics article,.staff-stats a,.metric-grid article { min-width: 0; padding: 15px; }
  .crm-metrics strong,.staff-stats strong,.metric-grid strong { font-size: 27px; }
  .crm-grid,.split,.three,.staff-grid,.homework-layout,.lead-layout,.records-grid,.homework-list,.family-grid,.release-grid { grid-template-columns: minmax(0,1fr) !important; }
  .course-card { min-height: 190px; }

  .toolbar,.action-bar,.task-toolbar,.preference-actions { align-items: stretch; flex-direction: column; }
  .toolbar input,.toolbar select,.toolbar button,.action-bar button,.preference-actions a,.preference-actions button { width: 100%; min-width: 0; }
  .form-grid input,.form-grid select,.form-grid textarea,.staff-dialog input,.staff-dialog select,.staff-dialog textarea { min-width: 0; font-size: 16px; }
  .actions { width: 100%; align-items: stretch; flex-direction: column; }
  .actions button,.actions select,.actions input[type=datetime-local],.actions input[name=ban_reason] { width: 100%; max-width: none; min-height: 42px; }

  .table { overflow: visible; }
  .tr,.tr.people { min-width: 0; grid-template-columns: minmax(0,1fr); gap: 9px; margin-top: 10px; padding: 15px; border: 1px solid #e4e8e2; border-radius: 14px; background: #fafbf9; font-size: 12px; }
  .tr.th { display: none; }
  .tr span,.tr form { min-width: 0; overflow-wrap: anywhere; }
  .tr select { width: 100%; min-height: 42px; font-size: 14px; }
  .api-intro,.api-method header { align-items: flex-start; flex-direction: column; }
  .api-method header code,.api-method pre { max-width: 100%; font-size: 12px; overflow-wrap: anywhere; white-space: pre-wrap; }

  .family-card>header { align-items: flex-start; flex-wrap: wrap; }
  .account-state { margin-left: 44px; }
  .inline-access,.inline-link { grid-template-columns: minmax(0,1fr); }
  .access-result>div { display: grid; }
  .access-result button { min-height: 42px; }
  .reset-row { align-items: stretch; flex-direction: column; }

  .workspace { padding-bottom: calc(104px + env(safe-area-inset-bottom)); }
  .workspace-main { width: 100%; min-width: 0; }
  .workspace-grid { grid-template-columns: minmax(0,1fr); }
  .next-lesson { grid-template-columns: 50px minmax(0,1fr); gap: 12px; padding: 14px; }
  .next-lesson h3,.next-lesson p,.task-line b,.task-line small { overflow-wrap: anywhere; }
  .task-line { align-items: flex-start; flex-wrap: wrap; }
  .task-line time { width: 100%; padding-left: 39px; }
  .crm-table { overflow: visible; }
  .crm-row { min-width: 0; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; padding: 13px 0; }
  .crm-row-head { display: none; }

  .records,.profile-shell,.notification-settings { width: min(100% - 24px,1050px); padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: calc(105px + env(safe-area-inset-bottom)); }
  .records>header,.profile-grid { margin-top: 28px; }
  .records h1,.profile-grid h1,.notification-settings h1 { font-size: clamp(34px,11vw,46px); }
  .homework-card,.records-grid>section,.profile-card { min-width: 0; padding: 16px; border-radius: 17px; }
  .homework-head { align-items: flex-start; flex-direction: column; }
  .grade { align-items: flex-start; }
  .attendance-item { flex-wrap: wrap; }
  .attendance-item>span { width: 100%; padding-left: 42px; }

  .notification-settings header { margin: 28px 0 20px; }
  .preference-table { overflow: visible; border: 0; background: transparent; }
  .preference-row { grid-template-columns: repeat(3,minmax(0,1fr)); margin-bottom: 10px; padding: 15px 10px; border: 1px solid #dfe4de; border-radius: 15px; background: #fff; }
  .preference-row strong { grid-column: 1/-1; overflow-wrap: anywhere; }

  .schedule-head { padding-top: calc(18px + env(safe-area-inset-top)); }
  .week-nav { grid-template-columns: repeat(7,54px); padding: 5px; overflow-x: auto; scrollbar-width: none; }
  .week-nav::-webkit-scrollbar { display: none; }
  .day-board { width: calc(100% - 16px); min-width: 0; grid-template-columns: 50px minmax(0,1fr); margin-inline: 8px; margin-bottom: calc(105px + env(safe-area-inset-bottom)); }
  .time-rail span { right: 8px; }
  .sticky-note { left: 8px; width: calc(100% - 16px); padding-left: 10px; }
  .sticky-note b { font-size: 11px; }
  .quick-dialog,.lesson-dialog,.staff-dialog,.crm-task-dialog { width: calc(100% - 18px); max-height: calc(100dvh - 24px); padding: 20px; overflow-y: auto; border-radius: 19px; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .dialog-actions a { text-align: center; }
  .schedule-list { width: calc(100% - 16px); padding-bottom: calc(95px + env(safe-area-inset-bottom)); }
  .schedule-item { grid-template-columns: 54px minmax(0,1fr); gap: 11px; padding: 14px; }
  .schedule-copy h2 { overflow-wrap: anywhere; }
  .schedule-copy p { display: grid; grid-template-columns: 50px minmax(0,1fr); }
  .schedule-actions { grid-column: 1/-1; grid-auto-flow: row; justify-items: stretch; }
  .schedule-actions a { text-align: center; }
}

@media (max-width: 390px) {
  .crm-metrics,.staff-stats,.metric-grid { grid-template-columns: minmax(0,1fr); }
  .mobile-tabs { left: 6px; right: 6px; }
  .mobile-tabs a,.mobile-tabs button { font-size: 8px; }
}
