/* Transportes Rino — Pedimentos automáticos
   Sistema de operación aduanal. Estética: instrumento fiscal, no landing.
   Display: Sora · Cuerpo: Inter · Datos/códigos: IBM Plex Mono */

:root {
  /* Tinta corporativa (navy Rino, refinado) */
  --ink-900: #071c28;
  --ink-800: #0b2634;
  --ink-700: #123246;
  --ink-600: #1c4258;

  /* Teal de marca */
  --teal: #3bc4da;
  --teal-bright: #5fd3e8;
  --teal-deep: #1b8ba0;

  /* Superficies claras */
  --paper: #eaeef1;
  --surface: #ffffff;
  --surface-2: #f6f9fa;
  --surface-3: #eef3f5;

  /* Líneas y texto */
  --line: #dce4e9;
  --line-strong: #c4d0d8;
  --text: #0d2531;
  --text-soft: #3d4f5a;
  --muted: #62747f;

  /* Semánticos */
  --green: #109067;
  --green-dark: #0b6f49;
  --amber: #b7791f;
  --red: #c23a31;

  --shadow-sm: 0 2px 8px rgba(7, 28, 40, 0.06);
  --shadow-md: 0 14px 34px rgba(7, 28, 40, 0.12);
  --shadow-lg: 0 30px 70px rgba(7, 28, 40, 0.20);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--paper);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0 0 56px;
}

.card {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  min-width: 0;
}

/* ---------- Topbar (glass) ---------- */
.topbar {
  position: absolute;
  top: 20px;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1180px, calc(100% - 48px));
  min-height: 64px;
  padding: 12px 16px 12px 20px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  background: rgba(9, 32, 45, 0.42);
  box-shadow: 0 10px 34px rgba(4, 18, 28, 0.28);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
}

.brand strong {
  color: var(--teal-bright);
  font-weight: 800;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 11px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}

.home-link:hover {
  border-color: var(--teal);
  color: var(--ink-900);
  background: var(--teal-bright);
  transform: translateY(-1px);
}

/* ---------- Hero (instrumento fiscal, sin foto) ---------- */
.hero {
  position: relative;
  min-height: 0;
  padding: 100px max(32px, calc((100vw - 1180px) / 2 + 32px)) 56px;
  border-bottom: 0;
  background:
    radial-gradient(115% 90% at 88% -20%, rgba(59, 196, 218, 0.20), transparent 52%),
    radial-gradient(90% 120% at 0% 0%, rgba(28, 66, 88, 0.55), transparent 60%),
    linear-gradient(168deg, #0a2534 0%, #071b27 60%, #061620 100%);
  color: #ffffff;
  isolation: isolate;
  overflow: hidden;
}

/* Retícula fina = naturaleza tabular del pedimento (produce un Excel) */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  background-position: center top;
  -webkit-mask-image: radial-gradient(120% 90% at 30% 20%, #000 30%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 30% 20%, #000 30%, transparent 78%);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 72px;
  z-index: -1;
  background: linear-gradient(0deg, var(--paper), rgba(234, 238, 241, 0));
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 12px;
  color: var(--teal-bright);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.kicker::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--teal);
  flex: 0 0 auto;
}

.hero h1 {
  margin: 0;
  max-width: 15ch;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1.03;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.hero h1 span {
  display: inline;
}

.hero h1 span + span {
  color: var(--teal-bright);
}

.hero p {
  max-width: 62ch;
  margin: 12px 0 0;
  color: rgba(226, 238, 244, 0.82);
  font-size: clamp(0.95rem, 1.2vw, 1.06rem);
  font-weight: 400;
  overflow-wrap: anywhere;
}

code {
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ink-700);
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 0.88em;
  font-weight: 500;
}

.hero code {
  color: var(--teal-bright);
  background: rgba(59, 196, 218, 0.14);
  box-shadow: inset 0 0 0 1px rgba(95, 211, 232, 0.4);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  max-width: 100%;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(59, 196, 218, 0.22);
}

/* ---------- Form shell ---------- */
#gpaForm {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 48px));
  margin: -40px auto 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.pedimentos-stack {
  display: grid;
  gap: 16px;
}

