:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #fafafa;
  --card: #ffffff;
  --soft: #f3f4f6;
  --accent: #111827;
  --accent-hover: #1f2937;
  --ok: #065f46;
  --ok-bg: #ecfdf5;
  --ok-line: #a7f3d0;
  --no: #991b1b;
  --no-bg: #fef2f2;
  --no-line: #fecaca;
  --warn-bg: #fff7ed;
  --warn-line: #fed7aa;
  --radius: 6px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.shell {
  width: min(760px, 92vw);
  margin: 0 auto;
  padding: 56px 0 48px;
}

/* Hero */
.hero { text-align: center; margin-bottom: 28px; }
.hero h1 {
  margin: 14px 0 8px;
  font-size: clamp(2.1rem, 6vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.035em;
}
.hero p { margin: 0 auto; max-width: 540px; color: var(--muted); }
.hero-small { margin-bottom: 22px; }
.hero-small h1 { font-size: 1.8rem; }
.pill {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: #374151;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pill-link { text-decoration: none; text-transform: none; letter-spacing: 0; font-size: 0.8rem; }
.pill-link:hover { border-color: #d1d5db; }

/* Upload */
.upload { margin: 0 0 20px; }
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 220px;
  padding: 32px 24px;
  border: 1.5px dashed #d1d5db;
  border-radius: var(--radius);
  background: var(--card);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover,
.dropzone:focus-within,
.dropzone.dragover {
  border-color: var(--accent);
  background: #f9fafb;
}
.dropzone.has-file { border-style: solid; border-color: #9ca3af; }
.dropzone strong { font-size: 1.02rem; font-weight: 650; }
.dropzone span { color: var(--muted); font-size: 0.92rem; }
.dropzone small { margin-top: 8px; color: var(--muted); font-size: 0.78rem; }
.drop-icon { width: 34px; height: 34px; color: #4b5563; margin-bottom: 4px; }

.file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  min-height: 42px;
}
.upload-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 12px 0 0;
  color: #374151;
  font-size: 0.85rem;
  font-weight: 550;
}

/* Spinner (solo formas circulares) */
.spinner {
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.8s; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-ghost {
  background: var(--card);
  color: var(--ink);
  border-color: #d1d5db;
}
.btn-ghost:hover { background: var(--soft); border-color: #9ca3af; }
.link { color: var(--ink); font-size: 0.9rem; text-underline-offset: 3px; }

/* Panel */
.panel {
  margin-top: 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: #374151;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.03em;
}
.badge-done { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.badge-error { background: var(--no-bg); border-color: var(--no-line); color: var(--no); }
.badge-busy { display: inline-flex; align-items: center; gap: 7px; }
.working {
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9fafb;
  color: #374151;
  font-size: 0.86rem;
}
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* Progress */
.bar {
  display: block;
  width: 100%;
  height: 8px;
  margin: 0 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--line);
  overflow: hidden;
  appearance: none;
}
.bar::-webkit-progress-bar { background: var(--line); }
.bar::-webkit-progress-value { background: var(--accent); }
.bar::-moz-progress-bar { background: var(--accent); }
.bar-wait {
  position: relative;
  background: var(--line);
}
.bar-wait::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 38%;
  border-radius: var(--radius);
  background: var(--accent);
  animation: wait 1.2s ease-in-out infinite;
}
@keyframes wait {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(265%); }
}

/* Counters */
.counters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.counter {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.counter span { color: var(--muted); font-size: 0.8rem; }
.counter strong { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.02em; }
.counter.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.counter.no { background: var(--no-bg); border-color: var(--no-line); color: var(--no); }
.counter.ok span, .counter.no span { color: inherit; opacity: 0.78; }

/* Actions and lists */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 18px;
}
.list { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.list summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 550;
  color: #374151;
}
.list ul {
  max-height: 220px;
  overflow: auto;
  margin: 10px 0 4px;
  padding: 8px 10px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.6;
}
.list li { overflow-wrap: anywhere; }
.again { margin: 16px 0 0; }

/* Messages */
.alert, .note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-bg);
  color: #7c2d12;
  font-size: 0.88rem;
}
.note { margin: 0 0 14px; }
.panel-error { text-align: center; }
.error-text { margin: 14px 0 18px; color: #7c2d12; overflow-wrap: anywhere; }

/* Footer */
.foot {
  margin-top: 36px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}
.foot p { margin: 4px 0; }

/* HTMX */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline; }
.htmx-request .upload-status,
.upload-status.htmx-request { display: flex; }

@media (max-width: 520px) {
  .shell { padding-top: 36px; }
  .counters { grid-template-columns: 1fr; }
  .dropzone { min-height: 190px; padding: 26px 16px; }
}
