/* Internal interface redesign. Login styles intentionally remain in theme-v3.css. */
body.app-active {
  --app-bg: #f7fcfd;
  --app-surface: #fff;
  --app-surface-soft: #eef9fb;
  --app-navy: #0b2b46;
  --app-navy-soft: #244a66;
  --app-copy: #617b90;
  --app-line: #d8e8ef;
  --app-teal: #0ba99f;
  --app-teal-dark: #07867f;
  --app-blue: #1287c7;
  --app-success: #16a879;
  --app-warning: #f0a13b;
  --app-danger: #ea4d60;
  --app-radius-sm: 12px;
  --app-radius: 16px;
  --app-radius-lg: 20px;
  --app-shadow: 0 8px 24px rgba(11, 43, 70, .08);
  margin: 0;
  overflow-x: hidden;
  background: var(--app-bg);
  color: var(--app-navy);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

body.app-active *,
body.app-active *::before,
body.app-active *::after { box-sizing: border-box; }

.app-shell {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
  background: var(--app-bg);
  color: var(--app-navy);
}

.app-shell button,
.app-shell input,
.app-shell select,
.app-shell textarea { font: inherit; }

.app-shell button { touch-action: manipulation; }

.app-shell .topbar {
  position: sticky;
  z-index: 60;
  top: 0;
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--app-line);
  background: rgba(255, 255, 255, .96);
  padding: 8px max(24px, calc((100vw - 1440px) / 2));
  backdrop-filter: blur(16px);
}