.pedimento-card,
.invoice-card,
.error-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.pedimento-card {
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.pedimento-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.pedimento-header,
.invoice-card-header,
.pedimento-tools,
.builder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pedimento-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.pedimento-header h2 {
  margin: 3px 0 0;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.24rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.pedimento-kicker {
  margin: 0;
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 12px;
}

.pedimento-fields {
  margin-top: 12px;
}

.provider-auto-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--teal-deep);
  font-size: 0.9rem;
  font-weight: 600;
}

.fields label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.fields input,
.fields select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.fields input:focus,
.fields select:focus {
  border-color: var(--teal-deep);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(59, 196, 218, 0.22);
}

.invoice-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.invoice-card {
  padding: 14px;
  background: var(--surface-2);
}

.invoice-card-header {
  margin-bottom: 12px;
  color: var(--text);
}

.invoice-card-header strong {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 600;
}

.drop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.drop-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

/* Dropzone = ranura de recepción de documentos */
.dropzone {
  position: relative;
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 96px;
  padding: 14px 112px 14px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}

.dropzone input[type="file"] {
  display: none;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--teal-deep);
  background: rgba(59, 196, 218, 0.06);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.dropzone.dragover {
  border-style: solid;
}

.dropzone strong {
  color: var(--text);
  font-size: 0.96rem;
  font-weight: 700;
}

.drop-hint {
  color: var(--muted);
  font-size: 0.88rem;
}

.file-name {
  color: var(--text-soft);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 500;
}

.file-name-full {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.drop-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 74px;
  min-height: 42px;
  transform: translateY(-50%);
  border-radius: 11px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.docx-icon {
  color: var(--teal-deep);
  box-shadow: inset 0 0 0 1px rgba(27, 139, 160, 0.4);
}

.pdf-icon {
  color: var(--ink-700);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.dropzone.filled {
  border-style: solid;
  border-color: rgba(16, 144, 103, 0.5);
  background: linear-gradient(135deg, #ecfaf3 0, #f6fdfa 100%);
}

/* Estado cargado: una sola píldora verde "✓ Listo" (reemplaza el icono PDF),
   sin badge flotante que se encime. */
.drop-done {
  position: absolute;
  right: 16px;
  top: 50%;
  display: none;
  align-items: center;
  gap: 7px;
  padding: 0 15px 0 12px;
  min-height: 42px;
  transform: translateY(-50%);
  border-radius: 999px;
  color: #ffffff;
  background: var(--green);
  box-shadow: 0 6px 16px rgba(16, 144, 103, 0.32);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.drop-check {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  position: relative;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}

.drop-check::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(45deg);
}

.dropzone.filled .drop-icon {
  display: none;
}

.dropzone.filled .drop-done {
  display: inline-flex;
  animation: dropDonePop 0.34s var(--ease) both;
}

/* Cargado: se oculta el "toca para seleccionar" (ya no aplica) y el nombre
   del archivo pasa a primer plano en verde. */
.dropzone.filled .drop-hint {
  display: none;
}

.dropzone.filled .file-name {
  color: var(--green-dark);
  font-weight: 600;
}

@keyframes dropDonePop {
  0% { opacity: 0; transform: translateY(-50%) scale(0.8); }
  60% { transform: translateY(-50%) scale(1.06); }
  100% { opacity: 1; transform: translateY(-50%) scale(1); }
}

.req-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 0 8px;
  border: 1px solid rgba(59, 196, 218, 0.5);
  border-radius: 999px;
  color: var(--teal-deep);
  background: rgba(59, 196, 218, 0.12);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: middle;
}

.dropzone.docx-optional {
  opacity: 0.55;
  pointer-events: none;
  border-style: dotted;
}

.dropzone.docx-optional .req-badge {
  color: var(--muted);
  background: var(--surface-3);
  border-color: var(--line);
}

.pedimento-tools,
.builder-actions {
  margin-top: 12px;
  flex-wrap: wrap;
}

.pedimento-tools {
  justify-content: flex-start;
}

.pedimento-batch-hint {
  flex-basis: 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Botones ---------- */
.secondary-btn,
.text-btn,
#submitBtn {
  border: 0;
  border-radius: 11px;
  font-weight: 600;
}

.secondary-btn {
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--ink-800);
  color: var(--ink-800);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.76rem;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.secondary-btn:hover {
  border-color: var(--ink-900);
  color: #ffffff;
  background: var(--ink-900);
  transform: translateY(-1px);
}

.text-btn {
  padding: 3px 0;
  color: var(--teal-deep);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 600;
}

.text-btn:hover {
  text-decoration: underline;
}

.danger-text {
  color: var(--red);
}

.action-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface) 0, var(--surface-2) 100%);
  box-shadow: var(--shadow-sm);
}

