.bac-page {
  display: grid;
  gap: 1.25rem;
}

.teacher-page {
  display: grid;
  gap: 1.25rem;
}

.bac-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde4f0);
  border-radius: 8px;
  padding: 1.4rem;
  box-shadow: var(--shadow, 0 2px 16px rgba(21,101,192,.10));
}

.bac-kicker {
  margin: 0 0 .25rem;
  color: var(--accent, #ff6f00);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.bac-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.15rem);
}

.bac-intro {
  margin: .55rem 0 0;
  color: var(--text-sec, #64748b);
  max-width: 680px;
}

.bac-header-action,
.bac-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--primary, #1565c0);
  color: #fff;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.bac-header-action {
  padding: .65rem 1rem;
}

.bac-link {
  padding: .45rem .7rem;
  font-size: .86rem;
}

.bac-link-secondary {
  background: #0f766e;
}

.bac-link-correction {
  background: #b45309;
}

.teacher-latex-link {
  background: #5b21b6;
}

.teacher-tutor-link,
.teacher-viewer-transfer {
  background: #9333ea;
  white-space: normal;
}

.teacher-generate-correction {
  border: 0;
  cursor: pointer;
  background: #0f766e;
}

.teacher-correction-link {
  background: #047857;
}

.teacher-correction-missing {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border, #dde4f0);
  border-radius: 6px;
  color: var(--text-sec, #64748b);
  font-size: .84rem;
  font-weight: 800;
  line-height: 1.2;
  padding: .42rem .65rem;
  white-space: nowrap;
}

.teacher-correction-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .85rem;
}

.teacher-correction-status {
  color: var(--text-sec, #64748b);
  font-weight: 700;
}

.bac-header-action:hover,
.bac-link:hover {
  color: #fff;
  opacity: .88;
  text-decoration: none;
}

.bac-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 180px) minmax(180px, 260px);
  gap: .9rem;
  align-items: end;
}

.bac-search,
.bac-filter {
  display: grid;
  gap: .3rem;
  color: var(--text-sec, #64748b);
  font-size: .82rem;
  font-weight: 700;
}

.bac-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
}

.bac-search input,
.bac-filter select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border, #dde4f0);
  border-radius: 6px;
  background: var(--card-bg, #fff);
  color: var(--text, #1a1a2e);
  font: inherit;
  font-weight: 500;
  padding: .55rem .7rem;
}

.bac-search-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--primary, #1565c0);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1.2;
  padding: .55rem .9rem;
  white-space: nowrap;
}

.bac-search-button:hover,
.bac-search-button:focus {
  opacity: .88;
}

.bac-section {
  display: grid;
  gap: .8rem;
}

.bac-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.bac-section-head h2 {
  margin: 0;
}

.bac-section-head p {
  margin: .2rem 0 0;
  color: var(--text-sec, #64748b);
}

.bac-paper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: .9rem;
}

.bac-paper-card {
  display: grid;
  gap: .7rem;
  align-content: start;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde4f0);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: var(--shadow, 0 2px 16px rgba(21,101,192,.10));
}

