:root {
  color-scheme: light;
  --blue: #0a84ff;
  --blue-dark: #0066cc;
  --black: #050505;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d8dce2;
  --fill: #f5f7fb;
  --white: #ffffff;
  --danger: #c8372d;
  --success: #167a45;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--white);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 42px;
  width: 100%;
  color: var(--black);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 10px 12px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.12);
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
}

.login-panel {
  width: min(100%, 440px);
  display: grid;
  gap: 26px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-top: 7px;
  color: var(--black);
  font-size: clamp(30px, 7vw, 48px);
  line-height: 1;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  background: var(--fill);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  padding: 22px;
  color: var(--white);
  background: var(--black);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--blue);
  color: var(--white);
}

#nav {
  display: grid;
  gap: 8px;
  align-content: start;
}

.nav-btn {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
}

.nav-btn.active,
.nav-btn:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px);
}

.topbar h1 {
  color: var(--black);
  font-size: clamp(25px, 3vw, 36px);
  line-height: 1.05;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.view {
  min-width: 0;
  padding: 24px 28px 42px;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

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

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
}

.auth-tab {
  min-height: 36px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 760;
}

.auth-tab.active {
  color: var(--black);
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

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

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

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

.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.panel {
  padding: 18px;
}

.card {
  min-height: 116px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric-value {
  color: var(--black);
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  font-weight: 820;
}

.metric-value.compact-value {
  font-size: clamp(18px, 2.8vw, 27px);
  line-height: 1.08;
}

.metric-label,
.muted {
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 190px)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar.compact {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto;
}

.toolbar.results-toolbar {
  grid-template-columns: minmax(170px, 0.9fr) minmax(240px, 1.3fr) minmax(150px, 0.8fr) minmax(140px, 0.7fr) auto;
}

.toolbar.bulk-toolbar {
  grid-template-columns: auto minmax(190px, 260px) auto auto;
  justify-content: start;
  align-items: center;
}

.selection-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

input[type="file"] {
  min-height: 46px;
  padding: 7px 9px;
}

input[readonly] {
  color: var(--muted);
  background: var(--fill);
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 750;
  white-space: nowrap;
}

.primary {
  color: var(--white);
  background: var(--blue);
}

.primary:hover {
  background: var(--blue-dark);
}

.secondary {
  color: var(--black);
  background: var(--white);
  border: 1px solid var(--line);
}

.secondary:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.ghost {
  color: currentColor;
  background: transparent;
}

.ghost:hover {
  background: rgba(10, 132, 255, 0.08);
}

.danger {
  color: var(--danger);
  background: #fff4f2;
}

.full {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar-actions {
  justify-content: flex-end;
}

.ai-import-panel,
.ai-review,
.ai-history {
  margin-bottom: 16px;
}

.ai-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.reference-file-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.new-assessment-files {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reference-file-group {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding-top: 12px;
  border-top: 2px solid var(--black);
}

.reference-upload-form,
.reference-file-list,
.reference-file-details,
.ai-shared-references {
  display: grid;
  gap: 10px;
}

.reference-file-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.reference-file-item .button-row {
  grid-column: 1 / -1;
}

.reference-file-details strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-thumbnail,
.reference-document-mark {
  width: 58px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--fill);
}

.reference-thumbnail {
  display: block;
  object-fit: contain;
}

.reference-document-mark {
  display: grid;
  place-items: center;
  color: var(--blue-dark);
  font-size: 11px;
  font-weight: 800;
}

.reference-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.compact-empty {
  padding: 12px;
}

.ai-shared-references {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--fill);
}

.reference-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.ai-assessment-mode {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.ai-assessment-mode legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.ai-assessment-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-assessment-option {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  cursor: pointer;
}

.ai-assessment-option:has(input:checked) {
  border-color: var(--blue);
  background: #eef6ff;
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

.ai-assessment-option input[type="radio"] {
  flex: 0 0 auto;
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--blue);
}

.ai-warning {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-left: 4px solid #b26a00;
  background: #fff8e8;
}

.ai-warning p {
  color: #6d4708;
}

.ai-review-item {
  display: grid;
  gap: 13px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.ai-review-item:last-child {
  border-bottom: 1px solid var(--line);
}

.ai-review-table input,
.ai-review-table select {
  min-width: 135px;
}

.ai-review-table textarea {
  min-width: 180px;
  min-height: 70px;
}

.student-import-table {
  min-width: 1320px !important;
}

.descriptor-review-table table {
  min-width: 700px;
}

.ai-class-choices {
  min-width: 170px;
  display: grid;
  gap: 7px;
}

.check-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--ink);
  font-weight: 650;
}

.check-line input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 1px 0 0;
}

.compact-check {
  font-size: 12px;
  font-weight: 600;
}

.ai-history-table td:nth-child(2) {
  max-width: 300px;
  overflow-wrap: anywhere;
}

.tag.status-draft {
  color: var(--blue-dark);
  border-color: #c9e4ff;
  background: #eaf4ff;
}

.tag.status-applied {
  color: var(--success);
  border-color: #b9e5cb;
  background: #edf9f2;
}

.tag.status-reverted {
  color: var(--muted);
  background: #eef0f3;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--fill);
  font-size: 12px;
  font-weight: 700;
}

.tag.blue {
  color: var(--blue-dark);
  background: #eaf4ff;
  border-color: #c9e4ff;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

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

.result-table th,
.result-table td {
  min-width: 140px;
}

.result-table th:first-child,
.result-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 170px;
  background: var(--white);
}

.result-select {
  min-width: 130px;
}

.class-line {
  display: block;
  line-height: 1.45;
}

.class-membership-line {
  min-width: 180px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.class-membership-line + .class-membership-line {
  margin-top: 5px;
}

.membership-remove {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.class-overview-grid {
  align-items: start;
}

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

.compact-list article {
  display: grid;
  gap: 3px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.compact-list article:last-child {
  border-bottom: 0;
}

.compact-list article.membership-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.membership-row > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.compact-list span {
  color: var(--muted);
  font-size: 13px;
}

.criterion-score-input {
  max-width: 104px;
  min-height: 36px;
  margin-top: 8px;
}

.score-input {
  max-width: 120px;
}

.mini-label {
  max-width: 112px;
  margin-top: 8px;
  gap: 4px;
  font-size: 11px;
}

.mini-label input {
  min-height: 34px;
  padding: 6px 8px;
}

.feedback-cell {
  max-width: 420px;
  min-width: 320px;
}

.comment-input {
  min-height: 104px;
  margin-bottom: 8px;
  font-size: 13px;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #e9edf3;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.36);
}

.delete-confirmation {
  z-index: 30;
}

.unsaved-confirmation {
  z-index: 35;
}

.modal {
  width: min(100%, 560px);
  max-height: calc(100vh - 36px);
  overflow: auto;
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.large-modal {
  width: min(100%, 1100px);
}

.rubric-list {
  display: grid;
  gap: 14px;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-weight: 700;
  white-space: pre-line;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(92vw, 360px);
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--white);
  background: var(--black);
  box-shadow: var(--shadow);
}

.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.score-pill {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--black);
  background: #eef6ff;
  font-weight: 780;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-columns: 1fr;
  }

  #nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-btn {
    justify-content: center;
  }

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

  .toolbar,
  .toolbar.compact,
  .toolbar.bulk-toolbar,
  .toolbar.results-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .ai-upload-grid {
    grid-template-columns: 1fr;
  }

  .reference-file-groups {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .view,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.four,
  .grid.three,
  .grid.two,
  .toolbar,
  .toolbar.compact,
  .toolbar.bulk-toolbar,
  .toolbar.results-toolbar {
    grid-template-columns: 1fr;
  }

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

  .ai-upload-grid.two-files {
    grid-template-columns: 1fr;
  }

  .ai-assessment-options {
    grid-template-columns: 1fr;
  }

  .ai-review .split {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-panel {
    padding: 22px;
  }
}
