.app-main {
  min-height: calc(100vh - 72px);
}

.app-alert {
  margin: 18px clamp(18px, 4vw, 56px) 0;
  padding: 14px 16px;
  background: #e7f7ec;
  border: 1px solid #b7e4c4;
  border-radius: 8px;
  color: #0b6b2a;
  font-weight: 700;
}

.app-alert.danger {
  color: #9b2c1f;
  background: #ffe7df;
  border-color: #ffc2b5;
}

.app-alert.warning {
  color: #7a5200;
  background: #fff0bd;
  border-color: #f5d66e;
}

.app-card {
  padding: 24px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.review-chip {
  min-height: 34px;
  padding: 6px 14px;
  color: #0b6b2a;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.app-status {
  margin-bottom: 18px;
}

.dashboard-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.dashboard-overview .app-status {
  margin-bottom: 0;
}

.dashboard-overview > :only-child {
  grid-column: 1 / -1;
}

.exam-workflow-panel {
  display: grid;
  align-content: start;
  gap: 18px;
  min-height: 100%;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.workflow-head {
  display: grid;
  justify-items: start;
  gap: 10px;
}

.workflow-head h3 {
  margin-bottom: 0;
}

.workflow-steps {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.workflow-steps li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.workflow-steps li > span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 700;
}

.workflow-steps strong {
  display: block;
  margin-bottom: 4px;
}

.workflow-steps p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.workflow-steps a {
  color: var(--blue);
  font-size: 14px;
  font-weight: 700;
}

.app-actions a {
  color: inherit;
}

select,
textarea,
.login-panel input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-family: "Inter", "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.login-panel {
  padding: 28px;
}

.login-panel h3 {
  margin-bottom: 18px;
  font-size: 22px;
  line-height: 1.3;
}

.login-panel label {
  font-size: 15px;
}

.login-panel textarea {
  min-height: 112px;
}

.admin-content {
  padding: 28px;
}

.checkbox-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.checkbox-list label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 600;
}

.question-grid a {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f6f8;
  font-size: 14px;
  font-weight: 800;
}

.countdown-box strong {
  font-variant-numeric: tabular-nums;
}

