body {
  background: #f6f7f9;
  color: #1f2933;
}

.app-main {
  max-width: 1480px;
}

.navbar {
  min-height: 56px;
}

.navbar .nav-link.active {
  color: #0d6efd;
  font-weight: 600;
}

.page-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.15rem;
}

.page-title h1 {
  color: #0f172a;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
  line-height: 1.2;
  margin: 0;
}

.page-kicker {
  color: #64748b;
  font-size: .9rem;
  margin-top: .25rem;
}

.page-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: flex-end;
}

.page-narrow {
  max-width: 720px;
}

.panel {
  background: #fff;
  border-radius: 8px;
  padding: 1.25rem;
}

.metric {
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  min-height: 92px;
  padding: 1rem;
}

.metric span {
  color: #667085;
  display: block;
  font-size: .875rem;
  margin-bottom: .35rem;
}

.metric strong {
  display: block;
  font-size: clamp(1.25rem, 1.8vw, 1.75rem);
  line-height: 1.2;
}

.action-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  max-width: 920px;
}

.login-wrap {
  display: grid;
  min-height: calc(100vh - 110px);
  place-items: center;
}

.login-panel {
  background: #fff;
  border-radius: 8px;
  max-width: 420px;
  padding: 2rem;
  width: 100%;
}

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

.summary-card {
  background: #fff;
  border: 1px solid #d9dee7;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  min-height: 76px;
  padding: .85rem 1rem;
}

.summary-card span {
  color: #526070;
  display: block;
  font-size: .8rem;
  line-height: 1.2;
  margin-bottom: .35rem;
}

.summary-card strong {
  color: #0f172a;
  display: block;
  font-size: 1.55rem;
  line-height: 1;
}

.summary-card .summary-text {
  font-size: 1rem;
  line-height: 1.2;
}

.data-panel {
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  overflow: hidden;
}

.data-panel-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid #d9dee7;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: .8rem 1rem;
}

.data-panel-header h2 {
  color: #0f172a;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.panel-body {
  padding: 1rem;
}

.data-table-scroll {
  max-height: calc(100vh - 300px);
  min-height: 260px;
  overflow: auto;
}

.data-table-scroll-lg {
  max-height: calc(100vh - 340px);
}

.dashboard-action-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  padding: 1rem;
}

.dashboard-action {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  color: #1f2937;
  display: flex;
  gap: .75rem;
  min-height: 64px;
  padding: .9rem 1rem;
  text-decoration: none;
}

.dashboard-action:hover {
  background: #eef6ff;
  border-color: #cfe2f7;
  color: #0d6efd;
}

