:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --panel-soft: #fffaf3;
  --text: #202522;
  --muted: #69736d;
  --line: #ded8cf;
  --primary: #2f6f62;
  --primary-dark: #20534a;
  --link: #175f52;
  --on-primary: #ffffff;
  --primary-soft: #eef8f1;
  --primary-line: #b8d8bf;
  --accent: #d9b76f;
  --accent-soft: #fff4d5;
  --rose: #c57a88;
  --rose-soft: #fff0f2;
  --lavender: #7b75b6;
  --sky: #4f8aa5;
  --danger: #a0413b;
  --danger-soft: #fff0ed;
  --menu-shadow: 0 12px 28px rgba(32, 37, 34, 0.14);
  --focus: 0 0 0 3px rgba(47, 111, 98, 0.18);
  --radius: 8px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101413;
  --panel: #202926;
  --panel-soft: #27312e;
  --text: #fbf7ef;
  --muted: #c8d0cb;
  --line: #52615c;
  --primary: #80d2c2;
  --primary-dark: #d4fff7;
  --link: #b8f8ed;
  --on-primary: #11221f;
  --primary-soft: #163c35;
  --primary-line: #69a99c;
  --accent: #f0c870;
  --accent-soft: #3b321f;
  --rose: #f0aeb9;
  --rose-soft: #3c252b;
  --lavender: #b8b1ec;
  --sky: #8abbd1;
  --danger: #f09a8f;
  --danger-soft: #402623;
  --menu-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px rgba(114, 183, 168, 0.22);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #101413;
    --panel: #202926;
    --panel-soft: #27312e;
    --text: #fbf7ef;
    --muted: #c8d0cb;
    --line: #52615c;
    --primary: #80d2c2;
    --primary-dark: #d4fff7;
    --link: #b8f8ed;
    --on-primary: #11221f;
    --primary-soft: #163c35;
    --primary-line: #69a99c;
    --accent: #f0c870;
    --accent-soft: #3b321f;
    --rose: #f0aeb9;
    --rose-soft: #3c252b;
    --lavender: #b8b1ec;
    --sky: #8abbd1;
    --danger: #f09a8f;
    --danger-soft: #402623;
    --menu-shadow: 0 16px 34px rgba(0, 0, 0, 0.35);
    --focus: 0 0 0 3px rgba(114, 183, 168, 0.22);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--link);
  font-weight: 650;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: var(--panel-soft);
  background: color-mix(in srgb, var(--panel-soft) 92%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(14px);
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.topbar-actions form {
  margin: 0;
}

.theme-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.theme-toggle:hover {
  background: var(--panel);
  border-color: var(--line);
  color: var(--primary-dark);
}

.brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-size: 20px;
  font-weight: 800;
  gap: 9px;
  letter-spacing: 0;
}

.brand::before {
  background:
    linear-gradient(135deg, var(--primary), var(--rose));
  border-radius: 999px 999px 999px 3px;
  content: "";
  height: 18px;
  transform: rotate(-18deg);
  width: 18px;
}

.nav {
  display: flex;
  flex: 1;
  gap: 16px;
}

.nav a {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  font-size: 14px;
  gap: 7px;
  opacity: 0.86;
}

.nav a:hover {
  color: var(--primary-dark);
  opacity: 1;
  text-decoration: none;
}

.icon-sprite {
  display: none;
}

.icon {
  flex: 0 0 auto;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  fill: none;
  width: 16px;
}

.flip-x {
  transform: scaleX(-1);
}

.shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px;
  width: 100%;
}

.page-head {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-head h1,
.profile-head h1,
.panel h2,
.auth-panel h1 {
  letter-spacing: 0;
  margin: 0;
}

.page-head h1,
.profile-head h1 {
  font-size: 32px;
}

.panel h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.panel-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.panel-head a {
  flex: 0 0 auto;
  font-size: 13px;
}

.eyebrow {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  margin: 6px 0 0;
}

.profile-head {
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 20px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 12px 0 0;
}

.profile-meta div {
  min-width: 160px;
}

.profile-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 3px;
}

.profile-meta dd {
  font-size: 15px;
  margin: 0;
}

.actions {
  display: flex;
  gap: 10px;
}

.actions form {
  margin: 0;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.button:focus-visible,
.theme-toggle:focus-visible,
.action-menu summary:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: var(--focus);
  outline: 0;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  background: var(--primary);
  color: var(--on-primary);
}

