:root {
  --bg: #08070b;
  --bg-soft: #110d15;
  --panel: rgba(14, 10, 16, 0.78);
  --panel-strong: rgba(20, 14, 24, 0.94);
  --panel-2: rgba(35, 22, 34, 0.92);
  --border: rgba(152, 108, 124, 0.22);
  --border-strong: rgba(212, 181, 142, 0.28);
  --text: #f1e8df;
  --muted: #b4a4a4;
  --accent: #d9b187;
  --accent-2: #8f3149;
  --accent-3: #6b1b34;
  --good: #7bc8a4;
  --bad: #d77272;
  --new: #e5bc7a;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(122, 32, 58, 0.16), transparent 30%),
    linear-gradient(180deg, #0c0a0f 0%, #08070b 55%, #060508 100%);
}

/* Fondo opcional: coloca tu imagen en public/assets/bg.jpg para activarlo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: url("assets/bg.png");
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  pointer-events: none;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  color: var(--text);
  font: 14px/1.45 "Manrope", system-ui, sans-serif;
  background: transparent;
}

body.auth-locked .topbar,
body.auth-locked .tab-bar,
body.auth-locked .layout {
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 5, 10, 0.72);
  backdrop-filter: blur(8px);
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(460px, 100%);
  border-radius: 20px;
  padding: 24px;
}

.login-card h2 {
  margin: 0 0 10px;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.backdrop-orb {
  position: absolute;
  width: 38rem;
  height: 38rem;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.18;
}

.orb-left {
  top: -14rem;
  left: -10rem;
  background: radial-gradient(circle, rgba(143, 49, 73, 0.75), transparent 68%);
}

.orb-right {
  right: -12rem;
  bottom: -15rem;
  background: radial-gradient(circle, rgba(93, 21, 44, 0.72), transparent 70%);
}

.backdrop-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 90px 90px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.65), transparent 90%);
}

.surface {
  position: relative;
  background: linear-gradient(180deg, rgba(25, 17, 27, 0.92), rgba(11, 8, 14, 0.88));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  margin: 22px auto 14px;
  width: min(1280px, calc(100% - 24px));
  border-radius: 28px;
  padding: 22px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  gap: 18px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  width: 78px;
  height: 78px;
  border-radius: 24px;
  position: relative;
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(circle at 50% 38%, rgba(217, 177, 135, 0.22), transparent 38%),
    linear-gradient(180deg, rgba(74, 23, 39, 0.95), rgba(14, 10, 16, 1));
  box-shadow: inset 0 0 30px rgba(255, 226, 196, 0.06), 0 10px 30px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  flex-shrink: 0;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(217, 177, 135, 0.28);
}

.brand-mark::after {
  inset: 24px;
  border-color: rgba(217, 177, 135, 0.45);
}

.brand-core {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f4d6a8, #9d2946);
  box-shadow: 0 0 18px rgba(217, 177, 135, 0.35);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 11px;
  color: var(--accent);
}

.topbar h1,
h2,
h3 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 0.94;
}

.brand-copy {
  margin: 10px 0 0;
  max-width: 48ch;
  color: var(--muted);
}

.tabs,
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  position: relative;
  width: min(1280px, calc(100% - 24px));
  margin: 0 auto 18px;
  padding: 8px 10px;
  border-radius: 999px;
  overflow: hidden;
}

.tab {
  position: relative;
  z-index: 2;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  transition: color 180ms ease, transform 180ms ease;
}

.tab:hover { color: var(--text); transform: translateY(-1px); }

.tab.active {
  color: var(--text);
}

.tab-indicator {
  position: absolute;
  z-index: 1;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(143, 49, 73, 0.85), rgba(43, 18, 30, 0.95));
  border: 1px solid rgba(217, 177, 135, 0.45);
  box-shadow: 0 0 18px rgba(143, 49, 73, 0.35), inset 0 0 0 1px rgba(255, 223, 188, 0.06);
  transform: translateX(0);
  transition: transform 320ms cubic-bezier(.4,.2,.1,1), width 320ms cubic-bezier(.4,.2,.1,1);
  pointer-events: none;
}

/* ---- header lado derecho ---- */
.header-side {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ar-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.autorefresh-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(217, 177, 135, 0.18);
  background: rgba(255, 255, 255, 0.02);
}

.autorefresh-info .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(217, 177, 135, 0.12);
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.6; }
}

.ar-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.ar-value {
  margin: 1px 0 0;
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
  line-height: 1;
}

.ar-counts {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 10px;
  border-left: 1px solid rgba(217, 177, 135, 0.15);
}

.ar-count {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}

.ar-count-new {
  color: var(--new);
}

/* ---- barra de estado dentro de cada sección ---- */
.tab-status-bar {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 4px 10px;
  min-height: 24px;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.tab-status-bar:empty {
  display: none;
}

/* ---- country picker (móvil entre secciones) ---- */
.country-picker {
  width: min(1280px, calc(100% - 24px));
  margin: 0 auto 16px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(25, 17, 27, 0.92), rgba(11, 8, 14, 0.88));
}

