:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #52606d;
  --line: #cbd5df;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --focus: #f59e0b;
  font-size: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
select {
  font: inherit;
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  padding: 0.8rem clamp(1rem, 3vw, 2rem);
}

.topbar .section-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-grow: 2;
  flex-shrink: 1;
  min-width: 0;
}

.topbar .topbar-title-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.topbar .section-heading h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
}

.topbar .section-heading p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}


.brand,
.back-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.page:has(.grading-panel) {
  max-width: 1440px;
}

.section-heading h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.8rem, 2.4vw, 2.4rem);
  line-height: 1.2;
}

.section-heading p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.selection-panel,
.grading-panel,
.grade-panel,
.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.session-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.session-name {
  font-weight: 800;
}

.logout-button {
  min-height: 2.6rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.field-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 800;
}

.large-select {
  width: min(100%, 420px);
  min-height: 3rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  background: #fff;
}

.large-input {
  width: min(100%, 420px);
  min-height: 3rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  background: #fff;
  font: inherit;
}

.large-textarea {
  width: 100%;
  min-height: 5.4rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  background: #fff;
  font: inherit;
  resize: vertical;
}

.login-form {
  display: grid;
  gap: 0.8rem;
  max-width: 460px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0;
}

.grade-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}

.filter-button,
.grade-button,
.primary-action,
.set-link {
  min-height: 3.2rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 1.2rem;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
}

.grade-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.2rem;
  text-align: center;
  min-width: 0;
  font-size: 0.66rem;
  line-height: 1.1;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
}

.filter-button.is-active,
.grade-button.is-selected,
.primary-action {
  background: var(--accent);
  color: #fff;
}

.set-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1rem;
}

.pager.is-hidden {
  display: none;
}

.pager-button {
  min-height: 3rem;
  min-width: 6rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
}

.pager-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pager-status {
  min-width: 5rem;
  text-align: center;
  font-weight: 800;
}

.set-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
}

.grading-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(420px, 0.9fr);
  gap: 1.5rem;
  align-items: start;
}

.review-column {
  min-width: 0;
}

.grade-sidebar {
  min-width: 0;
}

.pose-groups {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.pose-section {
  border-top: 2px solid var(--line);
  padding-top: 1rem;
}

.pose-heading {
  margin: 0 0 0.75rem;
  font-size: 1.4rem;
}

.grade-panel {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.image-card {
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0.5rem;
  cursor: pointer;
}

.image-card img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  background: #f1f5f9;
}

.orientation-label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 800;
  text-transform: uppercase;
}

.missing-image,
.popup-image-slot .missing-image {
  display: grid;
  min-height: 180px;
  place-items: center;
  border: 2px dashed var(--danger);
  color: var(--danger);
  font-weight: 800;
}

.selected-grade,
.status-message {
  min-height: 1.8rem;
  font-weight: 700;
}

.status-message.is-error {
  color: var(--danger);
}

.status-message.is-success {
  color: var(--accent-dark);
}

.popup {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 0.72);
  padding: 1rem;
}

.popup[hidden] {
  display: none;
}

.popup-dialog {
  width: min(1100px, 100%);
  max-height: 94vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 8px;
  padding: 1rem;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.icon-button {
  width: 3rem;
  height: 3rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.popup-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.popup-images figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.popup-image-slot {
  display: grid;
  place-items: center;
  min-height: 320px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #f1f5f9;
  overflow: hidden;
}

.popup-image-slot img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
}

.popup-hover-zoom {
  background-color: #f1f5f9;
  background-repeat: no-repeat;
}

.popup-image-slot.popup-hover-zoom {
  width: 100%;
  height: 450px;
  min-height: auto;
}

.popup-hover-zoom.has-preview {
  background-color: #f1f5f9;
}

.popup-hover-idle {
  padding: 1rem;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 900px) {
  :root {
    font-size: 19px;
  }

  .grading-layout {
    grid-template-columns: 1fr;
  }

  .grade-panel {
    position: static;
  }

  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .popup-images {
    grid-template-columns: 1fr;
  }

  .pager {
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  :root {
    font-size: 18px;
  }

  .grading-layout {
    gap: 1rem;
  }

  .image-grid {
    grid-template-columns: 1fr;
  }

  .filter-button,
  .grade-button,
  .primary-action,
  .large-input {
    width: 100%;
  }

  .topbar,
  .session-controls {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* --- Senior-Friendly UI Gallery and Rotator Layouts --- */

/* Control/Toggle Buttons */
.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.5rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.control-btn:hover {
  background: #f8fafc;
  border-color: var(--accent);
}

.control-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* 4x2 Visual Gallery Grid & Cards (Scroll-free landing) */
.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  width: 100%;
}

.header-container:not(:has(.section-heading)) {
  justify-content: flex-end;
}

.header-container .section-heading {
  flex-grow: 2;
  flex-shrink: 1;
  min-width: 0;
}

.header-container .section-heading h1 {
  margin: 0;
}

.header-container .section-heading p {
  margin: 0.25rem 0 0;
}

.filter-toggle-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-grow: 0;
  flex-shrink: 0;
}

.filter-toggle-btn {
  min-width: 160px;
}

.gallery-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
}

.gallery-wrapper .visual-gallery {
  flex-grow: 1;
  margin-top: 0;
}

.pager-arrow-button {
  min-height: 3.5rem;
  min-width: 3.5rem;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  user-select: none;
}

.pager-arrow-button:hover:not(:disabled) {
  background: var(--accent);
  color: #fff;
}

.pager-arrow-button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: var(--line);
  color: var(--muted);
}

