:root {
  --bg: #0b0d0f;
  --border: #20262b;
  --card: #14181b;
  --muted: #9aa4ad;
  --page-max: 1200px;
  --primary: #5b9cff;
  --radius: 16px;
  --text: #e6edf3;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial;
  margin: 0;
}

.container {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  margin: 0 auto;
  max-width: var(--page-max);
  padding: 24px 28px;
  width: 100%;
}

.table-area {
  width: 100%;
}

.header {
  align-items: center;
  display: flex;
  gap: 12px;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: .2px;
  margin: 0;
}

.muted {
  color: var(--muted);
  margin: 8px 0 18px;
}

form {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}

label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

select {
  background: #0f1316;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px;
}

.file-row {
  align-items: center;
  display: flex;
  gap: 12px;
}

.file-name {
  color: var(--muted);
  font-size: 14px;
}

.btn,
.btn-outline,
.btn.primary {
  background: #0f1316;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 10px 14px;
}

.btn:hover,
.btn-outline:hover {
  border-color: #2b343b;
}

.btn.primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.result {
  background: #0a0e11;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 14px;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
}

.hidden {
  display: none;
}

/* === Menú principal === */
.menu {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  justify-content: center;
}

.menu h1 {
  font-size: 2rem;
  margin-bottom: 30px;
}

.menu .btn {
  cursor: pointer;
  font-size: 1.2rem;
  padding: 15px 30px;
}

/* === Filtros === */
.filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.filters .row {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-item {
  display: flex;
  flex: 1 1 180px;
  flex-direction: column;
  min-width: 140px;
}

.filter-item select,
.filter-item input[type="date"] {
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  padding: 6px 8px;
  width: 100%;
}

@media (max-width: 768px) {
  .filter-item {
    flex: 1 1 45%;
  }
}

@media (max-width: 480px) {
  .filter-item {
    flex: 1 1 100%;
  }
}

/* --- Menú superior --- */
.menu-top {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 10px;
}

.btn-square {
  align-items: center;
  background: #0f1316;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 1rem;
  font-weight: 700;
  height: 140px;
  justify-content: center;
  width: 180px;
}

.btn-square.primary {
  background: var(--primary);
  border: none;
  color: #fff;
}

/* --- Divisor --- */
.divider {
  background: var(--border);
  height: 1px;
  margin: 12px 0 4px;
  max-width: 420px;
  width: 100%;
}

/* --- Botones inferiores --- */
.menu>.btn {
  background: #0f1316;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  height: auto;
  padding: 12px 20px;
  width: auto;
}

.menu>.btn:hover {
  border-color: #2b343b;
}

.menu>.btn.primary {
  background: var(--primary);
  border: none;
  color: #fff;
}

/* === Modal === */
.modal-backdrop {
  background: rgba(0, 0, 0, .55);
  display: grid;
  inset: 0;
  place-items: center;
  position: fixed;
  z-index: 9999;
}

.modal-card {
  background: #121212;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color: #eaeaea;
  font-family: inherit;
  overflow: hidden;
  width: min(480px, 92vw);
}

.modal-header {
  border-bottom: 1px solid #2a2a2a;
  font-weight: 600;
  padding: 16px 20px;
}

.modal-body {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
}

.modal-body label {
  font-size: .9rem;
  opacity: .9;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 10px;
  color: #eaeaea;
  padding: 10px 12px;
  width: 100%;
}

.modal-footer {
  border-top: 1px solid #2a2a2a;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 20px;
}

.modal-btn {
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  padding: 10px 14px;
}

.modal-btn.primary {
  background: #3b82f6;
  color: white;
}

.modal-btn.ghost {
  background: transparent;
  border: 1px solid #333;
  color: #eaeaea;
}

.reports-actions {
  padding-bottom: 15px;
}

/* --- Aviso para editores --- */
.warning {
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid #ffd166;
  border-radius: 6px;
  color: #ffd166;
  display: flex;
  font-size: 0.92rem;
  gap: 8px;
  margin: 12px 0 18px 0;
  padding: 10px 14px;
}

.warning svg {
  fill: #ffd166;
  flex-shrink: 0;
  height: 18px;
  width: 18px;
}

/* --- Botones activos --- */
.btn-square.active {
  background: var(--primary);
  border: none;
  color: #fff;
  transform: scale(1.05);
  transition: all 0.15s ease;
}

.btn-square:not(.active):hover {
  border-color: #2b343b;
}

.btn-square:hover {
  background: var(--primary);
  border: none;
  border-color: #2b343b;
  color: #fff;
  transform: scale(1.05);
  transition: all 0.2s ease;
}

/* === Ajustes responsivos generales === */
@media (max-width: 900px) {
  .container {
    padding: 20px;
  }

  .card {
    padding: 20px;
  }

  .menu-top {
    flex-wrap: wrap;
    gap: 12px;
  }

  .btn-square {
    width: 45%;
    height: 120px;
    font-size: 1rem;
  }
}

/* === Ajustes específicos para móviles === */
@media (max-width: 600px) {
  .container {
    padding: 16px;
    align-items: flex-start;
  }

  .card {
    border-radius: 12px;
    padding: 16px;
  }

  h1 {
    font-size: 1.5rem;
    text-align: center;
  }

  .menu {
    gap: 16px;
    padding: 20px 0;
  }

  .menu-top {
    flex-direction: column;
    align-items: center;
    gap: 14px;
  }

  .btn-square {
    width: 100%;
    height: 100px;
    font-size: 1rem;
  }

  .filters {
    gap: 8px;
  }

  .filters .row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filter-item {
    min-width: 100%;
  }

  .btn,
  .btn.primary {
    width: 100%;
    font-size: 1rem;
    padding: 12px;
  }

  .modal-card {
    width: 94vw;
    border-radius: 12px;
  }

  .modal-body {
    padding: 12px 16px;
  }

  .modal-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-btn {
    width: 100%;
    padding: 12px;
  }

  .warning {
    font-size: 0.85rem;
    padding: 8px 10px;
  }
}

/* === Import Help (plantillas / ejemplo / fuente) === */
#import-help {
  margin-top: 16px;
}