.app-shell .brand { min-width: 0; }
.app-shell .brand img { width: 44px; height: 44px; }
.app-shell .brand strong { display: block; overflow: hidden; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .brand span { display: block; color: var(--app-teal-dark); font-size: .78rem; }
.app-shell .topbar-user { display: flex; align-items: center; gap: 10px; }
.app-shell .topbar-user > span { display: grid; }
.app-shell .topbar-user small { color: var(--app-copy); }

.app-shell .layout {
  display: block;
  width: min(1440px, 100%);
  min-width: 0;
  flex: 1 1 auto;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.role-workspace {
  display: grid;
  min-width: 0;
  grid-template-columns: 214px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.role-content { min-width: 0; }

.app-shell .role-navigation {
  position: sticky;
  top: 92px;
  display: grid;
  min-width: 0;
  grid-template-columns: 1fr;
  gap: 6px;
  overflow: visible;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
  padding: 8px;
}

.app-shell .role-navigation button {
  display: grid;
  min-width: 0;
  min-height: 50px;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  gap: 10px;
  border: 0;
  border-radius: var(--app-radius-sm);
  background: transparent;
  color: var(--app-copy);
  padding: 10px 12px;
  text-align: left;
}

.app-shell .role-navigation button.active {
  background: #e2f7f5;
  box-shadow: inset 3px 0 0 var(--app-teal);
  color: var(--app-navy);
}

.app-shell .role-navigation .nav-icon { color: currentColor; font-size: 1.12rem; }
.app-shell .role-navigation button span:last-child { overflow: visible; white-space: normal; }

.app-shell .app-page {
  display: grid;
  min-width: 0;
  gap: 20px;
  animation: internal-page-in 220ms cubic-bezier(.2, .75, .2, 1) both;
}

@keyframes internal-page-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.app-shell .page-heading {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.app-shell .page-heading h1 { margin: 0; color: var(--app-navy); font-size: clamp(1.55rem, 2.6vw, 2.15rem); line-height: 1.12; }
.app-shell .page-heading p { margin: 5px 0 0; color: var(--app-copy); line-height: 1.45; }

.app-shell .card,
.app-shell .section-card,
.app-shell .lesson-card,
.app-shell .slot-card,
.app-shell .mobile-agenda-card,
.app-shell .table-panel,
.app-shell .tide-panel,
.app-shell .stat-card,
.app-shell .next-lesson-card {
  min-width: 0;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius);
  background: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.app-shell .card,
.app-shell .section-card { padding: 20px; }

.app-shell .section-title,
.app-shell .section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-shell .section-title h2,
.app-shell .section-head h2,
.app-shell .card h2 { margin: 0; color: var(--app-navy); font-size: 1.08rem; }
.app-shell .muted { color: var(--app-copy); }
.app-shell .eyebrow { color: var(--app-teal-dark); font-size: .72rem; font-weight: 800; text-transform: uppercase; }

.app-shell .primary-action,
.app-shell .secondary-action,
.app-shell .ghost-action,
.app-shell .danger-action,
.app-shell .icon-action,
.app-shell .text-action {
  min-height: 44px;
  border-radius: var(--app-radius-sm);
  font-weight: 750;
}

.app-shell .primary-action {
  border: 1px solid transparent;
  background: linear-gradient(105deg, #0db7ac, #1287c7);
  color: #fff;
  box-shadow: 0 8px 18px rgba(11, 169, 159, .17);
}
.app-shell .secondary-action { border: 1px solid #9bded8; background: #effaf9; color: var(--app-teal-dark); }
.app-shell .ghost-action,
.app-shell .icon-action { border: 1px solid var(--app-line); background: #fff; color: var(--app-navy); }
.app-shell .danger-action { border: 1px solid #f4b7c0; background: #fff6f7; color: #cb3347; }
.app-shell .text-action { border: 0; background: transparent; color: var(--app-teal-dark); padding-inline: 8px; }
.app-shell .full { width: 100%; }

.app-shell input,
.app-shell select,
.app-shell textarea {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #cfe2e9;
  border-radius: var(--app-radius-sm);
  background: #fff;
  color: var(--app-navy);
  padding: 10px 12px;
}
.app-shell textarea { min-height: 104px; resize: vertical; }
.app-shell input:focus,
.app-shell select:focus,
.app-shell textarea:focus { border-color: var(--app-teal); box-shadow: 0 0 0 3px rgba(11, 169, 159, .12); outline: 0; }
.app-shell label > span { color: var(--app-navy-soft); font-size: .82rem; font-weight: 650; }

/* Dashboard */
.app-shell .welcome-banner {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 0;
  border-radius: var(--app-radius-lg);
  background: #e9f8fc url("/assets/dashboard-wave.webp") center / cover no-repeat;
  box-shadow: var(--app-shadow);
  padding: clamp(24px, 4vw, 42px);
}
.app-shell .welcome-banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(255,255,255,.97), rgba(255,255,255,.8) 45%, rgba(255,255,255,.08) 78%); }
.app-shell .welcome-banner > div { position: relative; z-index: 2; max-width: 620px; }
.app-shell .welcome-banner h1 { margin: 5px 0 7px; color: var(--app-navy); font-size: clamp(1.8rem, 4vw, 2.75rem); }
.app-shell .welcome-banner p { margin: 0 0 14px; color: #3c6079; }
.app-shell .banner-wave { position: absolute; z-index: 2; right: 20px; bottom: 18px; display: grid; width: 54px; height: 54px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--app-blue); font-size: 1.55rem; }

.app-shell .student-summary-grid,
.app-shell .modern-stats { display: grid; min-width: 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.app-shell .next-lesson-card { grid-column: 1 / -1; }
.app-shell .stat-card,
.app-shell .next-lesson-card { display: flex; min-height: 100px; align-items: center; gap: 14px; padding: 16px; }
.app-shell .stat-icon { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e6f7fa; color: var(--app-blue); }
.app-shell .stat-card > div,
.app-shell .next-lesson-card > div { display: grid; min-width: 0; gap: 2px; }
.app-shell .stat-card strong { color: var(--app-navy); font-size: 1.65rem; }
.app-shell .next-lesson-card strong { overflow: visible; overflow-wrap: anywhere; text-overflow: clip; white-space: normal; font-size: 1.05rem; }
.app-shell .stat-card small,
.app-shell .next-lesson-card small { color: var(--app-copy); }

.app-shell .quick-actions > div:last-child { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.app-shell .quick-actions button { display: grid; min-height: 76px; place-items: center; align-content: center; gap: 6px; border: 0; border-radius: var(--app-radius-sm); background: var(--app-surface-soft); color: var(--app-navy); }
.app-shell .quick-actions button .ui-icon { width: 24px; height: 24px; color: var(--app-blue); font-size: 1.25rem; }
.app-shell .quick-actions button > span:last-child { min-width: 0; max-width: 100%; color: inherit; font-size: .86rem; font-weight: 700; line-height: 1.15; overflow-wrap: normal; text-align: center; white-space: normal; word-break: normal; }

/* Student booking and lessons */
.app-shell .student-agenda-page { grid-template-columns: minmax(260px, .72fr) minmax(0, 1.45fr); align-items: start; }
.app-shell .student-agenda-page > .page-heading { grid-column: 1 / -1; }
.app-shell .agenda-teacher-step { position: sticky; top: 92px; }
.app-shell .teacher-selector { display: grid; grid-template-columns: 1fr; gap: 10px; }
.app-shell .teacher-option { display: grid; min-height: 66px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: #fff; color: var(--app-navy); padding: 9px 12px; text-align: left; }
.app-shell .teacher-option span:nth-child(2) { display: grid; min-width: 0; }
.app-shell .teacher-option small { color: var(--app-copy); }
.app-shell .teacher-option.active { border-color: var(--app-teal); background: #effaf8; box-shadow: inset 0 0 0 1px var(--app-teal); }
.app-shell .teacher-check { color: var(--app-teal-dark); font-size: 1.2rem; }
.app-shell .agenda-empty-state { align-self: stretch; min-height: 360px; align-content: center; justify-items: center; text-align: center; }
.app-shell .empty-state-icon { display: grid; width: 72px; height: 72px; place-items: center; border-radius: 50%; background: #e6f7fa; color: var(--app-blue); font-size: 2rem; }
.app-shell .agenda-empty-state p { max-width: 300px; color: var(--app-copy); }

.app-shell .day-tabs { display: flex; max-width: 100%; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.app-shell .day-tabs::-webkit-scrollbar { display: none; }
.app-shell .day-tabs button { min-width: 96px; min-height: 46px; flex: 1 0 96px; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: #fff; color: var(--app-copy); font-weight: 750; overflow-wrap: normal; white-space: nowrap; word-break: normal; }
.app-shell .day-tabs button.active { border-color: var(--app-teal); background: #e3f7f5; color: var(--app-navy); box-shadow: inset 0 -3px 0 var(--app-teal); }
.app-shell .schedule-list { display: grid; min-width: 0; gap: 9px; }
.app-shell .schedule-row { display: grid; min-width: 0; min-height: 66px; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: #fff; padding: 9px 10px; }
.app-shell .schedule-row-main { display: flex; min-width: 0; align-items: center; gap: 10px; }
.app-shell .schedule-row-main > strong { font-size: 1rem; }
.app-shell .schedule-row-action { min-width: 0; }
.app-shell .schedule-row-action button { min-width: 92px; }
.app-shell .status-pill { display: inline-flex; width: fit-content; min-height: 24px; align-items: center; border-radius: 999px; padding: 3px 9px; font-size: .72rem; font-weight: 750; }
.app-shell .status-free { background: #e4f7ef; color: #08795b; }
.app-shell .status-confirmed { background: #e4f4fb; color: #0879aa; }
.app-shell .status-unavailable,
.app-shell .status-used { background: #edf2f5; color: #627787; }
.app-shell .status-red,
.app-shell .status-cancelled { background: #fde8eb; color: #c72f43; }

.app-shell .segmented-control { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: #edf6f8; padding: 4px; }
.app-shell .segmented-control button { min-height: 42px; border: 0; border-radius: 9px; background: transparent; color: var(--app-copy); font-weight: 700; }
.app-shell .segmented-control button.active { background: #fff; color: var(--app-teal-dark); box-shadow: 0 3px 10px rgba(11,43,70,.08); }
.app-shell .lesson-grid { display: grid; gap: 10px; }
.app-shell .lesson-summary-card { display: grid; min-height: 82px; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px; }
.app-shell .lesson-date-block { display: grid; width: 54px; height: 60px; place-items: center; align-content: center; border-right: 1px solid var(--app-line); }
.app-shell .lesson-date-block strong { font-size: 1.4rem; }
.app-shell .lesson-date-block span { color: var(--app-copy); font-size: .7rem; }
.app-shell .lesson-summary-main { display: grid; min-width: 0; gap: 5px; }
.app-shell .lesson-detail-hero { display: flex; min-height: 160px; align-items: center; gap: 18px; background: url("/assets/dashboard-wave.webp") center / cover no-repeat; }
.app-shell .lesson-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

/* Teacher */
.app-shell .compact-segments { width: min(100%, 420px); }
.app-shell .teacher-lesson-section { display: grid; min-width: 0; gap: 12px; }
.app-shell .teacher-lesson-section-head { display: flex; min-width: 0; align-items: flex-end; justify-content: space-between; gap: 12px; padding-inline: 2px; }
.app-shell .teacher-lesson-section-head > div { display: grid; min-width: 0; gap: 3px; }
.app-shell .teacher-lesson-section-head h2 { margin: 0; color: var(--app-navy); font-size: 1.25rem; }
.app-shell .teacher-lesson-section-head p { margin: 0; color: var(--app-copy); font-size: .86rem; }
.app-shell .teacher-section-count { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e5f6f8; color: var(--app-teal-dark); font-weight: 800; }
.app-shell .teacher-dashboard-lessons { display: grid; min-width: 0; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.app-shell .teacher-dashboard-lesson { display: grid; min-width: 0; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; border: 1px solid var(--app-line); border-left: 4px solid var(--app-teal); border-radius: var(--app-radius); background: #fff; box-shadow: var(--app-shadow); padding: 12px; }
.app-shell .teacher-dashboard-lesson.is-history { border-left-color: #6d8798; }
.app-shell .teacher-lesson-date { display: grid; width: 58px; min-height: 64px; align-self: start; place-items: center; align-content: center; gap: 1px; border-radius: 12px; background: #eaf8fa; color: var(--app-navy); }
.app-shell .teacher-dashboard-lesson.is-history .teacher-lesson-date { background: #eef3f6; }
.app-shell .teacher-lesson-date strong { font-size: 1.45rem; line-height: 1; }
.app-shell .teacher-lesson-date span { color: var(--app-teal-dark); font-size: .68rem; font-weight: 800; }
.app-shell .teacher-lesson-content { display: grid; min-width: 0; align-content: start; gap: 9px; }
.app-shell .teacher-lesson-heading { display: flex; min-width: 0; align-items: flex-start; justify-content: space-between; gap: 8px; }
.app-shell .teacher-lesson-time { display: grid; min-width: 0; gap: 1px; }
.app-shell .teacher-lesson-time strong { color: var(--app-navy); font-size: 1.12rem; line-height: 1.1; }
.app-shell .teacher-lesson-time span { color: var(--app-copy); font-size: .74rem; }
.app-shell .teacher-dashboard-lesson .user-mini-identity { min-width: 0; }
.app-shell .teacher-dashboard-lesson .user-mini-identity > span:last-child { min-width: 0; }
.app-shell .teacher-dashboard-lesson .user-mini-identity strong,
.app-shell .teacher-dashboard-lesson .user-mini-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .teacher-lesson-note { margin: 0; color: var(--app-copy); font-size: .78rem; line-height: 1.35; }
.app-shell .teacher-lesson-actions { align-items: stretch; }
.app-shell .teacher-lesson-actions > button { min-height: 44px; flex: 1 1 150px; }
.app-shell .teacher-lesson-actions > .muted { width: 100%; font-size: .78rem; line-height: 1.35; }
.teacher-timeline { display: grid; min-width: 0; }
.timeline-entry { display: grid; min-width: 0; grid-template-columns: 58px 20px minmax(0, 1fr); align-items: stretch; }
.timeline-entry > time { padding-top: 17px; color: var(--app-navy); font-weight: 800; }
.timeline-rail { position: relative; display: flex; justify-content: center; }
.timeline-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--app-line); }
.timeline-rail span { position: relative; z-index: 1; width: 12px; height: 12px; margin-top: 21px; border: 3px solid #fff; border-radius: 50%; background: var(--app-teal); box-shadow: 0 0 0 2px var(--app-teal); }
.timeline-entry.is-booked .timeline-rail span { background: #7756c7; box-shadow: 0 0 0 2px #7756c7; }
.timeline-entry.is-blocked .timeline-rail span { background: var(--app-danger); box-shadow: 0 0 0 2px var(--app-danger); }
.timeline-event { min-width: 0; margin-bottom: 10px; border: 1px solid var(--app-line); border-left: 4px solid var(--app-teal); border-radius: var(--app-radius-sm); background: #effaf8; padding: 12px; }
.timeline-entry.is-booked .timeline-event { border-left-color: #7756c7; background: #f5f1fd; }
.timeline-entry.is-blocked .timeline-event { border-left-color: var(--app-danger); background: #fff4f6; }
.timeline-event-head { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; }
.timeline-event-head > div { display: grid; }
.timeline-event-head small { color: var(--app-copy); }
.timeline-event .action-row { margin-top: 10px; }
.app-shell .teacher-week-grid { display: grid; min-width: 0; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.app-shell .week-day-column { display: grid; align-content: start; gap: 8px; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: #fff; padding: 10px; }
.app-shell .week-day-column header { display: grid; gap: 2px; }
.app-shell .week-day-column header span { color: var(--app-copy); font-size: .75rem; }
.app-shell .week-slot { display: grid; min-height: 58px; align-content: center; gap: 2px; border: 0; border-left: 4px solid var(--app-teal); border-radius: 9px; background: #e9f8f4; color: var(--app-navy); padding: 8px; text-align: left; }
.app-shell .week-slot.booked { border-left-color: #7756c7; background: #f1edfb; }
.app-shell .week-slot.blocked,
.app-shell .week-slot.unavailable { border-left-color: var(--app-danger); background: #fdecef; }
.teacher-student-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.teacher-student-card { display: grid; min-width: 0; gap: 14px; border: 1px solid var(--app-line); border-radius: var(--app-radius); background: #fff; box-shadow: var(--app-shadow); padding: 16px; }
.teacher-student-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.teacher-student-metrics span { display: grid; gap: 2px; border-radius: 10px; background: var(--app-surface-soft); color: var(--app-copy); padding: 8px; font-size: .72rem; }
.teacher-student-metrics strong { color: var(--app-navy); font-size: 1rem; }
.message-hero { display: flex; align-items: center; gap: 16px; }
.message-hero-icon { display: grid; width: 58px; height: 58px; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e7f3fc; color: var(--app-blue); font-size: 1.55rem; }
.message-hero h2 { margin: 4px 0; }
.message-hero p { margin: 0; color: var(--app-copy); }

/* Administrative */
.app-shell .admin-more-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.app-shell .admin-more-item { display: grid; min-width: 0; min-height: 82px; grid-template-columns: 46px minmax(0,1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--app-line); border-radius: var(--app-radius); background: #fff; color: var(--app-navy); box-shadow: var(--app-shadow); padding: 14px; text-align: left; }
.app-shell .admin-more-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 13px; background: #e7f6f8; color: var(--app-teal-dark); font-size: 1.25rem; }
.app-shell .admin-more-item > span:nth-child(2) { display: grid; min-width: 0; gap: 3px; }
.app-shell .admin-more-item small { color: var(--app-copy); }
.app-shell .admin-agenda-mobile { display: none; }
.app-shell .table-panel { overflow: auto; }
.app-shell .admin-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.app-shell .admin-table th,
.app-shell .admin-table td { border-bottom: 1px solid var(--app-line); padding: 12px; vertical-align: top; }
.app-shell .admin-table th { color: var(--app-navy-soft); font-size: .78rem; text-align: left; }
.app-shell .cell-stack { display: grid; min-width: 150px; gap: 9px; }
.app-shell .two-col,
.app-shell .registry-grid,
.app-shell .registry-intro-grid { display: grid; min-width: 0; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.app-shell .registry-intro-grid { grid-template-columns: minmax(0,1.5fr) minmax(260px,.7fr); }
.app-shell .registry-overview { position: sticky; top: 92px; }
.app-shell .compact-form,
.app-shell .form-grid { display: grid; min-width: 0; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.app-shell .compact-form label,
.app-shell .form-grid label { display: grid; min-width: 0; gap: 6px; }
.app-shell .compact-form .full,
.app-shell .form-grid .full { grid-column: 1 / -1; }
.app-shell .student-directory { padding: 0; overflow: hidden; }
.app-shell .student-directory > .section-head { padding: 18px 18px 0; }
.app-shell .student-directory-filters { display: grid; grid-template-columns: minmax(220px,1.5fr) repeat(2,minmax(130px,.5fr)); gap: 10px; margin: 16px 18px; border-radius: var(--app-radius-sm); background: var(--app-surface-soft); padding: 12px; }
.app-shell .student-directory-filters label { display: grid; min-width: 0; gap: 5px; }
.app-shell .admin-list { display: grid; min-width: 0; }
.app-shell .list-row { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--app-line); padding: 14px 18px; }
.app-shell .list-row:last-child { border-bottom: 0; }
.app-shell .editable-row > div:first-child { display: grid; min-width: 0; gap: 3px; }
.app-shell .editable-row span,
.app-shell .editable-row small { overflow-wrap: anywhere; color: var(--app-copy); }
.app-shell .row-actions,
.app-shell .action-row { display: flex; flex-wrap: wrap; gap: 7px; }
.app-shell .ticket-summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
.app-shell .ticket-summary > div { display: grid; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: var(--app-surface-soft); padding: 12px; }
.app-shell .ticket-summary strong { font-size: 1.35rem; }
.fixed-schedule-overview { overflow: hidden; }
.fixed-schedule-desktop { max-width: 100%; overflow-x: auto; margin-top: 14px; }
.fixed-schedule-table { width: 100%; min-width: 820px; border-collapse: separate; border-spacing: 5px; }
.fixed-schedule-table th { color: var(--app-navy-soft); font-size: .74rem; text-align: center; }
.fixed-schedule-table tbody th { width: 64px; }
.fixed-schedule-table td { min-width: 96px; height: 42px; border-radius: 9px; background: #f4f8fa; padding: 4px; text-align: center; }
.fixed-rule-chip { display: block; border-radius: 7px; background: #e5f7f1; color: #08795b; padding: 5px 6px; font-size: .72rem; font-weight: 750; }
.fixed-rule-chip + .fixed-rule-chip { margin-top: 4px; }
.fixed-rule-empty { color: #9bb0bf; }
.fixed-schedule-mobile { display: none; }

/* Profile, tide and dialogs */
.app-shell .profile-hero { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 20px; background: linear-gradient(135deg,#fff,#eef9fb); }
.app-shell .profile-photo-wrap { position: relative; }
.app-shell .profile-avatar.avatar-xl { width: 96px; height: 96px; }
.app-shell .profile-layout { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.app-shell .profile-setting-card { overflow: hidden; padding: 0; }
.app-shell .profile-setting-card summary { min-height: 68px; }
.app-shell .profile-setting-content { padding: 16px; }
.app-shell .profile-support-card a,
.app-shell .profile-support-card button { min-height: 58px; }
.app-shell .tide-panel { overflow: hidden; }
.app-shell .tide-canvas { max-width: 100%; }
.app-shell .site-footer { padding: 20px 24px 30px; }

.app-shell .modal {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(5, 32, 53, .62);
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  backdrop-filter: blur(6px);
}
.app-shell .modal-panel,
.app-shell .wide-modal {
  width: min(100%, 720px);
  max-height: min(88dvh, 860px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--app-line);
  border-radius: var(--app-radius-lg);
  background: #fff;
  box-shadow: 0 20px 60px rgba(11,43,70,.24);
  padding: 20px;
}

.app-shell .mobile-bottom-nav { display: none; }

@media (max-width: 980px) and (min-width: 761px) {
  .app-shell .layout { padding: 20px; }
  .role-workspace { grid-template-columns: 1fr; }
  .app-shell .role-navigation { position: static; grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0,1fr); }
  .app-shell .role-navigation button { grid-template-columns: auto minmax(0,auto); justify-content: center; }
  .app-shell .role-navigation button span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-shell .student-dashboard { grid-template-columns: 1fr; }
  .app-shell .student-dashboard > *,
  .app-shell .student-dashboard .student-summary-grid,
  .app-shell .student-dashboard .quick-actions { grid-column: 1; grid-row: auto; }
  .app-shell .student-dashboard .quick-actions > div:last-child { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .app-shell .student-agenda-page { grid-template-columns: minmax(230px,.75fr) minmax(0,1.35fr); }
  .app-shell .agenda-teacher-step,
  .app-shell .registry-overview { position: static; }
}

@media (max-width: 760px) {
  body.app-active { height: 100dvh; overflow: hidden; }
  body.app-active .app-shell { height: 100dvh; min-height: 0; overflow: hidden; padding: 0; }
  .app-shell .topbar,
  .app-shell .role-navigation,
  .app-shell .site-footer { display: none; }
  body.app-active .app-shell .layout {
    width: 100%;
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding: max(52px, calc(env(safe-area-inset-top) + 12px)) 10px calc(92px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(92px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }
  .role-workspace { display: block; }
  .app-shell .app-page { gap: 14px; }
  .app-shell .page-heading { align-items: flex-start; }
  .app-shell .page-heading h1 { font-size: 1.36rem; }
  .app-shell .page-heading p { font-size: .86rem; }
  .app-shell .page-heading > .primary-action { min-width: 44px; padding-inline: 12px; }
  .app-shell .card,
  .app-shell .section-card { padding: 14px; }
  .app-shell .welcome-banner { min-height: 198px; padding: 18px; background-position: 58% center; }
  .app-shell .welcome-banner > div { max-width: 72%; }
  .app-shell .welcome-banner h1 { font-size: 1.46rem; }
  .app-shell .welcome-banner p { font-size: .84rem; }
  .app-shell .welcome-banner .primary-action { min-height: 44px; }
  .app-shell .banner-wave { width: 44px; height: 44px; right: 12px; bottom: 12px; }
  .app-shell .mobile-page-intro { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; }

  .app-shell .student-summary-grid,
  .app-shell .modern-stats { grid-template-columns: 1fr; gap: 9px; }
  .app-shell .stat-card,
  .app-shell .next-lesson-card { min-height: 76px; gap: 12px; padding: 11px 12px; }
  .app-shell .stat-card .stat-icon,
  .app-shell .next-lesson-card .stat-icon { width: 40px; height: 40px; }
  .app-shell .stat-card strong { font-size: 1.26rem; }
  .app-shell .stat-card small { display: block; }
  .app-shell .quick-actions { padding: 12px; }
  .app-shell .quick-actions > div:last-child { gap: 5px; }
  .app-shell .quick-actions button { min-height: 62px; padding: 5px 2px; font-size: .68rem; }
  .app-shell .quick-actions button > span:last-child { font-size: .72rem; line-height: 1.1; }

  .app-shell .teacher-lesson-section { gap: 10px; }
  .app-shell .teacher-lesson-section-head { align-items: center; }
  .app-shell .teacher-lesson-section-head h2 { font-size: 1.08rem; }
  .app-shell .teacher-lesson-section-head p { font-size: .78rem; }
  .app-shell .teacher-dashboard-lessons { grid-template-columns: minmax(0, 1fr); }
  .app-shell .teacher-dashboard-lesson { grid-template-columns: 52px minmax(0, 1fr); gap: 10px; padding: 10px; }
  .app-shell .teacher-lesson-date { width: 52px; min-height: 58px; }
  .app-shell .teacher-lesson-date strong { font-size: 1.3rem; }
  .app-shell .teacher-lesson-heading { align-items: center; }
  .app-shell .teacher-lesson-time strong { font-size: 1.02rem; }
  .app-shell .teacher-dashboard-lesson .status-pill { flex: 0 0 auto; }
  .app-shell .teacher-lesson-actions > button { width: 100%; flex-basis: 100%; }

  .app-shell .student-agenda-page { grid-template-columns: 1fr; }
  .app-shell .student-agenda-page > .page-heading { grid-column: auto; }
  .app-shell .agenda-teacher-step { position: static; }
  .app-shell .agenda-empty-state { min-height: 280px; }
  .app-shell .day-tabs { margin-inline: -14px; padding-inline: 14px; }
  .app-shell .schedule-row { grid-template-columns: auto minmax(0,1fr) auto; gap: 8px; }
  .app-shell .schedule-row-main { display: grid; gap: 3px; }
  .app-shell .schedule-row-action button { min-width: 82px; padding-inline: 10px; }
  .app-shell .lesson-detail-grid { grid-template-columns: 1fr; }

  .timeline-entry { grid-template-columns: 48px 18px minmax(0,1fr); }
  .timeline-entry > time { font-size: .82rem; }
  .timeline-event { padding: 10px; }
  .timeline-event-head { align-items: flex-start; }
  .app-shell .teacher-week-grid { grid-template-columns: repeat(6, minmax(142px, 1fr)); margin-inline: -10px; padding-inline: 10px; }
  .teacher-student-list { grid-template-columns: 1fr; }
  .teacher-student-metrics { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .message-hero { align-items: flex-start; }

  .app-shell .admin-more-grid { grid-template-columns: 1fr; gap: 9px; }
  .app-shell .admin-more-item { min-height: 74px; padding: 11px; }
  .app-shell .table-panel { display: none; }
  .app-shell .admin-agenda-mobile { display: grid; gap: 10px; }
  .app-shell .mobile-agenda-card { padding: 12px; }
  .app-shell .mobile-agenda-row { padding: 10px 0; }
  .app-shell .two-col,
  .app-shell .registry-grid,
  .app-shell .registry-intro-grid,
  .app-shell .profile-layout { grid-template-columns: 1fr; }
  .app-shell .registry-overview { position: static; }
  .app-shell .compact-form,
  .app-shell .form-grid { grid-template-columns: 1fr; }
  .app-shell .compact-form .full,
  .app-shell .form-grid .full { grid-column: auto; }
  .app-shell .student-directory-filters { grid-template-columns: 1fr; margin: 12px; padding: 10px; }
  .app-shell .student-directory > .section-head { padding: 14px 14px 0; }
  .app-shell .list-row { display: grid; align-items: start; gap: 10px; padding: 13px 14px; }
  .app-shell .row-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; }
  .app-shell .row-actions > :only-child { grid-column: 1 / -1; }
  .app-shell .ticket-summary { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .app-shell .ticket-summary > div { padding: 9px; }
  .fixed-schedule-desktop { display: none; }
  .fixed-schedule-mobile { display: grid; gap: 8px; margin-top: 12px; }
  .fixed-day-card { overflow: hidden; border: 1px solid var(--app-line); border-radius: var(--app-radius-sm); background: #fff; }
  .fixed-day-card summary { display: grid; min-height: 50px; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; }
  .fixed-day-card summary::-webkit-details-marker { display: none; }
  .fixed-day-card summary span { color: var(--app-copy); font-size: .75rem; }
  .fixed-day-card > div { display: grid; border-top: 1px solid var(--app-line); }
  .fixed-day-row { display: grid; grid-template-columns: 58px minmax(0,1fr) auto; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--app-line); }
  .fixed-day-row:last-child { border-bottom: 0; }
  .fixed-day-row time { font-weight: 800; }
  .fixed-day-row small { color: var(--app-copy); }

  .app-shell .profile-hero { grid-template-columns: 1fr; justify-items: center; gap: 12px; text-align: center; }
  .app-shell .profile-hero .danger-action { width: 100%; }

  .app-shell .mobile-bottom-nav {
    position: fixed;
    z-index: 100;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 8px;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0,1fr);
    gap: 2px;
    min-height: 64px;
    border: 1px solid var(--app-line);
    border-radius: 16px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 12px 32px rgba(11,43,70,.16);
    padding: 5px;
    backdrop-filter: blur(14px);
  }
  .app-shell .mobile-bottom-nav button {
    display: grid;
    min-width: 0;
    min-height: 54px;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: var(--app-copy);
    padding: 4px 1px;
    font-size: .61rem;
  }
  .app-shell .mobile-bottom-nav button span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-shell .mobile-bottom-nav .nav-icon { font-size: 1.15rem; }
  .app-shell .mobile-bottom-nav button.active { background: #dff5f3; color: var(--app-teal-dark); }

  body.app-active .toast {
    z-index: 160;
    right: 10px;
    bottom: calc(84px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-width: none;
  }

  .app-shell .modal { place-items: end center; padding: max(8px, env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)); }
  .app-shell .modal-panel,
  .app-shell .wide-modal { width: 100%; max-height: calc(100dvh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))); border-radius: 18px; padding: 16px; }
}

@media (max-width: 360px) {
  body.app-active .app-shell .layout { padding-inline: 8px; }
  .app-shell .welcome-banner { min-height: 188px; }
  .app-shell .welcome-banner > div { max-width: 78%; }
  .app-shell .quick-actions button { font-size: .62rem; }
  .app-shell .quick-actions button > span:last-child { font-size: .65rem; }
  .app-shell .teacher-dashboard-lesson { grid-template-columns: 48px minmax(0, 1fr); gap: 8px; padding: 9px; }
  .app-shell .teacher-lesson-date { width: 48px; }
  .app-shell .next-lesson-card { align-items: flex-start; }
  .app-shell .next-lesson-card strong { font-size: .94rem; line-height: 1.18; }
  .app-shell .mobile-bottom-nav { right: 5px; left: 5px; }
  .app-shell .mobile-bottom-nav button { font-size: .56rem; }
  .app-shell .schedule-row { grid-template-columns: auto minmax(0,1fr); }
  .app-shell .schedule-row-action { grid-column: 1 / -1; }
  .app-shell .schedule-row-action button { width: 100%; }
  .app-shell .row-actions { grid-template-columns: 1fr; }
  .app-shell .row-actions > * { grid-column: auto; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell *,
  .app-shell *::before,
  .app-shell *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