#submitBtn {
  min-height: 52px;
  padding: 0 28px;
  color: #ffffff;
  background: var(--ink-900);
  box-shadow: 0 10px 24px rgba(7, 28, 40, 0.22);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), opacity 0.18s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease);
}

#submitBtn:hover:not(:disabled) {
  color: var(--ink-900);
  background: var(--teal-bright);
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(59, 196, 218, 0.32);
}

#submitBtn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  box-shadow: none;
}

#submitBtn.is-loading {
  cursor: progress;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.status.ok {
  color: var(--green-dark);
}

.status.error {
  color: var(--red);
}

.error-panel {
  margin-top: 14px;
  padding: 16px;
  border-color: rgba(194, 58, 49, 0.24);
  background: #fdf5f4;
}

.error-panel strong {
  display: block;
  margin-bottom: 8px;
  color: var(--red);
  font-family: var(--font-display);
}

.error-log {
  max-height: 260px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid rgba(194, 58, 49, 0.2);
  border-radius: var(--radius-sm);
  color: #6f2424;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
}

/* ---------- Footer ---------- */
.app-footer {
  width: 100%;
  margin: 56px auto 0;
  padding: 30px 20px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  background: var(--ink-900);
}

.app-footer strong {
  color: var(--teal-bright);
  font-weight: 600;
}

/* ---------- Overlay de procesamiento ---------- */
.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(6, 22, 32, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

.processing-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.processing-card {
  position: relative;
  width: min(500px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.4);
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  transition: transform 0.25s var(--ease), opacity 0.25s var(--ease);
}

.processing-overlay.active .processing-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.processing-spinner-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.processing-spinner {
  width: 58px;
  height: 58px;
  border: 4px solid rgba(59, 196, 218, 0.16);
  border-top-color: var(--teal-deep);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.processing-title {
  margin: 0;
  color: var(--text);
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.processing-subtitle {
  margin: 6px 0 20px;
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
}

.processing-progress {
  margin-bottom: 20px;
}

.processing-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-3);
}

.processing-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal-bright));
  transition: width 0.22s var(--ease);
}

.processing-percent {
  margin: 7px 0 0;
  color: var(--muted);
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
}

.processing-steps {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.processing-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: var(--surface-2);
  font-size: 0.9rem;
  font-weight: 500;
}

.step-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  color: var(--text-soft);
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
}

.processing-steps li.active {
  border-color: rgba(59, 196, 218, 0.36);
  color: var(--teal-deep);
  background: rgba(59, 196, 218, 0.08);
}

.processing-steps li.active .step-marker {
  color: #ffffff;
  background: var(--teal-deep);
}

.processing-steps li.done {
  border-color: rgba(16, 144, 103, 0.3);
  color: var(--green-dark);
  background: #ecfaf3;
}

.processing-steps li.done .step-marker {
  color: #ffffff;
  background: var(--green);
}

.processing-steps li.done .step-marker span {
  display: none;
}

.processing-steps li.done .step-marker::after {
  content: "";
  width: 6px;
  height: 11px;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(45deg) translate(-1px, -1px);
}

.processing-steps li.error {
  border-color: rgba(194, 58, 49, 0.3);
  color: var(--red);
  background: #fdf3f2;
}

.processing-steps li.error .step-marker {
  color: #ffffff;
  background: var(--red);
}

.processing-dots {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
}

.processing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  animation: dotBounce 1.1s ease-in-out infinite;
}

.processing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.processing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

.processing-steps li:not(.active) .processing-dots {
  display: none;
}

.processing-success {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 0 2px;
}

.processing-card.is-success .processing-spinner-wrap,
.processing-card.is-success .processing-progress,
.processing-card.is-success .processing-steps,
.processing-card.is-success .processing-title,
.processing-card.is-success .processing-subtitle {
  display: none;
}

