@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --accent-border: rgba(245, 158, 11, 0.35);
  --bg: #050a14;
  --card-bg: rgba(15, 20, 40, 0.5);
  --border: rgba(255, 255, 255, 0.08);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
}

body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

.bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 20%, rgba(245,158,11,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(251,191,36,0.08) 0%, transparent 60%);
}
.grid-overlay {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(245,158,11,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,158,11,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
#constellation { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

.container {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.back {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--text-faint); font-size: 0.8rem; text-decoration: none;
  margin-bottom: 1.5rem; transition: color 0.2s;
}
.back:hover { color: var(--text-dim); }

.head { text-align: center; margin-bottom: 2.5rem; }

.badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 1rem; border-radius: 100px;
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent-2); margin-bottom: 1.5rem;
}
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-2); box-shadow: 0 0 6px rgba(251,191,36,0.8);
  animation: dotPulse 2s ease-in-out infinite;
}
.badge-dot.off { background: #475569; box-shadow: none; animation: none; }
@keyframes dotPulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.75); } }

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800; line-height: 1.1; margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #fff 40%, var(--accent-2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.subtitle { color: var(--text-dim); font-size: 1rem; }

.panel {
  background: var(--card-bg); backdrop-filter: blur(24px);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 1.5rem; margin-bottom: 1.5rem;
}
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 0.75rem; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .slider { width: 52px; height: 28px; background: #1e293b; border-radius: 100px; position: relative; transition: background 0.2s; }
.toggle .slider::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #94a3b8; transition: transform 0.2s, background 0.2s; }
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::after { transform: translateX(24px); background: #fff; }
.toggle-label { font-weight: 600; font-size: 0.95rem; }

.btn {
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  color: var(--accent-2); padding: 0.6rem 1.2rem; border-radius: 100px;
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
  transition: all 0.2s; font-family: inherit;
}
.btn:hover { background: rgba(245,158,11,0.25); border-color: rgba(245,158,11,0.6); color: #fde68a; }
.btn:disabled { opacity: 0.5; cursor: wait; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.card {
  background: var(--card-bg); backdrop-filter: blur(24px);
  border: 1px solid var(--border); border-radius: 18px;
  padding: 1.25rem;
}
.card.wide { grid-column: 1 / -1; }
.card h3 { font-size: 0.9rem; font-weight: 700; margin-bottom: 1rem; color: var(--accent-2); }
.field label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.val { color: #fff; font-weight: 600; }
.hint { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.5rem; }

input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: #1e293b; border-radius: 4px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 0 8px rgba(245,158,11,0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--accent); cursor: pointer;
}

.dual-range { position: relative; display: flex; flex-direction: column; gap: 0.5rem; }

.formatos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.fmt label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.35rem; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.4rem 0.85rem; border-radius: 100px; border: 1px solid var(--border);
  background: rgba(255,255,255,0.02); font-size: 0.78rem; cursor: pointer;
  color: var(--text-dim); transition: all 0.15s; user-select: none;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-2); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
  padding: 1rem; text-align: center;
}
.stat-val { display: block; font-size: 1.5rem; font-weight: 700; color: #fff; }
.stat-lbl { display: block; font-size: 0.72rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 0.25rem; }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); align-items: stretch; }
.tab {
  background: none; border: none; color: var(--text-dim); padding: 0.75rem 1.25rem;
  font-weight: 600; font-size: 0.9rem; cursor: pointer; font-family: inherit;
  border-bottom: 2px solid transparent; transition: all 0.15s;
}
.tab.active { color: var(--accent-2); border-color: var(--accent); }

.tab-content.hidden { display: none; }

.table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: 14px; overflow: hidden; }
.table th, .table td { padding: 0.75rem 1rem; text-align: left; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.table th { background: rgba(255,255,255,0.02); color: var(--text-dim); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.table tr { transition: background 0.15s; cursor: pointer; }
.table tr:hover { background: rgba(245,158,11,0.03); }
.table .empty { text-align: center; color: var(--text-faint); padding: 2rem; cursor: default; }
.estado-sent { color: #6ee7b7; }
.estado-error { color: #fca5a5; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.modal.hidden { display: none; }
.modal-content { background: #0f1425; border: 1px solid var(--border); border-radius: 16px; padding: 2rem; max-width: 700px; width: 100%; max-height: 80vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 0.75rem; right: 1rem; background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; }
.modal pre { white-space: pre-wrap; font-family: inherit; font-size: 0.9rem; line-height: 1.5; color: var(--text); }

.toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(2rem);
  background: #1e293b; color: #fff; padding: 0.75rem 1.5rem;
  border-radius: 100px; font-size: 0.85rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
  z-index: 200; border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(110,231,183,0.4); color: #6ee7b7; }
.toast.warn { border-color: rgba(251,191,36,0.5); color: #fbbf24; }
.toast.err { border-color: rgba(252,165,165,0.5); color: #fca5a5; }

footer { position: relative; z-index: 1; text-align: center; color: #1e293b; font-size: 0.75rem; padding: 1rem; }

/* Filtros del historial */
.hf-sel {
  padding: 0.4rem 0.85rem;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  color: var(--text);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.hf-sel:hover { border-color: rgba(245,158,11,0.4); }
.btn-ghost:hover { background: rgba(245,158,11,0.08); }

/* Estados de entrega */
.delivery-pending     { color: #94a3b8; }
.delivery-sent_to_resend { color: #94a3b8; }
.delivery-delivered   { color: #4ade80; }
.delivery-opened      { color: #60a5fa; }
.delivery-clicked     { color: #a78bfa; }
.delivery-bounced     { color: #f87171; }
.delivery-complained  { color: #fb923c; }
.delivery-failed      { color: #f87171; }

/* Modal items table */
.modal-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.modal-items th, .modal-items td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.modal-items th {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}
.modal-items tr:hover { background: rgba(245,158,11,0.04); }
.modal-items td.sku { font-family: ui-monospace, monospace; font-size: 0.78rem; opacity: 0.85; }
.modal-items td.cant { text-align: right; font-variant-numeric: tabular-nums; }
.modal-items a { color: inherit; text-decoration: underline; text-decoration-color: rgba(245,158,11,0.4); }

/* Modal meta grid */
.modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.modal-meta-cell {
  padding: 0.6rem 0.8rem;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.modal-meta-cell .lbl {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}
.modal-meta-cell .val {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.25rem;
}





/* Botón colapsar/expandir secciones */
.toggle-secciones {
  margin-left: auto !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.4rem !important;
  padding: 0.4rem 0.95rem !important;
  background: transparent !important;
  color: var(--text-faint) !important;
  border: 1px solid var(--border) !important;
  border-radius: 100px !important;
  font-family: inherit !important;
  font-size: 0.78rem !important;
  cursor: pointer !important;
  transition: color 0.15s, border-color 0.15s, background 0.15s !important;
  align-self: center !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  outline: none !important;
  white-space: nowrap !important;
}
.toggle-secciones:hover {
  color: var(--accent) !important;
  border-color: rgba(245,158,11,0.5) !important;
  background: rgba(245,158,11,0.06) !important;
}
.toggle-secciones[aria-expanded="false"] {
  color: var(--accent) !important;
  border-color: rgba(245,158,11,0.4) !important;
  background: rgba(245,158,11,0.04) !important;
}
.toggle-secciones #toggleSeccionesIcon {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 0.7rem;
}
.toggle-secciones[aria-expanded="false"] #toggleSeccionesIcon {
  transform: rotate(-90deg);
}

/* Estado colapsado: oculta TODOS los tab-content */
body.secciones-colapsadas .tab-content { display: none !important; }
body.secciones-colapsadas .tab.active { color: var(--text-faint) !important; border-color: transparent !important; }
body.secciones-colapsadas .tab { opacity: 0.5 !important; cursor: default !important; pointer-events: none !important; }
body.secciones-colapsadas .toggle-secciones { pointer-events: auto !important; opacity: 1 !important; }
