/* Shared mobile visual system. Keep dimensions stable across focus and loading. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif;
  font-synthesis: none;
  color: #202630;
  background: #f5f6f9;
  --blue: #007aff;
  --blue-soft: #edf4ff;
  --muted: #747d8a;
  --line: #e5e8ef;
  --surface: #fff;
  --surface-subtle: #f7f8fb;
  --good: #117750;
  --bad: #be3449;
  --excused: #94631c;
  --radius-panel: 14px;
  --radius-control: 9px;
  --font-input: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --control-height: 42px;
  --control-compact: 38px;
  --space-list-y: 10px;
  --space-list-x: var(--space-3);
  --space-meta: var(--space-1);
  --radius-inner: 10px;
  --focus-ring: #007aff;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; line-height: 1.45; }
.site-registration { flex:0 0 auto; padding:8px 12px; color:var(--muted); font-size:11px; line-height:18px; text-align:center; }
.site-registration a { display:inline-block; max-width:100%; color:inherit; text-decoration:none; overflow-wrap:anywhere; }
.site-registration a:hover { color:inherit; text-decoration:underline; text-underline-offset:3px; }
.trial-shell { display:flex; flex-direction:column; }
.trial-shell > main { flex:1 0 auto; }
.trial-shell > .site-registration { padding-bottom:max(8px,env(safe-area-inset-bottom)); }
body.attendance-embedded .site-registration { display:none; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button {
  min-height: var(--control-height);
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: #eef1f6;
  cursor: pointer;
  line-height: 1.25;
  transition: background-color .12s ease, color .12s ease;
}
button.primary { background: var(--blue); color: #fff; font-weight: 600; }
button:active:not(:disabled) { opacity: .88; }
button:disabled { opacity: .55; cursor: default; }
button[aria-busy="true"] { cursor: progress; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
input, select, textarea {
  min-height: var(--control-height);
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  font-size: var(--font-input);
  line-height: 1.35;
}
/* Do not lower editable control text below 16px: iOS otherwise zooms on focus. */
input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: var(--font-input); }
input::placeholder, textarea::placeholder { color: #9097a3; opacity: 1; }
input:disabled, select:disabled, textarea:disabled { color: var(--muted); -webkit-text-fill-color: var(--muted); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 21px; font-weight: 700; line-height: 1.25; letter-spacing: -.5px; }
h2 { font-size: 18px; font-weight: 650; line-height: 1.35; }
small, .muted { color: var(--muted); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.excused { color: var(--excused); }
.error { color: var(--bad); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.error:empty { display: none; }
.owner-employee-management { margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.owner-employee-management h3 { font-size: 16px; font-weight: 650; }
.owner-employee-list { margin-top: var(--space-3); }
.owner-employee-row { display: flex; align-items: center; gap: var(--space-3); padding-block: var(--space-3); border-top: 1px solid var(--line); }
.owner-employee-row > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.owner-employee-row small { display: block; margin-top: 3px; font-size: 12px; }
.owner-employee-row button { flex-shrink: 0; min-height: 40px; font-size: 13px; }
#owner-employee-password-form { display: grid; gap: var(--space-3); }
#owner-employee-password-form label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
#owner-employee-password-form input { width: 100%; }
#owner-employee-password-form .owner-self-confirm { display: flex; align-items: flex-start; gap: var(--space-2); }
#owner-employee-password-form .owner-self-confirm input { width: 18px; min-height: 18px; margin: 2px 0 0; flex: 0 0 18px; }
.loading, .empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.loading { min-height: 110px; display: grid; place-items: center; }

/* Application frame and persistent navigation. */
.shell { max-width: 760px; margin: auto; min-height: 100svh; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.shell > header {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: #f5f6f9;
}
.top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; min-height: 42px; }
.top > div { min-width: 0; }
.top > .brand { flex:0 0 auto; padding-top:8px; }
.account-identity { display:flex; flex:0 1 auto; flex-direction:column; align-items:flex-end; min-width:0; max-width:calc(100% - 104px); margin-top:-3px; }
.account { min-width: 44px; min-height: 42px; max-width: 46%; padding: 7px 0 7px 8px; background: transparent; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity > .account { width:100%; max-width:100%; text-align:right; }
.site-registration--account { max-width:100%; padding:0; text-align:right; }
.site-registration--account a { white-space:nowrap; overflow-wrap:normal; }
.sync-time { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; line-height: 1.4; margin-top: 3px; }
.shell nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; overflow: visible; background: #e9ecf2; border-radius: 11px; padding: 3px; margin-top: 9px; }
.shell nav::-webkit-scrollbar { display: none; }
.shell nav button { flex: 1 0 auto; min-width: 46px; min-height: 36px; padding: 7px 6px; border-radius: 8px; background: transparent; font-size: 13px; color: #657080; white-space: nowrap; }
.shell nav button.active { color: #202630; font-weight: 600; background: var(--surface); box-shadow: 0 1px 2px #2026300b; }
.nav-group { position: relative; min-width: 0; flex: 1; }
.shell nav > .nav-group, .shell nav > button { min-width: 0; }
.shell nav .nav-group > button { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; min-width: 0; }
.nav-chevron { flex-shrink: 0; opacity: .65; }
.nav-menu { position: absolute; left: 0; top: calc(100% + 7px); z-index: 6; width: 146px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); box-shadow: 0 6px 20px #17233b14; }
.nav-group:last-of-type .nav-menu { left: auto; right: 0; }
.nav-menu[hidden] { display: none; }
.table-scroll:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.shell nav .nav-menu button { display: block; width: 100%; min-height: 44px; padding: 10px 12px; text-align: left; font-size: 14px; }
.shell nav .nav-menu button.active { color: var(--blue); background: var(--blue-soft); box-shadow: none; }
main { min-width: 0; padding: var(--space-3); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: var(--space-3); }
.toolbar input { flex: 1; width: 0; background: var(--surface); }
.refresh-warning { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); }
.refresh-warning p { flex: 1; min-width: 0; font-size: 12px; overflow-wrap: anywhere; }
.refresh-warning button { flex: none; min-height: 36px; padding: 5px 10px; font-size: 13px; }
.toolbar span { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.page-heading h2 { font-size: 17px; }
.page-heading button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.student-toolbar { display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; min-width: 0; margin-bottom: var(--space-3); }
.student-toolbar input { flex: 1 1 0; width: 0; min-width: 36px; min-height: 44px; padding: 7px 6px; font-size: 16px; }
.student-toolbar #count { flex: 0 0 44px; width: 44px; min-width: 44px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; white-space: nowrap; text-align: center; font-variant-numeric: tabular-nums; }
.student-tools { display: flex; flex: 0 0 auto; align-items: center; gap: 4px; min-width: 0; padding: 0; }
.student-tools button { flex: 0 0 38px; width: 38px; min-width: 38px; min-height: 44px; padding: 6px; font-size: 12px; white-space: nowrap; background: var(--surface); border-color: var(--line); }
.student-tools [data-action="student-create"] { flex-basis: 50px; width: 50px; min-width: 50px; }
.student-scope-label { padding: 5px 4px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.person-course-actions { display: flex; justify-content: flex-end; padding: 10px 0 0; }
.person-course-actions:empty { display: none; }
.person-course-actions button { min-height: 40px; font-size: 13px; padding: 7px 11px; }
.student-course-status { margin: 8px 0; font-size: 13px; color: var(--muted); }
.student-course-status.is-error { color: var(--bad); }
.student-course-check { min-height: 44px; }
.student-course-check[hidden] { display: none; }
@media (max-width: 360px) {
  .shell nav > button, .shell nav .nav-group > button { padding-inline: 3px; font-size: 12px; gap: 2px; }
  .shell nav .nav-chevron { width: 6px; }
}

/* The same date-based timetable content as Mac, adapted to touch scrolling. */
.planning-date-tools { display: flex; justify-content: flex-start; align-items: center; gap: 6px; margin-bottom: 10px; }
.planning-date-tools button { min-height: 38px; min-width: 38px; padding: 6px 10px; border: 1px solid var(--line); background: var(--surface); font-size: 18px; }
.planning-date-tools .planning-date { display: flex; align-items: center; gap: 12px; min-width: 160px; font-size: 15px; font-variant-numeric: tabular-nums; }
.timetable.planning-table { width: 1416px; min-width: 1416px; }
.planning-table .planning-label-column { width: 96px; }
.planning-table th { padding: 0; height: 38px; }
.planning-table th:first-child { padding: 10px 5px; }
.planning-table td { padding: 0; }
.planning-table td:first-child { padding: 8px; }
.planning-table th:first-child, .planning-table td:first-child { position: sticky; left: 0; z-index: 2; border-right: 1px solid var(--line); background: var(--surface); }
.planning-table th:first-child { z-index: 3; background: #f1f3f7; }
.planning-table td:first-child strong { display: block; font-size: 13px; color: #313b49; font-weight: 600; }
.planning-table td:first-child small { display: block; margin-top: 4px; font-size: 11px; font-weight: 400; }
.planning-ruler { position: relative; height: 38px; margin-right: 2px; }
.planning-ruler span { position: absolute; top: 12px; transform: translateX(-50%); font-size: 11px; font-weight: 400; color: var(--muted); line-height: 16px; font-variant-numeric: tabular-nums; }
.planning-ruler span:first-child { transform: none; }
.planning-ruler span:nth-child(2) { transform: translateX(-25%); }
.planning-ruler span:nth-last-child(2) { transform: translateX(-75%); }
.planning-ruler span:last-child { transform: translateX(-100%); }
.planning-track { position: relative; background-image: linear-gradient(to right, transparent calc(100% - 1px), var(--line) 0); background-size: calc(100% / 30) 100%; }
.planning-event-position { position: absolute; padding-inline: 2px; }
.timetable.planning-table .planning-event { height: 58px; min-height: 58px; padding: 8px; border-left-width: 3px; border-radius: var(--radius-control); }
.planning-table .planning-event strong { font-size: 12px; }
.planning-event .course-foot { margin-top: 3px; font-size: 10px; }
.course.individual-course { background: #fff2e3; border-color: #edc293; }
.planning-pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 8px; border-top: 1px dashed var(--line); }
.planning-pending .planning-event { width: 175px; margin: 0; }
.planning-disclosure { margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); overflow: hidden; }
.planning-empty { margin-bottom: var(--space-2); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--muted); font-size: 13px; text-align: center; }
.planning-disclosure summary { padding: 12px; font-size: 13px; font-weight: 550; cursor: pointer; }
.planning-disclosure summary span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.planning-disclosure .individual-list { border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.planning-warnings { padding: 0 12px 12px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.planning-warnings p + p { margin-top: 6px; }
.planning-cancelled > div { padding: 10px 12px; border-top: 1px solid var(--line); }
.planning-cancelled strong { display: block; font-size: 13px; font-weight: 550; }
.planning-cancelled span { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.directory-list, .individual-list { border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden; background: var(--surface); }
.directory-row, .individual-row { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 62px; width: 100%; padding: var(--space-list-y) var(--space-list-x); text-align: left; border: 0; border-radius: 0; background: var(--surface); }
.directory-row + .directory-row, .individual-row + .individual-row { border-top: 1px solid var(--line); }
.directory-row > div, .individual-row > div:first-child { flex: 1; min-width: 0; }
.directory-row strong, .individual-row strong { display: block; font-size: 15px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.directory-row small, .individual-row small { display: block; margin-top: var(--space-meta); font-size: 11px; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.directory-avatar { display: grid; place-items: center; width: 32px; height: 32px; flex: 0 0 32px; border-radius: 9px; font-size: 12px; color: #61718a; background: #f0f3f8; }
.directory-status { font-size: 11px; color: var(--good); white-space: nowrap; }
.directory-status.is-disabled, .individual-row.is-cancelled { color: var(--muted); }
.individual-meta { flex: 0 0 auto; max-width: 42%; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.planning-detail { margin: 0 0 16px; }
.planning-detail > div { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.planning-detail dt { color: var(--muted); flex: 0 0 38px; }
.planning-detail dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.detail-section-title { font-size: 13px; margin-bottom: 8px; }

/* A single compact calendar with marked class dates and fixed grid geometry. */
.calendar-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.calendar-heading button { width: 38px; min-height: 38px; padding: 0; font-size: 22px; }
.calendar-heading strong { font-size: 16px; font-weight: 600; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 3px; }
.calendar-weekdays { margin-bottom: 4px; color: var(--muted); text-align: center; font-size: 12px; line-height: 28px; }
.calendar-day { position: relative; min-width: 0; min-height: 42px; padding: 7px 0; border-radius: 8px; font-size: 15px; background: transparent; }
.calendar-day.outside { color: #aab2bf; }
.calendar-day.today { border-color: #aecaff; }
.calendar-day.selected { color: #fff; background: var(--blue); }
.calendar-day i { position: absolute; left: calc(50% - 2px); bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }
.calendar-day.selected i { background: #fff; }
.calendar-help { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.calendar-help i { width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }

/* Self-service deliberately has no editable identity or permission fields. */
.employee-panel { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.employee-summary { display: flex; align-items: center; gap: var(--space-3); padding: 4px 0 var(--space-3); }
.employee-avatar { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #536b91; background: var(--blue-soft); font-size: 16px; font-weight: 600; }
.employee-summary strong { font-size: 19px; font-weight: 650; line-height: 1.35; }
.employee-summary small { display: block; margin-top: var(--space-meta); font-size: 12px; }
.employee-readonly { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: var(--space-2); margin: 0 0 var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.employee-readonly dt { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.employee-readonly dd { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
#employee-form { display: grid; gap: var(--space-3); }
#employee-form label { display: grid; gap: 6px; min-width: 0; color: #596678; font-size: 12px; }
#employee-form input { width: 100%; color: #202630; }
.employee-help { font-size: 12px; color: var(--muted); line-height: 1.65; }
.text-button { color: var(--muted); background: transparent; }

/* Student lists use separators, not another card for each row. */
.students { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden; }
.student-row { display: flex; align-items: center; text-align: left; width: 100%; min-height: 62px; padding: var(--space-list-y) var(--space-list-x); gap: 10px; border: 0; border-radius: 0; background: var(--surface); }
.student-row + .student-row { border-top: 1px solid #f0f2f6; }
.student-sequence { flex: 0 0 26px; text-align: center; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.avatar { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 29px; border: 1px solid #e9ecf3; border-radius: 9px; background: #f2f4f8; color: #626c7b; font-size: 11px; font-weight: 550; }
.student-text { min-width: 0; flex: 1; }
.student-text strong { font-size: 15px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.student-text small { display: block; margin-top: var(--space-meta); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.count { flex: 0 0 auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.divider { padding: 8px 12px; border-top: 1px solid var(--line); color: var(--muted); background: var(--surface-subtle); font-size: 11px; font-weight: 500; }
.student-history-label { display: inline-block; margin-left: 6px; color: var(--muted); font-size: 10px; font-weight: 400; }

/* Compact information cards keep contact details at the right. */
.person { padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); margin-bottom: var(--space-3); }
.person-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.name { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.name strong { min-width: 0; font-size: 18px; font-weight: 650; line-height: 1.4; overflow-wrap: anywhere; }
.tag { max-width: 100%; padding: 2px 6px; border-radius: 5px; color: #4a6b9c; background: #edf3ff; font-size: 10px; line-height: 1.6; overflow-wrap: anywhere; }
.contact { display: flex; flex-direction: column; gap: 2px; flex: 0 1 auto; max-width: 44%; text-align: right; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); margin-top: var(--space-3); }
.slot { min-width: 0; min-height: 56px; padding: var(--space-2); border: 1px solid #edf0f5; border-radius: var(--radius-inner); background: var(--surface-subtle); }
.time { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; margin-bottom: var(--space-meta); }
.course { width: 100%; min-width: 0; min-height: 56px; padding: var(--space-2); border: 1px solid #d8edfd; border-radius: var(--radius-control); background: #edf7ff; text-align: left; }
.course + .course { margin-top: 6px; }
/* Retain established subject and grade colors across all views. */
.course.physics { background: #edfbf8; border-color: #d1f4ec; }
.course.chemistry { background: #fffae9; border-color: #f8ebbd; }
.course.english { background: #f5f1ff; border-color: #e5dcfa; }
.course.grade2 { background: #e5f3ff; }
.course.grade2.physics { background: #e3f7f2; }
.course.grade2.chemistry { background: #fff6d9; }
.course.grade2.english { background: #eee8fc; }
.course.grade3 { background: #fff0f3; border-color: #f5dbe3; }
.course strong { display: block; font-size: 13px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.course-foot { display: flex; justify-content: space-between; gap: 6px; margin-top: var(--space-meta); color: #6f7d8d; font-size: 10px; line-height: 1.4; }
.course-foot span { min-width: 0; overflow-wrap: anywhere; }
.course-foot span:last-child { text-align: right; }
.person-footer { display: flex; justify-content: flex-end; margin-top: 8px; }
.person-footer button { min-height: 36px; padding: 6px 10px; font-size: 12px; }

/* The table owns horizontal scrolling. The page owns vertical scrolling. */
.table-view-heading { display: flex; align-items: center; gap: 7px; margin-right: auto; min-width: 0; }
.table-view-heading h2 { font-size: 16px; font-weight: 600; }
.table-view-heading button { font-size: 12px; white-space: nowrap; }
.planning-toolbar-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; margin-bottom: 8px; }
.planning-toolbar-top .table-view-heading { flex: 0 0 auto; margin-right: 0; }
.planning-toolbar-top .table-view-heading h2 { white-space: nowrap; }
.planning-toolbar-top .table-view-heading button { min-height: 38px; padding: 6px 8px; border-color: var(--line); background: var(--surface); }
.planning-toolbar-top .planning-date-tools { min-width: 0; gap: 4px; margin-bottom: 0; }
.planning-toolbar-top .planning-date-tools button { min-width: 30px; padding-inline: 7px; }
.planning-toolbar-top .planning-date-tools .planning-date { min-width: 112px; gap: 6px; font-size: 14px; white-space: nowrap; }
/* Only the formal phone timetable is a stationary workspace. All other
   employee pages and the independent modal keep their existing scrolling. */
html:has(#app[data-fixed-timetable="true"]),
body:has(#app[data-fixed-timetable="true"]) { height: 100%; overflow: hidden; overscroll-behavior-y: none; }
#app[data-fixed-timetable="true"] { position: fixed; inset: 0; height: 100vh; height: 100dvh; overflow: hidden; touch-action: pan-x pan-y; }
#app[data-fixed-timetable="true"] .shell { display: flex; flex-direction: column; height: 100%; min-height: 0; }
#app[data-fixed-timetable="true"] .shell > header { flex: 0 0 auto; }
#app[data-fixed-timetable="true"] #main { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; padding: 8px var(--space-3) max(8px, env(safe-area-inset-bottom)); }
#app[data-fixed-timetable="true"] .planning-toolbar-top { flex: 0 0 auto; flex-wrap: nowrap; }
#app[data-fixed-timetable="true"] .planning-toolbar-top .planning-date-tools .planning-date { min-width: 106px; gap: 4px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) { justify-content: flex-start; gap: 4px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) .table-view-heading { gap: 4px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) .table-view-heading h2 { font-size: 14px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) .table-view-heading button { min-height: 32px; height: 32px; padding: 4px 6px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) .planning-date-tools { flex: 1 1 auto; justify-content: flex-end; gap: 3px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) .planning-date-tools button { min-height: 32px; height: 32px; min-width: 20px; padding: 4px; font-size: 17px; }
#app[data-fixed-timetable="true"] .planning-toolbar-top:not(.academic-timeline-toolbar) .planning-date-tools .planning-date { min-width: 62px; justify-content: center; gap: 4px; font-size: 12px; }
.planning-toolbar-top:not(.academic-timeline-toolbar) .planning-date-tools .planning-shortcut { min-width: 36px; padding: 4px 5px; font-size: 12px; white-space: nowrap; }
.planning-shortcut[aria-pressed="true"] { color: var(--blue); background: var(--blue-soft); border-color: #bfd9ff; }
.planning-tools-menu { position: relative; z-index: 4; flex: 0 0 28px; }
.planning-tools-menu > summary { display: grid; place-items: center; height: 32px; min-height: 32px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: #536073; cursor: pointer; list-style: none; }
.planning-tools-menu > summary::-webkit-details-marker { display: none; }
.planning-tools-menu > summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.planning-tools-panel { position: absolute; top: calc(100% + 6px); right: 0; width: 176px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); box-shadow: 0 6px 20px #17233b14; }
.planning-tools-menu:not([open]) .planning-tools-panel { display: none; }
.planning-tools-panel > button { display: block; width: 100%; min-height: 38px; padding: 8px 10px; border: 0; background: transparent; text-align: left; font-size: 14px; }
.planning-width-control { display: grid; gap: 3px; padding: 7px 10px 3px; color: #536073; font-size: 13px; }
.planning-width-control input { width: 100%; height: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; accent-color: var(--blue); }
#app[data-fixed-timetable="true"] .planning-scroll { flex: 1 1 0%; min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
#app[data-fixed-timetable="true"] .planning-empty { flex: 0 0 auto; }
#app[data-fixed-timetable="true"] .planning-disclosure { flex: 0 0 auto; max-height: 24dvh; overflow: auto; overscroll-behavior: contain; margin-top: 8px; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar { gap: 4px; flex-wrap: nowrap; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar .table-view-heading { gap: 5px; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar h2 { font-size: 14px; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar button { min-height: 30px; height: 30px; padding: 3px 6px; font-size: 12px; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar .planning-date-tools { margin-left: auto; gap: 3px; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar .planning-date-tools > button:not(.planning-date) { min-width: 22px; width: 22px; }
#app[data-fixed-academic="true"] .academic-timeline-toolbar .planning-date-tools .planning-date { min-width: 66px; gap: 4px; font-size: 12px; }
#app[data-fixed-academic="true"] .academic-width-control { display: flex; flex: 0 0 36px; align-items: center; height: 30px; min-width: 0; margin-left: auto; }
#app[data-fixed-academic="true"] .academic-width-control input { width: 100%; min-height: 30px; height: 30px; padding: 0; border: 0; border-radius: 0; background: transparent; accent-color: var(--blue); }
#app[data-fixed-timetable="true"] .planning-table thead { position: sticky; top: 0; z-index: 3; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overscroll-behavior-x: contain; touch-action: pan-x pan-y; }
.table-zoom-stage { position: relative; width: 100%; }
.table-zoom-stage.is-ready .timetable { position: absolute; top: 0; left: 0; transform-origin: top left; }
.timetable { width: 100%; min-width: 790px; border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 12px; }
.timetable .row-label-column { width: 70px; }
.timetable .time-column { width: 180px; }
.timetable th { padding: 10px 6px; background: #f1f3f7; text-align: center; font-weight: 600; white-space: nowrap; }
.timetable td { min-width: 0; padding: 6px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); vertical-align: top; }
.timetable td:first-child { text-align: center; vertical-align: middle; color: #667384; font-weight: 500; overflow-wrap: anywhere; }
.timetable td:last-child { border-right: 0; }
.timetable .course { display: flex; flex-direction: column; justify-content: space-between; height: 66px; min-height: 66px; margin: 0; padding: 9px; }
.timetable .course + .course { margin-top: 6px; }
.timetable .course strong { line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timetable .course-foot { line-height: 14px; white-space: nowrap; }
.timetable-empty { display: grid; place-items: center; height: 66px; color: #9aa2ae; }

/* Receipts remain readable full images, never cropped into decorative tiles. */
.images { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 520px)); gap: var(--space-3); justify-content: center; }
.receipt { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden; }
.receipt img { display: block; width: 100%; height: auto; object-fit: contain; background: #fff; }
.receipt a { display: block; }
.receipt-image-slot { position: relative; min-height: 120px; background: var(--surface-subtle); }
.receipt-image-slot img:not([src]) { display: none; }
.receipt-image-slot[data-receipt-state="ready"] { min-height: 0; }
.receipt-image-feedback { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: var(--muted); font-size: 12px; text-align: center; }
.receipt-image-feedback[hidden] { display: none; }
.receipt-freshness { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; color: var(--muted); font-size: 11px; }
.receipt-freshness button { flex: 0 0 auto; min-height: 28px; padding: 2px 6px; color: var(--blue); font-size: 12px; }
.receipt-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: var(--space-3); border-bottom: 1px solid #edf0f5; font-size: 12px; }
.receipt-meta > div { min-width: 0; overflow-wrap: anywhere; }
.receipt-meta strong { flex-shrink: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.receipt-meta small { display: block; margin-top: 3px; font-size: 11px; }
/* Receipts use the full stationary workspace for search and the roster.
   Selected information lives in the independent modal outside #app. */
html:has(#app[data-fixed-receipts="true"]),
body:has(#app[data-fixed-receipts="true"]) { height: 100%; overflow: hidden; overscroll-behavior-y: none; }
#app[data-fixed-receipts="true"] { position: fixed; inset: 0; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
#app[data-fixed-receipts="true"] .shell { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 0; }
#app[data-fixed-receipts="true"] .shell > header { flex: 0 0 auto; }
#app[data-fixed-receipts="true"] #main { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; padding: 4px var(--space-3) 0; }
#app[data-fixed-receipts="true"] .phone-receipt-roster { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius-panel) var(--radius-panel) 0 0; background: var(--surface); }
#app[data-fixed-receipts="true"] .phone-receipt-roster > .toolbar { flex: 0 0 auto; gap: 8px; margin: 0; padding: 8px; border-bottom: 1px solid var(--line); }
#app[data-fixed-receipts="true"] .phone-receipt-roster #count { flex: 0 0 auto; font-size: 11px; color: var(--muted); white-space: nowrap; }
#app[data-fixed-receipts="true"] [data-phone-receipt-roster] { flex: 1 1 0%; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; padding-bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 32px)); scroll-padding-bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 32px)); }
#app[data-fixed-receipts="true"] [data-phone-receipt-roster] > .students { border: 0; border-radius: 0; }
/* Student search uses the same full-height roster treatment as receipts.
   The unchanged course card dimensions now live in an independent dialog. */
html:has(#app[data-fixed-students="true"]),
body:has(#app[data-fixed-students="true"]) { height: 100%; overflow: hidden; overscroll-behavior-y: none; }
#app[data-fixed-students="true"] { position: fixed; inset: 0; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; }
#app[data-fixed-students="true"] .shell { display: flex; flex-direction: column; height: 100%; min-height: 0; padding-bottom: 0; }
#app[data-fixed-students="true"] .shell > header { flex: 0 0 auto; }
#app[data-fixed-students="true"] #main { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; padding: 4px var(--space-3) 0; }
#app[data-fixed-students="true"] .phone-student-roster { display: flex; flex-direction: column; flex: 1 1 0%; min-height: 0; overflow: hidden; border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius-panel) var(--radius-panel) 0 0; background: var(--surface); }
#app[data-fixed-students="true"] .phone-student-roster > .student-toolbar { flex: 0 0 auto; margin: 0; padding: 8px; border-bottom: 1px solid var(--line); }
#app[data-fixed-students="true"] [data-phone-student-roster] { flex: 1 1 0%; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; padding-bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 32px)); scroll-padding-bottom: max(64px, calc(env(safe-area-inset-bottom, 0px) + 32px)); }
#app[data-fixed-students="true"] [data-phone-student-roster] > .students { border: 0; border-radius: 0; }
.performance-filters { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); }
.performance-filters input, .performance-filters select { flex: 1; width: 0; min-width: 0; }
.total { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); margin-bottom: var(--space-3); }
.total strong { display: block; margin-top: 6px; font-size: 29px; font-weight: 650; line-height: 1.25; letter-spacing: -.8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.total p { font-size: 12px; color: var(--muted); }
.total p.error { color: var(--bad); margin-top: 8px; }

/* One modal treatment: fixed close target, bounded content, no opening scale. */
dialog { width: calc(100% - 24px); max-width: 700px; max-height: min(88svh, 760px); padding: var(--space-4); border: 1px solid #e1e5ec; border-radius: 16px; background: #f7f8fb; color: inherit; box-shadow: 0 12px 40px #15233824; overscroll-behavior: contain; }
dialog::backdrop { background: #17233b70; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: var(--space-3); }
.dialog-head h2 { min-width: 0; font-size: 18px; overflow-wrap: anywhere; }
.dialog-head h2:focus { outline: none; }
.dialog-head .dialog-close { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: var(--radius-control); background: transparent; box-shadow: none; color: var(--muted); }
.dialog-close svg { pointer-events: none; }
.dialog-head .dialog-close:focus-visible { outline-offset: -3px; }
.dialog-head .dialog-close:active:not(:disabled) { background: #e8ebf1; color: #202630; }
#detail-content > .person:last-child { margin-bottom: 0; }
.back { margin-top: var(--space-3); margin-bottom: 0; min-height: 40px; font-size: 13px; }
body:has(dialog[open]) { overflow: hidden; }

/* Receipt modal: compact identity at the top, originals scroll below it.
   Attribute scope keeps every other phone dialog unchanged. */
dialog[data-receipt-modal="true"][open] { display: flex; flex-direction: column; padding: 0; background: var(--surface); overflow: hidden; }
dialog[data-receipt-modal="true"] #detail-content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: inherit; }
dialog[data-receipt-modal="true"] .phone-receipt-detail { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; min-height: 0; max-height: inherit; overflow: hidden; }
dialog[data-receipt-modal="true"] .dialog-head { position: relative; flex: 0 0 auto; min-width: 0; margin: 0; padding: 12px 52px 10px 12px; border-bottom: 1px solid var(--line); }
dialog[data-receipt-modal="true"] .phone-receipt-header { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 4px 8px; max-height: min(28svh, 176px); overflow-y: auto; overscroll-behavior-y: contain; }
dialog[data-receipt-modal="true"] .phone-receipt-header .name { min-width: 0; gap: 5px; }
dialog[data-receipt-modal="true"] .phone-receipt-header h2 { font-size: 18px; line-height: 1.35; }
dialog[data-receipt-modal="true"] .phone-receipt-header .avatar { width: 26px; height: 26px; flex-basis: 26px; border-radius: 8px; }
dialog[data-receipt-modal="true"] .phone-receipt-count { align-self: center; color: var(--muted); font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; white-space: nowrap; }
dialog[data-receipt-modal="true"] .phone-receipt-contact { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 12px; min-width: 0; color: var(--muted); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
dialog[data-receipt-modal="true"] .phone-receipt-contact > span { min-width: 0; }
dialog[data-receipt-modal="true"] .dialog-close { position: absolute; top: 4px; right: 4px; }
dialog[data-receipt-modal="true"] .phone-receipt-records-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; padding: 12px; scroll-padding-block: 12px; }
dialog[data-receipt-modal="true"] .phone-receipt-records-scroll .images { grid-template-columns: minmax(0,1fr); gap: 12px; }
dialog[data-receipt-modal="true"] .phone-receipt-records-scroll .receipt { border-radius: var(--radius-inner); }
dialog[data-receipt-modal="true"] .phone-receipt-records-scroll .empty { padding: 20px 12px; }
dialog[data-receipt-modal="true"] .phone-receipt-records-scroll > .error { margin-bottom: 12px; }
dialog[data-receipt-modal="true"] .phone-receipt-records-scroll > .loading { min-height: 120px; }
dialog[data-student-modal="true"][open] { display: flex; flex-direction: column; padding: 0; background: var(--surface); overflow: hidden; }
dialog[data-student-modal="true"] #detail-content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; max-height: inherit; }
dialog[data-student-modal="true"] .phone-student-detail { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; max-height: inherit; padding: 0; margin: 0; border: 0; border-radius: 0; overflow: hidden; }
dialog[data-student-modal="true"] .dialog-head { position: relative; flex: 0 0 auto; margin: 0; padding: 12px 52px 8px 12px; }
dialog[data-student-modal="true"] .phone-student-header { display: grid; grid-template-columns: minmax(0,1fr); gap: 4px; max-height: min(28svh, 176px); overflow-y: auto; overscroll-behavior-y: contain; }
dialog[data-student-modal="true"] .phone-student-header .name { gap: 6px; }
dialog[data-student-modal="true"] .phone-student-header h2 { font-size: 18px; line-height: 1.4; }
dialog[data-student-modal="true"] .phone-student-header .contact { flex-direction: row; flex-wrap: wrap; gap: 2px 12px; max-width: none; text-align: left; }
dialog[data-student-modal="true"] .dialog-close { position: absolute; top: 4px; right: 4px; }
dialog[data-student-modal="true"] .phone-student-records-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch; padding: 0 12px 12px; scroll-padding-block: 12px; }
dialog[data-student-modal="true"] .phone-student-records-scroll > .error { margin-block: 8px 12px; }

/* Quiet, accessible sign-in form. No imagery or decorative dependency. */
.login { width: calc(100% - 40px); max-width: 360px; margin: 12svh auto 24px; padding: 24px 0; }
.login h1 { font-size: 28px; margin-bottom: 28px; }
.login form { display: grid; gap: 12px; }
.login input, .login button { min-height: 46px; }
.login button { margin-top: 4px; }

@media (hover: hover) {
  button:not(:disabled):not(.course):hover { background-color: #e5eaf3; }
  button.primary:not(:disabled):hover { background-color: #066fea; }
  .shell nav button:not(:disabled):hover { background-color: #f4f6fa; }
  .shell nav button.active:hover { background-color: var(--surface); }
  .student-row:not(:disabled):hover { background: var(--surface-subtle); }
  .dialog-head .dialog-close:not(:disabled):hover { background: #e8ebf1; color: #202630; }
  .account:hover { background: transparent; }
}
.student-row:active { background: var(--blue-soft); }
@media (max-width: 370px) {
  .shell > header { padding-inline: 10px; }
  main { padding: 8px; }
  .shell nav button { font-size: 12px; padding-inline: 5px; }
  .person { padding: 10px; }
  .slot { padding: 7px; }
  .name strong { font-size: 17px; }
  .contact { font-size: 10px; }
  .course { padding: 7px; }
  dialog { width: calc(100% - 16px); padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