.processing-card.is-success .processing-success {
  display: flex;
}

.success-check {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--green);
}

.success-check::after {
  content: "";
  position: absolute;
  left: 27px;
  top: 16px;
  width: 18px;
  height: 34px;
  border-right: 5px solid #ffffff;
  border-bottom: 5px solid #ffffff;
  transform: rotate(45deg);
}

.processing-success-title {
  margin: 5px 0 0;
  color: var(--green-dark);
  font-family: var(--font-display);
  font-size: 1.14rem;
  font-weight: 700;
}

.processing-success-sub {
  margin: 0;
  color: var(--muted);
}

.confetti-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: inherit;
}

.confetti-piece {
  position: absolute;
  top: 0;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall 1.6s ease-in forwards;
}

/* ---------- Animaciones ---------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes dotBounce {
  0%,
  80%,
  100% {
    transform: scale(0.62);
    opacity: 0.45;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -40px, 0) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translate3d(var(--cx, 0), 100vh, 0) rotate(720deg);
    opacity: 0;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Entrada fluida escalonada del hero */
.hero .kicker,
.hero h1,
.hero p,
.hero-meta {
  animation: riseIn 0.7s var(--ease) both;
}

.hero h1 {
  animation-delay: 0.06s;
}

.hero p {
  animation-delay: 0.14s;
}

.hero-meta {
  animation-delay: 0.22s;
}

#gpaForm {
  animation: riseIn 0.7s var(--ease) 0.18s both;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .page {
    width: 100%;
    padding-top: 0;
  }

  .topbar {
    width: calc(100% - 32px);
    top: 16px;
  }

  .hero {
    min-height: 420px;
    padding: 148px 24px 96px;
  }

  #gpaForm {
    width: calc(100% - 32px);
    padding: 18px;
  }

  .fields,
  .drop-grid {
    grid-template-columns: 1fr;
  }

  .action-bar {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
    grid-template-columns: 1fr;
    gap: 10px;
    box-shadow: 0 16px 34px rgba(6, 22, 32, 0.18);
  }

  #submitBtn {
    width: 100%;
  }

  .status {
    text-align: center;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .page {
    width: 100%;
    padding: 0 0 16px;
  }

  .card {
    width: 100%;
    border-radius: 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    width: calc(100% - 20px);
    top: 10px;
    padding: 12px;
  }

  .brand {
    justify-content: center;
  }

  .topbar-actions,
  .home-link {
    width: 100%;
  }

  .home-link {
    min-height: 42px;
  }

  .hero {
    min-height: 480px;
    padding: 182px 22px 88px;
    text-align: center;
  }

  .kicker {
    justify-content: center;
    font-size: 0.68rem;
    letter-spacing: 0.16em;
  }

  .hero h1 {
    max-width: 100%;
    font-size: 2.1rem;
    line-height: 1.06;
  }

  .hero p {
    max-width: 42ch;
    margin-right: auto;
    margin-left: auto;
    font-size: 0.98rem;
  }

  .hero-meta {
    align-items: center;
    flex-direction: column;
    justify-content: center;
    max-width: 320px;
    margin-right: auto;
    margin-left: auto;
  }

  .pill {
    justify-content: center;
    width: 100%;
    min-height: 36px;
    text-align: center;
  }

  .pedimento-card {
    max-width: 100%;
    padding: 16px;
    overflow: hidden;
  }

  #gpaForm {
    width: calc(100% - 20px);
    margin-top: -52px;
    padding: 14px;
  }

  .pedimento-header,
  .invoice-card-header,
  .builder-actions,
  .pedimento-tools {
    align-items: flex-start;
    flex-direction: column;
  }

  .dropzone {
    min-height: 150px;
    padding: 16px;
  }

  .drop-icon {
    position: static;
    width: max-content;
    min-width: 58px;
    min-height: 30px;
    transform: none;
    font-size: 0.76rem;
  }

  .drop-done {
    position: static;
    min-height: 34px;
    margin-top: 2px;
    transform: none;
  }

  .dropzone.filled .drop-done {
    animation: none;
    transform: none;
  }

  .app-footer {
    width: 100%;
  }
}

