:root {
  --ink: #17212b;
  --ink-soft: #344454;
  --muted: #687786;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --surface-tint: #eef5f6;
  --page: #edf1f3;
  --border: #dbe2e7;
  --border-strong: #c6d1d8;
  --brand: #143d59;
  --brand-strong: #0d3048;
  --brand-soft: #e7f0f5;
  --accent: #167d7f;
  --accent-strong: #0f6567;
  --accent-soft: #e1f2f1;
  --success: #287852;
  --success-soft: #e3f3e9;
  --warning: #9c5a0b;
  --warning-soft: #fff1d8;
  --danger: #a63d40;
  --danger-soft: #fbe7e7;
  --purple: #69538c;
  --purple-soft: #eee9f6;
  --shadow-sm: 0 1px 2px rgb(20 61 89 / 5%), 0 3px 10px rgb(20 61 89 / 4%);
  --shadow-md: 0 12px 35px rgb(20 61 89 / 10%);
  --radius-sm: 7px;
  --radius: 12px;
  --radius-lg: 18px;
  --shell: 1280px;
  --font: Inter, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, summary { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { color: var(--brand); }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--ink); line-height: 1.22; }
h1 { margin-bottom: .45rem; font-size: clamp(1.75rem, 3vw, 2.35rem); letter-spacing: -.03em; }
h2 { margin-bottom: .4rem; font-size: 1.18rem; letter-spacing: -.012em; }
h3 { margin-bottom: .35rem; font-size: 1rem; }
small { font-size: .82rem; }

:focus-visible {
  outline: 3px solid rgb(22 125 127 / 35%);
  outline-offset: 2px;
}

