:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #0b5ed7;
  --primary-hover: #094db2;
  --primary-light: #e0f2fe;
  --danger: #dc3545;
  --danger-hover: #b52a37;
  --warn: #f59e0b;
  --warn-hover: #d97706;
  --success: #10b981;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --transition: all 0.2s ease-in-out;
  --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* { 
  box-sizing: border-box; 
}

body { 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg); 
  margin: 0; 
  padding: 20px; 
  color: var(--text);
  line-height: 1.6;
}

.container { 
  max-width: 1200px; 
  margin: 0 auto; 
}

h1 { 
  margin: 0 0 20px; 
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin: 20px 0;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card h2 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.form-group { 
  margin: 16px 0; 
}

label { 
  display: block; 
  font-weight: 600; 
  margin-bottom: 8px; 
  color: var(--text);
  font-size: 14px;
}

input[type="text"], input[type="number"], textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  transition: var(--transition);
  background: #fff;
  color: var(--text);
}

input[type="text"]:focus, input[type="number"]:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 94, 215, 0.1);
}

textarea { 
  height: 120px; 
  resize: vertical; 
  font-family: inherit;
}

.help, .muted { 
  font-size: 13px; 
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.tip { 
  margin-left: 10px; 
}

.alert {
  border-radius: 12px;
  padding: 14px 16px;
  margin: 16px 0;
  border: 1px solid;
  font-size: 14px;
  line-height: 1.5;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert.success { 
  background: #d1fae5; 
  border-color: #6ee7b7; 
  color: #065f46; 
}

.alert.error { 
  background: #fee2e2; 
  border-color: #fca5a5; 
  color: #991b1b; 
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  background: #f3f4f6;
  color: var(--text);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn:active {
  transform: translateY(0);
}

.btn.primary { 
  background: var(--primary); 
  color: #fff; 
}

.btn.primary:hover { 
  background: var(--primary-hover); 
  box-shadow: 0 4px 12px rgba(11, 94, 215, 0.3);
}

.btn.danger { 
  background: var(--danger); 
  color: #fff; 
}

.btn.danger:hover { 
  background: var(--danger-hover); 
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn.warn { 
  background: var(--warn); 
  color: #fff; 
}

.btn.warn:hover { 
  background: var(--warn-hover); 
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.grid-2 { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 12px; 
}

@media (max-width: 680px) { 
  .grid-2 { 
    grid-template-columns: 1fr; 
  }
  
  .thumb-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
  }
  
  .actions {
    grid-template-columns: 1fr;
  }
  
  .actions .btn {
    width: 100%;
  }
  
  .container {
    padding: 0 10px;
  }
  
  body {
    padding: 15px 10px;
  }
}

.meta {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.meta b {
  color: var(--text);
  font-weight: 600;
}

.order-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 12px;
  border: 1px solid #bae6fd;
}

.thumb-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  transition: var(--transition);
}

.thumb-grid.dragging-active {
  cursor: grabbing;
}

.thumb-grid.dragging-active .thumb-card:not(.dragging) {
  transition: transform 0.2s ease;
}

.thumb-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  user-select: none;
  transition: var(--transition);
  position: relative;
  cursor: grab;
}

.thumb-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--primary);
}

.thumb-card:active {
  cursor: grabbing;
}

.thumb-card.dragging {
  opacity: 0.4;
  transform: scale(0.95);
  pointer-events: none;
  cursor: grabbing;
}

.toprow { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 10px; 
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  color: #0369a1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
}

.right { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}

.poschip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111;
}

.thumb-wrap {
  margin-top: 12px;
  background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
  border: 1px solid #f0f0f0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb {
  width: 100%;
  height: 180px;
  object-fit: contain;
  display: block;
  background: transparent;
  transition: var(--transition);
}

.thumb.broken { 
  opacity: 0.3; 
  filter: grayscale(100%);
}

.filename { 
  margin-top: 12px; 
  font-size: 12px; 
  word-break: break-all;
  color: var(--muted);
  font-weight: 500;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
}

