:root {
  --bg: #0b0d12;
  --bg-2: #11141b;
  --panel: #151922;
  --panel-2: #1b2029;
  --border: #252b37;
  --text: #e8ebf1;
  --muted: #8b93a5;
  --accent: #7c5cff;
  --accent-2: #a18bff;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }

/* ---------- Login ---------- */
.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(800px 400px at 20% -10%, rgba(124, 92, 255, .25), transparent 60%),
    radial-gradient(600px 400px at 110% 110%, rgba(34, 197, 94, .12), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #4f8bff);
  box-shadow: 0 6px 18px rgba(124, 92, 255, .4);
}
.brand-logo svg { width: 18px; height: 18px; }
.auth-card h1 { font-size: 22px; margin: 24px 0 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 22px; }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 92, 255, .2); }
textarea.input { min-height: 90px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #232937; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #6a48ff; }
.btn-block { width: 100%; padding: 11px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.error { color: #fca5a5; background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .3);
  padding: 9px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.hidden { display: none !important; }

/* ---------- App layout ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: rgba(124, 92, 255, .14); color: var(--text); }
.nav a.active svg { color: var(--accent-2); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .count { margin-left: auto; font-size: 11px; background: var(--panel-2); padding: 1px 7px; border-radius: 99px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 14px; }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 600; }
.me-info { min-width: 0; flex: 1; }
.me-info div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-info .role { color: var(--muted); font-size: 12px; }

.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 28px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(11, 13, 18, .85); backdrop-filter: blur(10px); z-index: 5;
}
.topbar h1 { font-size: 18px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 24px 28px 60px; max-width: 1400px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.kpi .hint { color: var(--muted); font-size: 12px; }
.kpi.highlight { border-color: rgba(34, 197, 94, .4); background: linear-gradient(180deg, rgba(34, 197, 94, .08), var(--panel)); }
.kpi.highlight .value { color: var(--green); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.section-head h2 { font-size: 16px; }
.section-head .muted { font-size: 13px; }
.muted { color: var(--muted); }

/* ---------- Filtros ---------- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 18px;
}
.filters .field { margin: 0; min-width: 140px; flex: 1; }
.filters .field.grow { flex: 2; min-width: 200px; }
.filters .field.small { max-width: 130px; min-width: 100px; }
.chip-toggle { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg-2); cursor: pointer; user-select: none; }
.chip-toggle input { accent-color: var(--accent); }

/* ---------- Product cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #3a4254; transform: translateY(-2px); }
.card.winner { border-color: rgba(34, 197, 94, .35); }
.card-head { display: flex; gap: 10px; align-items: flex-start; }
.page-avatar { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  font-weight: 700; color: #fff; }
.card-title { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-page { color: var(--muted); font-size: 12px; margin-top: 2px; }
.star { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--muted); padding: 2px; }
.star.on { color: var(--amber); }
.star svg { width: 18px; height: 18px; }
.card-body { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.metric .m-label { font-size: 11px; color: var(--muted); }
.metric .m-value { font-size: 18px; font-weight: 700; }
.metric.good .m-value { color: var(--green); }
.metric.warn .m-value { color: var(--amber); }
.bar { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); }
.card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.flags { display: flex; gap: 4px; flex-wrap: wrap; }
.flags img { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); text-transform: capitalize; }
.badge.s-nuevo { color: #93c5fd; border-color: rgba(59, 130, 246, .35); background: rgba(59, 130, 246, .1); }
.badge.s-revisando { color: #fcd34d; border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .1); }
.badge.s-testeando { color: #c4b5fd; border-color: rgba(124, 92, 255, .35); background: rgba(124, 92, 255, .12); }
.badge.s-ganador { color: #86efac; border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .1); }
.badge.s-descartado { color: #fca5a5; border-color: rgba(239, 68, 68, .3); background: rgba(239, 68, 68, .08); }
.badge.fire { color: #86efac; border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .1); }
.ml-auto { margin-left: auto; }

/* ---------- Table ---------- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--bg-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.wrap { white-space: normal; min-width: 240px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Countries ---------- */
.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.country {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  cursor: pointer; transition: border-color .15s;
}
.country:hover { border-color: var(--accent); }
.country-top { display: flex; align-items: center; gap: 10px; }
.country-top img { width: 30px; height: 22px; border-radius: 4px; object-fit: cover; }
.country-name { font-weight: 600; }
.country-region { font-size: 12px; color: var(--muted); }
.country-stats { display: flex; gap: 16px; margin-top: 12px; }
.country-stats b { display: block; font-size: 18px; }
.country-stats span { font-size: 11px; color: var(--muted); }
.country.empty { opacity: .55; }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100%);
  background: var(--bg-2); border-left: 1px solid var(--border); z-index: 21;
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }
.drawer h3 { font-size: 14px; margin: 22px 0 10px; }
.ad-row { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: var(--panel); }
.ad-row .ad-meta { flex: 1; min-width: 0; font-size: 13px; }
.ad-row .ad-meta div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); background: var(--panel);
  border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 15px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row .field { margin: 0; flex: 1; min-width: 160px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2);
  border: 1px solid var(--border); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: all .2s; z-index: 50; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border); border-radius: 99px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 14px 16px; }
  .content { padding: 18px 16px 60px; }
  .grid { grid-template-columns: 1fr; }
  .topbar .sub { display: none; }
}

