:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #245bdb;
  --accent-soft: #e9efff;
  --danger: #b42318;
  --ok: #027a48;
  --warn: #b54708;
  --ok-bg: #f0fdf4;
  --ok-border: #53b483;
  --danger-bg: #fff4f2;
  --danger-border: #f08a7c;
  --warn-bg: #fffbeb;
  --warn-border: #f0b429;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  min-height: 56px;
  padding: 0 28px;
}

.brand {
  color: var(--text);
  font-weight: 700;
}

.nav {
  display: flex;
  flex: 1;
  gap: 16px;
}

.nav a {
  color: var(--muted);
  font-size: 14px;
}

.nav a:hover {
  color: var(--text);
}

.page {
  margin: 0 auto;
  max-width: 1440px;
  padding: 28px;
}

.page-header {
  align-items: end;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

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

h1 {
  font-size: 28px;
}

h2 {
  font-size: 19px;
  margin-bottom: 10px;
}

h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}

.review-workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
}

.scroll-panel {
  max-height: calc(100vh - 196px);
  overflow-y: auto;
}

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

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 20px;
}

.stat,
.panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat {
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 24px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.notice {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  margin: 12px 0 14px;
  padding: 10px 12px;
}

.notice strong {
  font-size: 14px;
}

.notice span {
  color: var(--muted);
  font-size: 13px;
}

.notice.ok {
  background: var(--ok-bg);
  border-color: #b7e4cb;
}

.notice.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.table-wrap {
  overflow: hidden;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: #fbfcfe;
  color: var(--muted);
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.upload-panel {
  margin-bottom: 18px;
}

.upload-form {
  gap: 14px 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.upload-form .full {
  grid-column: 1 / -1;
}

.checkbox-row {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  gap: 8px;
}

.checkbox-row input {
  min-height: auto;
  width: auto;
}

.submissions-history {
  display: grid;
  gap: 10px;
}

.sheet-source {
  border-bottom: 1px solid var(--line);
  margin: 6px 0 14px;
  padding-bottom: 12px;
}

.sheet-source summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
}

.sheet-answer-section {
  display: grid;
  gap: 12px;
  margin-bottom: 4px;
}

.sheet-answer {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 10px;
}

.sheet-answer textarea {
  min-height: 72px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.button,
button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  text-align: center;
  white-space: nowrap;
}

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

.button.secondary,
button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.button.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

.button.compact,
button.compact {
  font-size: 12px;
  min-height: 30px;
  padding: 5px 8px;
}

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

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

.action-bar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 16px;
  padding-bottom: 14px;
}

.review-pass-form {
  align-items: flex-start;
  display: grid;
  gap: 10px;
}

.advanced-passes {
  color: var(--text);
}

.advanced-passes summary {
  cursor: pointer;
  font-weight: 650;
}

.checkbox-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.pass-option {
  align-items: flex-start;
}

.pass-option > span {
  display: grid;
  gap: 2px;
}

.pass-meta,
.pass-focus {
  font-size: 0.88rem;
}

.meta-strip {
  align-items: center;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin: -6px 0 16px;
  padding: 10px 12px;
}

.meta-strip details {
  color: var(--muted);
  font-size: 13px;
  max-width: 720px;
}

.meta-strip summary {
  cursor: pointer;
  font-weight: 650;
}

.meta-strip ul,
.meta-strip p {
  margin-bottom: 0;
}

.section-head {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.section-head .muted {
  margin: 0;
}

.badge {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.status-strip {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin: 10px 0 14px;
  padding: 12px;
}

.status-strip.is-running {
  border-color: #b7c7ff;
}

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

.progress {
  background: #edf1f7;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, #245bdb, #03989e);
  border-radius: inherit;
  height: 100%;
  transition: width 240ms ease;
}

.badge.ok {
  background: #ecfdf3;
  border: 1px solid #b7e4cb;
  color: var(--ok);
}

.badge.warn {
  background: #fffaeb;
  border: 1px solid #fedf89;
  color: var(--warn);
}

.badge.danger {
  background: #fef3f2;
  border: 1px solid #fecdca;
  color: var(--danger);
}

.finding {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  overflow: hidden;
  padding: 16px;
  position: relative;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease, opacity 180ms ease;
}

.finding::before {
  background: #c7d0dd;
  bottom: 0;
  content: "";
  left: 0;
  position: absolute;
  top: 0;
  width: 5px;
}

.finding strong {
  font-size: 16px;
}

.finding.status-accepted {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  box-shadow: 0 1px 2px rgba(2, 122, 72, 0.08);
}

.finding.status-accepted::before {
  background: var(--ok);
}

.finding.status-rejected {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  opacity: 0.78;
}

.finding.status-rejected::before {
  background: var(--danger);
}

.finding.status-later {
  background: var(--warn-bg);
  border-color: var(--warn-border);
}

.finding.status-later::before {
  background: var(--warn);
}

.finding.status-accepted button[data-active],
.finding.status-accepted form[data-action="accepted"] button,
.finding.status-rejected form[data-action="rejected"] button,
.finding.status-later form[data-action="later"] button {
  background: rgba(255, 255, 255, 0.75);
  border-color: currentColor;
  color: var(--text);
  opacity: 1;
}

.finding.is-updated {
  box-shadow: 0 0 0 3px rgba(36, 91, 219, 0.14);
}

.finding + .finding {
  margin-top: 12px;
}

.inline-section {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.draft-section textarea {
  min-height: 330px;
}

.draft-section .sheet-answer textarea {
  min-height: 72px;
}

.draft-section #review_text {
  min-height: 840px;
}

.login {
  margin: 10vh auto;
  max-width: 380px;
}

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

  .page {
    padding: 18px;
  }

  .stats,
  .review-workspace,
  .grid.two,
  .upload-form,
  .score-grid {
    grid-template-columns: 1fr;
  }

  .scroll-panel {
    max-height: none;
    overflow: visible;
  }

  .page-header,
  .section-head,
  .meta-strip {
    align-items: stretch;
    flex-direction: column;
  }
}