.bac-paper-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.bac-year {
  display: inline-flex;
  border-radius: 999px;
  background: var(--primary, #1565c0);
  color: #fff;
  padding: .18rem .55rem;
  font-size: .76rem;
  font-weight: 900;
}

.bac-paper-card h3 {
  margin: 0;
  color: var(--primary-dark, #0d47a1);
}

.bac-paper-day {
  margin: 0;
  color: var(--text-sec, #64748b);
  font-weight: 800;
}

.bac-table-wrap {
  overflow-x: auto;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde4f0);
  border-radius: 8px;
  box-shadow: var(--shadow, 0 2px 16px rgba(21,101,192,.10));
}

.bac-table {
  width: 100%;
  min-width: 960px;
  border-collapse: collapse;
  font-size: .92rem;
  table-layout: fixed;
}

.teacher-table {
  min-width: 920px;
}

.teacher-table th:nth-child(1),
.teacher-table td:nth-child(1) {
  width: 8%;
}

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

.teacher-table th:nth-child(3),
.teacher-table td:nth-child(3) {
  width: 10%;
}

.teacher-table th:nth-child(4),
.teacher-table td:nth-child(4) {
  width: 16%;
}

.teacher-table th:nth-child(5),
.teacher-table td:nth-child(5) {
  width: 32%;
}

.teacher-table th:nth-child(6),
.teacher-table td:nth-child(6) {
  width: 16%;
}

.bac-table th:nth-child(1),
.bac-table td:nth-child(1) {
  width: 13%;
}

.bac-table th:nth-child(2),
.bac-table td:nth-child(2) {
  width: 13%;
}

.bac-table th:nth-child(3),
.bac-table td:nth-child(3) {
  width: 10%;
}

.bac-table th:nth-child(4),
.bac-table td:nth-child(4) {
  width: 24%;
}

.bac-table th:nth-child(5),
.bac-table td:nth-child(5) {
  width: 20%;
}

.bac-table th:nth-child(6),
.bac-table td:nth-child(6) {
  width: 8%;
}

.bac-table th:nth-child(7),
.bac-table td:nth-child(7) {
  width: 12%;
}

.bac-table th,
.bac-table td {
  padding: .8rem .85rem;
  border-bottom: 1px solid var(--border, #dde4f0);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

.bac-table th {
  position: sticky;
  top: 0;
  background: var(--primary-light, #e3f2fd);
  color: var(--primary-dark, #0d47a1);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  z-index: 1;
}

.bac-table tbody tr:hover {
  background: rgba(21, 101, 192, .055);
}

.bac-document-actions {
  display: grid;
  gap: .45rem;
}

.bac-document-actions .bac-link {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  white-space: normal;
  text-align: center;
}

.bac-muted {
  color: var(--text-sec, #64748b);
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
}

.bac-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.bac-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--primary-light, #e3f2fd);
  color: var(--primary-dark, #0d47a1);
  padding: .22rem .55rem;
  font-size: .78rem;
  font-weight: 700;
  text-decoration: none;
}

.bac-chip:hover {
  text-decoration: none;
  opacity: .82;
}

.bac-level {
  display: inline-flex;
  border-radius: 999px;
  background: var(--accent-light, #fff3e0);
  color: #9a4d00;
  padding: .22rem .55rem;
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}

.bac-empty {
  margin: 0;
  padding: 1rem;
  color: var(--text-sec, #64748b);
  font-weight: 700;
}

.bac-viewer {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde4f0);
  border-radius: 8px;
  box-shadow: var(--shadow, 0 2px 16px rgba(21,101,192,.10));
  overflow: hidden;
}

.bac-viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border, #dde4f0);
  background: var(--primary-light, #e3f2fd);
}

.bac-viewer-toolbar h2 {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--primary-dark, #0d47a1);
  font-size: 1rem;
}

.bac-viewer-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.bac-viewer-link,
.bac-viewer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border, #dde4f0);
  font: inherit;
  font-size: .84rem;
  font-weight: 800;
  line-height: 1.2;
  padding: .4rem .7rem;
  cursor: pointer;
  text-decoration: none;
}

.bac-viewer-link {
  background: #fff;
  color: var(--primary-dark, #0d47a1);
}

.bac-viewer-close {
  background: var(--primary-dark, #0d47a1);
  color: #fff;
}

.bac-viewer-link:hover,
.bac-viewer-close:hover {
  opacity: .88;
  text-decoration: none;
}

.bac-pdf-frame {
  display: block;
  width: 100%;
  height: min(78vh, 860px);
  min-height: 560px;
  border: 0;
  background: #f8fafc;
}

.bac-sources {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde4f0);
  border-radius: 8px;
  padding: 1rem 1.2rem;
}

.teacher-compose-panel {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #dde4f0);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow, 0 2px 16px rgba(21,101,192,.10));
}

.teacher-compose-panel h2 {
  margin: 0;
  color: var(--primary-dark, #0d47a1);
  font-size: 1.15rem;
}

.teacher-compose-panel p {
  margin: .45rem 0 0;
  color: var(--text-sec, #64748b);
}

.bac-sources h2 {
  margin-top: 0;
}

@media (max-width: 720px) {
  .bac-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .bac-toolbar {
    grid-template-columns: 1fr;
  }

  .bac-search-control {
    grid-template-columns: 1fr;
  }

  .bac-viewer-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .bac-pdf-frame {
    height: 72vh;
    min-height: 420px;
  }
}
