/* ─────────────────────────────────────────────────────────────────────
   Image Inspector · design system
   ───────────────────────────────────────────────────────────────────── */
:root {
  /* palette */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e0;
  --text: #0f172a;
  --text-soft: #475569;
  --text-mute: #94a3b8;
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --accent: #0ea5e9;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  /* radius / shadow */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);

  /* type */
  --font:
    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'JetBrains Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ───────── Header ───────── */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 60%, #312e81 100%);
  color: #e2e8f0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.app-header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 32px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #818cf8, #6366f1 55%, #4f46e5);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  color: white;
}
.brand-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-title h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #f8fafc;
}
.brand-title .brand-tag {
  font-size: 12px;
  color: #a5b4fc;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
}
.header-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.subtitle-bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px 22px;
  color: #cbd5e1;
  font-size: 13.5px;
  max-width: 1180px;
}

/* ───────── Layout ───────── */
main {
  max-width: 1180px;
  margin: -16px auto 0;
  padding: 0 32px 72px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 650;
  font-size: 13px;
  flex-shrink: 0;
}
.card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
}
.card-header .header-aside {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-mute);
}

.hint {
  color: var(--text-soft);
  font-size: 13px;
  margin: 0 0 14px;
}
.muted {
  color: var(--text-mute);
  font-size: 13px;
}
code {
  font-family: var(--font-mono);
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text);
}

/* ───────── How-to ───────── */
.howto {
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--r-lg);
  padding: 0;
}
.howto details {
  padding: 16px 22px;
}
.howto summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}
.howto summary::-webkit-details-marker {
  display: none;
}
.howto summary::before {
  content: '?';
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.howto summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--text-mute);
  font-size: 12px;
  transition: transform 0.15s ease;
}
.howto details[open] summary::after {
  transform: rotate(180deg);
}
.howto-list {
  margin: 14px 0 4px 32px;
  padding: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-soft);
}
.howto-list strong {
  color: var(--text);
}
.howto-list ul {
  margin: 6px 0 6px 20px;
}

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.05s;
}
.btn:hover {
  background: var(--surface-2);
  border-color: #94a3b8;
}
.btn:active {
  transform: translateY(1px);
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}
.btn.primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.25);
}
.btn.primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}
.btn.big {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 600;
}
.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn.small {
  padding: 5px 11px;
  font-size: 12px;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}
.btn.ghost:hover {
  background: var(--surface-3);
  border-color: transparent;
}

/* spinner inside button */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ───────── Validators ───────── */
#validators-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}
.validator-item {
  background: var(--surface-2);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition:
    border-color 0.12s,
    background 0.12s;
}
.validator-item:hover {
  border-color: #c7d2fe;
}
.validator-item label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.validator-item input[type='checkbox'] {
  margin-top: 3px;
  width: 15px;
  height: 15px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}
.vname {
  font-weight: 600;
  color: var(--text);
  font-size: 13.5px;
}
.vdesc {
  color: var(--text-soft);
  font-size: 12.5px;
  margin-top: 3px;
  line-height: 1.45;
}

/* ───────── Upload ───────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dropzone {
  background: var(--surface-2);
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 18px;
  min-height: 180px;
  transition:
    background 0.15s,
    border-color 0.15s;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
}
.dropzone:hover {
  border-color: #a5b4fc;
  background: #fafbff;
}
.dropzone.drag-over {
  background: var(--brand-soft);
  border-color: var(--brand);
  border-style: solid;
}
.dz-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.dz-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.dropzone[data-kind='gen'] .dz-icon {
  background: #ecfeff;
  color: #0e7490;
}
.dropzone h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.dropzone-hint {
  margin: 0 0 12px;
  font-size: 12.5px;
  color: var(--text-soft);
}
.dropzone-hint .link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-weight: 500;
}
.dz-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
}
.dz-count {
  font-size: 12px;
  color: var(--text-mute);
}

.file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.file-thumb {
  position: relative;
  width: 96px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s;
}
.file-thumb:hover {
  transform: translateY(-1px);
}
.file-thumb img {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--surface-3);
}
.file-thumb-name {
  width: 100%;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  color: var(--text-soft);
}
.file-thumb-sku {
  margin-top: 3px;
  font-size: 10px;
  color: var(--brand-strong);
  background: var(--brand-soft);
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-weight: 500;
}
.file-thumb-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.7);
  color: white;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.file-thumb:hover .file-thumb-remove {
  opacity: 1;
}

/* ───────── Prompt textarea ───────── */
.prompt-label {
  display: block;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
}
.prompt-label textarea,
.group-prompt {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 0.12s,
    box-shadow 0.12s;
}
.prompt-label textarea:focus,
.group-prompt:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