.dashboard-action i {
  align-items: center;
  background: #fff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  display: inline-flex;
  font-size: 1rem;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.dashboard-action span {
  font-weight: 700;
}

.table {
  background: #fff;
}

.data-table {
  margin-bottom: 0;
}

.data-table thead th {
  background: #f8fafc;
  border-bottom: 1px solid #cfd7e3;
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table td,
.data-table th {
  padding: .65rem .8rem;
}

.table thead th {
  color: #4b5563;
  font-size: .82rem;
  text-transform: uppercase;
}

.table thead th.table-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table thead th.table-sortable:focus {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
}

.table thead th.table-sortable::after {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid #9ca3af;
  content: "";
  display: inline-block;
  margin-left: .4rem;
  opacity: .5;
  transform: translateY(2px);
}

.table thead th.table-sortable[data-sort-direction="asc"]::after {
  border-bottom: 4px solid #0d6efd;
  border-top: 0;
  opacity: 1;
  transform: translateY(-1px);
}

.table thead th.table-sortable[data-sort-direction="desc"]::after {
  border-top-color: #0d6efd;
  opacity: 1;
}

.empty-row {
  color: #667085;
  padding: 1.1rem !important;
}

.code-pill,
.formula-pill {
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #d8e0ea;
  border-radius: 999px;
  color: #1f2937;
  display: inline-flex;
  font-size: .8rem;
  font-weight: 700;
  justify-content: center;
  min-width: 2.25rem;
  padding: .15rem .5rem;
}

.formula-pill {
  background: #eef6ff;
  border-color: #cfe2f7;
  color: #24537a;
}

.status-badge {
  background: #f1f5f9;
  border: 1px solid #d8e0ea;
  border-radius: 999px;
  color: #334155;
  display: inline-flex;
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.2;
  padding: .2rem .55rem;
  white-space: nowrap;
}

.status-warning {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.status-ok {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}

.score-chip {
  background: #f8fafc;
  border: 1px solid #d9dee7;
  border-radius: 6px;
  color: #111827;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 3.5rem;
  padding: .15rem .45rem;
  text-align: right;
}

.table-actions {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: flex-end;
}

.table-actions form {
  display: inline-flex;
  margin: 0;
}

.icon-btn {
  align-items: center;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}

.option-distribution {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  min-width: 170px;
}

.option-chip {
  align-items: center;
  border: 1px solid #d9dee7;
  border-radius: 999px;
  display: inline-flex;
  font-size: .78rem;
  overflow: hidden;
}

.option-chip span {
  background: #f1f5f9;
  color: #475569;
  font-weight: 700;
  padding: .1rem .35rem;
}

.option-chip strong {
  color: #111827;
  font-weight: 600;
  min-width: 1.6rem;
  padding: .1rem .4rem;
  text-align: center;
}

.area-score-list {
  display: grid;
  gap: .15rem;
  min-width: 190px;
}

.area-score-list span {
  color: #334155;
  font-size: .82rem;
  line-height: 1.25;
}

.area-average-grid {
  display: grid;
  gap: .75rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  padding: 1rem;
}

.area-average-card {
  align-items: center;
  background: #f8fafc;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: 76px;
  padding: .9rem 1rem;
}

.area-average-card span,
.area-average-card small {
  display: block;
  line-height: 1.25;
}

.area-average-card span {
  color: #0f172a;
  font-weight: 700;
}

.area-average-card small {
  color: #64748b;
  font-size: .78rem;
  margin-top: .2rem;
}

.area-average-card strong {
  color: #0f172a;
  flex: 0 0 auto;
  font-size: 1.35rem;
  line-height: 1;
}

.result-table {
  font-size: .9rem;
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

.result-table td,
.result-table th {
  line-height: 1.25;
  overflow-wrap: anywhere;
  padding: .7rem .75rem;
  white-space: normal;
}

.result-table thead th {
  color: #334155;
  font-size: .74rem;
  letter-spacing: 0;
  line-height: 1.15;
}

.result-table thead th.table-sortable {
  white-space: normal;
}

.result-table thead th span {
  color: #64748b;
  display: block;
  font-size: .68rem;
  font-weight: 700;
}

.result-col-applicant {
  width: 30%;
}

.result-col-responses {
  width: 10%;
}

.result-col-exam {
  width: 10%;
}

.result-col-presentation {
  width: 10%;
}

.result-col-bonus {
  width: 12%;
}

.result-col-final {
  width: 10%;
}

.result-col-areas {
  width: 18%;
}

.result-table .code-pill {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-table .score-chip {
  min-width: 0;
  max-width: 100%;
}

.result-table .status-badge {
  border-radius: 6px;
  justify-content: center;
  max-width: 100%;
  text-align: center;
  white-space: normal;
}

.result-response-pair,
.result-bonus-list {
  display: inline-grid;
  gap: .1rem;
  line-height: 1.15;
}

.result-response-pair strong {
  color: #111827;
  font-weight: 700;
}

.result-response-pair span,
.result-bonus-list span {
  color: #475569;
  font-size: .78rem;
}

.result-table .area-score-list {
  min-width: 0;
}

.result-table .area-score-list span {
  font-size: .78rem;
  overflow-wrap: normal;
}

.result-applicant-cell {
  display: grid;
  gap: .28rem;
}

.result-applicant-cell strong {
  color: #0f172a;
  font-weight: 700;
}

.result-applicant-cell > span {
  align-items: center;
  color: #475569;
  display: flex;
  flex-wrap: wrap;
  font-size: .82rem;
  gap: .35rem;
}

.issue-table {
  min-width: 980px;
}

.item-number input {
  max-width: 84px;
}

.review-image {
  border: 1px solid #d9dee7;
  border-radius: 8px;
  max-width: 100%;
}

.omr-reading-layout {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.omr-image-frame {
  overflow: auto;
}

.omr-readout {
  background: #f8fafc;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 1rem;
}

.omr-readout h3 {
  color: #0f172a;
  font-size: .95rem;
  font-weight: 700;
  margin: 0 0 .85rem;
}

.readout-list {
  display: grid;
  gap: .6rem;
  margin: 0 0 1rem;
}

.readout-list div {
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: .6rem;
}

.readout-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.readout-list dt {
  color: #64748b;
  font-size: .76rem;
  line-height: 1.2;
  margin-bottom: .2rem;
  text-transform: uppercase;
}

.readout-list dd {
  color: #0f172a;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  overflow-wrap: anywhere;
}

.answer-readout-grid {
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.answer-readout-grid div {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: .65rem .75rem;
}

.answer-readout-grid span {
  color: #64748b;
  display: block;
  font-size: .75rem;
  line-height: 1.2;
  margin-bottom: .25rem;
}

.answer-readout-grid strong {
  color: #0f172a;
  display: block;
  font-size: 1.25rem;
  line-height: 1;
}

.readout-note {
  color: #475569;
  font-size: .86rem;
  margin: .85rem 0 0;
}

.processing-cell {
  align-items: center;
  display: flex;
  gap: .75rem;
  max-width: 420px;
}

.processing-progress {
  background: #e5e7eb;
  flex: 1 1 180px;
  height: .7rem;
  min-width: 140px;
}

.processing-percent {
  color: #111827;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  min-width: 4rem;
  text-align: right;
}

select.form-select,
input.form-control {
  min-height: 38px;
}

.machote-table-wrap {
  max-height: calc(100vh - 330px);
  min-height: 420px;
  overflow: auto;
}

.machote-table {
  margin-bottom: 0;
  min-width: 920px;
  table-layout: fixed;
}

.machote-table thead th {
  background: #f8fafc;
  border-bottom: 1px solid #cfd7e3;
  position: sticky;
  top: 0;
  z-index: 2;
}

.machote-table td,
.machote-table th {
  padding: .55rem .75rem;
}

.machote-table .machote-item-col {
  width: 72px;
}

.machote-table .machote-type-col {
  width: 180px;
}

.machote-table .formula-a-head {
  background: #edf4fb;
  border-left: 1px solid #d8e6f3;
  color: #24537a;
}

.machote-table .formula-b-head {
  background: #eef8f2;
  border-left: 2px solid #c9d8cf;
  color: #2f6847;
}

.machote-table .formula-a-cell {
  background: #f7fbff;
}

.machote-table .formula-b-cell {
  background: #f8fcf9;
}

.machote-table .formula-split {
  border-left: 2px solid #d6dde5;
}

.machote-scored-fields,
.machote-experimental-fields,
.machote-formula-block {
  align-items: end;
  display: grid;
  gap: .75rem;
}

.machote-scored-fields {
  grid-template-columns: minmax(260px, 380px) 120px;
  max-width: 540px;
}

.machote-experimental-fields {
  grid-template-columns: repeat(2, minmax(260px, 340px));
  max-width: 760px;
}

.machote-formula-block {
  border-left: 3px solid #d6dde5;
  grid-template-columns: minmax(180px, 1fr) 110px;
  padding: .45rem .75rem;
}

.machote-formula-block strong {
  color: #4b5563;
  font-size: .78rem;
  grid-column: 1 / -1;
  text-transform: uppercase;
}

.machote-scored-fields label,
.machote-formula-block label {
  margin: 0;
}

.machote-scored-fields span,
.machote-formula-block span {
  color: #667085;
  display: block;
  font-size: .75rem;
  line-height: 1.1;
  margin-bottom: .15rem;
  text-transform: uppercase;
}

.machote-config-cell .form-select-sm {
  min-height: 34px;
}

.machote-row.is-scored .machote-experimental-fields,
.machote-row.is-experimental .machote-scored-fields {
  display: none;
}

.machote-table tbody tr:hover .formula-a-cell {
  background: #eef6fd;
}

.machote-table tbody tr:hover .formula-b-cell {
  background: #eef8f2;
}

@media (max-width: 900px) {
  .page-header,
  .data-panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions,
  .page-actions .btn,
  .page-actions form,
  .data-panel-header .btn {
    width: 100%;
  }

  .machote-table-wrap {
    max-height: none;
  }

  .machote-scored-fields,
  .machote-experimental-fields,
  .machote-formula-block {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .omr-reading-layout {
    grid-template-columns: 1fr;
  }
}
