:root {
  color-scheme: light dark;
  --bg: #f4f1ec;
  --paper: #fffdf8;
  --ink: #1d1a17;
  --muted: #6d675f;
  --line: #d9d2c8;
  --accent: #9b2d5a;
  --good: #2f7d4a;
  --warn: #9a6b12;
  --bad: #a13333;
  --btn: #1d1a17;
  --btn-ink: #fffdf8;
  --input: #ffffff;
  --th: #faf7f2;
  --hover: #fbf6ef;
  --shadow: 0 18px 50px rgba(29, 26, 23, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --paper: #161b24;
    --ink: #f0ece6;
    --muted: #9aa0ab;
    --line: #2a3140;
    --accent: #d45a8a;
    --good: #4caf72;
    --warn: #d4a017;
    --bad: #e05a5a;
    --btn: #f0ece6;
    --btn-ink: #0b0e14;
    --input: #1c2230;
    --th: #121722;
    --hover: #1c2230;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans", "Noto Sans SC", "Noto Sans", system-ui, sans-serif;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 28px 12px;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand img,
.login-brand img {
  display: block;
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.login-brand img {
  width: 48px;
  height: 48px;
}

.top-search {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  min-width: 0;
  align-self: center;
}

.top-search input {
  width: min(380px, 100%);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: 7px 12px;
  border-radius: 2px;
}

.top-search input::placeholder {
  color: var(--muted);
}

.top-search input:focus {
  outline: none;
  border-color: var(--accent);
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.sub, .top-meta, .hint {
  color: var(--muted);
}

.sub { margin: 2px 0 0; }

.top .top-meta {
  margin: 0;
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1.2;
}

main { padding: 0 28px 40px; }

body.signed-out .top,
body.signed-out main,
body.signed-out .row-pop,
body.signed-out .scan-pop,
body.signed-out .viewer {
  display: none;
}

.login-pop {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.signed-out .login-pop { display: flex; }

.login-card {
  width: min(400px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 26px 24px;
  box-shadow: var(--shadow);
}

.login-card h1,
.login-brand h1 {
  font-size: 22px;
  margin: 0;
}

.login-brand {
  margin: 0 0 6px;
}

.login-lead {
  margin: 0 0 18px;
  color: var(--muted);
}

.connect-note {
  margin: -8px 0 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--hover);
  color: var(--ink);
  font-size: 13px;
}

.connect-note[hidden],
.connect-toast[hidden] { display: none; }

.connect-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(420px, calc(100% - 32px));
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 12px;
  font-weight: 600;
}

.login-field[hidden],
.login-error[hidden],
#login-form[data-mode="signin"] #login-confirm-wrap {
  display: none;
}

.login-field input,
.user-add input,
.user-add select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--ink);
  font: inherit;
}

.login-card .analyze {
  width: 100%;
  margin-top: 8px;
}

.login-switch {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.login-error {
  color: var(--bad);
  margin: 0 0 10px;
  font-size: 13px;
}

.login-error.login-note {
  color: var(--muted);
}

.account-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  align-self: center;
}

.sign-out {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: 5px 10px;
  cursor: pointer;
}

.users-panel {
  margin: 18px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 500;
}

.user-row button {
  font: inherit;
  padding: 4px 8px;
  cursor: pointer;
}

.user-add {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.user-add button {
  grid-column: 1 / -1;
}

.scans-wrap {
  overflow-x: auto;
}

.scans {
  width: 100%;
  min-width: 1000px;
  table-layout: auto;
  border-collapse: collapse;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.scans th, .scans td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.scans th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
  background: var(--th);
  vertical-align: middle;
}

.scans thead th {
  height: 1px;
}

.scans thead th .th-fill {
  display: flex;
  align-items: center;
  height: 100%;
  box-sizing: border-box;
}

.scans thead th.num .th-fill {
  justify-content: flex-end;
}

.scans tr:last-child td { border-bottom: 0; }
.scans tbody tr { cursor: pointer; }

.scans th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.scans th.sortable:hover { color: var(--ink, #1c1917); }
.scans th.sortable .sort-arrow {
  display: inline-block;
  width: 1.1em;
  margin-left: 2px;
  font-size: 10px;
}
.scans th.sortable.sorted { color: var(--ink, #1c1917); }
.scans tbody tr:hover td { background: var(--hover); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.scans th.col-image:first-child,
.scans td.col-image:first-child {
  min-width: 185px;
  width: 16%;
}

.scans .col-image-narrow { display: none; }

@media (max-width: 1399px) {
  .scans th.col-image:first-child,
  .scans td.col-image:first-child {
    display: none;
  }
  .scans .col-image-wide { display: none; }
  .scans .col-image-narrow { display: inline; }
}
.scans th.col-image:nth-child(2),
.scans td.col-image:nth-child(2) {
  min-width: 104px;
  width: 8%;
}
.scans .col-head {
  min-width: 120px;
  width: 8%;
  white-space: nowrap;
}
.scans .serial {
  min-width: 72px;
  white-space: nowrap;
}
.scans th[data-sort="info"],
.scans td.info {
  min-width: 196px;
  width: 18%;
  white-space: normal;
}
.scans th.num,
.scans td.num {
  min-width: 64px;
  white-space: nowrap;
}
.scans th.col-count,
.scans td.col-count {
  min-width: 48px;
}
.scans th.sortable.col-count {
  white-space: normal;
}
.scans th.col-faults,
.scans td.col-faults {
  width: 1%;
  min-width: 4.75em;
  white-space: normal;
}
.scans th.col-faults .th-fill {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.scans th.col-faults .th-faults-label {
  min-width: 0;
  max-width: 5.5em;
  white-space: normal;
  text-align: right;
  line-height: 1.25;
}
.scans td.col-faults {
  white-space: nowrap;
}
.scans th.col-score-rank,
.scans td.col-score-rank {
  min-width: 5.5em;
  white-space: normal;
}
.scans .th-stack,
.scans .score-rank-stack {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  line-height: 1.25;
  vertical-align: middle;
}
.scans th[data-sort="verdict"],
.scans td.num:has(.verdict) {
  min-width: 96px;
}
.scans th[data-sort="test_date"],
.scans th[data-sort="date"],
.scans td.date {
  min-width: 81px;
  white-space: normal;
}
.scans td.num .err {
  white-space: normal;
  max-width: 14em;
}
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }

.image-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.thumb-empty {
  width: 88px;
  height: 120px;
  border: 1px dashed var(--line);
  color: #b3ada4;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  line-height: 1.3;
  padding: 6px;
}

.image-meta {
  min-width: 0;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.image-name {
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.thumb {
  display: block;
  flex: 0 0 auto;
  width: 88px;
  height: 120px;
  object-fit: cover;
  object-position: top center;
  border: 1px solid var(--line);
  background: #eee;
  cursor: zoom-in;
}

.dash { color: #b3ada4; }

.col-head { white-space: nowrap; }

.head-pick {
  appearance: none;
  max-width: 100%;
  border: 1px solid var(--line);
  background: var(--paper) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path fill='%236d675f' d='M0 0l5 6 5-6z'/></svg>") no-repeat right 8px center;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  padding: 4px 22px 4px 8px;
  cursor: pointer;
}

.head-pick:hover,
.head-pick:focus {
  border-color: var(--accent);
  outline: none;
}

.head-pick:disabled {
  opacity: 0.55;
  cursor: wait;
}

.score-num { color: var(--muted); font-weight: 650; }
.score-perfect { color: #008000; font-weight: 650; }
.score-good { color: var(--good); font-weight: 650; }
.score-ok { color: var(--warn); font-weight: 650; }
.score-bad { color: var(--bad); font-weight: 650; }
.rank-num { font-size: 1.875em; }
.verdict {
  display: inline-block;
  padding: 4px 10px;
  font-weight: 750;
  letter-spacing: 0.06em;
  color: #fff;
  line-height: 1.2;
}
.verdict.pass { background: #00A000; }
.verdict.fail { background: #C00000; }
.cnt-missing { color: var(--bad); font-weight: 650; }
.cnt-misfire { color: #d97e00; font-weight: 650; }

.analyze, #viewer-close {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: var(--btn);
  color: var(--btn-ink);
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.analyze:disabled {
  opacity: 0.55;
  cursor: wait;
}

.err {
  color: var(--bad);
  font-size: 12px;
}

.serial {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.info {
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
}

.info-text {
  white-space: normal;
  overflow-wrap: anywhere;
}

.date {
  white-space: normal;
}

.date-stack {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.25;
}

.date-stack span {
  white-space: nowrap;
}

.date small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.listen-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  align-self: center;
}

.listen-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.listen-check:has(input:disabled) {
  opacity: 0.4;
  cursor: default;
}

.scanner-name {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.settings-open,
.scan-open {
  appearance: none;
  border: 0;
  color: #fff;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  align-self: center;
}

.settings-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  line-height: 0;
}

.scan-open {
  padding: 9px 22px;
  background: #000080;
}

.settings-open:hover,
.scan-open:hover { filter: brightness(1.1); }

.settings-pop-card {
  min-width: 320px;
  text-align: left;
  max-height: min(86vh, 720px);
  overflow: auto;
}

.settings-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
  font-weight: 600;
}

.settings-input {
  display: flex;
  align-items: center;
  gap: 6px;
}

.settings-input input {
  width: 5.5em;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.settings-input em {
  font-style: normal;
  color: var(--muted);
}

.settings-select {
  min-width: 9.5em;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.settings-hint {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.scan-pop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.45);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-pop.hidden { display: none; }

/* Keep wheel/scroll events from reaching the table behind the dialog. */
html.modal-open,
body.modal-open {
  overflow: hidden;
}

.scan-card {
  background: var(--paper);
  border: 1px solid var(--line);
  width: 90vw;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  outline: none;
}

.scan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.scan-head h2 { margin: 0; font-size: 17px; }

#scan-close {
  appearance: none;
  border: 0;
  background: var(--btn);
  color: #fff;
  padding: 6px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.scan-body {
  display: flex;
  gap: 18px;
  padding: 18px;
  flex: 1 1 auto;
  min-height: 0;
}

.scan-preview {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  background: #efece6;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.scan-stage {
  position: relative;
}

.scan-stage img {
  display: block;
  width: 100%;
  height: 100%;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scan-rect {
  position: absolute;
  border: 2px solid #2f7d4a;
  box-sizing: border-box;
  overflow: hidden;
}

.scan-rect .scan-rect-tag {
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(47, 125, 74, 0.85);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
}

.scan-rect.scanning { border-color: #d97e00; }
.scan-rect.scanning .scan-rect-tag { background: rgba(217, 126, 0, 0.9); }
.scan-rect.processing { border-color: #3a6ea5; }
.scan-rect.processing .scan-rect-tag { background: rgba(58, 110, 165, 0.9); }

.scan-progress-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 3px;
  background: rgba(217, 30, 30, 0.85);
  transition: left 0.25s linear;
}

.scan-rect.done { border-color: #2f7d4a; background: rgba(47, 125, 74, 0.12); }
.scan-rect.failed { border-color: var(--bad); background: rgba(161, 51, 51, 0.12); }

.scan-score,
.scan-processing {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-score-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28em;
  padding: 0.45em 0.65em;
  border-radius: 0.18em;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
  background: rgba(20, 18, 16, 0.72);
}

.scan-metric-head {
  color: #fff;
  font-weight: 650;
  font-size: clamp(12px, 1.6vw, 20px);
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}

.scan-metric-score {
  color: #fff;
  font-weight: 650;
  font-size: clamp(11px, 1.4vw, 16px);
  line-height: 1;
  opacity: 0.9;
}

.scan-metric-rank {
  color: #fff;
  font-weight: 750;
  font-size: clamp(22px, 3.4vw, 48px);
  line-height: 1;
}

.scan-metric-verdict {
  color: #fff;
  font-weight: 750;
  font-size: clamp(12px, 1.6vw, 18px);
  letter-spacing: 0.08em;
  line-height: 1.2;
  padding: 0.2em 0.55em;
}

.scan-metric-verdict.pass { background: #00A000; }
.scan-metric-verdict.fail { background: #C00000; }

.work-progress {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: min(420px, 72%);
}

.work-progress[hidden],
.work-progress.hidden {
  display: none;
}

#row-pop-progress {
  width: 100%;
  margin-top: 4px;
}

.scan-processing .work-progress {
  width: min(520px, 70%);
  padding: 18px 20px 14px;
  border-radius: 12px;
  background: rgba(20, 18, 16, 0.78);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.work-progress-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: #e8e2d8;
  overflow: hidden;
}

.scan-processing .work-progress-track {
  background: rgba(255, 255, 255, 0.18);
}

.work-progress-track i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f6496, #5b9ad4);
  transition: width 0.35s ease;
}

.work-progress-track i::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  animation: work-progress-sheen 1.4s ease-in-out infinite;
}

.work-progress-track em {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.work-progress-stage {
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.scan-processing .work-progress-stage {
  color: rgba(255, 255, 255, 0.92);
}

@keyframes work-progress-sheen {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.scan-rect.failed .scan-rect-tag { background: rgba(161, 51, 51, 0.9); }

.scan-cancel {
  appearance: none;
  border: 0;
  background: var(--bad);
  color: #fff;
  padding: 7px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.scan-status {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.scan-status.scan-msg-error { color: var(--bad); }

.scan-preview-msg {
  color: var(--muted);
  padding: 12px;
  text-align: center;
  max-width: 90%;
}

.scan-preview-msg.scan-msg-error { color: var(--bad); }

.scan-opts {
  flex: 0 0 230px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scan-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.scan-field select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path fill='%236d675f' d='M0 0l5 6 5-6z'/></svg>") no-repeat right 8px center;
  color: var(--ink);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  padding: 7px 24px 7px 9px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: normal;
}

.scan-field select:disabled { opacity: 0.55; }

.scan-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}

#scan-prescan { margin-top: auto; }

.row-pop {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 16, 0.45);
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-pop.hidden { display: none; }

.row-pop-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 22px 28px;
  min-width: 280px;
  text-align: center;
}

.row-pop-name {
  margin: 0 0 14px;
  font-weight: 600;
  word-break: break-all;
}

.row-pop-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.info-pop-card {
  width: min(640px, 92vw);
}

.info-pop-text {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 14px;
  padding: 8px 10px;
  font: inherit;
  border: 1px solid var(--line);
  resize: vertical;
}

td.info-editable {
  cursor: pointer;
}

td.info-editable:hover .info-text {
  text-decoration: underline;
  text-decoration-style: dotted;
}

.row-pop-delete {
  appearance: none;
  border: 0;
  background: var(--bad);
  color: #fff;
  padding: 7px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.row-pop-delete:disabled {
  opacity: 0.55;
  cursor: wait;
}

.viewer {
  position: fixed;
  inset: 0;
  background: #141210;
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer.hidden { display: none; }

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  color: #f4f1ec;
  min-width: 0;
}

.viewer-bar-left,
.viewer-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  min-width: 0;
}

.viewer-bar-right {
  flex: 0 0 auto;
  margin-left: auto;
}

.viewer-bar .hint { display: none; }

.viewer-banner {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-width: 0;
  pointer-events: none;
}

.viewer-banner-grade {
  display: inline-flex;
  align-items: stretch;
  gap: 14px;
}

.viewer-banner[hidden] { display: none; }

.viewer-banner-score,
.viewer-banner-rank {
  color: #c4c0b8;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.viewer-banner-score { font-size: 15px; }
.viewer-banner-rank {
  display: flex;
  align-items: center;
  font-size: 1.875em;
  line-height: 1.35;
}

.viewer-banner-grade .verdict {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  box-sizing: border-box;
  padding: 0 10px;
  line-height: 1;
}

.viewer-banner-label {
  font-size: 1.35em;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.viewer:not(.explore) .viewer-banner-score,
.viewer:not(.explore) .viewer-banner-rank,
.viewer:not(.explore) .viewer-banner-grade,
.viewer:not(.explore) #viewer-banner-verdict { display: none; }

.viewer.explore .viewer-banner-label { display: none; }

#viewer-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(28em, 32vw);
}

.viewer:not(.explore) #viewer-bad,
.viewer:not(.explore) .viewer-bad-nav { display: none; }

.viewer:not(.explore) #viewer-report { display: none; }

.viewer-btn {
  appearance: none;
  border: 1px solid #d9d2c8;
  background: transparent;
  color: #f4f1ec;
  padding: 6px 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.viewer-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.viewer-icon {
  padding: 5px 7px;
  line-height: 0;
}

.viewer-copy {
  margin-left: -6px;
}

.viewer-btn.on {
  background: #c43c3c;
  border-color: #c43c3c;
  color: #fff;
}

.viewer-bad-nav {
  min-width: 0;
}

.viewer-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
}

.viewer-stage {
  position: absolute;
  inset: 0;
  overflow: auto;
  cursor: grab;
}

.viewer-stage.panning { cursor: grabbing; }

.viewer-zoom {
  position: absolute;
  right: 28px;
  bottom: 28px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.viewer-zoom > * {
  pointer-events: auto;
}

.viewer-zoom-level {
  appearance: none;
  width: 44px;
  padding: 5px 0;
  border: 1px solid #4a433c;
  background: #1d1a17;
  color: #fffdf8;
  font-size: 11px;
  font-weight: 650;
  text-align: center;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.viewer-zoom-btn {
  appearance: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #4a433c;
  background: #1d1a17;
  color: #fffdf8;
  font: 22px/1 "Segoe UI", system-ui, sans-serif;
  font-weight: 650;
  cursor: pointer;
}

.viewer-zoom-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.viewer-zoom-fit {
  height: auto;
  padding: 8px 0;
  font-size: 12px;
  letter-spacing: 0.04em;
}

#viewer-pad {
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

#viewer-layer {
  position: relative;
  flex: 0 0 auto;
}

#viewer-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
}

#viewer-marks {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

#viewer-marks.hidden { display: none; }

#viewer-marks .bad-nozzle {
  fill: rgba(255, 0, 0, 0.22);
  stroke: #ff0000;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .misfire-nozzle {
  fill: rgba(255, 140, 0, 0.22);
  stroke: #ff8c00;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .misfire-nozzle-label-bg {
  fill: #d97e00;
  stroke: #fff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .bad-nozzle-label-bg {
  fill: #c43c3c;
  stroke: #fff;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .bad-nozzle-num {
  fill: #fff;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

#viewer-marks .pinned-nozzle.pinned-good {
  fill: rgba(0, 128, 0, 0.18);
  stroke: #008000;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .pinned-nozzle.pinned-bad {
  fill: rgba(255, 0, 0, 0.18);
  stroke: #ff0000;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .pinned-nozzle-label-bg {
  fill: #1d1a17;
  stroke: #ffd650;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .pinned-nozzle-num {
  fill: #fffdf8;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

#viewer-marks .hover-nozzle.hover-good {
  fill: rgba(0, 128, 0, 0.18);
  stroke: #008000;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .hover-nozzle.hover-bad {
  fill: rgba(255, 0, 0, 0.18);
  stroke: #ff0000;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#viewer-marks .hover-nozzle.hover-misfire,
#viewer-marks .pinned-nozzle.pinned-misfire {
  fill: rgba(255, 140, 0, 0.18);
  stroke: #ff8c00;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.viewer-tip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: #1d1a17;
  color: #fffdf8;
  border: 1px solid #3a342e;
  padding: 5px 9px;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.viewer-tip.hidden { display: none; }
