:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --paper: #f4f7fb;
  --panel: #ffffff;
  --line: #d6e0ec;
  --line-soft: #e7edf5;
  --navy: #172033;
  --brand-blue: #172033;
  --brand-blue-deep: #101827;
  --brand-blue-soft: #243044;
  --orange: #f97316;
  --orange-deep: #c2410c;
  --orange-soft: #fff1df;
  --orange-line: #fed7aa;
  --gold: #ffd447;
  --green: #15803d;
  --amber: #b45309;
  --red: #b42318;
  --radius: 7px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4fb 0, var(--paper) 310px, #f9fafc 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.portal-shell {
  min-height: 100vh;
}

.login-view {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 420px);
  align-items: center;
  gap: 44px;
  padding: 48px max(24px, calc((100vw - 1120px) / 2));
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.86)),
    radial-gradient(circle at 28% 24%, rgba(249, 115, 22, 0.32), transparent 32%),
    var(--navy);
}

.login-brand img {
  width: min(520px, 82vw);
}

.login-panel,
.metric,
.console-panel,
.app-status,
.subscription-pill,
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(23, 32, 51, 0.05);
}

.login-panel {
  display: grid;
  gap: 16px;
  padding: 28px;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.reset-view {
  grid-template-columns: minmax(320px, 0.9fr) minmax(320px, 460px);
}

.reset-panel .meta {
  color: var(--muted);
  font-weight: 700;
}

.password-reset-form {
  display: grid;
  gap: 14px;
}

.password-checks {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  list-style: none;
}

.password-checks li::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: #cbd5e1;
  border-radius: 50%;
}

.password-checks li.passed {
  color: var(--green);
}

.password-checks li.passed::before {
  background: var(--green);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 3vw, 42px);
  line-height: 1.03;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
  line-height: 1.15;
}

.eyebrow {
  color: var(--orange-deep);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 850;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 5px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(249, 115, 22, 0.22);
  border-color: var(--orange);
}

.button {
  min-height: 40px;
  padding: 9px 14px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 900;
}

.button.primary {
  color: var(--brand-blue);
  background: linear-gradient(180deg, var(--gold), #ffc328);
}

.button.secondary {
  color: #ffb15f;
  background: linear-gradient(180deg, var(--brand-blue-soft), var(--brand-blue));
  border-color: rgba(255, 255, 255, 0.08);
}

.button.ghost,
.button.quiet {
  color: var(--orange-deep);
  background: var(--orange-soft);
  border-color: var(--orange-line);
}

.button.danger {
  color: #ffffff;
  background: var(--red);
}

.button:disabled {
  cursor: default;
  opacity: 0.55;
}

.form-status,
.app-status {
  min-height: 20px;
  color: var(--green);
  font-weight: 750;
}

.form-status.error,
.app-status.error {
  color: var(--red);
}

.app-view {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 64px;
  gap: 24px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-deep) 100%);
  border-bottom: 3px solid var(--orange);
  box-shadow: 0 10px 26px rgba(23, 32, 51, 0.22);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 286px;
  color: var(--orange);
  text-decoration: none;
}

.brand-flame {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 9px 18px rgba(0, 0, 0, 0.2);
}

.brand-flame img {
  width: 29px;
  height: 29px;
  object-fit: contain;
}

.brand-wordmark {
  color: var(--orange);
  font-size: 19px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.topnav-item {
  min-height: 64px;
  padding: 0 2px;
  color: #ffb15f;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  font-weight: 850;
}

.topnav-item.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.topnav-item:hover {
  color: var(--gold);
}

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

.topbar .button.quiet {
  color: var(--brand-blue);
  background: var(--gold);
  border-color: transparent;
}

.auto-status {
  color: #ffd8ad;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.workspace {
  padding: 28px;
}

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

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 750;
}

.subscription-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  padding: 12px 14px;
  border-left: 4px solid var(--orange);
}

.subscription-pill strong,
.subscription-pill span {
  display: block;
}

.subscription-pill span:last-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.green {
  background: var(--green);
}

.app-status {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-left: 4px solid var(--green);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  min-height: 82px;
  padding: 14px;
  position: relative;
  overflow: hidden;
  border-top: 3px solid var(--orange);
  background:
    linear-gradient(180deg, #ffffff 0%, #fffaf3 100%);
}

.metric span {
  color: var(--orange-deep);
  font-size: 13px;
  font-weight: 850;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--brand-blue);
  font-size: 28px;
  line-height: 1;
}