/* ---------- Login / registro ---------- */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; margin-top: 22px; }
.tab { background: transparent; border: 0; border-radius: 9px; padding: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }
.auth-card h1 { margin-top: 20px; }
.only-hidden { display: none !important; }
.switch-line { text-align: center; margin: 16px 0 0; font-size: 13px; }
.save-dot { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.card-links { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.card-links .btn { text-decoration: none; }
.niche-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 24px; }
.niche-chip { background: var(--panel); border: 1px solid var(--border); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-weight: 500; }
.niche-chip:hover { border-color: var(--accent); }
.niche-chip span { color: var(--muted); font-size: 12px; margin-left: 4px; }
.badge.wa { color: #86efac; border-color: rgba(37, 211, 102, .45); background: rgba(37, 211, 102, .12); text-transform: none; }
.badge.lp { color: #93c5fd; border-color: rgba(59, 130, 246, .35); background: rgba(59, 130, 246, .1); text-transform: none; }

.badge.dg { color: #fde68a; border-color: rgba(245, 158, 11, .35); background: rgba(245, 158, 11, .1); text-transform: none; }

.badge.net { color: #f0abfc; border-color: rgba(217, 70, 239, .4); background: rgba(217, 70, 239, .1); text-transform: none; }

/* ---------- Motor de ofertas ---------- */
.rank { width: 38px; height: 38px; flex: none; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 13px; }
.badges-row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.badges-row:empty { display: none; }
.metrics-3 { grid-template-columns: repeat(3, 1fr); }
.metrics-4 { grid-template-columns: repeat(4, 1fr); }
.metrics-3 .m-value, .metrics-4 .m-value { font-size: 17px; }
.m-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.growth { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.growth span { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; }
.growth span.up { color: #86efac; border-color: rgba(34, 197, 94, .35); }
.interp { font-size: 12px; color: var(--muted); line-height: 1.45; }
.interp-panel { margin: 12px 0 0; font-size: 13px; }
.badge.tier-monster { color: #fecaca; border-color: rgba(239, 68, 68, .55); background: linear-gradient(90deg, rgba(239, 68, 68, .25), rgba(217, 70, 239, .2)); text-transform: none; }
.badge.tier-super { color: #fed7aa; border-color: rgba(249, 115, 22, .5); background: rgba(249, 115, 22, .15); text-transform: none; }
.badge.tier-winner { color: #86efac; border-color: rgba(34, 197, 94, .45); background: rgba(34, 197, 94, .12); text-transform: none; }
.badge.alert { color: #fecaca; border-color: rgba(239, 68, 68, .55); background: rgba(239, 68, 68, .15); text-transform: none; }
.card.alerting { box-shadow: 0 0 0 1px rgba(239, 68, 68, .45) inset; }
.alert-banner { background: rgba(239, 68, 68, .1); border: 1px solid rgba(239, 68, 68, .4); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.alert-chip { background: var(--panel); border: 1px solid rgba(239, 68, 68, .4); color: var(--text); border-radius: 99px; padding: 5px 10px; cursor: pointer; font-size: 12px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 22px; }
.quick a { text-decoration: none; }
.empty-state.small { padding: 22px; margin-bottom: 26px; }
.grid + .section-head, .empty-state.small + .section-head { margin-top: 26px; }
.medal { width: 34px; text-align: center; font-size: 18px; flex: none; }
.chart { width: 100%; height: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.chart .bar-rect { fill: var(--accent); }
.chart .bar-val { fill: var(--text); font-size: 10px; text-anchor: middle; }
.chart .bar-lbl { fill: var(--muted); font-size: 10px; }
.chart .axis { stroke: var(--border); }
@media (max-width: 900px) { .metrics-4 { grid-template-columns: repeat(2, 1fr); } }

/* ---------- Bienvenida y estado del radar ---------- */
.onboard { text-align: center; padding: 56px 24px; background: radial-gradient(600px 260px at 50% 0%, rgba(124, 92, 255, .18), transparent 70%), var(--panel);
  border: 1px solid var(--border); border-radius: 20px; max-width: 760px; margin: 20px auto; }
.onboard-icon { font-size: 44px; margin-bottom: 10px; }
.onboard h2 { font-size: 24px; margin-bottom: 10px; }
.onboard p { color: var(--muted); max-width: 520px; margin: 0 auto 24px; line-height: 1.55; }
.btn-xl { font-size: 18px; font-weight: 700; padding: 16px 34px; border-radius: 14px; box-shadow: 0 10px 30px rgba(124, 92, 255, .35); }
.run-strip { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 18px; }
.run-strip .muted { font-size: 13px; }
.run-strip.running { border-color: rgba(124, 92, 255, .5); background: linear-gradient(90deg, rgba(124, 92, 255, .12), var(--panel)); }
.dot-on { width: 10px; height: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(34, 197, 94, .18); flex: none; }
.pulse { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, .6); } 50% { box-shadow: 0 0 0 9px rgba(124, 92, 255, 0); } }

/* ---------- Modo "ver radar de otra cuenta" ---------- */
.view-banner { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 10px 16px;
  background: rgba(245, 158, 11, .14); border-bottom: 1px solid rgba(245, 158, 11, .4); color: #fde68a; font-size: 13px; }
