:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-card: #1a2029;
  --border: #263040;
  --text: #e6edf3;
  --text-dim: #8b98a8;
  --accent: #3fb950;
  --accent-2: #58a6ff;
  --hi: #3fb950;
  --mid: #d29922;
  --lo: #f85149;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "Inter", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #16202e 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.wrap { width: min(1080px, 92vw); margin: 0 auto; }

/* Topbar */
.topbar {
  border-bottom: 1px solid var(--border);
  background: rgba(13, 17, 23, 0.7);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 34px; }
.brand h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.sub { color: var(--text-dim); font-size: 13px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px; color: var(--text-dim);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.pill-ghost { background: transparent; }

/* Tabs */
.tabs { display: flex; gap: 8px; margin: 26px 0 20px; flex-wrap: wrap; }
.tab {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); background: var(--bg-soft);
  border: 1px solid var(--border); padding: 9px 18px; border-radius: 999px;
  transition: all 0.15s ease;
}
.tab:hover { color: var(--text); border-color: #3a4757; }
.tab.active { color: #06210d; background: var(--accent); border-color: var(--accent); }

/* Grid de cards */
.grid { display: grid; gap: 14px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow); display: grid;
  grid-template-columns: 44px 76px 1fr auto; gap: 16px; align-items: center;
}

.thumb {
  width: 76px; height: 60px; border-radius: 10px; overflow: hidden;
  background: var(--bg-soft); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { font-size: 26px; opacity: 0.5; }
.rank-n {
  font-size: 26px; font-weight: 800; color: var(--text-dim);
  text-align: center; font-variant-numeric: tabular-nums;
}
.card:first-child .rank-n { color: var(--accent); }

.card-main { min-width: 0; }
.card-name { font-size: 17px; font-weight: 600; margin-bottom: 10px; }

.specs { display: flex; flex-wrap: wrap; gap: 7px; }
.spec {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 4px 9px; border-radius: 8px;
}
.spec b { color: var(--text); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.score { text-align: right; }
.score-n { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.bar { height: 6px; width: 90px; background: var(--bg-soft); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.price { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 8px; }
.valor { font-size: 11px; color: var(--accent-2); margin-top: 2px; white-space: nowrap; }

/* Barra de orden (Puntaje / Calidad-precio) */
.orden-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; flex-wrap: wrap; }
.orden-lbl { font-size: 13px; color: var(--text-dim); }
.orden-btn {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); background: var(--bg-soft); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 999px; transition: all 0.15s ease;
}
.orden-btn:hover { color: var(--text); border-color: #3a4757; }
.orden-btn.active { color: #06210d; background: var(--accent); border-color: var(--accent); }

/* Paneles */
.panel {
  margin-top: 26px; padding: 20px; border-radius: var(--radius);
  background: var(--bg-soft); border: 1px solid var(--border);
}
.panel h2 { font-size: 16px; margin-bottom: 4px; }
.panel-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 12px; }
.panel.warn { border-color: #5c4415; background: #241d0e; }
.panel.warn h2 { color: var(--mid); }
.panel ul { list-style: none; display: grid; gap: 6px; }
.panel li { font-size: 13px; color: var(--text-dim); }
.excl li b { color: var(--text); }

.foot { color: var(--text-dim); font-size: 12px; padding: 30px 0; text-align: center; }
.hidden { display: none; }

/* Navegación de vistas (Ranking / Componentes) */
.views { display: flex; gap: 8px; margin: 26px 0 8px; }
.view-btn {
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  color: var(--text-dim); background: transparent; border: none;
  border-bottom: 2px solid transparent; padding: 8px 6px; transition: all 0.15s ease;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* Vista Comparar (tabla) */
.guia-intro { color: var(--text-dim); font-size: 14px; margin: 14px 0 20px; max-width: 680px; }
.table-wrap {
  overflow-x: auto; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-card);
}
.comp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.comp-table th, .comp-table td {
  padding: 11px 14px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.comp-table thead th {
  color: var(--text-dim); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.03em;
  position: sticky; top: 0; background: var(--bg-soft); z-index: 2;
}
.th-peso { color: var(--accent-2); font-weight: 600; margin-left: 6px; font-size: 11px; }
.comp-table .tname {
  font-weight: 600; text-transform: none;
  position: sticky; left: 0; background: var(--bg-card); z-index: 1;
}
.comp-table .cell { display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; }
.comp-table .cell b { color: var(--text-dim); font-weight: 700; font-variant-numeric: tabular-nums; }
.comp-table .ttotal { font-weight: 800; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; }
.comp-table tbody tr:hover td { background: var(--bg-soft); }
.comp-table tbody tr:hover .tname { background: var(--bg-soft); }

/* Guía de Equipamiento (una tabla por tipo) */
.equip-sec { margin-bottom: 24px; }
.equip-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.equip-head h2 { font-size: 18px; font-weight: 700; }
.equip-table td, .equip-table th { text-transform: none; }
.equip-table .tname { text-transform: none; font-weight: 600; }
.equip-table .col-notas { white-space: normal; min-width: 240px; color: var(--text-dim); }
.equip-table .tnivel { text-align: center; }
.equip-table .tnivel .dot { display: inline-block; margin-right: 6px; vertical-align: middle; }
.equip-table .tnivel b { font-variant-numeric: tabular-nums; }

/* Link comprar */
.buy {
  display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600;
  color: var(--accent-2); text-decoration: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 10px; white-space: nowrap;
}
.buy:hover { border-color: var(--accent-2); background: var(--bg-soft); }

/* Filtro presupuesto */
.presu { display: inline-flex; align-items: center; gap: 4px; }
.presu-input {
  font: inherit; font-size: 13px; width: 130px; background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px;
  color: var(--text); outline: none;
}
.presu-input:focus { border-color: var(--accent-2); }

/* Gráfico calidad-precio (scatter) */
.scatter-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; overflow-x: auto; }
.scatter { width: 100%; height: auto; min-width: 660px; display: block; }
.scatter .grid { stroke: var(--border); stroke-width: 1; }
.scatter .avg { stroke: var(--text-dim); stroke-width: 1.5; stroke-dasharray: 5 5; opacity: .55; }
.scatter .ax { fill: var(--text-dim); font-size: 12px; }
.scatter .ax-r { text-anchor: end; }
.scatter .ax-c { text-anchor: middle; }
.scatter .ax-lbl { fill: var(--text); font-weight: 600; }
.scatter .pt-lbl { fill: var(--text); font-size: 11px; }
.scatter circle { cursor: pointer; }

/* Comparar lado a lado */
.cmp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.cmp-chip {
  font: inherit; font-size: 13px; cursor: pointer; color: var(--text-dim);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 13px; transition: all 0.15s ease;
}
.cmp-chip:hover { color: var(--text); border-color: #3a4757; }
.cmp-chip.on { color: #06210d; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.cmp-table td { white-space: normal; }
.cmp-table .buy { margin-top: 0; }

@media (max-width: 560px) {
  .card { grid-template-columns: 36px 60px 1fr; }
  .thumb { width: 60px; height: 48px; }
  .score { grid-column: 3; text-align: left; margin-top: 6px; }
  .bar { margin-left: 0; }
}
