:root {
  color-scheme: light;
  font-family:
    Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: rgb(247, 248, 250);
  --surface: rgb(255, 255, 255);
  --ink: rgb(23, 32, 42);
  --muted: rgb(102, 112, 133);
  --line: rgb(216, 222, 232);
  --blue: rgb(36, 87, 197);
  --green: rgb(18, 128, 92);
  --amber: rgb(184, 107, 0);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: white;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.exam-name {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
}

h2 {
  font-size: 1.15rem;
}

.health {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.health span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.panel {
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.upload-zone {
  display: grid;
  gap: 8px;
  border: 1px dashed rgb(154, 167, 184);
  border-radius: 8px;
  padding: 18px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

input[type="file"] {
  width: 100%;
}

#fileHint {
  margin: 0;
  color: var(--muted);
}

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

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: rgb(251, 252, 254);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
}

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

#reportButton,
.modal-actions button,
.report-header button {
  background: var(--green);
}

.results,
.report-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.report-summary div {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.metric span,
.report-summary span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.metric strong,
.report-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(231, 235, 242);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 180ms ease;
}

#progressText {
  margin: 8px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.modal::backdrop {
  background: rgba(23, 32, 42, 0.42);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head button {
  min-width: 42px;
  padding: 0;
  background: rgb(61, 70, 82);
}

.modal-body {
  padding: 16px;
  overflow-x: auto;
}

.modal-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.report-page {
  background: rgb(255, 255, 255);
}

.report {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.report-header {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.report section {
  margin-top: 28px;
}

.report-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.report-image-page {
  width: min(980px, calc(100vw - 32px));
}

.report-image-list {
  display: grid;
  gap: 28px;
  margin-top: 24px;
}

.report-image-card {
  display: grid;
  gap: 10px;
  break-inside: avoid;
}

.report-image-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.report-image-title span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 0.84rem;
}

.report-image-card img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 30px rgba(23, 32, 42, 0.12);
}

.report-empty {
  margin-top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid,
  .results,
  .report-summary {
    grid-template-columns: 1fr;
  }

  .modal-summary {
    flex-direction: column;
  }
}

@media print {
  .report-header button {
    display: none;
  }

  .report-image-page {
    width: 100%;
    padding: 0;
  }

  .report-image-title {
    display: none;
  }

  .report-image-card img {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    page-break-after: always;
  }
}