/* ============ Portada de inicio (gate con botón Iniciar) ============ */
#introGate {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(115% 90% at 88% -20%, rgba(59, 196, 218, 0.22), transparent 52%),
    radial-gradient(90% 120% at 0% 0%, rgba(28, 66, 88, 0.55), transparent 60%),
    linear-gradient(168deg, #0a2534 0%, #071b27 60%, #061620 100%);
  transition: opacity 0.5s var(--ease);
}

/* Retícula fina, como el hero */
#introGate::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 30%, #000 30%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 50% 30%, #000 30%, transparent 78%);
  pointer-events: none;
}

/* Ya vio la guía: no se muestra la portada */
.tour-seen #introGate {
  display: none;
}

#introGate.hide {
  opacity: 0;
  pointer-events: none;
}

.intro-inner {
  position: relative;
  max-width: 540px;
  animation: introRise 0.7s var(--ease) both;
}

.intro-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 22px;
}

.intro-eyebrow {
  margin: 0 0 12px;
  color: var(--teal-bright);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.intro-title {
  margin: 0;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 3.2rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.02em;
}

.intro-title span {
  color: var(--teal-bright);
}

.intro-sub {
  margin: 14px auto 0;
  max-width: 42ch;
  color: rgba(226, 238, 244, 0.82);
  font-size: 1.02rem;
}

.intro-start {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 32px;
  padding: 16px 40px;
  border: 0;
  border-radius: 14px;
  color: var(--ink-900);
  background: linear-gradient(135deg, var(--teal-bright), var(--teal));
  font-family: var(--font-display);
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 40px rgba(59, 196, 218, 0.36);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}

.intro-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(59, 196, 218, 0.48);
  filter: brightness(1.04);
}

.intro-start:active {
  transform: translateY(0);
}

.intro-play {
  font-size: 0.82rem;
  transform: translateX(1px);
}

.intro-skip {
  display: block;
  margin: 16px auto 0;
  padding: 6px 10px;
  border: 0;
  color: rgba(226, 238, 244, 0.62);
  background: transparent;
  font-size: 0.86rem;
  font-weight: 500;
  transition: color 0.18s var(--ease);
}

.intro-skip:hover {
  color: #ffffff;
  text-decoration: underline;
}

@keyframes introRise {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ Botón de ayuda (topbar / revisión) ============ */
.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 11px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.help-btn:hover {
  border-color: var(--teal);
  color: var(--ink-900);
  background: var(--teal-bright);
  transform: translateY(-1px);
}

.help-btn .help-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--ink-900);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
}

.help-btn:hover .help-ic {
  background: var(--ink-900);
  color: var(--teal-bright);
}

/* ============ Tour de onboarding (spotlight + globos guía) ============ */
#tourLayer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
}

#tourLayer.active {
  display: block;
}

.tour-spotlight {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 0 0 9999px rgba(6, 22, 32, 0.76);
  pointer-events: none;
  transition:
    top 0.42s var(--ease),
    left 0.42s var(--ease),
    width 0.42s var(--ease),
    height 0.42s var(--ease),
    border-radius 0.42s var(--ease);
}

.tour-spotlight::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 2px solid var(--teal-bright);
  animation: tourPulse 1.9s var(--ease) infinite;
}

.tour-spotlight.is-center::after {
  display: none;
}

@keyframes tourPulse {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(59, 196, 218, 0.3);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(59, 196, 218, 0);
  }
}

.tour-pop {
  position: fixed;
  z-index: 3001;
  width: min(360px, calc(100vw - 32px));
  padding: 18px 18px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 26px 68px rgba(0, 0, 0, 0.44);
  pointer-events: auto;
  opacity: 0;
  transition:
    opacity 0.26s var(--ease),
    top 0.34s var(--ease),
    left 0.34s var(--ease);
}

.tour-pop.show {
  opacity: 1;
}

.tour-pop-arrow {
  position: absolute;
  left: 24px;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  transform: rotate(45deg);
}

.tour-pop[data-place="bottom"] .tour-pop-arrow {
  top: -8px;
  border-right: 0;
  border-bottom: 0;
}

.tour-pop[data-place="top"] .tour-pop-arrow {
  bottom: -8px;
  border-left: 0;
  border-top: 0;
}