.country-picker[hidden] { display: none; }

.country-picker-fields {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 12px 18px;
  align-items: end;
}

.country-picker label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}

.country-picker input,
.country-picker select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(217, 177, 135, 0.14);
  padding: 10px 12px;
  border-radius: 12px;
  outline: none;
  font: inherit;
}

.country-picker input:focus,
.country-picker select:focus {
  border-color: rgba(217, 177, 135, 0.42);
  box-shadow: 0 0 0 3px rgba(217, 177, 135, 0.08);
}

/* Cuando el picker está dentro de una sección, ya no necesita el margin externo */
.country-picker-slot .country-picker {
  width: 100%;
  margin: 8px 0 16px;
}

.status {
  min-height: 24px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  flex-basis: 100%;
}

.layout {
  width: min(1280px, calc(100% - 24px));
  margin: 0 auto 28px;
  display: grid;
  gap: 18px;
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
}
.tab-panel.anim-in {
  animation: tabFadeIn 320ms cubic-bezier(.4,.2,.1,1) both;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.995); filter: blur(2px); }
  to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.section-panel {
  border-radius: 28px;
  padding: 22px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-head-actions {
  display: flex;
  gap: 8px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 320px;
}

.small {
  font-size: 12px;
}

h2 {
  font-size: clamp(1.9rem, 2.6vw, 2.6rem);
}

h3 {
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.hint {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  margin-left: 8px;
  border: 1px solid rgba(217, 177, 135, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--accent);
  font: 700 12px/1 "Manrope", sans-serif;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.surface-inner {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(20, 13, 18, 0.88), rgba(10, 8, 12, 0.92));
  border: 1px solid rgba(217, 177, 135, 0.1);
}

.table-wrap {
  overflow: auto;
  border: 1px solid rgba(217, 177, 135, 0.12);
  border-radius: 18px;
  background: rgba(6, 5, 8, 0.52);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(217, 177, 135, 0.08);
}

th {
  position: sticky;
  top: 0;
  background: rgba(26, 15, 22, 0.95);
  color: #cdbab1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tr.is-new td {
  background: rgba(229, 188, 122, 0.08);
  animation: flash 1.4s ease-in-out 3;
}

@keyframes flash {
  0%, 100% { background: rgba(229, 188, 122, 0.08); }
  50% { background: rgba(229, 188, 122, 0.22); }
}

.muted { color: var(--muted); }

.btn-link {
  background: none;
  border: none;
  color: #dfc3a7;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.btn-link:hover {
  color: #f0dcc2;
  text-decoration: underline;
}

.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(217, 177, 135, 0.12);
}

.pill.attacker {
  color: #f1b1b1;
  border-color: rgba(215, 114, 114, 0.4);
}

.pill.defender {
  color: #d5b78f;
  border-color: rgba(217, 177, 135, 0.28);
}

.per1k-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.per1k-low {
  color: #f2a2a2;
  background: rgba(215, 114, 114, 0.15);
  border-color: rgba(215, 114, 114, 0.35);
}

.per1k-mid {
  color: #f2c48f;
  background: rgba(217, 177, 135, 0.13);
  border-color: rgba(217, 177, 135, 0.35);
}

.per1k-good {
  color: #e2d788;
  background: rgba(210, 190, 104, 0.14);
  border-color: rgba(210, 190, 104, 0.35);
}

.per1k-elite {
  color: #92ddb9;
  background: rgba(123, 200, 164, 0.13);
  border-color: rgba(123, 200, 164, 0.4);
}

.kv-list {
  display: grid;
  gap: 10px;
}

.kv-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(217, 177, 135, 0.08);
  padding-bottom: 8px;
}

.kv-key {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.kv-value {
  color: var(--text);
  font-weight: 600;
  text-align: right;
}

.config-form {
  display: grid;
  gap: 10px;
  max-width: 560px;
}

.config-form label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
}

.config-form input {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(217, 177, 135, 0.14);
  padding: 11px 12px;
  border-radius: 12px;
}

.config-form input:focus {
  border-color: rgba(217, 177, 135, 0.42);
  box-shadow: 0 0 0 3px rgba(217, 177, 135, 0.08);
  outline: none;
}

.config-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.secondary {
  background: rgba(255, 255, 255, 0.03) !important;
  color: var(--text);
}

tr.selected td {
  background: rgba(143, 49, 73, 0.16);
}

@media (max-width: 1024px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .tabs {
    justify-content: start;
  }

  .controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .topbar,
  .section-panel {
    width: min(100% - 14px, 1280px);
    padding: 16px;
    border-radius: 22px;
  }

  .brand {
    align-items: start;
  }

  .brand-mark {
    width: 62px;
    height: 62px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px 11px;
  }
}