.muted-metric strong {
  font-size: 20px;
}

.console-panel {
  padding: 16px;
  border-top: 4px solid var(--orange);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.panel-action-status {
  margin: -4px 0 12px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.panel-action-status.error {
  color: var(--red);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1.7fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr);
  gap: 12px;
  margin-bottom: 14px;
}

.staff-tools {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
  gap: 12px;
  margin-bottom: 14px;
}

.staff-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(220px, 1.3fr) minmax(130px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
}

.csv-upload {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  border-radius: var(--radius);
}

.csv-upload p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.file-button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 11px 14px;
  color: #ffb15f;
  background: var(--brand-blue);
  border-radius: 6px;
  font-weight: 900;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.table-panel {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.staff-table {
  min-width: 780px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  text-align: left;
  font-size: 14px;
  white-space: nowrap;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  color: #ffb15f;
  background: var(--brand-blue);
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

button.sort-button {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

button.sort-button::after {
  content: "\2195";
  color: rgba(255, 209, 156, 0.78);
  font-size: 12px;
  line-height: 1;
}

button.sort-button.asc::after {
  content: "\2191";
  color: var(--orange);
}

button.sort-button.desc::after {
  content: "\2193";
  color: var(--orange);
}

button.sort-button:hover {
  color: var(--gold);
}

button.sort-button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 3px;
}

tbody tr:hover {
  background: #fff7ed;
}

.student-row {
  cursor: pointer;
}

.student-row:focus {
  outline: 2px solid var(--orange);
  outline-offset: -2px;
}

.warning-cell {
  color: var(--amber);
  font-weight: 850;
}

.status-active {
  color: #047857;
  font-weight: 850;
}

.status-inactive {
  color: var(--muted);
  font-weight: 850;
}

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

.table-action {
  min-height: 32px;
  padding: 6px 9px;
  color: var(--orange-deep);
  background: var(--orange-soft);
  border: 1px solid var(--orange-line);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 850;
}

.table-action.danger {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.table-action.danger:hover {
  background: #fee2e2;
}

.login-code-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-code-value {
  min-width: 64px;
  font-weight: 900;
  letter-spacing: 0;
}

.login-code-value.masked {
  color: var(--muted);
  font-weight: 800;
}

.reveal-code-button {
  min-height: 28px;
  padding: 4px 8px;
  color: var(--orange-deep);
  background: #ffffff;
  border: 1px solid #fed7aa;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 900;
}

.role-select {
  width: auto;
  min-width: 132px;
  min-height: 32px;
  padding: 5px 28px 5px 8px;
  font-size: 13px;
  font-weight: 850;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  font-weight: 750;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.52);
}

.modal {
  width: min(420px, 100%);
  padding: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.modal p {
  margin-top: 10px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.student-drawer {
  position: fixed;
  inset: 0;
  z-index: 18;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 39, 0.52);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(430px, 100%);
  height: 100%;
  padding: 14px;
  overflow: auto;
  background:
    linear-gradient(180deg, #f8fbff 0%, #fff7ed 100%);
  box-shadow: -18px 0 60px rgba(15, 23, 42, 0.24);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.drawer-header p:last-child {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.drawer-header h2 {
  font-size: 20px;
}

.icon-button {
  width: 32px;
  height: 32px;
  color: var(--orange);
  background: var(--brand-blue);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  font-size: 21px;
  line-height: 1;
}

.student-snapshot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.student-snapshot article,
.coach-card,
.next-badge-card,
.unlocked-badge {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.05);
}

.student-snapshot article {
  min-height: 58px;
  padding: 9px 10px;
  border-top: 3px solid var(--orange);
}

.student-snapshot span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.student-snapshot strong {
  display: block;
  margin-top: 5px;
  color: var(--brand-blue);
  font-size: 21px;
  line-height: 1;
}

.coach-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: var(--orange-soft);
  border-color: var(--orange-line);
}

.coach-card p {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.3;
}

.coach-icon,
.mini-flame {
  flex: 0 0 auto;
  display: inline-block;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(249, 115, 22, 0.25));
}

.coach-icon {
  width: 26px;
  height: 26px;
}

.mini-flame {
  width: 18px;
  height: 18px;
}

.login-letter-card {
  display: grid;
  gap: 10px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius);
}

.login-letter-card p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.drawer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.drawer-actions .button {
  min-height: 36px;
  padding-inline: 10px;
  font-size: 13px;
}

.drawer-action-status {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 850;
}

.drawer-action-status.error {
  color: var(--red);
}

.attendance-accordion {
  overflow: hidden;
  background: #fff4dd;
  border: 1px solid var(--orange-line);
  border-radius: var(--radius);
}

.attendance-section {
  display: block;
}

.attendance-accordion > summary,
.calendar-month > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
}

.attendance-accordion > summary::-webkit-details-marker,
.calendar-month > summary::-webkit-details-marker {
  display: none;
}

.attendance-accordion > summary {
  padding: 10px 12px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 950;
  border-bottom: 1px solid rgba(248, 216, 168, 0.72);
}

.attendance-accordion > summary small,
.calendar-month > summary small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.attendance-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 0 12px 8px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
}

.attendance-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calendar-status {
  margin: 0 12px 8px;
  padding: 8px 10px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.calendar-month-list {
  display: grid;
  gap: 8px;
  padding: 0 12px 10px;
}

.calendar-month {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid #f3dfbd;
  border-radius: var(--radius);
}

.calendar-month > summary {
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 950;
}

.calendar-weeks {
  display: grid;
  gap: 6px;
  padding: 0 10px 10px;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(5, minmax(34px, 1fr)) 52px;
  align-items: center;
  column-gap: 6px;
  min-height: 42px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.68);
  border-radius: 14px;
}

.calendar-week.header {
  min-height: 24px;
  padding-block: 0;
  color: var(--orange);
  background: transparent;
  font-size: 12px;
  font-weight: 950;
}

.calendar-week.header span:last-child {
  text-align: right;
}

.calendar-day {
  display: grid;
  grid-template-rows: 16px 22px;
  align-items: center;
  justify-items: center;
  gap: 2px;
  width: 100%;
  min-height: 40px;
  min-width: 0;
  color: #414858;
  font-size: 12px;
  font-weight: 900;
}

.calendar-day strong {
  display: block;
  width: 100%;
  line-height: 16px;
  text-align: center;
}

.calendar-day.empty::after {
  content: "-";
  color: #cbd5e1;
  font-weight: 800;
  grid-row: 1 / -1;
}

.attendance-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cfc7b9;
  color: #ffffff;
  font-size: 9px;
  font-style: normal;
  font-weight: 950;
  line-height: 10px;
  text-align: center;
  vertical-align: middle;
}