#import-help h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2px;
  margin: 0 0 8px;
}

#tpl-list .btn {
  background: #0f1316;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 10px 14px;
}

#tpl-list .btn:hover {
  border-color: #2b343b;
}

#source-box .muted {
  color: var(--muted);
}

#source-box .btn {
  background: #0f1316;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  padding: 8px 12px;
}

#source-box .btn:hover {
  border-color: #2b343b;
}

#example-img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
  margin-top: 12px;
}

#example-caption {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  #tpl-list {
    gap: 10px;
  }

  #tpl-list .btn {
    width: 100%;
    text-align: center;
  }

  #source-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

#examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

#examples figure {
  margin: 0;
}

#examples img.example-img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}

#examples figcaption {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.9rem;
}

#source-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* === Toggle de Guía de importación === */
.toggle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-header h2 {
  margin: 0;
}

/* Botón + / – */
#toggle-help {
  background: none;
  border: none;
  color: var(--text);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  border-radius: 6px;
  cursor: pointer;
  transition: background .2s ease;
}

#toggle-help:hover {
  background: rgba(255, 255, 255, .08);
}

/* Cerrado → “+”, Abierto → “–” */
#toggle-help::before {
  content: "+";
  display: block;
}

#toggle-help[aria-expanded="true"]::before {
  content: "–";
}

/* Cuerpo colapsable */
#import-help-body {
  margin-top: 10px;
  transition: max-height .3s ease, opacity .3s ease;
  overflow: hidden;
  max-height: 1000px;
  opacity: 1;
}

#import-help-body.hidden {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Línea superior: Plantilla + Fuente de datos */
.import-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* Contenedor de la plantilla (nombre o link) */
#tpl-list {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Contenedor de la fuente de datos */
#source-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Responsive --- */
@media (max-width:600px) {
  #tpl-list {
    gap: 10px;
  }

  #tpl-list .btn {
    width: 100%;
    text-align: center;
  }

  #source-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

#spinner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  color: white;
}

#spinner.hidden {
  display: none !important;
}

.lds-dual-ring {
  display: inline-block;
  width: 64px;
  height: 64px;
}

.lds-dual-ring:after {
  content: " ";
  display: block;
  width: 46px;
  height: 46px;
  margin: 1px;
  border-radius: 50%;
  border: 5px solid #fff;
  border-color: #fff transparent #fff transparent;
  animation: lds-dual-ring 1.2s linear infinite;
}

@keyframes lds-dual-ring {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}