.button.primary:hover {
  background: var(--primary-dark);
  color: var(--on-primary);
}

.button.secondary {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--primary-dark);
}

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.compact-button {
  min-height: 34px;
  padding: 0 10px;
}

.link-button {
  background: none;
  border: 0;
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  padding: 0;
}

.link-button:hover {
  text-decoration: underline;
}

.danger {
  color: var(--danger);
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.grid > *,
.panel,
.stack {
  min-width: 0;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stack {
  display: grid;
  gap: 18px;
}

.panel,
.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 5%, transparent);
}

.panel.narrow {
  max-width: 1040px;
}

.auth-panel {
  max-width: 720px;
}

.mobile-card-list {
  display: none;
}

.record-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 14px;
  padding: 16px;
}

.record-card__head {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.record-card__head h2 {
  font-size: 18px;
  letter-spacing: 0;
  margin: 0;
}

.status-pill {
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  border-radius: 999px;
  color: var(--primary-dark);
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 750;
  padding: 5px 9px;
}

.record-card__facts {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.record-card__facts div {
  min-width: 0;
}

.record-card__fact-wide {
  grid-column: 1 / -1;
}

.record-card__facts dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 4px;
}

.record-card__facts dd {
  font-size: 15px;
  margin: 0;
}

.record-card__actions {
  display: flex;
  justify-content: flex-end;
}

.record-card__actions form {
  margin: 0;
}

.auth-panel {
  margin: 56px auto 0;
}

.stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.report-stats {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  margin-bottom: 18px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--accent);
  padding: 18px;
}

.stat:nth-child(2n) {
  box-shadow: inset 3px 0 0 var(--primary);
}

.stat:nth-child(3n) {
  box-shadow: inset 3px 0 0 var(--rose);
}

.stat:nth-child(4n) {
  box-shadow: inset 3px 0 0 var(--sky);
}

.stat span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 28px;
  letter-spacing: 0;
}

table {
  border-collapse: collapse;
  font-size: 14px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.actions-cell {
  position: relative;
  text-align: right;
  white-space: nowrap;
  width: 1%;
}

.cell-note {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
  margin-top: 4px;
  white-space: normal;
}

.subscription-preview-table {
  table-layout: fixed;
}

.subscription-preview-table th:first-child,
.subscription-preview-table td:first-child {
  width: 30%;
}

.subscription-preview-table th:nth-child(2),
.subscription-preview-table td:nth-child(2) {
  width: 18%;
}

.subscription-preview-table th:nth-child(3),
.subscription-preview-table td:nth-child(3) {
  width: 14%;
}

.subscription-preview-table th:nth-child(4),
.subscription-preview-table td:nth-child(4) {
  width: 20%;
}

.subscription-preview-table th:last-child,
.subscription-preview-table td:last-child {
  width: 18%;
}

tr:last-child td {
  border-bottom: 0;
}

.action-menu {
  display: inline-block;
  position: relative;
}

.action-menu summary {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--primary-dark);
  cursor: pointer;
  display: inline-flex;
  font-size: 13px;
  font-weight: 750;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  user-select: none;
}

.action-menu summary::marker,
.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu summary::after {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  content: "";
  margin-top: 2px;
}

.action-menu[open] summary {
  background: var(--primary-soft);
  border-color: var(--primary-line);
}

.action-menu__panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--menu-shadow);
  display: grid;
  gap: 2px;
  min-width: 160px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.action-menu__panel a,
.action-menu__panel .link-button {
  border-radius: 6px;
  display: block;
  font-size: 14px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.action-menu__panel a:hover,
.action-menu__panel .link-button:hover {
  background: var(--panel-soft);
  text-decoration: none;
}

.action-menu__panel form {
  margin: 0;
}

.form {
  display: grid;
  gap: 14px;
}

.form p {
  display: grid;
  gap: 6px;
  margin: 0;
}

.form h3 {
  font-size: 15px;
  margin: 0;
}

.form label,
.filters label {
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--primary);
  border-radius: 4px;
  min-height: 18px;
  padding: 0;
  width: 18px;
}

.form > p:has(> input[type="checkbox"]),
.form > p:has(> input[type="radio"]) {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 32px;
}

.form > p:has(> input[type="checkbox"]) label,
.form > p:has(> input[type="radio"]) label {
  order: 2;
}