.shell { width: min(calc(100% - 40px), var(--shell)); margin-inline: auto; }
.page-main { min-height: calc(100vh - 136px); padding-block: 34px 54px; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link {
  position: fixed;
  z-index: 9999;
  top: 10px;
  left: 10px;
  transform: translateY(-150%);
  padding: 9px 14px;
  color: white;
  background: var(--brand);
  border-radius: var(--radius-sm);
}
.skip-link:focus { transform: none; }
.muted { color: var(--muted); }
.preserve-lines { white-space: pre-line; }
.line-clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.eyebrow {
  margin-bottom: 5px;
  color: var(--accent-strong);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.eyebrow-warning { color: var(--warning); }

/* Header and navigation */
.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  height: 72px;
  color: white;
  background: var(--brand);
  box-shadow: 0 1px 0 rgb(255 255 255 / 10%), 0 5px 20px rgb(8 31 46 / 14%);
}
.header-inner { display: flex; height: 100%; align-items: center; gap: 28px; }
.brand { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 10px; color: white; }
.brand:hover { color: white; }
.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--brand);
  background: #f0b968;
  border-radius: 11px;
  font-size: .82rem;
  font-weight: 850;
  letter-spacing: -.03em;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 35%);
}
.brand-copy { display: grid; line-height: 1.1; }
.brand-copy strong { font-size: .96rem; letter-spacing: -.01em; }
.brand-copy small { margin-top: 4px; color: rgb(255 255 255 / 64%); font-size: .68rem; letter-spacing: .12em; }
.primary-nav { display: flex; height: 100%; align-items: center; gap: 3px; }
.primary-nav a {
  position: relative;
  display: grid;
  height: 100%;
  padding: 0 13px;
  place-items: center;
  color: rgb(255 255 255 / 76%);
  font-size: .9rem;
  font-weight: 580;
  white-space: nowrap;
}
.primary-nav a:hover { color: white; background: rgb(255 255 255 / 5%); }
.primary-nav a[aria-current="page"] { color: white; }
.nav-count {
  display: inline-grid;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding-inline: 5px;
  place-items: center;
  color: #5b3300;
  background: #f0b968;
  border-radius: 999px;
  font-size: .65rem;
  font-weight: 820;
  line-height: 1;
}
.primary-nav a[aria-current="page"]::after {
  position: absolute;
  right: 13px;
  bottom: 0;
  left: 13px;
  height: 3px;
  content: "";
  background: #f0b968;
  border-radius: 3px 3px 0 0;
}
.header-actions { display: flex; margin-left: auto; align-items: center; gap: 8px; white-space: nowrap; }
.header-actions .button-primary { color: var(--brand); background: #f0b968; border-color: #f0b968; }
.header-actions .button-primary:hover { background: #f6c77f; }
.header-actions .header-add-student { color: white; background: rgb(255 255 255 / 8%); border-color: rgb(255 255 255 / 28%); }
.header-actions .header-add-student:hover { color: white; background: rgb(255 255 255 / 15%); border-color: rgb(255 255 255 / 42%); }
.nav-toggle { display: none; }
.action-menu { position: relative; }
.action-menu > summary { list-style: none; cursor: pointer; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu-trigger { min-width: 78px; color: white; background: transparent; border-color: rgb(255 255 255 / 28%); }
.action-menu-trigger:hover { color: white; background: rgb(255 255 255 / 10%); border-color: rgb(255 255 255 / 42%); }
.action-menu-panel {
  position: absolute;
  z-index: 110;
  top: calc(100% + 10px);
  right: 0;
  display: grid;
  width: 230px;
  overflow: hidden;
  padding: 8px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.action-menu:not([open]) > .action-menu-panel { display: none; }
.action-menu-panel a,
.action-menu-panel .menu-button,
.action-menu-panel .menu-user { display: block; width: 100%; padding: 9px 10px; border-radius: 7px; text-align: left; }
.action-menu-panel a { color: var(--ink-soft); }
.action-menu-panel a:hover { color: var(--brand); background: var(--surface-soft); }
.action-menu-panel hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--border); }
.menu-user { overflow: hidden; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.menu-button { color: var(--danger); background: none; border: 0; cursor: pointer; }
.menu-button:hover { background: var(--danger-soft); }

/* Buttons and common controls */
.button {
  display: inline-flex;
  min-height: 42px;
  padding: 9px 16px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-soft);
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-weight: 680;
  line-height: 1.2;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.button:hover { color: var(--brand); background: var(--surface-soft); border-color: #aebdc6; }
.button:active { transform: translateY(1px); }
.button[disabled], .button.is-loading { opacity: .65; cursor: wait; }
.button-primary { color: white; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { color: white; background: var(--accent-strong); border-color: var(--accent-strong); }
.button-secondary { color: var(--brand); background: var(--brand-soft); border-color: #c9dce7; }
.button-secondary:hover { color: var(--brand-strong); background: #daeaf2; border-color: #b8cfdd; }
.button-warning { color: #6d3c00; background: #ffd995; border-color: #edbd67; }
.button-warning:hover { color: #5d3300; background: #ffcf78; }
.button-danger { color: white; background: var(--danger); border-color: var(--danger); }
.button-ghost { background: transparent; }
.button-small { min-height: 34px; padding: 7px 11px; border-radius: 8px; font-size: .84rem; }
.button-block { width: 100%; }
.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: inherit;
  background: rgb(255 255 255 / 8%);
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
}
.icon-button:hover { color: inherit; background: rgb(255 255 255 / 15%); }
.text-link { font-size: .88rem; font-weight: 680; }
.link-button { padding: 0; color: var(--accent-strong); background: none; border: 0; cursor: pointer; }
.danger-link { color: var(--danger); }
.inline-actions { display: flex; align-items: center; gap: 12px; font-size: .82rem; }
.inline-actions form { display: inline; }

/* Page structure and cards */
.page-header {
  display: flex;
  margin-bottom: 26px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}
.page-header h1 { margin-bottom: 3px; }
.page-subtitle { max-width: 760px; margin-bottom: 0; color: var(--muted); }
.page-actions { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.breadcrumbs { display: flex; margin: -7px 0 20px; align-items: center; flex-wrap: wrap; gap: 7px; color: var(--muted); font-size: .82rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--accent-strong); }
.card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 20px; }
.card-header { display: flex; margin-bottom: 18px; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-header h2, .card-header p { margin-bottom: 0; }
.card-header .muted { margin-top: 4px; font-size: .86rem; }
.card-actions { display: flex; margin-top: 18px; gap: 9px; }
.count-chip {
  display: inline-grid;
  min-width: 29px;
  height: 29px;
  padding-inline: 7px;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 750;
}
.count-chip-warning { color: #704000; background: var(--warning-soft); }
.count-chip-danger { color: var(--danger); background: var(--danger-soft); }

/* Alerts and flash messages */
.message-stack { position: fixed; z-index: 150; top: 84px; right: 0; left: 0; pointer-events: none; }
.message {
  display: flex;
  width: min(100%, 620px);
  margin: 0 0 8px auto;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: #14543a;
  background: #e8f7ed;
  border: 1px solid #b9dfc7;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}
.message-error { color: #7d2b2e; background: var(--danger-soft); border-color: #efbebe; }
.message-warning { color: #704000; background: var(--warning-soft); border-color: #f1d092; }
.message-close { color: currentColor; background: none; border: 0; font-size: 1.3rem; line-height: 1; cursor: pointer; }
.message.is-hiding { opacity: 0; transform: translateY(-8px); transition: .2s ease; }
.alert {
  display: flex;
  margin-bottom: 20px;
  padding: 13px 15px;
  align-items: flex-start;
  gap: 8px;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid #c8dde9;
  border-radius: 10px;
}
.alert > div { display: grid; gap: 2px; }
.alert-danger { color: #7d2b2e; background: var(--danger-soft); border-color: #efbebe; }
.alert-warning { color: #704000; background: var(--warning-soft); border-color: #f1d092; }
.error-summary ul { margin: 7px 0 0; padding-left: 20px; }
.error-summary a { color: inherit; text-decoration: underline; }
.stale-banner { justify-content: space-between; align-items: center; }
.stale-banner .button { flex: 0 0 auto; }

/* Badges */
.badge {
  display: inline-flex;
  min-height: 24px;
  padding: 3px 9px;
  align-items: center;
  color: var(--ink-soft);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 720;
  line-height: 1.2;
  white-space: nowrap;
}
.status-scheduled { color: #175e80; background: #e3f2f9; border-color: #c0dfea; }
.status-completed { color: #236b48; background: var(--success-soft); border-color: #b9ddc7; }
.status-student_leave, .status-teacher_leave { color: #78520a; background: var(--warning-soft); border-color: #edd39e; }
.status-cancelled { color: #5d6873; background: #edf0f2; border-color: #d5dce1; }
.status-rescheduled { color: #5f4b80; background: var(--purple-soft); border-color: #d6cce7; }
.status-no_show { color: #933a3d; background: var(--danger-soft); border-color: #ebc1c2; }
.student-status-active { color: #236b48; background: var(--success-soft); border-color: #b9ddc7; }
.student-status-prospect, .student-status-trial { color: #175e80; background: #e3f2f9; border-color: #c0dfea; }
.student-status-paused { color: #78520a; background: var(--warning-soft); border-color: #edd39e; }
.student-status-completed, .student-status-inactive { color: #5d6873; background: #edf0f2; border-color: #d5dce1; }
.billing-due, .billing-partial { color: #8b4c05; background: var(--warning-soft); border-color: #edd39e; }
.billing-paid, .billing-free { color: #236b48; background: var(--success-soft); border-color: #b9ddc7; }
.billing-unset, .billing-other { color: #5d6873; background: #edf0f2; border-color: #d5dce1; }
.payment-received { color: #236b48; background: var(--success-soft); border-color: #b9ddc7; }
.payment-pending { color: #78520a; background: var(--warning-soft); border-color: #edd39e; }
.payment-refunded { color: #5f4b80; background: var(--purple-soft); border-color: #d6cce7; }
.badge-warning { color: #78520a; background: var(--warning-soft); border-color: #edd39e; }

/* Dashboard */
.metric-grid { display: grid; margin-bottom: 20px; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card {
  position: relative;
  min-width: 0;
  padding: 18px 19px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.metric-card-accent { color: white; background: var(--brand); border-color: var(--brand); }
.metric-card-accent .metric-label, .metric-card-accent .metric-meta { color: rgb(255 255 255 / 73%); }
.metric-card-accent .metric-value { color: white; }
.metric-label { color: var(--muted); font-size: .79rem; font-weight: 650; }
.metric-value { display: block; margin: 4px 0 1px; color: var(--brand); font-size: 2rem; font-weight: 780; line-height: 1.1; letter-spacing: -.04em; }
.metric-meta { color: var(--muted); font-size: .78rem; }
.metric-link { display: inline-block; margin-top: 5px; font-size: .78rem; font-weight: 680; }
.attention-panel { margin-bottom: 20px; overflow: hidden; background: #fff9ed; border: 1px solid #eed49f; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.attention-heading { display: flex; padding: 18px 20px; align-items: center; gap: 14px; }
.attention-heading > div:nth-child(2) { flex: 1; }
.attention-heading h2 { margin-bottom: 2px; }
.attention-heading p { margin-bottom: 0; color: #765927; }
.attention-icon { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; color: #754200; background: #ffd893; border-radius: 50%; font-size: 1.15rem; font-weight: 850; }
.attention-list { border-top: 1px solid #eed9ae; }
.attention-item { display: grid; padding: 12px 20px; align-items: center; grid-template-columns: 125px 1fr auto; gap: 14px; border-bottom: 1px solid #f0dfbb; }
.attention-item:last-child { border-bottom: 0; }
.attention-item time { display: grid; }
.attention-item time span { color: var(--muted); font-size: .78rem; }
.attention-item > div:nth-child(2) { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.item-title { color: var(--ink); font-weight: 690; }
.item-actions { display: flex; gap: 7px; }
.dashboard-grid { display: grid; margin-bottom: 20px; gap: 20px; }
.dashboard-grid .card + .card { margin-top: 0; }
.dashboard-grid-primary { grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
.dashboard-grid-secondary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.next-lesson-card { background: linear-gradient(145deg, white 55%, #edf7f6); }
.next-lesson-body { display: flex; align-items: center; gap: 18px; }
.date-block { display: grid; width: 74px; min-height: 92px; flex: 0 0 auto; padding: 9px; place-items: center; color: var(--brand); background: var(--brand-soft); border: 1px solid #cbdee8; border-radius: 13px; line-height: 1.1; }
.date-block span, .date-block small { color: var(--muted); font-size: .72rem; }
.date-block strong { font-size: 2rem; letter-spacing: -.06em; }
.next-lesson-info { min-width: 0; }
.time-range { color: var(--accent-strong); font-size: .82rem; font-weight: 720; }
.next-lesson-info h3 { margin: 4px 0 1px; font-size: 1.45rem; }
.next-lesson-info h3 a { color: var(--ink); }
.next-lesson-info > p { margin-bottom: 8px; color: var(--muted); }
.next-step { padding: 7px 10px; color: var(--ink-soft); background: white; border: 1px solid var(--border); border-radius: 7px; font-size: .8rem; }
.schedule-list { display: grid; }
.schedule-item { display: grid; min-width: 0; padding: 10px 0; align-items: center; color: var(--ink); grid-template-columns: 48px 3px minmax(0, 1fr) auto; gap: 11px; border-bottom: 1px solid var(--border); }
.schedule-item:first-child { padding-top: 0; }
.schedule-item:last-child { padding-bottom: 0; border-bottom: 0; }
.schedule-item time { color: var(--brand); font-size: .82rem; font-weight: 730; }
.schedule-line { width: 3px; height: 32px; background: var(--accent); border-radius: 5px; }
.schedule-copy { display: grid; min-width: 0; }
.schedule-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.plain-list, .issue-list { margin: 0; padding: 0; list-style: none; }
.plain-list li { border-bottom: 1px solid var(--border); }
.plain-list li:last-child { border-bottom: 0; }
.plain-list a { display: flex; padding: 10px 0; align-items: center; justify-content: space-between; gap: 12px; color: var(--ink); }
.plain-list time { width: 44px; flex: 0 0 auto; color: var(--accent-strong); font-size: .8rem; font-weight: 720; }
.plain-list a > span { display: grid; min-width: 0; }
.plain-list small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.empty-copy { margin: 4px 0 0; padding: 18px 0; text-align: center; }
.issue-list { display: grid; gap: 12px; }
.issue-list li { display: flex; gap: 10px; }
.issue-list li > span:last-child { display: grid; }
.issue-list small { color: var(--danger); }
.issue-dot { width: 8px; height: 8px; flex: 0 0 auto; margin-top: 7px; background: var(--danger); border-radius: 50%; }
.ok-state { display: flex; padding: 15px; align-items: center; gap: 12px; color: var(--success); background: var(--success-soft); border-radius: 9px; }
.ok-state > span { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; color: white; background: var(--success); border-radius: 50%; font-weight: 800; }
.ok-state p { display: grid; margin: 0; }
.ok-state small { color: #507563; }
.upcoming-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.upcoming-tile { display: flex; min-width: 0; padding: 12px; align-items: center; gap: 11px; color: var(--ink); background: var(--surface-soft); border: 1px solid var(--border); border-radius: 9px; }
.upcoming-tile:hover { background: var(--surface-tint); border-color: #c3dadd; }
.upcoming-tile time { display: grid; width: 42px; flex: 0 0 auto; place-items: center; line-height: 1.05; }
.upcoming-tile time strong { color: var(--brand); font-size: 1.35rem; }
.upcoming-tile time span { color: var(--muted); font-size: .66rem; }
.upcoming-tile-copy { display: grid; min-width: 0; }
.upcoming-tile-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

/* Empty states */
.empty-state { padding: 45px 20px; color: var(--muted); text-align: center; }
.empty-state h3 { margin: 9px 0 4px; color: var(--ink); }
.empty-state p { max-width: 470px; margin: 0 auto 16px; }
.compact-empty { padding: 24px 12px; }
.empty-icon { display: inline-grid; width: 42px; height: 42px; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 50%; font-weight: 750; }

/* Filters and data tables */
.filter-card { margin-bottom: 20px; padding: 18px 20px; }
.filter-form { display: grid; align-items: end; grid-template-columns: minmax(210px, 1.3fr) minmax(190px, 1fr) minmax(155px, .7fr) auto; gap: 12px; }
.filter-field { display: grid; gap: 5px; }
.filter-field label { color: var(--ink-soft); font-size: .75rem; font-weight: 680; }
.filter-actions { display: flex; gap: 7px; }
.search-input { position: relative; }
.search-input > span { position: absolute; top: 50%; left: 12px; color: var(--muted); transform: translateY(-50%); }
.search-input .form-control { padding-left: 34px; }
.table-card { padding: 0; overflow: hidden; }
.table-card-header { margin: 0; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 11px 14px; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--border); font-size: .72rem; font-weight: 720; letter-spacing: .025em; text-align: left; white-space: nowrap; }
.data-table td { padding: 13px 14px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafcfc; }
.data-table .row-warning { background: #fffaf0; }
.data-table .row-warning:hover { background: #fff6e5; }
.actions-column { width: 50px; text-align: right !important; }
.person-link { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.person-link > span:last-child { display: grid; }
.person-link small { color: var(--muted); }
.avatar { display: inline-grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; color: var(--brand); background: var(--brand-soft); border: 1px solid #cfdee7; border-radius: 50%; font-size: .85rem; font-weight: 760; }
.avatar-large { width: 64px; height: 64px; font-size: 1.45rem; }
.cell-primary, .cell-secondary { display: block; }
.cell-secondary { margin-top: 1px; color: var(--muted); }
.icon-link { display: inline-grid; width: 30px; height: 30px; place-items: center; border-radius: 7px; }
.icon-link:hover { background: var(--brand-soft); }
.warning-text { display: block; margin-top: 4px; color: var(--warning); font-size: .72rem; font-weight: 670; }

/* Forms */
.form-page-header { margin-bottom: 18px; }
.form-layout { display: grid; align-items: start; grid-template-columns: minmax(0, 1fr) 290px; gap: 20px; }
.form-card { padding: 26px; }
.stacked-form { display: grid; gap: 21px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-field { display: grid; min-width: 0; align-content: start; gap: 6px; }
.form-field label { color: var(--ink-soft); font-size: .82rem; font-weight: 690; }
.required-marker { color: var(--danger); }
.form-control, .form-select {
  display: block;
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: inset 0 1px 1px rgb(20 61 89 / 2%);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:hover, .form-select:hover { border-color: #aebdc6; }
.form-control:focus, .form-select:focus { border-color: var(--accent); outline: 0; box-shadow: 0 0 0 3px rgb(22 125 127 / 14%); }
textarea.form-control { min-height: 90px; resize: vertical; }
.form-select { padding-right: 32px; }
.form-check-input { width: 18px; height: 18px; accent-color: var(--accent); }
.field-contact_info, .field-current_plan, .field-notes, .field-billing_notes,
.field-lesson_log, .field-next_step, .field-content, .field-review_reason { grid-column: 1 / -1; }
.help-text { margin: -1px 0 0; color: var(--muted); font-size: .75rem; }
.field-errors { margin: 0; padding: 0; color: var(--danger); font-size: .76rem; list-style: none; }
.has-error .form-control, .has-error .form-select { border-color: var(--danger); background: #fffafa; }
.form-actions { display: flex; padding-top: 19px; gap: 9px; border-top: 1px solid var(--border); }
.form-aside { position: sticky; top: 92px; }
.context-card { color: var(--ink-soft); }
.context-card h2 { overflow-wrap: anywhere; }
.context-card > p:last-child { margin-bottom: 0; }
.compact-list { display: grid; margin: 14px 0 0; gap: 9px; }
.compact-list > div { display: grid; grid-template-columns: 58px 1fr; gap: 10px; }
.compact-list dt { color: var(--muted); font-size: .76rem; }
.compact-list dd { margin: 0; font-size: .84rem; }

/* Student and lesson details */
.student-hero, .lesson-hero { display: flex; margin-bottom: 22px; align-items: center; justify-content: space-between; gap: 22px; }
.student-identity { display: flex; align-items: center; gap: 15px; }
.student-identity h1, .lesson-hero h1 { margin: 0; }
.student-identity p, .lesson-student { margin: 5px 0 0; color: var(--muted); }
.title-with-badge { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.metric-grid-student { grid-template-columns: .8fr .8fr 1.2fr 1.2fr; }
.metric-card-wide .metric-label { margin-bottom: 7px; }
.metric-event { display: grid; min-width: 0; }
.metric-event strong { color: var(--ink); font-size: 1rem; }
.metric-event span { overflow: hidden; margin-top: 2px; color: var(--muted); font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.metric-empty { color: var(--muted); font-size: 1rem; font-weight: 620; }
.detail-grid { display: grid; margin-bottom: 20px; align-items: start; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 20px; }
.detail-grid .card + .card { margin-top: 0; }
.detail-list { display: grid; margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 22px; }
.detail-list > div { min-width: 0; }
.detail-list-full { grid-column: 1 / -1; }
.detail-list dt, .money-summary dt { margin-bottom: 3px; color: var(--muted); font-size: .75rem; font-weight: 640; }
.detail-list dd, .money-summary dd { margin: 0; overflow-wrap: anywhere; }
.money-summary { display: grid; margin: 0 0 15px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.money-summary > div { padding: 12px; background: var(--surface-soft); border-radius: 8px; }
.money-summary dd { color: var(--brand); font-size: 1.05rem; font-weight: 740; }
.note-box { margin: 0 0 17px; padding: 11px 13px; color: var(--ink-soft); background: #fff9ed; border-left: 3px solid #e1aa4c; border-radius: 5px; }
.section-heading-row { display: flex; margin: 17px 0 8px; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading-row h3 { margin: 0; }
.record-list { border-top: 1px solid var(--border); }
.record-item { display: grid; padding: 12px 0; align-items: center; grid-template-columns: 105px 1fr auto; gap: 12px; border-bottom: 1px solid var(--border); }
.record-item:last-child { padding-bottom: 0; border-bottom: 0; }
.record-item > div:first-child { display: grid; }
.record-item time { color: var(--muted); font-size: .74rem; }
.record-copy { min-width: 0; }
.record-copy p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.timeline-card { margin-top: 20px; }
.timeline { position: relative; display: grid; }
.timeline::before { position: absolute; top: 5px; bottom: 8px; left: 6px; width: 2px; content: ""; background: var(--border); }
.timeline-item { position: relative; display: grid; padding: 0 0 20px; grid-template-columns: 14px 1fr; gap: 14px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-marker { position: relative; z-index: 1; width: 14px; height: 14px; margin-top: 4px; background: var(--accent); border: 3px solid white; border-radius: 50%; box-shadow: 0 0 0 1px var(--accent); }
.timeline-meta { display: flex; margin-bottom: 6px; align-items: center; flex-wrap: wrap; gap: 8px; }
.timeline-meta time { color: var(--muted); font-size: .76rem; }
.timeline-content p { margin-bottom: 7px; }
.lesson-summary-grid { display: grid; margin-bottom: 20px; grid-template-columns: 1.25fr .75fr 1fr; gap: 14px; }
.lesson-summary-grid .card + .card { margin-top: 0; }
.schedule-summary { display: flex; align-items: center; gap: 18px; }
.date-block-large { width: 86px; min-height: 108px; }
.date-block-large strong { font-size: 2.4rem; }
.schedule-summary h2 { margin-bottom: 3px; font-size: 1.5rem; }
.schedule-summary p { margin-bottom: 7px; color: var(--muted); }
.duration-summary dl, .context-summary dl { display: grid; margin: 13px 0 0; gap: 12px; }
.duration-summary dl > div, .context-summary dl > div { display: grid; gap: 2px; }
.duration-summary dt, .context-summary dt { color: var(--muted); font-size: .75rem; }
.duration-summary dd, .context-summary dd { margin: 0; }
.lesson-content-grid { display: grid; margin-bottom: 20px; align-items: start; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr); gap: 20px; }
.lesson-side-stack { display: grid; gap: 14px; }
.lesson-side-stack .card + .card { margin-top: 0; }
.lesson-side-stack p:last-child { margin-bottom: 0; }
.rich-text { min-height: 150px; overflow-wrap: anywhere; }
.empty-note { display: grid; min-height: 150px; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.empty-note > span { display: grid; width: 48px; height: 48px; margin-bottom: 8px; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 50%; font-size: .72rem; font-weight: 800; }
.empty-note p { margin: 0; }
.legacy-card { margin-top: 20px; }

/* Calendar */
.calendar-page .page-main { width: min(calc(100% - 30px), 1450px); padding-block: 18px 42px; }
.calendar-shell { overflow: hidden; background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.calendar-toolbar { display: grid; min-height: 66px; padding: 12px 16px; align-items: center; grid-template-columns: 1fr auto 1fr; gap: 14px; border-bottom: 1px solid var(--border); }
.calendar-toolbar h2 { margin: 0; text-align: center; }
.calendar-navigation { display: flex; align-items: center; gap: 7px; }
.calendar-navigation .icon-button { color: var(--ink-soft); background: white; border-color: var(--border); }
.calendar-navigation .icon-button:hover { background: var(--surface-soft); }
.segmented-control { display: flex; justify-self: end; padding: 3px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 9px; }
.segmented-control a { min-width: 45px; padding: 6px 10px; color: var(--muted); border-radius: 6px; font-size: .82rem; font-weight: 680; text-align: center; }
.segmented-control a[aria-current="page"] { color: var(--brand); background: white; box-shadow: 0 1px 4px rgb(20 61 89 / 10%); }
.calendar-legend { display: flex; padding: 9px 16px; justify-content: flex-end; gap: 16px; color: var(--muted); background: #fbfcfc; border-bottom: 1px solid var(--border); font-size: .72rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.legend-completed { background: var(--success); }
.legend-blocked { background: #77828d; }
.calendar-scroll { overflow-x: auto; outline-offset: -3px; }
.calendar-weekdays { display: grid; min-width: 910px; grid-template-columns: repeat(7, minmax(130px, 1fr)); border-bottom: 1px solid var(--border); }
.calendar-weekdays span { padding: 8px; color: var(--muted); background: var(--surface-soft); border-right: 1px solid var(--border); font-size: .7rem; font-weight: 700; text-align: center; }
.calendar-weekdays span:last-child { border-right: 0; }
.calendar-grid { display: grid; }
.calendar-grid-week, .calendar-grid-month { min-width: 910px; grid-template-columns: repeat(7, minmax(130px, 1fr)); }
.calendar-grid-day { grid-template-columns: 1fr; }
.calendar-day { position: relative; min-width: 0; min-height: 255px; padding: 9px; background: white; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar-grid-week .calendar-day { min-height: 480px; }
.calendar-grid-month .calendar-day { min-height: 175px; }
.calendar-grid-day .calendar-day { min-height: 540px; padding: 18px; }
.calendar-grid-month .calendar-day:nth-child(7n) { border-right: 0; }
.calendar-grid-week .calendar-day:last-child { border-right: 0; }
.calendar-day.is-today { background: #f5fbfa; box-shadow: inset 0 3px 0 var(--accent); }
.calendar-day.is-outside-month { background: #f7f8f9; }
.calendar-day.is-outside-month .calendar-date, .calendar-day.is-outside-month .calendar-events { opacity: .55; }
.calendar-day-header { display: flex; min-height: 35px; margin-bottom: 7px; align-items: flex-start; justify-content: space-between; gap: 7px; }
.calendar-date { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .7rem; }
.calendar-date strong { display: grid; width: 27px; height: 27px; place-items: center; color: var(--ink); border-radius: 50%; font-size: .84rem; }
.is-today .calendar-date strong { color: white; background: var(--accent); }
.calendar-grid-day .calendar-date { align-items: baseline; }
.calendar-grid-day .calendar-date span { font-size: .82rem; }
.calendar-grid-day .calendar-date strong { width: 35px; height: 35px; font-size: 1.05rem; }
.day-add-menu { position: relative; }
.day-add-menu > summary { display: grid; width: 27px; height: 27px; place-items: center; color: var(--muted); border: 1px solid transparent; border-radius: 6px; list-style: none; cursor: pointer; }
.day-add-menu > summary::-webkit-details-marker { display: none; }
.day-add-menu > summary:hover { color: var(--accent-strong); background: white; border-color: var(--border); }
.day-add-menu > div { position: absolute; z-index: 30; top: 31px; right: 0; display: grid; width: 165px; padding: 6px; background: white; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md); }
.day-add-menu:not([open]) > div { display: none; }
.day-add-menu a { padding: 7px 8px; color: var(--ink-soft); border-radius: 5px; font-size: .78rem; }
.day-add-menu a:hover { color: var(--brand); background: var(--surface-soft); }
.calendar-events { display: grid; align-content: start; gap: 6px; }
.calendar-event { position: relative; display: grid; min-width: 0; padding: 7px 8px; color: var(--ink); background: var(--accent-soft); border: 1px solid #c6e0df; border-left: 3px solid var(--accent); border-radius: 6px; line-height: 1.25; }
a.calendar-event:hover { color: var(--ink); background: #d8eceb; }
.calendar-event time { color: var(--accent-strong); font-size: .65rem; font-weight: 750; }
.calendar-event strong, .calendar-event span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event strong { margin-top: 2px; font-size: .78rem; }
.calendar-event span { color: var(--muted); font-size: .68rem; }
.calendar-event small { margin-top: 3px; color: var(--muted); }
.lesson-event.status-completed { background: var(--success-soft); border-color: #c0dfcc; border-left-color: var(--success); }
.lesson-event.status-cancelled, .lesson-event.status-rescheduled { opacity: .68; background: #f0f1f2; border-color: #d9dee2; border-left-color: #7a858e; }
.lesson-event.status-student_leave, .lesson-event.status-teacher_leave { background: var(--warning-soft); border-color: #edd39e; border-left-color: #b6781b; }
.lesson-event.status-no_show, .lesson-event.event-stale { background: var(--danger-soft); border-color: #ebc1c2; border-left-color: var(--danger); }
.blocked-event { display: block; padding: 0; background: #eef0f2; border-color: #d5dbe0; border-left-color: #77828d; }
.blocked-event > a { display: grid; min-width: 0; padding: 7px 27px 7px 8px; color: var(--ink-soft); }
.blocked-event time { color: #606c76; }
.event-delete { position: absolute; top: 3px; right: 3px; display: grid; width: 22px; height: 22px; padding: 0; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.event-delete:hover { color: var(--danger); background: white; }
.calendar-grid-day .calendar-events { max-width: 800px; }
.calendar-grid-day .calendar-event { min-height: 64px; padding: 10px 12px; grid-template-columns: 72px minmax(0, 1fr); align-items: center; column-gap: 12px; }
.calendar-grid-day .calendar-event time { grid-row: 1 / 4; font-size: .82rem; }
.calendar-grid-day .calendar-event strong { font-size: .92rem; }
.calendar-grid-day .blocked-event { display: block; min-height: auto; padding: 0; }
.calendar-grid-day .blocked-event > a { display: grid; min-height: 64px; padding: 10px 38px 10px 12px; grid-template-columns: 72px minmax(0, 1fr); align-items: center; column-gap: 12px; }
.calendar-grid-day .blocked-event time { grid-row: 1 / 3; }
.calendar-empty { display: grid; min-height: 75px; place-items: center; align-content: center; color: var(--muted); font-size: .68rem; opacity: 0; transition: opacity .15s ease; }
.calendar-day:hover .calendar-empty, .calendar-empty:focus-within { opacity: 1; }
.calendar-empty span { color: #a1aab2; }
.calendar-footnote, .statistics-note { margin: 11px 4px 0; color: var(--muted); font-size: .74rem; }

/* Upcoming and statistics */
.attention-section { margin-bottom: 20px; border-top: 3px solid #d49a3c; }
.task-list { display: grid; border-top: 1px solid var(--border); }
.task-item { display: grid; padding: 14px 4px; align-items: center; grid-template-columns: 125px minmax(0, 1fr) auto; gap: 16px; border-bottom: 1px solid var(--border); }
.task-item:last-child { padding-bottom: 0; border-bottom: 0; }
.task-date, .task-main { display: grid; }
.task-date span { color: var(--muted); font-size: .78rem; }
.task-main > a { color: var(--ink); font-weight: 700; }
.task-actions { display: flex; gap: 7px; }
.ok-state-large { max-width: 560px; margin: 12px auto 2px; padding: 24px; justify-content: center; }
.upcoming-section { margin-top: 20px; }
.agenda-list { display: grid; }
.agenda-day { display: flex; margin: 14px 0 5px; align-items: center; gap: 8px; color: var(--brand); font-size: .84rem; }
.agenda-day:first-child { margin-top: 0; }
.agenda-day small { padding: 2px 7px; color: var(--accent-strong); background: var(--accent-soft); border-radius: 999px; font-size: .66rem; }
.agenda-item { display: grid; padding: 13px 6px; align-items: center; grid-template-columns: 70px 3px minmax(0, 1fr) auto; gap: 14px; border-bottom: 1px solid var(--border); }
.agenda-item > time { display: grid; color: var(--brand); font-size: .9rem; font-weight: 730; }
.agenda-item > time small { color: var(--muted); font-size: .68rem; font-weight: 500; }
.agenda-accent { width: 3px; height: 38px; background: var(--accent); border-radius: 5px; }
.agenda-copy { min-width: 0; }
.agenda-copy > a { color: var(--ink); font-weight: 720; }
.agenda-copy p { margin: 1px 0; color: var(--muted); }
.agenda-copy small { color: var(--muted); }
.stats-period-grid { display: grid; margin-bottom: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stats-period-grid .card + .card { margin-top: 0; }
.period-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.period-metric { display: grid; min-width: 0; padding: 13px 10px; background: var(--surface-soft); border-radius: 8px; text-align: center; }
.period-metric > span { color: var(--muted); font-size: .72rem; }
.period-metric strong { color: var(--brand); font-size: 1.55rem; letter-spacing: -.04em; }
.period-metric small { color: var(--muted); font-size: .68rem; }
.period-metric-accent { background: var(--brand-soft); }

/* Login */
.auth-page { background: var(--brand); }
.auth-main { min-height: 100vh; padding: 40px 20px; }
.login-shell { display: grid; width: min(900px, 100%); min-height: calc(100vh - 80px); margin: 0 auto; align-items: center; grid-template-columns: minmax(0, 1fr) 390px; gap: 80px; }
.login-intro { color: rgb(255 255 255 / 76%); }
.login-intro .brand-mark-large { width: 58px; height: 58px; margin-bottom: 28px; border-radius: 16px; font-size: 1.05rem; }
.login-intro .eyebrow { color: #f0b968; }
.login-intro h1 { color: white; font-size: 2.7rem; }
.login-intro p:last-child { max-width: 430px; font-size: 1.05rem; }
.login-card { padding: 30px; box-shadow: 0 24px 70px rgb(0 0 0 / 22%); }
.login-card h2 { font-size: 1.45rem; }
.login-card .stacked-form { gap: 17px; }
.form-footnote { margin: 19px 0 0; color: var(--muted); font-size: .75rem; text-align: center; }

/* Footer */
.site-footer { min-height: 64px; color: var(--muted); background: #e5eaed; border-top: 1px solid var(--border); }
.footer-inner { display: flex; min-height: 64px; align-items: center; justify-content: space-between; gap: 20px; font-size: .75rem; }

@media (max-width: 1120px) {
  .header-inner { gap: 16px; }
  .brand-copy { display: none; }
  .primary-nav a { padding-inline: 10px; }
  .dashboard-grid-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid-secondary > :last-child { grid-column: 1 / -1; }
  .upcoming-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid-student { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-summary-grid { grid-template-columns: 1fr 1fr; }
  .context-summary { grid-column: 1 / -1; }
  .filter-form { grid-template-columns: 1fr 1fr 180px; }
  .filter-actions { grid-column: 1 / -1; }
  .period-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .shell { width: min(calc(100% - 28px), var(--shell)); }
  .site-header { height: 64px; }
  .header-inner { position: relative; }
  .brand-copy { display: grid; }
  .nav-toggle {
    display: grid;
    width: 40px;
    height: 40px;
    margin-left: auto;
    padding: 10px;
    place-content: center;
    gap: 4px;
    color: white;
    background: rgb(255 255 255 / 8%);
    border: 1px solid rgb(255 255 255 / 12%);
    border-radius: 9px;
  }
  .nav-toggle > span:not(.sr-only) { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }
  .primary-nav {
    position: absolute;
    top: 58px;
    right: 0;
    left: 0;
    display: none;
    height: auto;
    padding: 8px;
    background: var(--brand);
    border: 1px solid rgb(255 255 255 / 11%);
    border-radius: 0 0 12px 12px;
    box-shadow: var(--shadow-md);
  }
  .primary-nav.is-open { display: grid; }
  .primary-nav a { height: auto; padding: 10px 12px; justify-items: start; border-radius: 7px; }
  .primary-nav a[aria-current="page"] { background: rgb(255 255 255 / 8%); }
  .primary-nav a[aria-current="page"]::after { display: none; }
  .header-actions { margin-left: 0; }
  .header-actions > .button { display: none; }
  .page-main { padding-block: 26px 42px; }
  .page-header { align-items: flex-start; }
  .dashboard-grid-primary, .detail-grid, .lesson-content-grid { grid-template-columns: 1fr; }
  .detail-grid .card + .card { margin-top: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upcoming-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-layout { grid-template-columns: 1fr; }
  .form-aside { position: static; }
  .lesson-summary-grid { grid-template-columns: 1fr; }
  .context-summary { grid-column: auto; }
  .stats-period-grid { grid-template-columns: 1fr; }
  .task-item { grid-template-columns: 105px minmax(0, 1fr); }
  .task-actions { grid-column: 1 / -1; padding-left: 121px; }
  .login-shell { min-height: auto; grid-template-columns: 1fr; gap: 30px; }
  .login-intro { padding-top: 20px; text-align: center; }
  .login-intro .brand-mark-large { margin: 0 auto 20px; }
  .login-intro p:last-child { margin-inline: auto; }
  .login-card { width: min(430px, 100%); margin-inline: auto; }
  .calendar-toolbar { grid-template-columns: 1fr auto; }
  .calendar-toolbar h2 { grid-column: 1 / -1; grid-row: 1; }
  .calendar-navigation { grid-row: 2; }
  .segmented-control { grid-row: 2; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .shell { width: min(calc(100% - 20px), var(--shell)); }
  .brand-copy strong { font-size: .85rem; }
  .brand-copy small { display: none; }
  .message-stack { top: 72px; }
  .message { width: 100%; }
  .page-main { padding-block: 20px 34px; }
  .page-header, .student-hero, .lesson-hero { display: grid; align-items: start; }
  .page-header { margin-bottom: 20px; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions .button { flex: 1 1 auto; }
  .card { padding: 17px; border-radius: 10px; }
  .metric-grid { gap: 9px; }
  .metric-card { padding: 14px; }
  .metric-value { font-size: 1.65rem; }
  .attention-heading { align-items: flex-start; flex-wrap: wrap; }
  .attention-heading .button { margin-left: 54px; }
  .attention-item { grid-template-columns: 95px 1fr; padding-inline: 13px; }
  .attention-item .item-actions { grid-column: 1 / -1; }
  .dashboard-grid-secondary { grid-template-columns: 1fr; }
  .dashboard-grid-secondary > :last-child { grid-column: auto; }
  .upcoming-strip { grid-template-columns: 1fr; }
  .filter-form { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; }
  .filter-actions .button { flex: 1; }
  .table-card { padding: 0; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .responsive-table tr:last-child { border-bottom: 0; }
  .responsive-table td { display: grid; padding: 5px 0; align-items: start; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; border: 0; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: .72rem; font-weight: 670; }
  .responsive-table td.actions-column { display: none; }
  .responsive-table .person-link { align-items: flex-start; }
  .form-card { padding: 19px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field { grid-column: auto; }
  .form-actions .button { flex: 1; }
  .avatar-large { width: 52px; height: 52px; }
  .detail-list, .money-summary { grid-template-columns: 1fr; }
  .detail-list-full { grid-column: auto; }
  .record-item { grid-template-columns: 90px 1fr; }
  .record-item .inline-actions { grid-column: 1 / -1; }
  .schedule-summary { align-items: flex-start; }
  .date-block-large { width: 70px; min-height: 94px; }
  .task-item { grid-template-columns: 1fr; }
  .task-date { display: flex; align-items: baseline; gap: 8px; }
  .task-actions { grid-column: auto; padding-left: 0; flex-wrap: wrap; }
  .agenda-item { grid-template-columns: 58px 3px minmax(0, 1fr); gap: 9px; }
  .agenda-actions { display: none; }
  .period-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-page .page-main { width: min(calc(100% - 14px), 1450px); padding-block: 12px 28px; }
  .calendar-page-header .page-actions .button-secondary { display: none; }
  .calendar-toolbar { padding-inline: 10px; }
  .calendar-toolbar h2 { font-size: 1rem; }
  .calendar-legend { justify-content: flex-start; overflow-x: auto; }
  .calendar-grid-day .calendar-day { min-height: 430px; padding: 12px; }
  .calendar-grid-day .calendar-event { grid-template-columns: 55px minmax(0, 1fr); }
  .calendar-grid-day .blocked-event > a { grid-template-columns: 55px minmax(0, 1fr); }
  .login-intro h1 { font-size: 2rem; }
  .login-intro p:last-child { font-size: .9rem; }
  .login-card { padding: 22px 18px; }
  .auth-main { padding: 22px 14px; }
  .footer-inner { padding-block: 14px; align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; }
}

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

/* Teaching Manager V2: intentionally desktop-dense without forcing viewport overflow. */
@media (min-width: 1000px) {
  .shell { width: min(96vw, 1720px); }
  .primary-nav { gap: .15rem; }
  .primary-nav a { padding-inline: .62rem; font-size: .86rem; }
}

.compact-page-header { margin-bottom: 1rem; align-items: flex-end; }
.compact-page-header h1 { margin-bottom: .15rem; }
.dense-table { min-width: 1120px; font-size: .84rem; }
.dense-table th { padding: .55rem .7rem; white-space: nowrap; }
.dense-table td { padding: .58rem .7rem; vertical-align: top; }
.dense-table .avatar { width: 1.85rem; height: 1.85rem; font-size: .76rem; }
.dense-table .cell-secondary { margin-top: .2rem; max-width: 18rem; }
.compact-person { gap: .45rem; }
.danger-text, .row-danger .danger-text { color: #aa2230; font-weight: 750; }
.row-danger { background: #fff1f2 !important; }
.row-danger td:first-child { box-shadow: inset 4px 0 #c93445; }
.row-warning { background: #fff9e9 !important; }
.eyebrow-danger { color: #b42335; }
.count-chip-danger, .nav-count-danger { background: #b42335; color: #fff; }
.count-chip-today { background: #155a7a; color: #fff; }
.action-section { margin-bottom: 1rem; overflow: visible; }
.action-section-danger { border-top: 4px solid #c93445; }
.action-section-today { border-top: 4px solid #24789b; }
.action-section-warning { border-top: 4px solid #d99519; }
.health-warning { display: flex; gap: 1.2rem; align-items: center; margin-bottom: 1rem; }
.health-warning ul { margin: 0; flex: 1; }
.action-grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.action-grid-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.compact-action-list { display: grid; }
.compact-action-row { display: grid; grid-template-columns: 5rem minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .72rem 0; border-top: 1px solid var(--line); }
.compact-action-row:first-child { border-top: 0; }
.compact-action-row > time { font-weight: 750; color: var(--ink-muted); }
.compact-action-row p, .compact-action-row small { margin: .1rem 0 0; display: block; }
.dashboard-action-queue > a, .system-issue-list > a { color: inherit; text-decoration: none; padding-inline: .4rem; }
.dashboard-action-queue > a:hover, .system-issue-list > a:hover { color: inherit; background: #f4f8f8; }
.compact-warning-card { min-height: 12rem; }
.compact-warning-card > strong { display: block; margin: .5rem 0; font-size: 1.4rem; }
.compact-warning-card ul { padding-left: 1.1rem; margin: .5rem 0; }
.action-buttons { flex-wrap: nowrap; white-space: nowrap; }
.quick-action-stack { display: grid; gap: .25rem; min-width: 8rem; }
.schedule-chip { display: block; width: max-content; padding: .17rem .42rem; margin-bottom: .2rem; border-radius: 999px; background: #edf4f5; color: #234e57; white-space: nowrap; }
.dense-filter-form { grid-template-columns: minmax(260px, 1.4fr) minmax(180px, 1fr) minmax(180px, .8fr) auto; }
.prospect-table { min-width: 1500px; }
.active-table { min-width: 1600px; }

.student-split-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.student-current-column, .student-timeline-column { min-width: 0; display: grid; gap: 1rem; }
.dense-student-hero { margin-bottom: 1rem; }
.lifecycle-card { border-top: 4px solid #2b7d8a; }
.lifecycle-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; }
.lifecycle-detail-list { margin-bottom: .75rem; }
.lifecycle-actions { padding-top: .7rem; margin-top: .2rem; border-top: 1px solid var(--line); }
.lifecycle-studying, .schedule-scheduled { color: #225c36; background: #e4f3e8; }
.schedule-awaiting_schedule { color: #805414; background: #fff2d8; }
.lifecycle-completed { color: #235776; background: #e4f2f8; }
.lifecycle-withdrawn, .lifecycle-refunded { color: #7d3240; background: #f8e7ea; }
.lifecycle-form-summary { margin-block: .75rem; }
.compact-detail-list { grid-template-columns: 1fr 1fr; }
.teaching-focus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: .75rem 0; }
.teaching-focus-grid > div { padding: .75rem; border-radius: .55rem; background: #f5f8f8; border: 1px solid var(--line); }
.teaching-focus-grid span { display: block; color: var(--ink-muted); font-size: .75rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.teaching-focus-grid p { margin: .35rem 0 0; }
.student-period-metrics { grid-template-columns: repeat(2, 1fr); }
.period-metric-wide { grid-column: span 1; }
.period-history-list { display: grid; gap: .55rem; }
.period-history-list article { border: 1px solid var(--line); border-radius: .55rem; padding: .7rem; }
.period-history-list article > div:first-child { display: flex; justify-content: space-between; gap: .5rem; }
.period-history-list p { margin: .35rem 0; }
.sticky-timeline-card { position: sticky; top: 5.2rem; max-height: calc(100vh - 6.2rem); overflow: auto; }
.timeline-header { align-items: flex-start; }
.timeline-actions { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.timeline-filters { display: flex; gap: .25rem; flex-wrap: wrap; padding: .55rem; margin-bottom: .6rem; background: #f5f7f7; border-radius: .55rem; }
.timeline-filters a { padding: .32rem .55rem; border-radius: .35rem; color: var(--ink-muted); font-size: .8rem; }
.timeline-filters a.is-active { background: #fff; color: var(--accent); box-shadow: 0 1px 4px #1838471a; }
.v2-timeline .timeline-content h3 { margin: .35rem 0; font-size: 1rem; }
.timeline-session-detail { display: flex; gap: .5rem; color: var(--ink-muted); font-size: .78rem; }
.next-step-box { padding: .55rem; margin-top: .5rem; border-left: 3px solid #3b8993; background: #f2f8f8; }
.next-step-box p { margin: .2rem 0 0; }
.legacy-compat-card { margin-top: 1rem; }
.legacy-compat-card summary { cursor: pointer; padding: .4rem; }

.calendar-page .card + .card { margin-top: .6rem; }
.calendar-toolbar { display: grid; min-height: 0; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .7rem; padding: .5rem .75rem; margin-bottom: 0; }
.calendar-navigation { display: flex; min-width: 0; align-items: center; gap: .4rem; grid-column: auto; grid-row: auto; }
.calendar-navigation .icon-button { width: 34px; height: 34px; }
.calendar-navigation h2 { min-width: 0; margin: 0 0 0 .35rem; overflow: hidden; font-size: 1.05rem; text-overflow: ellipsis; white-space: nowrap; grid-column: auto; grid-row: auto; }
.calendar-toolbar-actions { display: flex; align-items: center; justify-content: center; gap: .4rem; white-space: nowrap; }
.calendar-toolbar .segmented-control { justify-self: end; }
.calendar-toolbar .segmented-control a { min-width: 40px; padding: .35rem .6rem; }
.segmented-control a.is-active, .segmented-control a[aria-current="page"] { color: #fff; background: var(--accent); box-shadow: 0 1px 4px rgb(20 61 89 / 12%); }
.calendar-attention-panel { padding: .55rem .8rem; margin-bottom: .6rem; border-left: 4px solid #2b7d8a; }
.calendar-attention-panel.has-priority { border-left-color: #b42335; }
.calendar-attention-panel.is-empty { padding-block: .5rem; }
.calendar-attention-header { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .65rem 1rem; }
.calendar-attention-title { display: flex; align-items: baseline; gap: .55rem; }
.calendar-attention-title .eyebrow, .calendar-attention-title h2 { margin: 0; }
.calendar-attention-title h2 { font-size: 1rem; }
.calendar-attention-counts { display: flex; align-items: center; gap: .35rem; }
.calendar-page .calendar-attention-counts .count-chip { min-width: auto; height: 23px; padding-inline: .55rem; font-size: .68rem; }
.calendar-attention-header > .text-link { justify-self: end; white-space: nowrap; }
.calendar-attention-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) minmax(145px, .58fr); gap: .65rem; padding-top: .45rem; margin-top: .4rem; border-top: 1px solid var(--border); }
.calendar-attention-group { min-width: 0; }
.calendar-attention-group + .calendar-attention-group, .calendar-course-summary { padding-left: .75rem; border-left: 1px solid var(--border); }
.calendar-attention-group h3, .calendar-course-summary h3 { margin: 0 0 .2rem; color: var(--muted); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }
.calendar-action-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: .4rem; min-width: 0; padding: .17rem .25rem; color: var(--ink); border-radius: .38rem; line-height: 1.3; }
.calendar-action-row:hover { color: var(--ink); background: #f3f7f7; }
.calendar-action-row .action-dot { width: 7px; height: 7px; background: #2b7d8a; border-radius: 50%; }
.calendar-action-row.severity-danger .action-dot { background: #b42335; box-shadow: 0 0 0 3px #b4233518; }
.calendar-action-row.severity-warning .action-dot { background: #b56c16; }
.calendar-action-copy { min-width: 0; }
.calendar-action-row strong, .calendar-action-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-action-row strong { font-size: .8rem; }
.calendar-action-row small { margin-top: .02rem; color: var(--muted); font-size: .66rem; line-height: 1.15; }
.calendar-action-row time { color: var(--ink-muted); font-size: .68rem; white-space: nowrap; }
.calendar-action-empty, .calendar-attention-empty { margin: .15rem 0 0; font-size: .76rem; }
.calendar-attention-empty { padding-top: .45rem; margin-top: .4rem; border-top: 1px solid var(--border); color: var(--muted); }
.calendar-course-summary { min-width: 0; color: var(--muted); }
.calendar-course-summary strong { display: block; color: var(--ink); font-size: 1rem; }
.calendar-course-summary > span { display: block; margin-top: .05rem; font-size: .72rem; }
.v2-calendar-shell { padding: 0; overflow: visible; }
.v2-calendar-grid-scroll { min-width: 0; }
.v2-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-height: 620px; }
.v2-calendar-grid.view-month { grid-template-rows: repeat(6, minmax(160px, auto)); }
.v2-calendar-grid.view-day { grid-template-columns: 1fr; }
.calendar-day { min-width: 0; padding: .5rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.is-outside { background: #f7f8f8; opacity: .72; }
.calendar-day.is-today { box-shadow: inset 0 4px #2b7d8a; }
.calendar-day-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.calendar-day-header > a { display: flex; gap: .35rem; align-items: baseline; color: var(--ink); }
.calendar-day-header span, .calendar-day-header small { color: var(--ink-muted); font-size: .7rem; }
.calendar-day-header strong { font-size: .9rem; }
.calendar-events { display: grid; gap: .35rem; position: relative; }
.calendar-event { position: relative; display: block; border-radius: .4rem; font-size: .72rem; line-height: 1.25; text-decoration: none; }
.calendar-event > a, .calendar-event-link { display: grid; gap: .1rem; padding: .42rem .48rem; color: inherit; text-decoration: none; }
.calendar-event time { font-size: .67rem; font-weight: 700; opacity: .78; }
.calendar-event strong { font-size: .76rem; }
.calendar-event span, .calendar-event small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-event { background: #dff2f2; color: #164c55; border-left: 4px solid #267b86; }
.session-event.status-completed { background: #e6f4e9; color: #2f6339; border-color: #4c965b; }
.session-event.status-rescheduled, .session-event.status-cancelled { opacity: .65; text-decoration: line-through; }
.appointment-event { padding: .42rem .48rem; background: #eee7fb; color: #5a3b82; border-left: 4px solid #8060ad; }
.blocked-event { background: repeating-linear-gradient(135deg,#eef0f1,#eef0f1 5px,#e4e7e8 5px,#e4e7e8 10px); color: #555f65; border-left: 4px solid #747d82; }
.legacy-event { padding: .42rem .48rem; background: #f5eee1; color: #72572e; border-left: 4px solid #b08a4e; }
.calendar-event.has-conflict { outline: 2px solid #c72e3d; box-shadow: 0 0 0 3px #c72e3d22; }
.calendar-empty-slot { display: flex; gap: .25rem; flex-wrap: wrap; padding: .4rem; color: var(--ink-muted); font-size: .7rem; opacity: 0; }
.calendar-day:hover .calendar-empty-slot { opacity: 1; }
.session-hover-popover { display: none; position: absolute; z-index: 50; left: calc(100% + .45rem); top: 0; width: 430px; max-height: 70vh; overflow: auto; padding: .8rem; border: 1px solid #9ebabe; border-radius: .65rem; background: #fff; color: var(--ink); box-shadow: 0 14px 34px #102a3560; text-align: left; }
.calendar-day:nth-child(7n) .session-hover-popover, .calendar-day:nth-child(7n-1) .session-hover-popover { left: auto; right: calc(100% + .45rem); }
.session-event:hover .session-hover-popover, .session-event:focus-within .session-hover-popover, .session-event:focus .session-hover-popover { display: block; }
.session-hover-popover > header { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .55rem; border-bottom: 1px solid var(--line); }
.session-hover-popover header span, .session-hover-popover header time { display: block; font-size: .72rem; color: var(--ink-muted); }
.hover-participant-list { display: grid; gap: .6rem; margin-top: .6rem; }
.hover-participant { padding: .65rem; border: 1px solid var(--line); border-radius: .5rem; background: #fbfcfc; }
.hover-participant h3 { display: flex; justify-content: space-between; margin: 0 0 .45rem; font-size: .9rem; }
.hover-participant h3 small { color: var(--ink-muted); font-size: .68rem; font-weight: 500; }
.hover-participant dl { display: grid; gap: .35rem; margin: 0; }
.hover-participant dl div { display: grid; grid-template-columns: 6.2rem 1fr; gap: .45rem; }
.hover-participant dt { color: var(--ink-muted); font-size: .7rem; }
.hover-participant dd { margin: 0; font-size: .75rem; white-space: normal; }
.planned-content-box { margin-top: .55rem; padding: .5rem; border-left: 3px solid #287985; background: #eef8f8; }
.planned-content-box p { margin: .2rem 0; font-size: .76rem; white-space: normal; }
.session-hover-popover footer { margin-top: .55rem; color: var(--ink-muted); font-size: .68rem; }
.calendar-legend { display: flex; gap: 1rem; align-items: center; margin-top: .65rem; color: var(--ink-muted); font-size: .75rem; }
.calendar-legend i { display: inline-block; width: .7rem; height: .7rem; margin-right: .25rem; border-radius: .2rem; }
.legend-session { background: #267b86; }.legend-appointment { background: #8060ad; }.legend-blocked { background: #747d82; }.legend-conflict { background: #c72e3d; }
.calendar-day-header .day-add-menu { position: relative; }
.calendar-day-header .day-add-menu > div { z-index: 60; }
.view-day .calendar-event { font-size: .82rem; }
.view-day .calendar-events { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.participant-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.participant-card { border: 1px solid var(--line); border-radius: .65rem; padding: .8rem; background: #fbfcfc; }
.participant-card > header { display: flex; justify-content: space-between; align-items: center; }
.participant-card > header > div { display: flex; gap: .5rem; align-items: center; }
.participant-card header small { display: block; color: var(--ink-muted); }
.participant-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.participant-card dl div { min-width: 0; }
.participant-card dt { color: var(--ink-muted); font-size: .72rem; }
.participant-card dd { margin: .18rem 0 0; }
.previous-context { margin-top: .5rem; padding: .55rem; background: #f1f6f6; border-radius: .45rem; }
.participant-actions { margin-top: .5rem; text-align: right; }
.completion-participant-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.participant-completion-card header { display: flex; gap: .65rem; align-items: center; margin-bottom: .7rem; }
.participant-completion-card header h2, .participant-completion-card header p { margin: 0; }
.participant-form-grid { grid-template-columns: 1fr 1fr; }
.participant-form-grid .field-lesson_log, .participant-form-grid .field-next_step, .participant-form-grid .field-note { grid-column: 1 / -1; }
.shared-log-card { margin-bottom: 1rem; }
.shared-log-card label { display: flex; justify-content: space-between; margin-bottom: .45rem; }
.sticky-form-actions { position: sticky; bottom: 0; z-index: 20; padding: .8rem; margin-top: 1rem; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -8px 20px #102a3514; }

.data-management-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; margin-bottom: 1rem; }
.settings-split-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 1rem; }
.large-action-list { display: grid; gap: .7rem; }
.large-action-list form { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .8rem; border: 1px solid var(--line); border-radius: .55rem; }
.large-action-list form p { margin: .2rem 0 0; color: var(--ink-muted); }
.backup-status-card small { overflow-wrap: anywhere; }
.settings-note { padding: .65rem; background: #f5f8f8; color: var(--ink-muted); border-radius: .45rem; font-size: .8rem; }
.statistics-summary-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 1rem; margin-bottom: 1rem; }
.stats-period-grid-three { grid-template-columns: repeat(3, 1fr); }
.period-status-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; }
.period-status-summary > div { display: flex; justify-content: space-between; align-items: center; padding: .55rem; background: #f5f8f8; border-radius: .45rem; }
.refund-summary { display: grid; gap: .35rem; }
.refund-summary strong { font-size: 1.8rem; }

.system-section { margin-bottom: 1.35rem; scroll-margin-top: 5.5rem; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: 0 0 .65rem; }
.section-heading h2, .section-heading p { margin-block: 0; }
.section-heading .muted { margin-top: .2rem; }
.system-health-grid, .system-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .7rem; }
.system-health-card, .system-metric-card { display: grid; align-content: start; min-height: 8.2rem; padding: .9rem; color: var(--ink); text-decoration: none; border-top: 3px solid #8da3a7; }
.system-health-card > span, .system-metric-card > span { color: var(--ink-muted); font-size: .74rem; font-weight: 750; letter-spacing: .03em; }
.system-health-card > strong, .system-metric-card > strong { margin: .35rem 0 .15rem; font-size: 1.45rem; }
.system-health-card > small, .system-metric-card > small { color: var(--ink-muted); overflow-wrap: anywhere; }
.system-health-card.health-success { border-top-color: #3c8a55; }
.system-health-card.health-warning { border-top-color: #d18b20; }
.system-health-card.health-danger { border-top-color: #be3141; }
.system-metric-card:hover { color: var(--ink); border-top-color: var(--accent); transform: translateY(-1px); }
.system-issue-list { margin-top: .7rem; padding: .35rem .75rem; }
.system-cumulative { margin-top: .7rem; padding: .75rem 1rem; }
.system-cumulative summary { cursor: pointer; font-weight: 750; }
.system-cumulative[open] summary { margin-bottom: .7rem; }

@media (max-width: 1080px) {
  .calendar-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .calendar-toolbar .calendar-navigation { grid-column: 1 / -1; grid-row: 1; }
  .calendar-toolbar-actions { grid-column: 1; grid-row: 2; justify-self: start; }
  .calendar-toolbar .segmented-control { grid-column: 2; grid-row: 2; }
}

@media (max-width: 760px) {
  /* V2's dense filter declaration appears after the legacy 640px rules, so
     explicitly collapse every filter to one shrinkable column here. */
  .filter-form,
  .dense-filter-form {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  .filter-form > *,
  .dense-filter-form > * { min-width: 0; }
  .filter-actions {
    min-width: 0;
    grid-column: auto;
    flex-wrap: wrap;
  }
  .filter-actions .button {
    min-width: 0;
    flex: 1 1 8rem;
  }
  /* Keep dense action rows usable without allowing their action column to
     determine the width of the whole page. */
  .compact-action-row {
    grid-template-columns: 4.5rem minmax(0, 1fr);
    align-items: start;
  }
  .compact-action-row > * { min-width: 0; }
  .compact-action-row > :nth-child(n + 3) {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .compact-action-row > div { overflow-wrap: anywhere; }
  .inline-actions { flex-wrap: wrap; }
  .stale-banner,
  .health-warning {
    align-items: stretch;
    flex-direction: column;
  }
  .stale-banner .inline-actions { width: 100%; }
  .health-warning > * { min-width: 0; }
  .health-warning ul { width: 100%; overflow-wrap: anywhere; }
  .sticky-timeline-card {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .error-summary {
    display: block;
    overflow-wrap: anywhere;
  }
  .error-summary > strong { display: block; }
  .error-summary ul { min-width: 0; }
  .calendar-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .calendar-navigation { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr); min-width: 0; grid-column: 1 / -1; grid-row: 1; }
  .calendar-navigation h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calendar-toolbar-actions { grid-column: 1; grid-row: 2; }
  .calendar-toolbar .segmented-control { grid-column: 2; grid-row: 2; }
  .calendar-day-header { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
  .calendar-day-header > a { display: grid; min-width: 0; gap: 0; }
  .calendar-day-header .day-add-menu { justify-self: start; }
  .v2-calendar-grid-scroll { overflow-x: auto; overscroll-behavior-inline: contain; }
  .v2-calendar-grid:not(.view-day) { min-width: 700px; }
  .v2-calendar-grid .calendar-events { min-width: 0; overflow: hidden; }
  .v2-calendar-grid .calendar-event,
  .v2-calendar-grid .calendar-event-link { min-width: 0; max-width: 100%; }
  .calendar-day:nth-child(7n + 1) .day-add-menu > div,
  .calendar-day:nth-child(7n + 2) .day-add-menu > div,
  .calendar-day:nth-child(7n + 3) .day-add-menu > div { right: auto; left: 0; }
  .calendar-attention-header { grid-template-columns: 1fr auto; }
  .calendar-attention-counts { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; }
  .calendar-attention-header > .text-link { grid-column: 2; grid-row: 1; }
  .calendar-attention-grid { grid-template-columns: 1fr; }
  .calendar-attention-group + .calendar-attention-group, .calendar-course-summary { padding-top: .5rem; padding-left: 0; border-top: 1px dashed var(--border); border-left: 0; }
  .section-heading { align-items: flex-start; }
  .action-grid-two,
  .action-grid-three,
  .student-split-layout,
  .compact-detail-list,
  .teaching-focus-grid,
  .student-period-metrics,
  .participant-card-grid,
  .completion-participant-grid,
  .participant-form-grid,
  .data-management-grid,
  .settings-split-grid,
  .statistics-summary-grid,
  .stats-period-grid-three,
  .period-status-summary,
  .system-health-grid,
  .system-metric-grid { grid-template-columns: minmax(0, 1fr); }
  .view-day .calendar-events { grid-template-columns: minmax(0, 1fr); }
  .session-hover-popover { display: none !important; }
}

@media (max-width: 520px) {
  .calendar-toolbar { grid-template-columns: minmax(0, 1fr); }
  .calendar-toolbar .calendar-navigation { grid-column: 1; grid-row: 1; }
  .calendar-toolbar-actions { max-width: 100%; overflow-x: auto; grid-column: 1; grid-row: 2; justify-self: stretch; }
  .calendar-toolbar .segmented-control { grid-column: 1; grid-row: 3; justify-self: start; }
  .system-health-grid, .system-metric-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .brand-copy { display: none; }
}

@media print {
  body { background: white; }
  .site-header, .site-footer, .page-actions, .button, .action-menu, .message-stack, .day-add-menu, .event-delete { display: none !important; }
  .page-main, .shell { width: 100%; padding: 0; }
  .card, .calendar-shell { break-inside: avoid; box-shadow: none; }
}
