:root {
  color-scheme: light;
  --ink: #182027;
  --ink-soft: #53616d;
  --surface: #ffffff;
  --surface-muted: #eef1f3;
  --line: #cfd6db;
  --header: #10171d;
  --header-soft: #202a32;
  --accent: #277694;
  --accent-dark: #17536a;
  --approved: #117a4a;
  --approved-soft: #e2f4eb;
  --rejected: #b9282d;
  --rejected-soft: #fde9e9;
  --review: #9a6500;
  --review-soft: #fff1c9;
  --focus: #197bff;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: #dfe4e7;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-header {
  display: flex;
  min-height: 5.5rem;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem clamp(1rem, 3vw, 3rem);
  border-bottom: 4px solid var(--accent);
  background: var(--header);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand__mark {
  display: grid;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border: 2px solid #6ab4cd;
  color: #8bd0e5;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 1.375rem;
  letter-spacing: 0.05em;
}

.brand div > span {
  color: #bdc8cf;
  font-size: 0.875rem;
}

.system-state {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border: 1px solid #42515d;
  background: var(--header-soft);
  color: #e8f6ed;
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.system-state > span:last-child {
  display: grid;
}

.system-state small {
  color: #bdc8cf;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.system-state__dot {
  flex: 0 0 auto;
  width: 0.75rem;
  height: 0.75rem;
  border: 2px solid #97e2ba;
  border-radius: 50%;
  background: #23a665;
  box-shadow: 0 0 0 3px rgb(35 166 101 / 18%);
}

.system-state--checking .system-state__dot {
  border-color: #b9c4cb;
  background: #6f7d87;
  box-shadow: none;
}

.system-state--degraded {
  color: #ffe6a6;
}

.system-state--degraded .system-state__dot {
  border-color: #ffd36b;
  background: #c88a00;
  box-shadow: 0 0 0 3px rgb(200 138 0 / 22%);
}

.system-state--offline {
  border-color: #a5464a;
  color: #ffd9da;
}

.system-state--offline .system-state__dot {
  border-color: #ffa7aa;
  border-radius: 0;
  background: #d23a40;
  box-shadow: 0 0 0 3px rgb(210 58 64 / 22%);
}

.inspection-page {
  width: min(100%, 100rem);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2.5rem);
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 0.25rem;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  line-height: 1.1;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.inspection-code {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.inspection-code strong {
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
}

.api-mode-tag {
  margin-left: 0.5rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--accent-dark);
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.api-mode-tag--fake {
  border-style: dashed;
  border-color: var(--review);
  background: var(--review-soft);
  color: #6b4600;
}

.app-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border-left: 6px solid var(--rejected);
  background: var(--rejected-soft);
  color: #71151a;
}

.app-error p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
}

.empty-state {
  margin-bottom: 1rem;
  padding: 2rem 1.5rem;
  border: 2px dashed var(--line);
  background: var(--surface);
  text-align: center;
}

.empty-state p {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
}

.loading-state {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-weight: 700;
}

.loading-state__spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.inspection-layout[data-view-state="loading"] .evidence-panel,
.inspection-layout[data-view-state="loading"] .result-panel {
  opacity: 0.45;
}

.inspection-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(25rem, 0.85fr);
  align-items: start;
  gap: 1.25rem;
}

.evidence-panel,
.result-panel,
.demo-panel {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 0.375rem 1.25rem rgb(30 42 50 / 8%);
}

.evidence-panel {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.panel-heading,
.operator-actions__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.source-tag {
  padding: 0.375rem 0.625rem;
  border: 1px solid #91a0aa;
  background: #f4f6f7;
  color: #4d5b65;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.evidence-frame {
  position: relative;
  overflow: hidden;
  margin: 1rem 0;
  background: #11171c;
}

.evidence-frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.evidence-placeholder {
  display: grid;
  aspect-ratio: 3 / 2;
  align-content: center;
  justify-items: center;
  gap: 0.35rem;
  padding: 1rem 1rem 3rem;
  background: repeating-linear-gradient(
    -45deg,
    #1a2229,
    #1a2229 14px,
    #202a32 14px,
    #202a32 28px
  );
  color: #dfe7ec;
  text-align: center;
}

.evidence-placeholder > span {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border: 3px solid currentColor;
  border-radius: 50%;
  font-size: 1.5rem;
  font-weight: 900;
}

.evidence-placeholder strong {
  font-size: 1.25rem;
}

.evidence-placeholder small {
  color: #aab7bf;
}

.evidence-frame[data-evidence-state="PENDING"] .evidence-placeholder {
  color: #9fd8ea;
}

.evidence-frame[data-evidence-state="UNAVAILABLE"] .evidence-placeholder,
.evidence-frame[data-evidence-state="LOAD_FAILED"] .evidence-placeholder {
  color: #ffb3b5;
}

.evidence-frame[data-evidence-state="EXPIRED"] .evidence-placeholder {
  color: #ffd98a;
}

.evidence-frame figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 0.625rem 0.875rem;
  background: rgb(8 13 17 / 82%);
  color: #ecf1f4;
  font-size: 0.8rem;
}

.evidence-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0;
}

.evidence-meta div {
  padding: 0.875rem 1rem;
  border-left: 4px solid #82929c;
  background: var(--surface-muted);
}

