:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d9e3dc;
  --surface: #fff;
  --wash: #f3f7f2;
  --green: #2f8f3a;
  --green-dark: #226c31;
  --gold: #f2bf1a;
  --navy: #25364b;
  --danger: #b42318;
  --ok: #027a48;
  --warning: #b54708;
  --shadow: 0 18px 42px rgba(23, 32, 51, .09);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(47, 143, 58, .08), transparent 36%),
    linear-gradient(220deg, rgba(242, 191, 26, .12), transparent 32%),
    #f6f8f5;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 220px;
  color: inherit;
  text-decoration: none;
}
.brand img {
  width: 62px;
  height: 54px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  flex: 0 0 auto;
}
.brand strong { display: block; font-size: 20px; line-height: 1.1; }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-weight: 700; }
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}
.login-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 24px;
}
.login-brand { min-width: 0; }
.login-form {
  display: grid;
  gap: 14px;
}
.login-form button { width: 100%; }
.login-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.language-toggle {
  min-width: 92px;
  white-space: nowrap;
}

.role-nav {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #eef3ef;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.role-nav a {
  min-width: 94px;
  text-align: center;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--navy);
  text-decoration: none;
  font-weight: 900;
}
.role-nav a.is-active {
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(23, 32, 51, .08);
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 30px);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.4vw, 24px);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.section-head.compact { margin-bottom: 12px; }
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(22px, 3vw, 30px); }
h2 { font-size: 20px; }

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 900;
}
input, select, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfd8d0;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 10px 12px;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(47, 143, 58, .16);
  border-color: var(--green);
}
input[readonly] { background: #f7faf8; color: #475467; }
select:disabled, input:disabled { opacity: .62; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef2f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.badge.ok { color: var(--ok); background: #ecfdf3; }
.badge.warn { color: var(--warning); background: #fffaeb; }
.badge.bad { color: var(--danger); background: #fef3f2; }
.muted { color: var(--muted); font-weight: 900; }
.dual {
  display: inline-grid;
  gap: 2px;
  align-items: start;
}
.dual small,
.zh {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.25;
}
.dual strong { display: block; }
.bilingual-title {
  display: grid;
  gap: 4px;
}
.bilingual-title small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.teacher-shell { display: grid; gap: 18px; }
.selector-panel { border-top: 4px solid var(--green); }
.select-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.teacher-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.roster-panel { position: sticky; top: 96px; }
.student-list { display: grid; gap: 8px; }
.empty-list {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.student-card {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
}
.student-card:hover, .student-card.is-active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 143, 58, .12);
}
.student-card.is-done { border-color: #abefc6; background: #f6fef9; }
.student-card.needs-revision { border-color: #f3b5ad; background: #fff7f6; }
.student-card.has-draft { border-color: #f7d15d; background: #fffdf2; }
.student-card strong { display: block; }
.student-card span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 800; }

.evaluation-panel.is-disabled {
  opacity: .74;
}
.mini-grid,
.date-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.date-row { grid-template-columns: minmax(180px, 260px); }
.wide-label { margin-top: 16px; }
.comment-sections {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
.comment-sections textarea {
  min-height: 230px;
}
.word-count {
  color: var(--danger);
  font-size: 12px;
  font-weight: 900;
  text-align: right;
}
.word-count.is-valid {
  color: var(--ok);
}

.signature-pad-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.signature-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid #cfd8d0;
  border-radius: 7px;
  background: #fff;
  color: var(--navy);
  padding: 10px 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(23, 32, 51, .04);
}
.file-button:hover {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 143, 58, .12);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.signature-canvas {
  display: block;
  width: 100%;
  height: 280px;
  border: 1px solid #cfd8d0;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}
.signature-canvas:focus {
  outline: 3px solid rgba(47, 143, 58, .16);
  border-color: var(--green);
}
.signature-preview {
  display: block;
  width: min(420px, 100%);
  min-height: 86px;
  max-height: 140px;
  object-fit: contain;
  object-position: left center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.criteria-list { display: grid; gap: 10px; }
.criterion {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}
.criterion strong { display: block; margin-bottom: 4px; }
.criterion p { margin: 0; color: var(--muted); line-height: 1.35; }
.rating-group {
  display: grid;
  grid-template-columns: repeat(5, 46px);
  gap: 6px;
}
.rating-group label { display: block; }
.rating-group input { position: absolute; opacity: 0; pointer-events: none; }
.rating-group span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid #cfd8d0;
  border-radius: 7px;
  background: #fff;
  font-weight: 900;
  cursor: pointer;
}
.rating-group input:checked + span {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.actions, .review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 15px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.primary { background: var(--green); color: #fff; }
.primary:hover { background: var(--green-dark); }
.secondary { background: #fff; color: var(--navy); border-color: #cfd8d0; }
.danger { background: #fff; color: var(--danger); border-color: #f3b5ad; }

.review-shell {
  display: grid;
  width: min(1760px, 100%);
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.review-panel { min-width: 0; }
.review-detail {
  width: 100%;
  display: block;
}
.queue-panel {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 124px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.queue-tools {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}
.queue-filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.queue-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: -4px 0 14px;
}
.queue-stats span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.queue-stats strong { color: var(--ink); }
.queue-list {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}
.queue-item {
  width: 100%;
  display: grid;
  gap: 9px;
  min-height: auto;
  height: auto;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  line-height: 1.25;
  overflow: visible;
  appearance: none;
}
.queue-item.is-active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 143, 58, .12);
}
.queue-title { min-width: 0; font-size: 16px; line-height: 1.25; font-weight: 900; overflow-wrap: anywhere; }
.queue-meta { color: var(--muted); font-size: 13px; line-height: 1.35; font-weight: 700; overflow-wrap: anywhere; }
.queue-row,
.queue-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}
.queue-row .badge { flex: 0 0 auto; }
.queue-foot {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  font-weight: 900;
}
.queue-foot span { min-width: 0; overflow-wrap: anywhere; }
.empty-state {
  min-height: 340px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
  border: 1px dashed var(--line);
  border-radius: 8px;
}
.compact-empty { min-height: 160px; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}
.detail-grid div, .feature {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fbfdfb;
}
.score-table { width: 100%; border-collapse: collapse; margin: 14px 0; table-layout: fixed; }
.score-table th, .score-table td { border: 1px solid var(--line); padding: 9px; text-align: left; }
.score-table th { background: #eef6ec; }
.score-table th:first-child,
.score-table td:first-child { width: 190px; }
.score-table th:nth-child(2),
.score-table td:nth-child(2) { width: 110px; text-align: center; }
.score-pill { color: var(--green); font-weight: 900; }
.review-score {
  min-height: 38px;
  min-width: 86px;
  padding: 6px 8px;
  font-weight: 900;
}
.comments-editor {
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.comments-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 10px;
}
.comments-editor-head h2 { font-size: 18px; }
.comments-editor textarea {
  display: block;
  width: 100%;
  min-height: 560px;
  max-height: 75vh;
  line-height: 1.62;
  font-size: 16px;
  padding: 18px;
  resize: vertical;
  background: #fbfdfb;
}
.feedback-editor textarea {
  min-height: 170px;
  max-height: 360px;
}
.feedback-note {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #f3b5ad;
  border-radius: 8px;
  background: #fff7f6;
}
.teacher-feedback {
  margin: 0 0 16px;
}
.feedback-note p {
  margin: 0;
  color: #7a271a;
  line-height: 1.5;
  font-weight: 800;
  white-space: pre-wrap;
}
.signature-field {
  width: min(460px, 100%);
  margin-top: 14px;
}

.admin-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 18px;
  align-items: start;
}
.admin-shell .panel:first-child { grid-row: span 2; }
.upload-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.search-row {
  display: grid;
  grid-template-columns: minmax(240px, 420px) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.admin-actions { margin-top: 12px; }
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid #cfd8d0;
  border-radius: 7px;
  padding: 9px 13px;
  color: var(--navy);
  background: #fff;
  text-decoration: none;
  font-weight: 900;
}
.column-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.result-box, .feature-grid { display: grid; gap: 10px; margin-top: 16px; }
.feature {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.feature span:last-child { text-align: right; }
.report-admin-panel { grid-column: 1 / -1; }
.report-list { display: grid; gap: 10px; }
.report-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}
.report-row strong,
.report-row span,
.report-row small { display: block; }
.report-row small { margin-top: 3px; color: var(--muted); font-weight: 800; }
.report-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.admin-command-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, .82fr);
  gap: 18px;
  align-items: start;
}
.admin-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  border-top: 4px solid var(--green);
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.hero-copy,
.section-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-weight: 800;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.metric-card {
  min-height: 96px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfdfb, #fff);
}
.metric-card span,
.metric-card small {
  color: var(--muted);
  font-weight: 900;
}
.metric-card strong {
  font-size: 28px;
  line-height: 1;
  color: var(--green);
}
.access-panel { grid-row: span 2; }
.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}
.user-admin-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.user-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.user-card-head,
.user-actions,
.user-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.user-card-head strong,
.user-card-head span { display: block; }
.user-card-head span,
.user-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.permission-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.user-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.password-reset-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.audit-list {
  display: grid;
  gap: 10px;
}
.audit-row {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}
.audit-row strong,
.audit-row span { display: block; }
.audit-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}
.audit-row code {
  display: block;
  min-width: 0;
  padding: 8px 10px;
  overflow: auto;
  border-radius: 7px;
  background: #eef3ef;
  color: var(--navy);
  font-size: 12px;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow);
  font-weight: 900;
}

@media (max-width: 1040px) {
  .select-grid, .mini-grid { grid-template-columns: 1fr 1fr; }
  .teacher-grid, .review-shell, .admin-shell, .admin-command-shell, .admin-hero { grid-template-columns: 1fr; }
  .roster-panel, .queue-panel { position: static; max-height: none; }
  .admin-shell .panel:first-child { grid-row: auto; }
  .access-panel, .admin-hero { grid-column: auto; grid-row: auto; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-create-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1041px) and (max-width: 1280px) {
  .review-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }
}

@media (max-width: 700px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .brand { min-width: 0; }
  .role-nav { width: 100%; }
  .role-nav a { flex: 1; min-width: 0; }
  .page-shell { padding: 14px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .topbar-actions .badge { flex: 1 1 100%; }
  .topbar-actions .button-link,
  .topbar-actions button { flex: 1 1 150px; }
  .select-grid, .mini-grid, .date-row, .detail-grid, .upload-row, .search-row, .queue-stats, .metric-grid, .admin-create-grid, .user-edit-grid, .password-reset-row, .audit-row { grid-template-columns: 1fr; }
  .criterion { grid-template-columns: 1fr; }
  .signature-canvas { height: 240px; }
  .signature-tools { width: 100%; justify-content: stretch; }
  .signature-tools .file-button,
  .signature-tools button { flex: 1 1 150px; }
  .rating-group { grid-template-columns: repeat(5, minmax(38px, 1fr)); }
  .actions button, .review-actions button { flex: 1 1 180px; }
  .report-row { align-items: stretch; flex-direction: column; }
  .report-actions { justify-content: flex-start; }
}