.actions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.actions .btn {
  padding: 10px 8px;
  font-size: 12px;
  white-space: nowrap;
}

/* Reorder effects */
.drop-hint {
  outline: 3px solid var(--primary);
  outline-offset: 4px;
  background: rgba(11, 94, 215, 0.08);
  border-color: var(--primary);
  transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(11, 94, 215, 0.2);
}

.drop-hint-before::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  z-index: 1;
}

.drop-hint-after::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  z-index: 1;
}

/* Ghost */
.drag-ghost {
  opacity: 0.92;
  box-shadow: var(--shadow-xl);
  border-radius: 16px;
  transform: rotate(2deg) scale(1.05);
  border: 2px solid var(--primary);
  filter: brightness(1.1);
  transition: transform 0.1s ease-out;
}

/* ===== Modal (para reemplazar) ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal.hidden { 
  display: none; 
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.modal-box,
.modal-card {
  position: relative;
  width: min(600px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-xl);
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head b {
  font-weight: 600;
  font-size: 18px;
  color: var(--text);
}

.modal-title { 
  font-weight: 600; 
  font-size: 18px; 
  color: var(--text);
}

.icon-btn {
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: var(--transition);
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.icon-btn:hover {
  background: #e5e7eb;
  color: var(--text);
  transform: rotate(90deg);
}

.modal-body { 
  margin-top: 0; 
}

.modal-actions { 
  margin-top: 20px; 
  display: flex; 
  justify-content: flex-end; 
  gap: 12px; 
}

/* Vista previa de imagen actual en modal */
.modal-current-image {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 16px;
  background: #f9fafb;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

@media (max-width: 680px) {
  .modal-current-image {
    grid-template-columns: 1fr;
  }
}

.modal-image-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-image-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-image-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  overflow: hidden;
}

.modal-image-wrap img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
}

.modal-image-error {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.modal-image-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
  min-width: 90px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.info-value {
  color: var(--text);
  font-size: 14px;
  word-break: break-all;
  flex: 1;
}

.info-link {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  word-break: break-all;
  transition: var(--transition);
}

.info-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Estilos adicionales */
code {
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: var(--primary);
  font-weight: 500;
  border: 1px solid #e5e7eb;
}

/* Scrollbar personalizado para modal */
.modal-box::-webkit-scrollbar {
  width: 8px;
}

.modal-box::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.modal-box::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 10px;
}

.modal-box::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Mejoras de accesibilidad */
.btn:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Animación suave para las tarjetas al cargar */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.thumb-card {
  animation: cardFadeIn 0.3s ease-out;
}

.thumb-card:nth-child(1) { animation-delay: 0.05s; }
.thumb-card:nth-child(2) { animation-delay: 0.1s; }
.thumb-card:nth-child(3) { animation-delay: 0.15s; }
.thumb-card:nth-child(4) { animation-delay: 0.2s; }
.thumb-card:nth-child(5) { animation-delay: 0.25s; }
.thumb-card:nth-child(n+6) { animation-delay: 0.3s; }

/* ===== Statistics Section ===== */
.filter-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-buttons .btn {
  padding: 10px 16px;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  border: 2px solid var(--border);
  background: #fff;
  color: var(--text);
}

.filter-buttons .btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.filter-buttons .btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.filter-buttons .btn.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 680px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}

.stat-card {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card.success {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  border-color: #6ee7b7;
}

.stat-card.warning {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #fbbf24;
}

.stat-card.primary {
  background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  border-color: #7dd3fc;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-bar-container {
  width: 100%;
  height: 32px;
  background: #f3f4f6;
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #0b5ed7 0%, #3b82f6 50%, #60a5fa 100%);
  border-radius: 16px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(11, 94, 215, 0.3);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0) 0%, 
    rgba(255, 255, 255, 0.1) 50%, 
    rgba(255, 255, 255, 0) 100%);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}