.evidence-meta dt,
.metric span {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.evidence-meta dd {
  margin: 0.25rem 0 0;
  font-size: clamp(0.95rem, 1.3vw, 1.125rem);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.evidence-meta div:nth-child(n + 5) dd {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
}

.result-panel {
  display: flex;
  flex-direction: column;
}

.status-banner {
  display: flex;
  min-height: 8.75rem;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid currentColor;
}

.status-banner--approved {
  background: var(--approved-soft);
  color: var(--approved);
}

.status-banner--rejected {
  background: var(--rejected-soft);
  color: var(--rejected);
}

.status-banner--review {
  background: var(--review-soft);
  color: var(--review);
}

.status-banner__icon {
  display: grid;
  flex: 0 0 4rem;
  width: 4rem;
  height: 4rem;
  place-items: center;
  border: 3px solid currentColor;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 900;
}

.status-banner__label,
.status-banner strong {
  display: block;
}

.status-banner__label {
  margin-bottom: 0.15rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.status-banner strong {
  font-size: clamp(1.75rem, 3.4vw, 3rem);
  line-height: 1.05;
}

.status-banner__reason {
  margin: 0.5rem 0 0;
  color: var(--ink);
  font-size: 0.875rem;
}

.defect-summary,
.metrics,
.operator-actions {
  padding: 1.25rem 1.5rem;
}

.defect-summary {
  border-bottom: 1px solid var(--line);
}

.defect-summary__kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.defect-summary__kicker .panel-kicker {
  margin: 0;
}

.result-badge {
  padding: 0.3rem 0.55rem;
  border: 2px solid currentColor;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.result-badge--conforming {
  color: var(--approved);
}

.result-badge--non-conforming {
  color: var(--rejected);
}

.result-badge--anomaly {
  border-style: dashed;
  color: #7a2f8f;
}

.result-badge--uncertain {
  border-style: dotted;
  color: var(--review);
}

.defect-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.defect-heading h2 {
  font-size: clamp(1.5rem, 2.5vw, 2.125rem);
}

.severity-badge {
  flex: 0 0 auto;
  padding: 0.4rem 0.6rem;
  border: 1px solid #82322c;
  background: #fff0ec;
  color: #832820;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.defect-summary > p:not(.panel-kicker, .classification-code) {
  margin-bottom: 0.75rem;
  color: #3e4b55;
  font-size: 1rem;
}

.classification-code {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.metrics {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(8rem, 0.8fr);
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}

.metric {
  min-width: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
}

.metric__heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.metric small {
  display: block;
  color: #687680;
  font-size: 0.75rem;
}

.metric strong {
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
}

.confidence-bar {
  overflow: hidden;
  height: 0.75rem;
  margin-top: 0.75rem;
  border: 1px solid #9ba8b0;
  background: #dfe4e7;
}

.confidence-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 180ms ease-out;
}

.metric--similarity {
  display: grid;
  align-content: center;
  gap: 0.3rem;
}

.versions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

.versions dt {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.versions dd {
  margin: 0.15rem 0 0;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.operator-actions {
  margin-top: auto;
}

.operator-field {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
}

.operator-field span {
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.operator-field input {
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid #9ba8b0;
  background: #fff;
  color: var(--ink);
}

.operator-field input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.operator-actions__heading > span {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.button,
.demo-controls button {
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  border: 2px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

.button--primary {
  background: var(--accent-dark);
  color: #fff;
}

.button--primary:hover {
  background: #0d4257;
}

.button--secondary {
  border-color: #9a6500;
  background: #fff8e5;
  color: #774e00;
}

.button--secondary:hover {
  background: #ffedb8;
}

.button--ghost {
  flex: 0 0 auto;
  border-color: #8f2a2f;
  background: #fff;
  color: #71151a;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.action-feedback {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.demo-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-top: 1.25rem;
  padding: 1.125rem 1.5rem;
  border-top: 4px solid #677681;
}

.demo-panel h2 {
  margin-bottom: 0.25rem;
}

.demo-panel p:last-child {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.875rem;
}

.demo-groups {
  display: grid;
  gap: 0.75rem;
}

.demo-controls {
  display: grid;
  gap: 0.35rem;
}

.demo-controls__label {
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.demo-controls__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.demo-controls button {
  min-height: 3rem;
  min-width: 7.75rem;
  border-color: #7d8b94;
  background: #fff;
  color: #34424c;
}

.demo-controls button:hover {
  background: #eef1f3;
}

.demo-controls button[aria-pressed="true"] {
  border-color: var(--header);
  background: var(--header);
  color: #fff;
}

[hidden] {
  display: none !important;
}

@media (max-width: 68rem) {
  .inspection-layout {
    grid-template-columns: 1fr;
  }

  .evidence-frame img {
    max-height: 34rem;
  }

  .demo-panel {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-groups {
    width: 100%;
  }

  .demo-controls button {
    flex: 1;
  }
}

@media (max-width: 42rem) {
  .app-header,
  .page-heading,
  .panel-heading,
  .operator-actions__heading {
    align-items: flex-start;
  }

  .app-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .system-state {
    align-self: stretch;
    justify-content: center;
  }

  .page-heading {
    flex-direction: column;
  }

  .panel-heading {
    flex-direction: column;
  }

  .evidence-meta,
  .metrics,
  .versions,
  .action-buttons {
    grid-template-columns: 1fr;
  }

  .app-error {
    align-items: stretch;
    flex-direction: column;
  }

  .status-banner {
    min-height: 7.5rem;
    padding: 1rem;
  }

  .status-banner__icon {
    flex-basis: 3.25rem;
    width: 3.25rem;
    height: 3.25rem;
  }

  .defect-summary,
  .metrics,
  .versions,
  .operator-actions {
    padding: 1rem;
  }

  .defect-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-controls__buttons {
    flex-direction: column;
  }

  .demo-controls button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