.calendar-day .attendance-dot {
  width: 20px;
  height: 20px;
  line-height: 20px;
}

.attendance-dot.full {
  background: #68d681;
}

.attendance-dot.half {
  background: #f47a2d;
}

.attendance-dot.absent {
  background: #ef4444;
}

.attendance-dot.holiday {
  background: #cfc7b9;
  color: #5f6673;
}

.week-percent {
  color: var(--orange);
  text-align: right;
  font-size: 13px;
}

.week-percent.low {
  color: var(--red);
}

.drawer-section h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.badge-list {
  display: grid;
  gap: 8px;
}

.next-badge-card {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.badge-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-card-head strong,
.badge-card-head span {
  display: block;
}

.badge-card-head span:last-child {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.next-badge-card p {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.3;
}

.next-badge-card small,
.unlocked-badge small {
  color: var(--muted);
  font-weight: 750;
}

.badge-progress {
  display: block;
  width: 100%;
  height: 6px;
  overflow: hidden;
  appearance: none;
  background: #e2e8f0;
  border: 0;
  border-radius: 999px;
}

.badge-progress::-webkit-progress-bar {
  background: #e2e8f0;
  border-radius: 999px;
}

.badge-progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--gold), var(--orange));
  border-radius: 999px;
}

.badge-progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--gold), var(--orange));
  border-radius: 999px;
}

.badge-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.unlocked-badge {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  align-items: center;
  padding: 9px;
}

.unlocked-badge strong {
  min-width: 0;
}

.unlocked-badge small {
  grid-column: 2;
}

.drawer-empty {
  padding: 10px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 750;
}

@media (max-width: 980px) {
  .login-view {
    grid-template-columns: 1fr;
    align-content: center;
  }

  .topbar,
  .school-heading,
  .panel-header {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar {
    position: static;
    padding: 12px;
  }

  .topnav,
  .topbar-actions,
  .panel-actions {
    flex-wrap: wrap;
  }

  .metric-grid,
  .filters,
  .staff-tools,
  .staff-form {
    grid-template-columns: 1fr;
  }

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

  .student-snapshot,
  .badge-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 18px;
  }

  .login-view {
    padding: 24px;
  }
}
