:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172024;
  --muted: #657078;
  --line: #d9e0e4;
  --accent: #16795f;
  --accent-dark: #0d5946;
  --warn: #a15b12;
  --danger: #b3261e;
  --shadow: 0 14px 35px rgba(23, 32, 36, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
}

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

h1 {
  font-size: 30px;
}

h2 {
  font-size: 17px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.status-pill.ready {
  color: var(--accent-dark);
  border-color: #a8d8c9;
}

.status-pill.missing {
  color: var(--danger);
  border-color: #e6b5b2;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(380px, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 180px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 150px;
  margin: 16px;
  border: 1px dashed #9aa8af;
  border-radius: 8px;
  background: #f9fbfb;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}

.drop-zone input {
  display: none;
}

.model-drop-zone {
  min-height: 112px;
  margin-top: 0;
}

.drop-title {
  display: block;
  color: var(--accent-dark);
  font-weight: 700;
}

.drop-sub {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.image-card {
  position: relative;
  display: block;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f3;
  cursor: pointer;
}

.image-card.selected {
  border-color: var(--accent);
}

.image-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-card span {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card select {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  width: calc(100% - 12px);
  min-height: 30px;
  margin: 0;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.94);
  font-size: 12px;
}

.image-card.view-assigned {
  border-color: #5d7990;
}

.model-grid {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.model-card {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--text);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.model-card.selected {
  border-color: var(--accent);
  background: #eef8f4;
}

.model-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-card span {
  color: var(--muted);
  font-size: 12px;
}

.primary-button,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 7px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
}

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

.primary-button:disabled {
  background: #b8c5c4;
  cursor: not-allowed;
}

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

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

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 13px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.segmented label {
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
}

.segmented input:checked + span {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #eaf6f1;
}

.view-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.view-slots button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-align: left;
  padding: 0 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-slots button.assigned {
  border-color: #5d7990;
  background: #eef5f8;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 82px;
  gap: 10px;
  align-items: center;
}

output {
  text-align: right;
  color: var(--accent-dark);
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 36px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.switch {
  width: 46px;
  height: 26px;
  position: relative;
}

.switch input {
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  background: #ccd5d8;
  border-radius: 999px;
  transition: 0.15s;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.15s;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.sub-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.field-help {
  grid-column: 1 / -1;
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.muted-options {
  opacity: 0.45;
  pointer-events: none;
}

.preview-strip {
  padding: 0 16px 16px;
}

.selected-preview {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  min-height: 116px;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f9fbfb;
}

.selected-preview > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.selected-preview img {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  object-fit: cover;
  background: #e8eef0;
}

.selected-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.job-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.job {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.job-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.job-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

.job-guidance {
  margin-top: 8px;
  border-left: 3px solid #8aa0aa;
  border-radius: 6px;
  padding: 8px 10px;
  background: #f4f7f8;
  color: #36464d;
  font-size: 12px;
  line-height: 1.45;
}

.job-guidance.running {
  border-left-color: var(--accent);
  background: #eef8f4;
  color: var(--accent-dark);
}

.job-guidance.manual {
  border-left-color: #c47b12;
  background: #fff7e8;
  color: #6d4308;
}

.job-guidance.ready {
  border-left-color: var(--accent);
  background: #eaf7f1;
  color: var(--accent-dark);
}

.job-guidance.failed {
  border-left-color: var(--danger);
  background: #fff6f5;
  color: var(--danger);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #dfe7e9;
  overflow: hidden;
  margin-top: 10px;
}

.progress span {
  display: block;
  height: 100%;
  width: 18%;
  background: var(--accent);
  animation: pulse-width 1.2s ease-in-out infinite alternate;
}

@keyframes pulse-width {
  from { width: 18%; }
  to { width: 92%; }
}

.job.done .progress span {
  width: 100%;
  animation: none;
}

.job.failed {
  border-color: #e6b5b2;
}

.job.needs-manual-fix {
  border-color: #e9c48c;
  background: #fffaf2;
}

.job details {
  margin-top: 10px;
}

.job summary {
  color: var(--warn);
  cursor: pointer;
  font-size: 13px;
}

.job pre {
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border-radius: 7px;
  background: #172024;
  color: #edf4f2;
  font-size: 12px;
  white-space: pre-wrap;
}

.links {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.orientation-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.orientation-preview figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #111;
}

.orientation-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.orientation-preview figcaption {
  padding: 4px 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.quality-gates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

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

.quality-gate.pass {
  border-color: #a8d8c9;
  background: #f0faf6;
}

.quality-gate.warning {
  border-color: #e9c48c;
  background: #fffaf2;
}

.quality-gate.fail {
  border-color: #e6b5b2;
  background: #fff6f5;
}

.quality-gate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

.quality-gate-head span {
  flex: 0 0 auto;
  border-radius: 5px;
  padding: 2px 6px;
  background: #edf1f2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.quality-gate.pass .quality-gate-head span {
  background: #d7efe6;
  color: var(--accent-dark);
}

.quality-gate.warning .quality-gate-head span {
  background: #fff0d5;
  color: #7a4b09;
}

.quality-gate.fail .quality-gate-head span {
  background: #f8dada;
  color: var(--danger);
}

.quality-gate-metric,
.quality-gate-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.quality-gate ul {
  display: grid;
  gap: 4px;
  margin: 7px 0 0;
  padding-left: 16px;
  color: #6d4308;
  font-size: 12px;
  line-height: 1.35;
}

.validation-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.validation-summary span {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 7px;
  background: #f7faf9;
  color: var(--ink);
  font-size: 12px;
}

.rig-warnings {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.rig-warnings span {
  border-left: 3px solid #c47b12;
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff7e8;
  color: #6d4308;
  font-size: 12px;
  line-height: 1.45;
}

.attempt-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.attempt-table-title {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.attempt-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 12px;
}

.input-attempt-table {
  min-width: 760px;
}

.attempt-table th,
.attempt-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #edf1f2;
  text-align: left;
  vertical-align: top;
}

.attempt-table th {
  color: var(--muted);
  font-weight: 700;
  background: #f7faf9;
}

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

.attempt-table tr.selected td {
  background: #eef8f4;
}

.chosen-front {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 5px;
  border-radius: 5px;
  background: #d7efe6;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.attempt-status {
  display: inline-block;
  min-width: 54px;
  padding: 2px 6px;
  border-radius: 5px;
  text-align: center;
  font-weight: 700;
}

.attempt-status.pass {
  background: #d7efe6;
  color: var(--accent-dark);
}

.attempt-status.manual {
  background: #fff0d5;
  color: #7a4b09;
}

.attempt-status.fail {
  background: #f8dada;
  color: var(--danger);
}

.attempt-status.neutral {
  background: #edf1f2;
  color: var(--muted);
}

.validation-preview figure {
  background: #202423;
}

.rig-preview {
  grid-template-columns: minmax(0, 1fr);
}

.rig-preview figure {
  background: #202423;
}

.links a,
.links button {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--accent-dark);
  text-decoration: none;
  cursor: pointer;
}

.links .primary-download,
.links .primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.links .review-download {
  border-color: #e9c48c;
  background: #fff7e8;
  color: #7a4b09;
}

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

  .form-grid {
    grid-template-columns: 1fr;
  }

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

  .quality-gates {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 1440px);
    padding: 12px 0;
  }

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

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

  .selected-preview {
    grid-template-columns: 72px 1fr;
  }

  .selected-preview img {
    width: 72px;
    height: 72px;
  }
}
.development-notice {
  margin: 18px 24px 0;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: minmax(240px, .75fr) 1.25fr;
  gap: 36px;
  border: 1px solid var(--accent);
  background: #e8f3ef;
}
.development-notice div { display: flex; flex-direction: column; gap: 10px; }
.development-notice span { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.development-notice strong { color: var(--text); font-size: clamp(18px, 2vw, 28px); }
.development-notice p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.9; }
.preview-only { pointer-events: none; }
.preview-footer {
  margin: 26px 24px 0;
  padding: 20px 0 28px;
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
}
.preview-footer a { color: var(--accent); text-decoration: none; font-weight: 800; }
@media (max-width: 720px) {
  .development-notice { grid-template-columns: 1fr; gap: 16px; margin-inline: 14px; padding: 18px; }
  .preview-footer { margin-inline: 14px; flex-direction: column; gap: 14px; }
}