.pager-status-container {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.is-hidden {
  display: none !important;
}

.visual-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
  margin-top: 1rem;
}

.set-card {
  display: flex;
  flex-direction: column;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
  transition: border-color 0.2s, transform 0.15s;
}

.set-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.set-card-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  padding: 0.5rem;
  font-weight: 800;
  font-size: 0.9rem;
  text-align: center;
}

.set-card-body {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0.4rem;
  background: #f1f5f9;
  min-height: 120px;
}

.set-thumbnail {
  max-width: 100%;
  max-height: 110px;
  object-fit: contain;
  border-radius: 4px;
}

.missing-thumbnail {
  color: var(--muted);
  font-weight: 800;
  font-size: 0.85rem;
}

.set-card-footer {
  padding: 0.4rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.grade-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-weight: 800;
  font-size: 0.8rem;
}

.is-yet-to-be-graded .grade-badge {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.is-graded .grade-badge {
  background: #f0fdf4;
  color: var(--accent-dark);
  border: 1px solid var(--accent);
}

/* Symmetrical Rotation Arrow Panel Styles */
.grading-layout-rotator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
}

.rotation-arrow {
  width: 3.5rem;
  height: 3.5rem;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: #fff;
  color: var(--accent);
  font-size: 1.8rem;
  font-weight: 800;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  user-select: none;
}

.rotation-arrow:hover {
  background: var(--accent);
  color: #fff;
}

.rotation-arrow:active {
  transform: scale(0.95);
}

.pose-toggle-container {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.pose-toggle-btn {
  min-width: 220px;
}

/* Hide inactive elements dynamic rules */
.pose-section.is-hidden {
  display: none !important;
}

.image-card {
  display: none !important;
}

.image-card.is-active {
  display: block !important;
}


/* Single large active image layout on grading page */
.grading-panel .image-grid {
  display: block;
  width: 100%;
}

.grading-panel .image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  cursor: default;
  width: 100%;
  max-width: 100%;
  background: #fff;
  margin: 0 auto;
}

.grading-panel .image-card img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
  border-radius: 6px;
  display: block;
  margin: 0 auto;
  background: #f1f5f9;
}

/* --- Inspection Checklist & Recommendation Styles --- */
.checklist-container {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-bottom: 1.2rem;
  padding: 0.8rem;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checklist-group {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed var(--line);
}

.checklist-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.checklist-group-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-dark);
  border-left: 3px solid var(--accent);
  padding-left: 0.4rem;
  margin-bottom: 0.2rem;
}

.characteristic-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.characteristic-field.is-invalid .characteristic-label,
.characteristic-field.is-invalid .characteristic-note {
  color: #b91c1c;
}

.characteristic-field.is-invalid .large-select {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.characteristic-field.is-invalid .rating-scale {
  border: 2px solid #dc2626;
  background: #fff1f2;
  padding: 2px;
}

.characteristic-field.is-invalid .rating-btn {
  color: #7f1d1d;
}

.characteristic-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.characteristic-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-dark);
}

.characteristic-note {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: normal;
}