/* ───────── Grouping ───────── */
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.group-card:hover {
  border-color: #c7d2fe;
}
.group-card--skip {
  opacity: 0.7;
  background: var(--surface-2);
}
.group-head {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.group-sku-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.group-sku-label {
  font-size: 10.5px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.group-sku-value {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  font-family: var(--font-mono);
  background: var(--surface-3);
  padding: 3px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.group-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  background: var(--surface-3);
  color: var(--text-soft);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
}
.chip-warn {
  background: var(--warning-soft);
  color: var(--warning);
}
.chip-skip {
  background: var(--danger-soft);
  color: var(--danger);
}
.group-prompt-label {
  display: block;
  font-size: 12px;
  color: var(--text-soft);
  margin: 8px 0;
  font-weight: 500;
}
.group-prompt {
  font-size: 12.5px;
  padding: 8px 10px;
}
.group-thumbs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px;
}
.group-thumbs h5 {
  margin: 0 0 6px;
  font-size: 11.5px;
  color: var(--text-mute);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.thumb-row img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface-3);
  transition: transform 0.1s;
}
.thumb-row img:hover {
  transform: scale(1.05);
}
.group-summary {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--brand-soft);
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--brand-strong);
  border: 1px solid #c7d2fe;
}
.group-summary strong {
  color: var(--brand-strong);
  font-weight: 650;
}

/* ───────── Actions / status ───────── */
.actions-bar {
  position: sticky;
  bottom: 18px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-lg);
}
.actions-bar #status {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.status {
  font-size: 13.5px;
  color: var(--text-soft);
  min-height: 20px;
}
.status.error {
  color: var(--danger);
}
.status.success {
  color: var(--success);
}
.status.loading {
  color: var(--brand);
}
.status.loading::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(79, 70, 229, 0.25);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -2px;
}

/* ───────── Results ───────── */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.results-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 24px;
  font-weight: 650;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.stat.success .stat-value {
  color: var(--success);
}
.stat.danger .stat-value {
  color: var(--danger);
}
.stat-meta {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}

.results-meta {
  font-size: 12.5px;
  color: var(--text-soft);
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}
.results-meta code {
  background: var(--surface);
}

.report-instance {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.report-instance h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 650;
  font-family: var(--font-mono);
  display: inline-block;
  background: var(--surface-3);
  padding: 3px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.instance-prompt {
  font-size: 12.5px;
  color: var(--text-soft);
  margin: 10px 0;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border-left: 3px solid var(--brand);
}
.instance-prompt strong {
  color: var(--text);
  font-weight: 600;
}

.report-image {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.report-image .img-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
}
.report-image .img-header strong {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}
.img-summary {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 10px;
}

.badge {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.pass {
  background: var(--success-soft);
  color: #166534;
}
.badge.fail {
  background: var(--danger-soft);
  color: #991b1b;
}
.severity {
  padding: 1px 7px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  margin-left: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.severity.info {
  background: #dbeafe;
  color: #1e40af;
}
.severity.baja {
  background: #fef9c3;
  color: #854d0e;
}
.severity.media {
  background: #fed7aa;
  color: #9a3412;
}
.severity.alta {
  background: var(--danger-soft);
  color: #991b1b;
}

.validator-result {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}
.validator-result:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}
.validator-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.validator-head strong {
  font-size: 13.5px;
  color: var(--text);
}
.latency {
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--font-mono);
}
.check-list {
  margin: 6px 0 0 0;
  padding: 0;
  font-size: 13px;
  list-style: none;
}
.check-list li {
  margin-bottom: 5px;
  padding-left: 22px;
  position: relative;
  line-height: 1.5;
}
.check-list li::before {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 700;
}
.check-list li.ok::before {
  content: '✓';
  color: var(--success);
}
.check-list li.ko::before {
  content: '✗';
  color: var(--danger);
}
.edit-instr {
  font-style: italic;
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 3px;
  display: block;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.checklist-details {
  margin: 10px 0;
  font-size: 12.5px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  border: 1px solid var(--border);
}
.checklist-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-soft);
  font-size: 12px;
}
.checklist-details ul {
  margin: 6px 0;
  padding-left: 20px;
}

.hidden {
  display: none !important;
}

/* ───────── Responsive ───────── */
@media (max-width: 820px) {
  .app-header-inner {
    padding: 22px 20px 18px;
  }
  .subtitle-bar {
    padding: 0 20px 18px;
  }
  main {
    padding: 0 16px 64px;
  }
  .card {
    padding: 18px 16px;
  }
  .upload-grid,
  .group-thumbs {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .actions-bar .btn {
    justify-content: center;
  }
}
