* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  background: #eef3f8;
  color: #1f2937;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px 1fr;
  min-height: 100vh;
}

.app-shell.grading-focus {
  grid-template-columns: 1fr;
}

.app-shell.teacher-shell-minimal {
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.app-shell.grading-focus .sidebar {
  display: none;
}

.app-shell.teacher-shell-minimal .sidebar {
  display: none;
}

.app-shell.grading-focus .main-content {
  padding: 0;
  gap: 0;
  min-height: 100vh;
}

.app-shell.teacher-shell-minimal .main-content {
  padding: 0;
  gap: 0;
  min-height: 100vh;
  background: #eef2f7;
}

.app-shell.grading-focus #banner {
  display: none !important;
}

.app-shell.teacher-shell-minimal #banner {
  display: none !important;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #16233d 100%);
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(148, 163, 184, 0.12);
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.brand p,
.muted {
  margin: 4px 0 0;
  color: #94a3b8;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item,
.sidebar-actions button {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  background: rgba(30, 41, 59, 0.95);
  color: #fff;
  transition:
    background 0.18s ease,
    transform 0.18s ease;
}

.nav-item.active {
  background: #2563eb;
}

.nav-item:hover,
.sidebar-actions button:hover {
  transform: translateY(-1px);
}

.main-content {
  padding: 24px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  background: #dbeafe;
  color: #1d4ed8;
}

.card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, 0.06);
  padding: 20px;
  border: 1px solid #e2e8f0;
}

.view {
  display: grid;
  gap: 16px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.2);
  border-color: #2563eb;
}

.readonly-box,
.form-grid input[readonly],
.form-grid textarea[readonly] {
  background: #f8fafc;
  color: #334155;
}

.checkbox-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.checkbox-row input {
  width: auto;
}

.full-width {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
}

button.secondary,
.button-link.secondary {
  background: #475569;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
}

button:hover {
  filter: brightness(1.03);
}

.top-gap {
  margin-top: 16px;
}

.hint {
  color: #64748b;
}

.section-note {
  margin: 10px 0 0;
  color: #64748b;
  font-size: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
  border: 1px solid #dbeafe;
}

.metric-card .label {
  color: #475569;
  font-size: 13px;
}

.metric-card .value {
  margin-top: 8px;
  font-size: 25px;
  font-weight: 700;
  color: #1e3a8a;
}

.metric-note {
  margin-top: 6px;
  color: #64748b;
  font-size: 13px;
}

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

.classroom-item {
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.classroom-item-main {
  display: grid;
  gap: 4px;
}

.classroom-item-meta {
  color: #475569;
  font-size: 14px;
}

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

.table-wrap {
  overflow-x: auto;
}

.roster-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.roster-table th,
.roster-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 8px;
  vertical-align: middle;
  text-align: left;
  font-size: 14px;
}

.roster-table th {
  color: #0f172a;
  font-weight: 700;
  background: #f8fafc;
}

.roster-table input,
.roster-table select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: white;
  font-size: 14px;
}

.roster-table .roster-stt {
  width: 64px;
  color: #334155;
  font-weight: 600;
}

.roster-table .roster-actions {
  width: 92px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.one-col-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
}

.code-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  font-weight: 600;
}

.subtle-text {
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
}

.empty-state {
  padding: 16px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  color: #64748b;
  background: #f8fafc;
}

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}

th {
  color: #475569;
  font-size: 13px;
  background: #f8fafc;
  position: sticky;
  top: 0;
}

.json-view {
  overflow: auto;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 10px;
  padding: 14px;
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #e2e8f0;
}

.json-view-compact {
  min-height: 56px;
  max-height: 96px;
  padding: 10px 12px;
  font-size: 13px;
}

.stack-note {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.status-note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
}

.status-note.warning {
  background: #fefce8;
  border-color: #fde68a;
  color: #92400e;
}

.status-note.ok {
  background: #ecfdf5;
  border-color: #86efac;
  color: #166534;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
}

.inline-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.grading-frame-wrap {
  width: 100%;
  min-height: 960px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.grading-frame-wrap iframe {
  width: 100%;
  min-height: 960px;
  border: 0;
  background: #fff;
}

.app-shell.grading-focus .grading-shell-card {
  margin: 0;
  padding: 12px 16px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.app-shell.teacher-shell-minimal .grading-shell-card {
  margin: 0;
  padding: 8px 14px;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

.app-shell.grading-focus .grading-shell-card h2 {
  margin: 0;
  font-size: 22px;
  min-height: 52px;
}

.app-shell.grading-focus .grading-shell-card .section-header {
  gap: 10px;
  align-items: center;
}

.grading-context-inline {
  margin-top: 8px;
  color: #475569;
  font-size: 14px;
}

.app-shell.grading-focus .grading-frame-card {
  margin: 0;
  padding: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  min-height: calc(100vh - 92px);
}

.app-shell.teacher-shell-minimal .grading-frame-card {
  margin: 0;
  padding: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  min-height: calc(100vh - 54px);
}

.app-shell.grading-focus .grading-frame-wrap,
.app-shell.grading-focus .grading-frame-wrap iframe {
  min-height: calc(100vh - 92px);
  border: 0;
  border-radius: 0;
}

.app-shell.teacher-shell-minimal .grading-frame-wrap,
.app-shell.teacher-shell-minimal .grading-frame-wrap iframe {
  min-height: calc(100vh - 54px);
  border: 0;
  border-radius: 0;
}

.app-shell.grading-focus #grading-exit-focus-btn {
  display: inline-flex !important;
}

.app-shell.teacher-shell-minimal #grading-exit-focus-btn,
.app-shell.teacher-shell-minimal #grading-back-homework-btn {
  display: none !important;
}

.app-shell.teacher-shell-minimal .grading-context-inline {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

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

.app-shell.teacher-shell-minimal .grading-minimal-bar {
  min-height: 34px;
}

.app-shell.teacher-shell-minimal .grading-minimal-bar .secondary {
  padding: 8px 14px;
  border-radius: 9px;
}

.app-shell.teacher-shell-minimal .grading-frame-wrap {
  background: #ffffff;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.quick-action-card {
  min-width: 220px;
  flex: 1 1 220px;
  border: 1px solid #dbeafe;
  border-radius: 18px;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  padding: 18px;
}

.quick-action-card h4 {
  margin: 0 0 6px;
  font-size: 16px;
}

.quick-action-card p {
  margin: 0 0 12px;
  color: #475569;
  font-size: 14px;
}

.quick-action-card-admin {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #eef2ff 0%, #ffffff 100%);
}

.quick-action-value {
  color: #1d4ed8;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

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

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

  .classroom-item-actions {
    justify-content: flex-start;
  }
}