.tour-pop[data-place="center"] .tour-pop-arrow {
  display: none;
}

/* Botón de voz: activo por defecto (rojo = silenciar); apagado = teal "escuchar" */
.tour-audio {
  position: absolute;
  top: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 0;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.16s var(--ease), color 0.16s var(--ease), transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.tour-audio.on {
  color: #ffffff;
  background: var(--red);
  box-shadow: 0 4px 12px rgba(194, 58, 49, 0.32);
}

.tour-audio.on:hover {
  background: #a82f27;
  transform: translateY(-1px);
}

.tour-audio.off {
  color: var(--teal-deep);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}

.tour-audio.off:hover {
  color: var(--ink-900);
  background: rgba(59, 196, 218, 0.14);
  transform: translateY(-1px);
}

.tour-audio .ic {
  font-size: 0.82rem;
  line-height: 1;
}

.tour-audio.speaking .ic {
  animation: tourSpeak 0.9s ease-in-out infinite;
}

@keyframes tourSpeak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.tour-pop-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 100px 8px 0;
  color: var(--teal-deep);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tour-pop-eyebrow .tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(59, 196, 218, 0.22);
}

.tour-pop h3 {
  margin: 0 0 6px;
  color: var(--ink-900);
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tour-pop p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.tour-pop-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}

.tour-progress {
  display: flex;
  gap: 5px;
  margin-right: auto;
}

.tour-progress i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}

.tour-progress i.on {
  background: var(--teal-deep);
  transform: scale(1.25);
}

.tour-btn {
  border: 0;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.16s var(--ease), background 0.16s var(--ease), box-shadow 0.16s var(--ease), color 0.16s var(--ease);
}

.tour-btn.primary {
  color: #ffffff;
  background: var(--ink-900);
}

.tour-btn.primary:hover {
  color: var(--ink-900);
  background: var(--teal-bright);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(59, 196, 218, 0.32);
}

.tour-btn.ghost {
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
}

.tour-btn.ghost:hover {
  color: var(--text);
}

@media (max-width: 640px) {
  .tour-pop {
    width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Bifurcación importación / exportación -------------------------------
   Misma piel que la portada de inicio (#introGate) para que se lea como un
   paso del mismo sistema y no como otra pantalla. */
#modoGate {
  position: fixed;
  inset: 0;
  z-index: 4100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(115% 90% at 88% -20%, rgba(59, 196, 218, 0.22), transparent 52%),
    radial-gradient(90% 120% at 0% 0%, rgba(28, 66, 88, 0.55), transparent 60%),
    linear-gradient(168deg, #0a2534 0%, #071b27 60%, #061620 100%);
  transition: opacity 0.42s var(--ease);
}
#modoGate::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 30%, #000 30%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 50% 30%, #000 30%, transparent 78%);
  pointer-events: none;
}
#modoGate.hide { opacity: 0; pointer-events: none; }
.modo-inner { position: relative; max-width: 780px; width: 100%; }

.modo-opciones {
  display: flex;
  gap: 16px;
  margin-top: 26px;
  flex-wrap: wrap;
  justify-content: center;
}
.modo-card {
  flex: 1 1 280px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.055);
  color: #eaf6fb;
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s var(--ease), border-color 0.18s var(--ease),
    background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.modo-card:hover {
  transform: translateY(-3px);
  border-color: var(--teal);
  background: rgba(59, 196, 218, 0.12);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}
.modo-card:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
.modo-ic {
  font-size: 26px;
  line-height: 1;
  color: var(--teal);
}
.modo-nombre {
  font-family: var(--font-display);
  font-size: 1.24rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modo-desc { font-size: 13px; color: #b8d4e0; line-height: 1.45; }
.modo-desc b { color: #eaf6fb; }
.modo-tag {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: #8fb4c4;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 2px 9px;
}

/* Indicador del modo activo en la barra superior */
.modo-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-800);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.16s var(--ease), background 0.16s var(--ease);
}
.modo-chip:hover { border-color: var(--teal-deep); background: rgba(59, 196, 218, 0.1); }
.modo-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal-deep);
}
.modo-chip.exportacion .modo-chip-dot { background: var(--amber); }
