:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --panel: #f6f8fb;
  --green: #137a45;
  --red: #b42318;
  --amber: #b54708;
  --blue: #1f5fbf;
  --black: #101828;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f7;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 28px;
  background: var(--black);
  color: white;
}

.eyebrow {
  margin: 0 0 4px;
  color: #b7c4d6;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  font-size: 28px;
  font-weight: 820;
}

h2 {
  font-size: 16px;
}

.system-status {
  min-width: 108px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  text-align: center;
  color: #d9e3f2;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  gap: 20px;
  padding: 20px;
}

.analysis-panel,
.result-panel,
.ops-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.analysis-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  padding: 16px;
}

.simple-steps {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 220px) minmax(180px, 240px);
  gap: 12px;
}

.upload-zone {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 2px dashed #9fb4cf;
  border-radius: 8px;
  background: #f7fbff;
  color: var(--ink);
  cursor: pointer;
}

.model-choice {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.model-choice span {
  margin-bottom: 0;
}

.model-choice select {
  min-height: 34px;
  border-color: transparent;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 860;
}

.upload-zone input,
.master-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-zone span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.upload-zone strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.primary-action {
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  padding: 0 22px;
  background: var(--black);
  color: white;
  font-size: 18px;
  font-weight: 860;
}

.primary-action.compact {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
}

.canvas-wrap {
  position: relative;
  width: min(72vh, 100%);
  max-width: 900px;
  aspect-ratio: 1;
  margin: 0 auto;
  background:
    linear-gradient(45deg, #dfe5ee 25%, transparent 25%),
    linear-gradient(-45deg, #dfe5ee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe5ee 75%),
    linear-gradient(-45deg, transparent 75%, #dfe5ee 75%);
  background-size: 32px 32px;
  background-position: 0 0, 0 16px, 16px -16px, -16px 0;
  border: 1px solid #c8d1df;
  overflow: hidden;
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pipeline span {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
}

.pipeline span.active {
  border-color: var(--blue);
  color: var(--blue);
  background: #e7f0ff;
}

.result-panel {
  display: grid;
  align-content: start;
  overflow: hidden;
}

.result-topline {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.result-topline span,
.result-grid span,
label span,
.readout-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.result-topline strong {
  color: var(--muted);
  font-size: 13px;
}

.decision {
  min-height: 128px;
  display: grid;
  place-items: center;
  color: white;
  font-size: 42px;
  font-weight: 900;
}

.decision.pass {
  background: var(--green);
}

.decision.reject {
  background: var(--red);
}

.decision.recheck {
  background: var(--amber);
}

.result-summary {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
  line-height: 1.35;
}

.gujarati-note {
  padding: 13px 16px;
  color: var(--ink);
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  font-weight: 800;
  line-height: 1.35;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid var(--line);
}

.result-grid div {
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.result-grid div:nth-child(2n) {
  border-right: 0;
}

.result-grid div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.result-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
}

.result-grid.quiet {
  border-bottom: 0;
}

.result-grid.quiet strong {
  font-size: 18px;
}

.result-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.result-section:last-child {
  border-bottom: 0;
}

.is-hidden {
  display: none;
}

.result-section.compact {
  padding-top: 14px;
}

#defectList {
  list-style: none;
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
}

#defectList li,
.readout-list div,
.report-kv div,
.asset-link {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel);
}

#defectList strong,
.readout-list dd {
  margin: 0;
  font-weight: 860;
  overflow-wrap: anywhere;
}

.readout-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.readout-list.padded {
  padding: 14px;
  margin: 0;
}

.technical-drawer {
  margin: 0 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.technical-drawer summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: var(--blue);
  font-weight: 860;
  cursor: pointer;
}

.technical-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

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

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

.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-grid,
.threshold-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c7d0dd;
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

.master-picker strong {
  min-height: 42px;
  display: grid;
  align-items: center;
  overflow: hidden;
  padding: 0 12px;
  border: 1px solid #c7d0dd;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0 14px 14px;
  border: 1px solid #c7d0dd;
  border-radius: 8px;
  overflow: hidden;
}

.mode-switch button {
  min-height: 42px;
  border: 0;
  background: white;
  color: var(--muted);
  font-weight: 820;
}

.mode-switch button.active {
  background: var(--blue);
  color: white;
}

.technical-note {
  padding: 0 14px 14px;
  color: var(--muted);
  line-height: 1.4;
}

.binding-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.binding-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.binding-list li:last-child {
  border-bottom: 0;
}

.binding-list span {
  color: var(--muted);
  font-weight: 780;
}

.binding-list strong {
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

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

.status-pill {
  display: inline-grid;
  place-items: center;
  min-width: 76px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 860;
}

.status-pill.pass {
  background: var(--green);
}

.status-pill.reject {
  background: var(--red);
}

.status-pill.recheck {
  background: var(--amber);
}

.text-action,
.asset-link {
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.review-panel {
  display: grid;
  align-content: start;
}

.report-body {
  display: grid;
  gap: 10px;
  padding: 14px;
  font-size: 14px;
}

.report-body p {
  color: var(--muted);
}

.report-kv {
  display: grid;
  gap: 8px;
}

.review-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 14px 12px;
}

.review-actions button,
.row-action {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 820;
}

.row-action {
  min-height: 30px;
  color: var(--blue);
}

.review-note {
  display: block;
  padding: 0 14px 14px;
}

.video-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.video-list a {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: var(--panel);
}

.video-list strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
}

.video-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 980px) {
  .workbench,
  .technical-grid {
    grid-template-columns: 1fr;
  }

  .canvas-wrap {
    width: min(100%, 620px);
  }
}

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

  h1 {
    font-size: 23px;
  }

  .workbench {
    padding: 12px;
  }

  .simple-steps,
  .result-grid,
  .settings-grid,
  .threshold-form,
  .review-actions {
    grid-template-columns: 1fr;
  }

  .primary-action,
  .upload-zone {
    min-height: 58px;
  }

  .decision {
    min-height: 108px;
    font-size: 34px;
  }

  .result-grid div {
    border-right: 0;
  }

  .result-grid div:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .result-grid div:last-child {
    border-bottom: 0;
  }

  .technical-drawer {
    margin: 0 12px 12px;
  }
}