.question-grid a.done {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.question-grid a.current {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.full {
  width: 100%;
  margin-top: 12px;
}

.danger-text {
  color: var(--red);
  font-weight: 800;
}

.result-detail {
  margin-top: 18px;
}

.muted-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.room-capture-panel {
  display: grid;
  gap: 20px;
}

.room-capture-head {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.room-capture-head h3 {
  margin: 10px 0 0;
}

.room-capture-head .muted-note {
  margin: 0;
  max-width: 820px;
}

.room-capture-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(170px, 0.8fr) minmax(220px, 0.9fr);
  gap: 16px;
  align-items: end;
}

.room-capture-grid label {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 15px;
}

.room-capture-grid input,
.room-capture-grid select {
  width: 100%;
  min-height: 46px;
}

.room-note-field {
  grid-column: 1 / -1;
}

.room-capture-actions {
  display: flex;
  justify-content: flex-start;
}

.class-info-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.class-info-item {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.class-info-item p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}

.class-info-item strong {
  display: inline-block;
  min-width: 78px;
  color: #344054;
}

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

.compact-table .table-row {
  gap: 0;
  padding: 0;
}

.compact-table .table-row > span {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  word-break: normal;
  overflow-wrap: anywhere;
}

.compact-table .table-row > span:last-child {
  border-right: 0;
}

.compact-table .table-head > span {
  min-height: 48px;
  color: #344054;
  font-weight: 700;
}

.compact-table .table-row:not(.table-head):hover {
  background: #f8fbfd;
}

.class-row {
  grid-template-columns: minmax(140px, 0.9fr) minmax(180px, 1fr) minmax(150px, 0.8fr);
  min-width: 620px;
}

.period-row {
  grid-template-columns: minmax(120px, 0.9fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(110px, 0.8fr);
  min-width: 680px;
}

.room-row {
  grid-template-columns: minmax(150px, 1fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr) minmax(220px, 1.4fr);
  min-width: 700px;
}

.class-row > span:nth-child(3),
.period-row > span:nth-child(2),
.period-row > span:nth-child(3),
.period-row > span:nth-child(4),
.room-row > span:nth-child(2),
.room-row > span:nth-child(3) {
  justify-content: center;
  text-align: center;
}

.import-template {
  margin-top: 18px;
}

.import-template.second {
  margin-top: 12px;
}

.error-list {
  display: grid;
  gap: 8px;
  color: var(--red);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.student-checks {
  margin-bottom: 16px;
}

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

.row-actions a,
.row-actions button {
  min-height: 30px;
  padding: 4px 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.row-actions form {
  margin: 0;
}

.password-panel {
  max-width: 520px;
}

.report-filter {
  margin-bottom: 18px;
}

.exam-row {
  grid-template-columns: minmax(220px, 1.4fr) 0.6fr 0.5fr 0.6fr minmax(130px, 0.7fr);
}

.category-row {
  grid-template-columns: minmax(180px, 1fr) 0.35fr minmax(220px, 1.2fr) minmax(130px, 0.7fr);
}

.question-row {
  grid-template-columns: minmax(150px, 0.8fr) 0.55fr minmax(220px, 1.25fr) minmax(130px, 0.7fr);
}

.question-image-preview,
.question-image {
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.question-image-preview img,
.question-image img {
  display: block;
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
}

.inline-check {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.result-question-thumb {
  max-width: 120px;
  max-height: 80px;
  margin-top: 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.template-preview {
  margin-bottom: 18px;
}

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

.drag-scroll {
  cursor: grab;
  scroll-behavior: auto;
}

.drag-scroll.dragging {
  cursor: grabbing;
  user-select: none;
}

.drag-scroll.dragging * {
  user-select: none;
}

.question-template-row {
  grid-template-columns: 150px 260px repeat(4, 120px) 110px 220px 260px;
  min-width: 1530px;
}

.student-template-row {
  grid-template-columns:
    minmax(90px, max-content)
    minmax(150px, max-content)
    minmax(88px, max-content)
    minmax(128px, max-content)
    minmax(96px, max-content)
    minmax(120px, max-content)
    minmax(140px, max-content)
    minmax(110px, max-content);
  width: max-content;
  min-width: 100%;
  gap: 0;
  padding: 0;
}

.student-template-row > span {
  display: flex;
  align-items: center;
  min-height: 54px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.student-template-row > span:last-child {
  border-right: 0;
}

.table-head.student-template-row > span {
  min-height: 50px;
  color: #344054;
  font-weight: 700;
}

.student-template-row > span:nth-child(1),
.student-template-row > span:nth-child(3),
.student-template-row > span:nth-child(4),
.student-template-row > span:nth-child(5),
.student-template-row > span:nth-child(8) {
  justify-content: center;
  text-align: center;
}

.signature-row {
  grid-template-columns: 56px 120px minmax(220px, 1.4fr) 110px 90px 130px 90px 110px 170px;
  min-width: 1096px;
  gap: 0;
  padding: 0;
}

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

.signature-table .signature-row > span {
  display: flex;
  align-items: center;
  min-height: 58px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}

.signature-table .signature-row > span:last-child {
  border-right: 0;
}

.signature-table .table-head.signature-row > span {
  min-height: 52px;
  color: #344054;
  font-weight: 700;
}

.signature-table .signature-row > span:nth-child(1),
.signature-table .signature-row > span:nth-child(4),
.signature-table .signature-row > span:nth-child(5),
.signature-table .signature-row > span:nth-child(6),
.signature-table .signature-row > span:nth-child(7),
.signature-table .signature-row > span:nth-child(8) {
  justify-content: center;
  text-align: center;
}

.print-title {
  display: none;
}

.signature-footer {
  display: none;
}

.import-panel {
  max-width: none;
}

.form-actions {
  justify-content: flex-start;
}

@media (max-width: 900px) {
  .dashboard-overview {
    grid-template-columns: 1fr;
  }

  .room-capture-head,
  .room-capture-grid {
    grid-template-columns: 1fr;
  }

  .compact-table .class-row {
    grid-template-columns: minmax(140px, 0.9fr) minmax(180px, 1fr) minmax(150px, 0.8fr);
  }

  .compact-table .period-row {
    grid-template-columns: minmax(120px, 0.9fr) minmax(150px, 1fr) minmax(150px, 1fr) minmax(110px, 0.8fr);
  }

  .compact-table .room-row {
    grid-template-columns: minmax(150px, 1fr) minmax(110px, 0.7fr) minmax(110px, 0.7fr) minmax(220px, 1.4fr);
  }

  .student-template-row {
    grid-template-columns:
      minmax(90px, max-content)
      minmax(150px, max-content)
      minmax(88px, max-content)
      minmax(128px, max-content)
      minmax(96px, max-content)
      minmax(120px, max-content)
      minmax(140px, max-content)
      minmax(110px, max-content);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* UI tuning: chu thuong normal, nut/heading moi dam */
.app-alert,
.review-chip,
.login-panel label,
.checkbox-list label,
.question-grid a,
.row-actions a,
.row-actions button {
  font-weight: 400;
}

.login-panel h3,
.admin-content h3,
.question-grid a.current,
.question-grid a.done {
  font-weight: 700;
}

.score-card strong {
  font-size: clamp(36px, 5vw, 44px);
}

@media (max-width: 680px) {
  .app-alert {
    margin-left: 18px;
    margin-right: 18px;
  }

  .signature-row {
    grid-template-columns: 56px 120px minmax(220px, 1.4fr) 110px 90px 130px 90px 110px 170px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .app-alert,
  .print-hidden,
  .nav,
  .ghost-button {
    display: none !important;
  }

  .workspace {
    padding: 0;
  }

  .admin-content,
  .room-print-sheet {
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .print-title {
    display: block;
    margin-bottom: 14px;
    text-align: center;
  }

  .print-title h2 {
    margin-bottom: 6px;
    font-size: 18px;
  }

  .signature-table {
    display: block;
    overflow: visible;
    margin-top: 10px;
    border-radius: 0;
  }

  .signature-row {
    display: grid;
    grid-template-columns: 36px 82px minmax(150px, 1.2fr) 70px 58px 78px 58px 68px 100px;
    min-width: 0;
    gap: 0;
    padding: 0;
    border-bottom: 1px solid #000;
  }

  .signature-row span {
    display: flex;
    align-items: center;
    min-height: 32px;
    padding: 6px;
    border-right: 1px solid #000;
    font-size: 11px;
  }

  .signature-row span:nth-child(1),
  .signature-row span:nth-child(4),
  .signature-row span:nth-child(5),
  .signature-row span:nth-child(6),
  .signature-row span:nth-child(7),
  .signature-row span:nth-child(8) {
    justify-content: center;
    text-align: center;
  }

  .signature-row span:first-child {
    border-left: 1px solid #000;
  }

  .table-head.signature-row {
    border-top: 1px solid #000;
    font-weight: 700;
  }

  .signature-footer {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    margin-top: 28px;
    text-align: center;
    font-weight: 700;
  }
}

/* Chuẩn hóa tiêu đề trên toàn bộ trang */
h2,
.section-heading h2,
.login-panel h2,
.admin-content h2,
.question-panel h2 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

h3,
.login-panel h3,
.admin-content h3,
.question-panel h3,
.security-card h3,
.admin-card h3,
.chart-card h3,
.wrong-list h3 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
}
