:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #d8dee8;
  --line-strong: #b4bfcc;
  --text: #17202b;
  --muted: #667386;
  --muted-2: #8a96a8;
  --teal: #0f766e;
  --teal-soft: #d9f4ef;
  --blue: #175cd3;
  --blue-soft: #e0edff;
  --green: #067647;
  --green-soft: #dcfae6;
  --red: #b42318;
  --red-soft: #fee4e2;
  --amber: #9a6700;
  --amber-soft: #fff3c7;
  --shadow: 0 14px 34px rgba(18, 27, 38, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.appShell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.brandBlock {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.configLine {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin-top: 2px;
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: 0;
}

.uploadBox {
  padding: 14px 18px 16px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 9px;
}

.uploadBox label,
.filters label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

input,
select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 80px;
  max-height: 210px;
  resize: vertical;
  padding: 8px 10px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input[type="file"] {
  height: auto;
  padding: 7px;
}

button,
.download {
  min-height: 36px;
  border: 1px solid var(--teal);
  border-radius: 7px;
  background: var(--teal);
  color: #fff;
  padding: 0 13px;
  font-weight: 760;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.download:hover {
  background: #115e59;
}

button:disabled,
.download.disabled {
  border-color: var(--line);
  background: #e8edf4;
  color: var(--muted);
  cursor: not-allowed;
  pointer-events: none;
}

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

.dangerBtn {
  border-color: #f04438;
  background: #f04438;
  color: #fff;
}

.dangerBtn:hover {
  background: #d92d20;
}

.secondary:hover,
.iconText:hover {
  background: var(--surface-soft);
}

.sideHead {
  min-height: 46px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.sideHead h2 {
  font-size: 14px;
}

.sideHead span {
  color: var(--muted);
  font-weight: 760;
}

.jobActions {
  display: grid;
  gap: 7px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f7fafc;
}

.jobActionRow {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.downloadRow {
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.schemeDownloads {
  display: contents;
}

.referenceForm {
  display: grid;
  gap: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.referenceHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.referenceHead strong {
  font-size: 12px;
}

.referenceForm input[type="file"] {
  background: #fff;
}

.referenceForm textarea {
  min-height: 70px;
  max-height: 140px;
}

.storageBanner {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.storageBanner.ready {
  border-color: #abefc6;
  background: var(--green-soft);
  color: var(--green);
}

.storageBanner.blocked {
  border-color: #fda29b;
  background: var(--red-soft);
  color: var(--red);
}

.storageBanner.checking {
  border-color: #b7d9ff;
  background: var(--blue-soft);
  color: var(--blue);
}

.jobActions button,
.jobActions .download {
  width: auto;
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
  flex: 0 0 auto;
}

.jobsList {
  overflow: auto;
  padding: 8px;
}

.jobCard {
  width: 100%;
  min-height: 100px;
  margin: 0 0 8px;
  padding: 12px;
  display: block;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.jobCard:hover {
  background: #f1f5f9;
}

.jobCard.active {
  border-color: #99d5cb;
  background: #edf8f6;
}

.jobCardTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.jobName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 780;
}

.jobMeta,
.jobNumbers {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.jobNumbers {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.warn {
  color: var(--amber);
  font-weight: 760;
}

.progressTrack {
  height: 6px;
  border-radius: 999px;
  background: #dfe6ef;
  overflow: hidden;
  margin-top: 9px;
}

.progressTrack span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.workspace {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.workspaceHeader {
  min-height: 92px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.workspaceHeader h2 {
  margin-top: 4px;
  max-width: 920px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.headerActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pageInfo {
  min-width: 108px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-align: center;
}

.summary {
  padding: 14px 22px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.summary.empty {
  display: block;
  color: var(--muted);
}

.metric {
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 11px;
}

.metric.danger {
  border-color: #f7b7b2;
  background: #fff6f5;
}

.metric.success {
  border-color: #9dd9bd;
  background: #f2fbf7;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filters {
  min-height: 62px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  display: grid;
  grid-template-columns: 130px 140px 140px minmax(220px, 1fr) 110px;
  gap: 10px;
  align-items: end;
}

.schemeVisibility {
  min-height: 44px;
  padding: 9px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.schemeVisibility > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.indexMode {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.indexMode > span {
  margin-right: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.indexMode button {
  min-width: 58px;
  height: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 780;
  cursor: pointer;
}

.indexMode button:first-of-type {
  border-radius: 6px 0 0 6px;
}

.indexMode button:last-of-type {
  margin-left: -3px;
  border-radius: 0 6px 6px 0;
}

.indexMode button.active {
  position: relative;
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.schemeMetrics {
  padding: 12px 22px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.schemeMetricsHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

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

.schemeMetricsHead span {
  color: var(--muted);
  font-size: 11px;
}

.schemeMetricsTableWrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.schemeMetricsTable {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12px;
}

.schemeMetricsTable th,
.schemeMetricsTable td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

.schemeMetricsTable th:first-child {
  text-align: left;
}

.schemeMetricsTable thead th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 800;
}

.schemeMetricsTable tbody tr:last-child th,
.schemeMetricsTable tbody tr:last-child td {
  border-bottom: 0;
}

.schemeToggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
  font-size: 12px;
  font-weight: 780;
}

.schemeToggle input {
  width: 14px;
  height: 14px;
}

.filters label {
  display: grid;
  gap: 5px;
}

.results {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 22px 24px;
}

.resultList {
  display: grid;
  gap: 10px;
}

.resultRow {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(18, 27, 38, 0.03);
}

.resultRow:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.rowIndex {
  padding: 16px 10px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  background: var(--surface-soft);
  border-radius: 8px 0 0 8px;
}

.rowMain {
  min-width: 0;
  padding: 13px 14px;
}

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

.titleStack {
  min-width: 0;
}

.titleStack h3 {
  max-width: 920px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titleStack span {
  display: block;
  margin-top: 3px;
  max-width: 720px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted-2);
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.rowBadges {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge,
.sourceBadge,
.confidence,
.compareBadge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.badge {
  background: #edf1f5;
  color: var(--muted);
}

.badge.completed,
.sourceBadge.cache {
  background: var(--green-soft);
  color: var(--green);
}

.badge.running,
.badge.queued,
.badge.pausing,
.badge.paused,
.badge.deleting,
.sourceBadge.generated {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.pausing,
.badge.paused {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.deleting {
  background: var(--red-soft);
  color: var(--red);
}

.badge.failed,
.sourceBadge.zero_fill {
  background: var(--red-soft);
  color: var(--red);
}

.confidence {
  background: #f1f5f9;
  color: #344054;
}

.compareBadge.match {
  background: var(--green-soft);
  color: var(--green);
}

.compareBadge.mismatch {
  background: var(--amber-soft);
  color: var(--amber);
}

.pairStrip {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 11px;
}

.pairChip {
  min-height: 31px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid #b7d9ff;
  border-radius: 7px;
  background: #f5faff;
}

.pairChip strong {
  color: var(--blue);
}

.pairChip span {
  font-weight: 760;
}

.pairChip em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.sequenceCompare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.schemeCompare {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.schemeBox {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.schemeBox.correct {
  border-color: #75e0a7;
  background: #f0fdf4;
}

.schemeBox.wrong {
  border-color: #fda29b;
  background: #fff5f5;
}

.schemeBox.disagree {
  border-color: #fdb022;
  background: #fffbeb;
}

.schemeBoxHead {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.schemeBoxHead strong {
  font-size: 13px;
}

.schemeBoxHead span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.schemeStatus {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
}

.schemeStatus.correct {
  background: var(--green-soft);
  color: var(--green);
}

.schemeStatus.wrong {
  background: var(--red-soft);
  color: var(--red);
}

.schemeStatus.disagree {
  background: var(--amber-soft);
  color: var(--amber);
}

.sequencePanel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
}

.sequencePanel > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 780;
}

.markedPanel {
  border-color: #b7d9ff;
  background: #f8fbff;
}

.referencePanel {
  border-color: #fedf89;
  background: #fffbeb;
}

.sequenceText,
.markedSequence {
  color: #243447;
  overflow-wrap: anywhere;
  font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.markedSequence {
  display: block;
}

.markedResidue {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  min-height: 22px;
  margin: 0 1px;
  padding: 0 3px;
  border-radius: 5px;
  border: 1px solid #bfdbfe;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 850;
}

.markedResidue sup {
  font-size: 10px;
  line-height: 1;
  color: inherit;
}

.markedResidue.mark2,
.markedResidue.mark5,
.markedResidue.mark8 {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #047857;
}

.markedResidue.mark3,
.markedResidue.mark6,
.markedResidue.mark9 {
  border-color: #fed7aa;
  background: #ffedd5;
  color: #c2410c;
}

.markedResidue.mark4,
.markedResidue.mark7 {
  border-color: #ddd6fe;
  background: #ede9fe;
  color: #6d28d9;
}

.plainResidue {
  display: inline;
}

.markDigit.stray {
  color: var(--red);
  font-weight: 850;
}

/*
.markedSequence {
  margin-top: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fbfdff;
  color: #243447;
  padding: 8px 9px;
  overflow-wrap: anywhere;
  font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*/

.noPairs {
  color: var(--muted);
  background: #f1f5f9;
  border-radius: 7px;
  padding: 6px 8px;
  font-weight: 700;
}

.rowDetails {
  margin-top: 10px;
}

.rowDetails summary {
  width: fit-content;
  cursor: pointer;
  color: var(--teal);
  font-weight: 780;
  list-style: none;
}

.rowDetails summary::-webkit-details-marker {
  display: none;
}

.detailGrid {
  display: grid;
  grid-template-columns: 90px 130px 210px minmax(0, 1fr);
  gap: 8px;
  margin-top: 9px;
}

.detailGrid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 8px;
}

.detailGrid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.detailGrid strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.warningLine {
  margin-top: 8px;
  border: 1px solid #fedf89;
  background: #fffaeb;
  color: var(--amber);
  border-radius: 7px;
  padding: 8px;
  font-size: 12px;
  font-weight: 700;
}

.sequence {
  margin-top: 8px;
  max-height: 96px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 8px;
  color: #344054;
  overflow-wrap: anywhere;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.emptyState {
  padding: 22px;
  color: var(--muted);
}

.errorBox {
  border: 1px solid #fda29b;
  background: #fff1f0;
  color: var(--red);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .appShell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .jobsList {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    max-height: 320px;
  }

  .workspaceHeader,
  .headerActions {
    align-items: stretch;
    flex-direction: column;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .searchField {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .resultRow {
    grid-template-columns: 1fr;
  }

  .rowIndex {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    text-align: left;
    border-radius: 8px 8px 0 0;
  }

  .rowTop {
    flex-direction: column;
  }

  .detailGrid,
  .sequenceCompare,
  .schemeCompare,
  .filters,
  .summary {
    grid-template-columns: 1fr;
  }
}