.large-select {
  width: 100%;
  padding: 0.4rem;
  border: 2px solid var(--line);
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 800;
  background-color: #fff;
  color: var(--text-dark);
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.large-select:focus {
  border-color: var(--accent);
}

.rating-scale {
  display: flex;
  gap: 4px;
  background: #e2e8f0;
  padding: 4px;
  border-radius: 6px;
}

.rating-btn {
  flex: 1;
  padding: 0.4rem 0;
  border: none;
  background: transparent;
  color: #475569;
  font-weight: 800;
  font-size: 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.rating-btn:hover {
  background: rgba(255, 255, 255, 0.5);
}

.rating-btn.is-active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.rating-btn.btn-text {
  font-size: 0.8rem;
}


/* --- Scroll-Free Dashboard Layout --- */
html:has(.grading-panel),
body:has(.grading-panel) {
  overflow: hidden;
  height: 100vh;
}

body:has(.grading-panel) {
  display: flex;
  flex-direction: column;
}

body:has(.grading-panel) .page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.5rem 2rem;
  width: 100%;
}

body:has(.grading-panel) .grading-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1.5rem;
}

body:has(.grading-panel) .grading-layout {
  flex: 1;
  min-height: 0;
  align-items: stretch;
  height: 100%;
}

body:has(.grading-panel) .review-column {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

body:has(.grading-panel) .grading-layout-rotator {
  height: 100%;
  min-height: 0;
}

body:has(.grading-panel) .pose-groups {
  flex: 1;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 0;
}

body:has(.grading-panel) .grade-sidebar {
  align-self: stretch;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  overflow: hidden;
}

body:has(.grading-panel) .grade-panel {
  position: relative;
  top: 0;
  width: 100%;
  min-height: 0;
  max-height: calc(100% - 0.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.5rem;
}

.consensus-page {
  display: grid;
  gap: 1rem;
}

.consensus-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
}

.consensus-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.consensus-page-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7rem;
  min-height: 3rem;
  padding: 0.6rem 1rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.consensus-page-button:hover:not(.is-disabled) {
  background: var(--accent);
  color: #fff;
}

.consensus-page-button.is-disabled {
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.consensus-page-status {
  min-width: 5rem;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.filter-group,
.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-button.is-primary-action {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
}

.filter-button.is-primary-action:hover {
  background: #0369a1;
  border-color: #0369a1;
}

#consensus-filter-select.large-select {
  min-width: 220px;
  width: auto;
  border: 2px solid var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
  cursor: pointer;
  height: 3.2rem;
  min-height: auto;
  border-radius: 8px;
  padding: 0.5rem 2rem 0.5rem 1rem;
  background-color: #fff;
}



.consensus-list {
  display: grid;
  gap: 1rem;
}

.consensus-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  display: grid;
  gap: 1rem;
}

.consensus-card.is-hidden {
  display: none;
}

.consensus-card-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.consensus-image-column,
.consensus-detail-column {
  min-width: 0;
}

.consensus-image-column {
  display: grid;
  gap: 0.85rem;
  align-content: start;
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  scrollbar-gutter: stable;
}

.consensus-viewer {
  display: grid;
  gap: 0.85rem;
}

.consensus-image-column .grading-layout-rotator {
  max-width: none;
  margin: 0;
  align-items: stretch;
}

.consensus-image-column .pose-groups {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.consensus-image-column .image-grid {
  grid-template-columns: 1fr;
}

.consensus-image-column .image-card {
  cursor: default;
  inline-size: max-content;
  width: 100%;
  max-width: 100%;
  padding: 0;
  margin: 0 auto;
}

.consensus-image-column .image-card img {
  display: block;
  margin: 0 auto;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
  border-radius: 6px;
  background: #f1f5f9;
}

.consensus-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.consensus-card-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.consensus-rootid {
  display: none;
}

.consensus-status {
  min-width: 10rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  display: grid;
  gap: 0.15rem;
  font-size: 0.9rem;
}

.consensus-status strong {
  font-size: 1rem;
}

.consensus-state-note {
  color: inherit;
  opacity: 0.9;
}

.consensus-status.is-majority {
  background: #dcfce7;
  color: #166534;
}

.consensus-status.is-pending {
  background: #fef3c7;
  color: #92400e;
}

.consensus-summary-stack {
  display: grid;
  gap: 0.75rem;
}

.consensus-summary-row {
  display: grid;
  gap: 0.75rem;
}

.consensus-summary-row--submission {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.consensus-summary-row--grades {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.consensus-card[data-state="pending"] .consensus-summary-row--grades {
  gap: 0.4rem;
}

.consensus-card[data-state="pending"] .consensus-summary-row--grades .consensus-metric {
  padding: 0.55rem 0.35rem;
  text-align: center;
}

.consensus-card[data-state="pending"] .consensus-summary-row--grades .metric-label {
  font-size: 0.75rem;
  line-height: 1.15;
  white-space: nowrap;
}

.consensus-metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: #f8fafc;
  min-width: 0;
}

.consensus-checklist-section,
.consensus-comments-section,
.tester-slot-section {
  display: grid;
  gap: 0.75rem;
}

.consensus-detail-column {
  display: grid;
  gap: 0.9rem;
  min-height: 0;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-gutter: stable;
}

.consensus-section-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.consensus-section-heading p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.consensus-comments-list {
  display: grid;
  gap: 0.5rem;
}

.consensus-comment {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: #fff;
}

.comment-label {
  display: inline-block;
  margin-bottom: 0.3rem;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.consensus-comment p {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.checklist-summary-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.checklist-summary-group {
  display: grid;
  gap: 0.55rem;
}

.checklist-summary-group-list {
  display: grid;
  gap: 0.75rem;
}

.checklist-summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: #f8fafc;
  display: grid;
  gap: 0.75rem;
}

.checklist-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
}

.checklist-summary-header h4 {
  margin: 0.15rem 0 0;
  font-size: 1rem;
}

.checklist-group-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.checklist-summary-meta {
  display: grid;
  gap: 0.2rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
}

.checklist-summary-meta strong {
  color: var(--text);
  font-size: 0.95rem;
}

.checklist-average-badge {
  align-self: start;
  padding: 0.35rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.9rem;
  white-space: nowrap;
}

.checklist-distribution-list {
  display: grid;
  gap: 0.4rem;
}

.checklist-distribution-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid #e2e8f0;
  padding-top: 0.4rem;
}

.checklist-distribution-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.distribution-count {
  font-weight: 800;
}

.checklist-no-data,
.tester-slot-loading {
  margin: 0;
  color: var(--muted);
}

.tester-slot-loading.is-error {
  color: var(--danger);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.tester-slot-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.tester-slot {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  display: grid;
  gap: 0.25rem;
  min-height: 5.25rem;
}

.tester-slot.is-submitted {
  background: #ecfeff;
  border-color: #99f6e4;
}

.tester-slot.is-pending {
  background: #f8fafc;
}

.tester-slot-name {
  font-weight: 800;
}

.tester-slot-grade {
  color: var(--muted);
}

.coordinator-confirm-section {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  margin-top: 1rem;
}

.confirm-grade-select-wrapper {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: center;
}

.confirm-grade-select {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background-color: white;
  font-size: 0.95rem;
  cursor: pointer;
  height: 3.2rem;
}

.confirm-grade-button {
  background: var(--accent);
  color: white;
  border: none;
  font-weight: 600;
  transition: opacity 0.2s;
  height: 3.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.confirm-grade-button:hover {
  opacity: 0.9;
}

.consensus-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.consensus-history-section {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.consensus-history-list {
  display: grid;
  gap: 0.5rem;
}

.consensus-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

.history-type-label {
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.history-type-label.is-consensus {
  background: #ecfeff;
  color: #0891b2;
  border: 1px solid #c5f2f7;
}

.history-type-label.is-override {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
}

.history-grade-label {
  font-weight: 700;
}

.history-meta-label {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 1200px) {
  .consensus-card-layout {
    grid-template-columns: 1fr;
  }

  .consensus-image-column .image-card img {
    max-height: 48vh;
  }

  .consensus-image-column,
  .consensus-detail-column {
    max-height: none;
    overflow: visible;
    position: static;
  }
}

@media (max-width: 900px) {
  .grade-buttons,
  .consensus-summary-row--grades {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .grade-button {
    padding: 0.65rem 0.25rem;
  }
}

.grade-action-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  width: 100%;
}

.grade-action-container .primary-action,
.back-link-sidebar {
  flex: 1;
  min-width: 0;
}

.back-link-sidebar {
  min-height: 3.2rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 1.2rem;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.back-link-sidebar:hover {
  background: #f0fdf4;
  border-color: var(--accent-dark);
  color: var(--accent-dark);
  text-decoration: none;
}

/* Spinner style */
.spinner {
  display: inline-block;
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