.form > p:has(> input[type="checkbox"]) input,
.form > p:has(> input[type="radio"]) input {
  flex: 0 0 auto;
  order: 1;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.form .helptext {
  color: var(--muted);
  font-size: 12px;
}

.errorlist {
  color: var(--danger);
  font-size: 13px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.compact {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.checkbox-line {
  align-items: flex-start;
  display: flex;
  gap: 10px;
}

.checkbox-line input {
  flex: 0 0 auto;
  margin-top: 2px;
  min-height: 18px;
  width: 18px;
}

.checkbox-line label {
  display: block;
  margin-bottom: 2px;
}

.checkbox-line small {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.checklist ul {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist li label,
.attendance-row {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  min-height: 48px;
  padding: 10px 12px;
}

.checklist input,
.attendance-row input {
  min-height: auto;
  width: 18px;
}

.attendance-list {
  display: grid;
  gap: 10px;
}

.attendance-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.facts {
  display: grid;
  gap: 12px;
  margin: 0;
}

.facts div {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  font-size: 20px;
  font-weight: 800;
  margin: 0;
}

.stacked-facts div {
  align-items: flex-start;
  display: grid;
  gap: 4px;
  justify-content: stretch;
}

.stacked-facts dt {
  font-size: 13px;
}

.stacked-facts dd {
  font-size: 15px;
  font-weight: 650;
}

.invite-actions,
.share-line,
.filters {
  align-items: end;
  display: flex;
  gap: 10px;
}

.invite-actions {
  align-items: stretch;
  flex-wrap: wrap;
}

.invite-actions .button {
  flex: 1 1 auto;
  min-width: 180px;
}

.invite-fallback {
  flex: 1 0 100%;
}

.form-note {
  color: var(--muted);
  flex: 1 0 100%;
  font-size: 12px;
  margin: 0;
  min-height: 16px;
}

.share-line input {
  flex: 1;
}

.report-filters {
  margin-bottom: 18px;
}

.report-filters .filters {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(150px, 180px)) auto;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message {
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  border-radius: var(--radius);
  color: var(--primary-dark);
  padding: 10px 12px;
}

.pagination {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.pagination span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.student-portal > .panel {
  margin-bottom: 18px;
}

.portal-summary {
  display: grid;
  gap: 16px;
}

.portal-summary h2 {
  margin-bottom: 0;
}

.portal-summary__grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.portal-summary__grid div {
  border-left: 1px solid var(--line);
  min-width: 0;
  padding-left: 16px;
}

.portal-summary__grid div:first-child {
  border-left: 0;
  padding-left: 0;
}

.portal-summary__grid dt {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.portal-summary__grid dd {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
}

@media (max-width: 1180px) {
  .grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: center;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr auto;
    min-height: auto;
    padding: 14px 16px 12px;
    position: static;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  .topbar-actions .button {
    min-height: 34px;
    padding: 0 10px;
  }

  .nav {
    display: grid;
    gap: 8px;
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .nav a {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 13px;
    justify-content: center;
    min-height: 34px;
    overflow: hidden;
    padding: 7px 8px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .shell {
    padding: 20px 14px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-head {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .profile-head h1 {
    font-size: 28px;
  }

  .profile-meta {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .invite-actions,
  .share-line,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .invite-actions .button {
    min-width: 0;
  }

  .report-filters .filters {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .report-actions {
    flex-direction: column;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .report-stats {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .portal-summary__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-summary__grid div,
  .portal-summary__grid div:first-child {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 12px;
  }

  .portal-summary__grid div:nth-child(-n + 2) {
    border-top: 0;
    padding-top: 0;
  }

  .plan-table-panel,
  .list-table-panel {
    display: none;
  }

  .mobile-card-list {
    display: grid;
    gap: 12px;
  }

  .record-card {
    gap: 12px;
    padding: 14px;
  }

  .record-card__facts {
    gap: 10px 14px;
  }

  .record-card__facts dt {
    margin-bottom: 3px;
  }

  .desktop-table {
    display: none;
  }

  .record-card__actions .button {
    width: 100%;
  }

  .record-card__actions form {
    width: 100%;
  }

  .record-card__actions .action-menu {
    width: 100%;
  }

  .record-card__actions .action-menu summary {
    justify-content: center;
    width: 100%;
  }

  .record-card__actions .action-menu__panel {
    left: 0;
    right: 0;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination span {
    text-align: center;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
