:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --surface-strong: #eef4f8;
  --text: #15202b;
  --muted: #627084;
  --line: #d9e2ec;
  --line-strong: #b8c7d6;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --accent-soft: #e5f5f2;
  --danger-soft: #fff1f2;
  --danger-line: #fecdd3;
  --danger: #be123c;
  --focus: #2563eb;
  --shadow: 0 12px 30px rgba(21, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #eef7f5 0, rgba(238, 247, 245, 0) 280px),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

button,
input,
a {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 22px;
}

.brand-block {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: 860px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

.eyebrow,
.step-label {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.page-header h1 {
  margin: 0;
  max-width: 760px;
  font-size: 34px;
  line-height: 1.15;
}

.lead,
.page-header p,
.panel-note,
.field-help {
  color: var(--muted);
}

.lead {
  max-width: 760px;
  margin: 10px 0 0;
  font-size: 16px;
}

.upload-form,
.status-layout {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2,
.action-panel h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.3;
}

.workflow-list {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: workflow;
}

.workflow-list li {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.workflow-list li::before {
  counter-increment: workflow;
  content: counter(workflow);
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset + fieldset,
.option-columns {
  margin-top: 18px;
}

legend {
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 800;
}

.segmented-control,
.option-grid,
.option-row {
  display: grid;
  gap: 10px;
}

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

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

.option-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.option-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.segmented-control label,
.option-grid label,
.option-row label {
  display: block;
  min-width: 0;
  cursor: pointer;
}

.segmented-control input,
.option-grid input,
.option-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span,
.option-grid span,
.option-row span {
  display: grid;
  gap: 5px;
  align-content: start;
  min-height: 96px;
  width: 100%;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.segmented-control strong,
.option-grid strong,
.option-row strong {
  font-size: 15px;
  line-height: 1.25;
}

.segmented-control small,
.option-grid small,
.option-row small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.segmented-control input:checked + span,
.option-grid input:checked + span,
.option-row input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.segmented-control input:focus-visible + span,
.option-grid input:focus-visible + span,
.option-row input:focus-visible + span,
button:focus-visible,
.button-link:focus-visible,
.file-field input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.25);
  outline-offset: 2px;
}

.file-fields {
  margin-top: 16px;
}

.file-field {
  display: grid;
  gap: 8px;
}

.file-field label {
  color: var(--text);
  font-weight: 800;
}

.file-field input {
  width: 100%;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.field-help {
  margin: 0;
  font-size: 13px;
}

.file-summary {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hidden {
  display: none;
}

.limit-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.limit-list li {
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.limit-list strong {
  color: var(--text);
}

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

.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.panel-note {
  margin: 6px 0 0;
}

.action-panel button {
  min-width: 180px;
  min-height: 48px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.action-panel button:hover,
.button-link:hover {
  background: var(--accent-strong);
}

.action-panel button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-link {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.secondary-link:hover {
  background: var(--surface-strong);
}

.status-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.empty-state {
  min-height: 92px;
  display: flex;
  align-items: center;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
}

.job-result {
  display: grid;
  gap: 10px;
}

.job-result-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.job-result-row span {
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.summary-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-item strong {
  overflow-wrap: anywhere;
}

.result-section {
  margin-top: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.result-card {
  display: grid;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.preview-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background:
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f1f5f9 75%),
    linear-gradient(-45deg, transparent 75%, #f1f5f9 75%);
  background-color: #ffffff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.result-card-body {
  display: grid;
  gap: 9px;
  padding: 13px;
}

.result-card-body h3,
.result-card-body p {
  margin: 0;
  overflow-wrap: anywhere;
}

.result-card-body h3 {
  font-size: 16px;
}

.result-card-body p {
  color: var(--muted);
  font-size: 13px;
}

.failure-list {
  padding: 14px;
  border: 1px solid var(--danger-line);
  border-radius: 8px;
  background: var(--danger-soft);
}

.failure-list strong {
  color: var(--danger);
}

.failure-list ul {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding-left: 20px;
}

.failure-list li {
  overflow-wrap: anywhere;
}

.failure-list span {
  display: block;
  color: var(--muted);
}

@media (max-width: 960px) {
  .workflow-list,
  .option-grid-four,
  .limit-list,
  .summary-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .option-columns,
  .status-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1160px);
    padding-top: 20px;
  }

  .page-header,
  .brand-block,
  .action-panel {
    flex-direction: column;
  }

  .page-header h1 {
    font-size: 27px;
  }

  .segmented-control,
  .option-row,
  .workflow-list,
  .option-grid-four,
  .limit-list,
  .summary-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .action-panel button,
  .button-link {
    width: 100%;
  }
}
