:root {
  --gold: #f2b138;
  --gold2: #da9120;
  --red: #cc4a3e;
  --blue: #1c4f8f;
  --green: #1f9a5b;
  --bg: #0f1a2a;
  --bg2: #16243a;
  --bg3: #1e2f4a;
  --bg4: #2a3f5f;
  --surface: #20324f;
  --border: rgba(242, 177, 56, 0.22);
  --text: #edf3ff;
  --text2: #c8d5eb;
  --text3: #93a7c7;
  --card-bg-empty: rgba(255, 255, 255, 0.04);
  --card-border-empty: rgba(255, 255, 255, 0.12);
  --neon-cyan: #3fb9ff;
  --neon-magenta: #ff7860;
  --neon-lime: #95d35a;
  --radius: 12px;
  --radius-lg: 18px;
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --topbar-height: 58px;
  --tabs-sticky-height: 46px;
  --filterbar-sticky-height: 48px;
  --section-sticky-top: calc(var(--topbar-height) + var(--tabs-sticky-height) + var(--filterbar-sticky-height));
  --mobile-sticker-width: calc((100vw - 40px) / 3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: clip; /* clip no crea scroll container → sticky funciona en iOS */
}

body::before {
  content: '';
  position: fixed;
  width: 680px;
  height: 680px;
  background: radial-gradient(circle, rgba(242, 177, 56, 0.16) 0%, rgba(63, 185, 255, 0.1) 44%, rgba(15, 26, 42, 0) 72%);
  top: -230px;
  right: -220px;
  z-index: -1;
  filter: blur(68px);
  pointer-events: none;
}

body::after {
  content: '';
  position: fixed;
  width: 620px;
  height: 620px;
  left: -240px;
  bottom: -260px;
  z-index: -1;
  pointer-events: none;
  filter: blur(72px);
  background: radial-gradient(circle, rgba(28, 79, 143, 0.22) 0%, rgba(15, 26, 42, 0) 70%);
}

/* ── TOPBAR ── */
#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(18, 34, 54, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#topbar .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-isologo {
  height: 30px;
  width: auto;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.5px;
  color: #fff;
}

#topbar .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  flex-shrink: 0;
}

#topbar .status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 8px rgba(204, 74, 62, 0.7);
}

#topbar .user-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--gold);
  cursor: pointer;
  flex-shrink: 0;
}

#topbar .spacer {
  flex: 1;
}

#topbar .search-btn,
.topbar-icon-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

/* ── MAIN CONTENT ── */
#app {
  padding-top: var(--topbar-height);
  padding-bottom: 72px;
}

/* ── HERO STATS ── */
#hero {
  padding: 20px 16px 0;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, rgba(9, 9, 11, 0.12) 0%, rgba(9, 9, 11, 0.64) 100%),
    url('./assets/images/portada-album.png');
  background-size: cover;
  background-position: center top;
  opacity: 0.46;
  pointer-events: none;
}

.progress-ring-wrap {
  display: flex;
  justify-content: center;
  padding: 20px 0 16px;
}

.ring-container {
  position: relative;
  width: 140px;
  height: 140px;
}

.ring-container svg {
  width: 140px;
  height: 140px;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--bg4);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: url(#goldGrad);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(.4, 0, .2, 1);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-pct {
  font-family: var(--font-display);
  font-size: 34px;
  color: var(--gold);
  line-height: 1;
}

.ring-label {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 0 0 16px;
}

.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}

.stat-card .val {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
}

.stat-card .lbl {
  font-size: 10px;
  color: var(--text3);
  margin-top: 3px;
  letter-spacing: 0.3px;
}

.stat-card.tengo .val {
  color: var(--green);
}

.stat-card.faltan .val {
  color: var(--red);
}

.stat-card.repetidas .val {
  color: var(--gold);
}

/* ── SECTION TABS ── */
#tabs-wrap {
  position: sticky;
  top: var(--topbar-height);
  z-index: 90;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

#tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 8px 12px;
  scrollbar-width: none;
}

#tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  background: none;
  color: var(--text3);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.tab.active {
  background: var(--gold);
  color: #1b2637;
  border-color: var(--gold);
}

/* ── FILTER BAR ── */
#filterbar {
  display: flex;
  gap: 8px;
  padding: 10px 16px 8px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: calc(var(--topbar-height) + var(--tabs-sticky-height));
  z-index: 89;
  background: rgba(15, 26, 42, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(242, 177, 56, 0.12);
}

#filterbar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.filter-count {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.filter-chip.active .filter-count {
  background: rgba(242, 177, 56, 0.25);
  color: var(--gold);
}

.filter-chip.active {
  background: var(--bg4);
  color: var(--text);
  border-color: var(--gold);
}

/* ── SEARCH BAR ── */
#searchbar {
  padding: 0 16px 10px;
  display: none;
}

#searchbar.visible {
  display: block;
}

#search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
}

#search-input:focus {
  border-color: var(--gold);
}

#search-input::placeholder {
  color: var(--text3);
}

/* ── COUNTRY SECTION ── */
.country-section {
  margin: 0 0 4px;
}

.country-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 8px;
  cursor: pointer;
  position: sticky;
  top: var(--section-sticky-top);
  z-index: 80;
  background: var(--bg);
}

.country-flag {
  font-size: 22px;
}

.country-flag-img {
  width: 36px;
  height: 28px;
  object-fit: contain;
  border-radius: 3px;
  flex-shrink: 0;
}

.country-name {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.5px;
  color: var(--text);
  flex: 1;
}

.section-group-label {
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text3);
  font-weight: 500;
  letter-spacing: 0;
}

.country-prog {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
}

.country-prog span {
  color: var(--gold);
}

.chevron {
  color: var(--text3);
  font-size: 16px;
  transition: transform 0.25s;
  flex-shrink: 0;
}

.country-section.collapsed .chevron {
  transform: rotate(-90deg);
}

.country-section.collapsed .stickers-grid {
  display: none;
}

/* ── STICKERS GRID ── */
.stickers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  padding: 0 12px 10px;
}

/* ── STICKER CARD ── */
.sticker {
  aspect-ratio: 3/4;
  border-radius: 12px;
  border: 1px solid var(--card-border-empty);
  background: transparent;
  display: block;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.sticker:active {
  transform: scale(0.93);
}

.sticker::before {
  content: none;
}

.sticker-svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* Estados */
.sticker.tengo {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 0 1px rgba(63, 185, 255, 0.34), 0 4px 12px rgba(28, 79, 143, 0.22);
}

.sticker.tengo::after {
  content: none;
}

.sticker.repetida {
  border-color: var(--neon-lime);
  box-shadow: 0 0 0 1px rgba(149, 211, 90, 0.32), 0 4px 12px rgba(17, 46, 35, 0.22);
}

.sticker.repetida::after {
  content: none;
}

.sticker.falta {
  border-color: rgba(255, 255, 255, 0.1);
}

.sticker-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  right: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.sticker.tengo .sticker-badge {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.sticker.repetida .sticker-badge {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  font-size: 16px;
}

/* Badge 'nueva' 24hs */
.sticker-new-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background: var(--gold);
  color: #1b2637;
  font-size: 9px;
  font-weight: 800;
  font-family: var(--font-body);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 6px;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  pointer-events: none;
}

/* Contador repetidas */
.repeat-count {
  position: absolute;
  top: 3px;
  right: 3px;
  bottom: auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: #fff;
  color: #111;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ── BOTTOM NAV ── */
#bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 26, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  transition: color 0.2s;
  font-size: 10px;
  font-weight: 500;
  gap: 3px;
}

.nav-btn .icon {
  font-size: 20px;
  line-height: 1;
}

.nav-btn.active {
  color: var(--gold);
}

.nav-btn .badge {
  position: absolute;
  background: var(--red);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  padding: 0 4px;
  min-width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  top: 6px;
}

/* ── VIEWS ── */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* ── INTERCAMBIO VIEW ── */
#view-intercambio {
  padding: 16px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.5px;
  color: var(--gold);
  margin-bottom: 4px;
}

.section-sub {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 16px;
}

.intercambio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.intercambio-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.intercambio-code {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}

.intercambio-name {
  font-size: 11px;
  color: var(--text2);
  line-height: 1.3;
}

.intercambio-count {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.count-badge {
  background: rgba(245, 200, 66, 0.2);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.export-btn {
  width: 100%;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 8px;
}

.export-btn:active {
  opacity: 0.8;
}

/* ── HISTORIAL VIEW ── */
#view-historial {
  padding: 16px;
}

.historial-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.historial-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hist-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hist-dot.add {
  background: var(--green);
}

.hist-dot.repeat {
  background: var(--gold);
}

.hist-dot.remove {
  background: var(--red);
}

.hist-info {
  flex: 1;
}

.hist-code {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
}

.hist-desc {
  font-size: 13px;
  color: var(--text2);
}

.hist-time {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
}

.hist-user {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text2);
  flex-shrink: 0;
}

/* ── MODAL ── */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

#modal-overlay.open {
  display: flex;
}

#modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  animation: slideUp 0.3s cubic-bezier(.4, 0, .2, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--bg4);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-code {
  font-family: var(--font-display);
  font-size: 32px;
  color: var(--gold);
  letter-spacing: 1px;
}

.modal-name {
  font-size: 16px;
  color: var(--text2);
  margin: 4px 0 8px;
}

.modal-group {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 20px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.modal-btn {
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.modal-btn:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.btn-tengo {
  background: rgba(0, 200, 83, 0.2);
  color: var(--green);
  border: 1px solid var(--green);
}

.btn-repetida {
  background: rgba(245, 200, 66, 0.15);
  color: var(--gold);
  border: 1px solid var(--gold);
}

.btn-falta {
  background: rgba(232, 36, 60, 0.15);
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-falta-wide {
  grid-column: span 2;
}

.repeat-controls {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.repeat-controls .rc-label {
  color: var(--text2);
  font-size: 13px;
  flex: 1;
}

.rc-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg4);
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.rc-btn:hover {
  background: var(--bg3);
}

.rc-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  min-width: 28px;
  text-align: center;
}

/* ── OCR VIEW ── */
#view-ocr {
  padding: 16px;
}

.ocr-area {
  background: var(--bg3);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  margin-bottom: 16px;
}

.ocr-area:hover {
  border-color: var(--gold);
}

.ocr-area.has-image {
  border-style: solid;
  border-color: var(--gold);
  padding: 0;
  overflow: hidden;
}

.ocr-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.ocr-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text);
}

.ocr-sub {
  font-size: 13px;
  color: var(--text3);
  margin-top: 4px;
}

#ocr-preview {
  width: 100%;
  border-radius: var(--radius-lg);
  display: block;
}

#ocr-input {
  display: none;
}

.ocr-results {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.ocr-results-title {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.ocr-detected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ocr-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(242, 177, 56, 0.2);
  border: 1px solid rgba(242, 177, 56, 0.46);
  color: var(--gold);
  cursor: pointer;
  transition: background 0.15s;
}

.ocr-chip.selected {
  background: var(--gold);
  color: #1b2637;
}

.ocr-chip.unknown {
  background: rgba(204, 74, 62, 0.18);
  border-color: rgba(204, 74, 62, 0.45);
  color: #ffd3ce;
  cursor: default;
}

.ocr-apply-btn {
  width: 100%;
  background: var(--gold);
  color: #1b2637;
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.ocr-apply-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ocr-processing {
  text-align: center;
  padding: 20px;
  color: var(--text3);
  font-size: 14px;
  display: none;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg4);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── USER SETUP ── */
#user-setup {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.setup-logo-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.setup-isologo {
  height: 60px;
  width: auto;
}

.setup-isologo-title {
  font-family: var(--font-display);
  font-size: 30px;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1;
}

.setup-logo {
  font-family: var(--font-display);
  font-size: 56px;
  background: linear-gradient(135deg, #ffe7ba, var(--gold), #f7c367);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
  line-height: 1;
}

.setup-sub {
  font-size: 14px;
  color: var(--text3);
  margin-bottom: 40px;
  letter-spacing: 2px;
}

.setup-label {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 8px;
  align-self: flex-start;
  width: 100%;
  max-width: 320px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.setup-input {
  width: 100%;
  max-width: 320px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 14px 16px;
  outline: none;
  margin-bottom: 10px;
}

.setup-input:focus {
  border-color: var(--gold);
}

.setup-btn {
  width: 100%;
  max-width: 320px;
  background: var(--gold);
  color: #1b2637;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: opacity 0.2s;
}

.setup-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.setup-room-info {
  font-size: 12px;
  color: var(--text3);
  margin-top: 12px;
  line-height: 1.6;
}

.setup-divider {
  width: 100%;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--text3);
  font-size: 13px;
}

.setup-divider::before,
.setup-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--bg4);
}

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transition: all 0.3s;
  z-index: 250;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── GRUPO BADGE ── */
.grupo-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
}

/* ── PROGRESS BARS ── */
.prog-bar-wrap {
  height: 4px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
  margin-bottom: 1px;
}

.prog-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── SYNC INDICATOR ── */
#sync-indicator {
  position: fixed;
  top: 58px;
  right: 0;
  background: rgba(31, 154, 91, 0.92);
  color: #e9fff2;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px 3px 8px;
  border-radius: 0 0 0 8px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 99;
}

#sync-indicator.show {
  opacity: 1;
}

/* ── CONFIG VIEW ── */
#view-config {
  padding: 16px;
}

.config-section {
  margin-bottom: 20px;
}

.config-section-title {
  font-size: 11px;
  color: var(--text3);
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.config-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(237, 243, 255, 0.08);
}

.config-row:last-child {
  border-bottom: none;
}

.config-row-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.config-row-info {
  flex: 1;
}

.config-row-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.config-row-sub {
  font-size: 12px;
  color: var(--text3);
  margin-top: 1px;
}

.config-row-val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--gold);
}

.config-action-btn {
  background: var(--bg4);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.danger-btn {
  width: 100%;
  background: rgba(204, 74, 62, 0.18);
  border: 1px solid var(--red);
  color: #ffbbb3;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
}

.empty-state .es-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state .es-title {
  font-size: 16px;
  color: var(--text2);
  margin-bottom: 6px;
}

.empty-state .es-sub {
  font-size: 13px;
}

/* ── TEAM SYNC / QR TRADE ── */
#view-team {
  padding: 16px;
}

.team-grid {
  display: grid;
  gap: 14px;
}

.team-panel {
  background: linear-gradient(180deg, rgba(237, 243, 255, 0.04), rgba(237, 243, 255, 0.015));
  border: 1px solid var(--card-border-empty);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.team-panel-head {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.6px;
  color: var(--gold);
}

.team-panel-sub {
  color: var(--text3);
  font-size: 13px;
  margin: 4px 0 12px;
  line-height: 1.45;
}

.trade-chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.trade-chip {
  border: 1px solid var(--card-border-empty);
  background: var(--bg2);
  border-radius: 12px;
  padding: 10px 8px;
  min-height: 74px;
  text-align: left;
  color: var(--text);
  position: relative;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.trade-chip:active {
  transform: scale(0.97);
}

.trade-chip.selected {
  border-color: var(--neon-cyan);
  background: linear-gradient(135deg, rgba(63, 185, 255, 0.2), rgba(28, 79, 143, 0.22));
}

.trade-chip .code {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.trade-chip .name {
  display: block;
  font-size: 11px;
  color: var(--text2);
  line-height: 1.25;
}

.trade-chip .meta {
  display: inline-flex;
  margin-top: 6px;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text3);
}

.trade-chip .pill {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(149, 211, 90, 0.2);
  color: var(--neon-lime);
}

.trade-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 12px;
}

.trade-primary-btn,
.trade-secondary-btn {
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease;
}

.trade-primary-btn {
  background: var(--gold);
  color: #1b2637;
}

.trade-secondary-btn {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}

.trade-primary-btn:active,
.trade-secondary-btn:active {
  transform: scale(0.98);
}

.trade-qr-wrap {
  min-height: 260px;
  display: grid;
  place-items: center;
  background: rgba(20, 37, 59, 0.48);
  border: 1px dashed var(--card-border-empty);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.trade-qr-wrap img {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1;
  object-fit: contain;
}

.trade-empty {
  padding: 20px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
  line-height: 1.5;
}

.trade-meta {
  margin-top: 10px;
  color: var(--text2);
  font-size: 12px;
  line-height: 1.45;
}

.trade-incoming {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.trade-offer-card {
  border: 1px solid var(--card-border-empty);
  background: rgba(237, 243, 255, 0.03);
  border-radius: var(--radius);
  padding: 12px;
}

.trade-offer-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold);
  margin-bottom: 4px;
}

.trade-offer-sub {
  color: var(--text3);
  font-size: 12px;
  margin-bottom: 10px;
}

.trade-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.trade-select-chip {
  border: 1px solid var(--card-border-empty);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text);
  padding: 8px;
  min-height: 66px;
  cursor: pointer;
}

.trade-select-chip.selected {
  border-color: var(--neon-magenta);
  box-shadow: inset 0 0 0 1px rgba(255, 120, 96, 0.4);
}

.trade-select-chip .t-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 2px;
}

.trade-select-chip .t-name {
  font-size: 10px;
  color: var(--text2);
  line-height: 1.2;
}

.trade-select-chip .t-state {
  display: inline-flex;
  margin-top: 6px;
  font-size: 9px;
  color: var(--neon-lime);
  font-weight: 700;
}

.incoming-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.incoming-btn {
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.incoming-btn.accept {
  background: rgba(31, 154, 91, 0.2);
  color: var(--green);
  border-color: rgba(31, 154, 91, 0.5);
}

.incoming-btn.reject {
  background: rgba(204, 74, 62, 0.16);
  color: var(--red);
  border-color: rgba(204, 74, 62, 0.4);
}

#trade-qr-input {
  display: none;
}

/* ── RESPONSIVE ── */
@media (min-width: 480px) {
  .stickers-grid {
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  }
}

@media (max-width: 899px) {
  /* Alturas reales en mobile para calcular los top del sticky */
  :root {
    --tabs-sticky-height: 50px;
    --filterbar-sticky-height: 100px; /* 2 filas de chips + padding */
    --section-sticky-top: calc(var(--topbar-height) + var(--tabs-sticky-height) + var(--filterbar-sticky-height));
  }

  /* tabs y filterbar son sticky en base — aquí solo ajustamos heights/layout */
  #tabs {
    padding: 10px 12px;
  }

  #filterbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px 16px 12px;
  }

  #searchbar {
    padding: 0 12px 10px;
  }

  .filter-chip {
    width: 100%;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
  }

  .country-header {
    padding: 10px 12px 8px;
  }

  .country-name {
    font-size: 18px;
  }

  .section-group-label {
    font-size: 12px;
  }

  .country-flag-img {
    width: 32px;
    height: 24px;
  }

  /* Scroll horizontal por fila — flex sin restricción de touch */
  .stickers-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 8px;
    padding: 0 12px 12px;
    scrollbar-width: none;
  }

  .stickers-grid::-webkit-scrollbar {
    display: none;
  }

  .sticker {
    flex: 0 0 calc((100vw - 40px) / 3);
    min-width: calc((100vw - 40px) / 3);
  }
}

@media (min-width: 900px) {
  #app {
    max-width: 1180px;
    margin: 0 auto;
  }

  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .trade-qr-wrap {
    min-height: 320px;
  }

  .trade-chip-grid,
  .trade-select-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .stickers-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

/* ── LANDSCAPE BLOCK ── */
#landscape-block {
  display: none;
}

@media (orientation: landscape) and (max-height: 600px) {
  #landscape-block {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
  }
  .landscape-icon {
    font-size: 56px;
    animation: rotate-hint 2s ease-in-out infinite;
  }
  .landscape-msg {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--gold);
    letter-spacing: 2px;
    text-align: center;
  }
  .landscape-sub {
    font-size: 14px;
    color: var(--text3);
    text-align: center;
  }
}

@keyframes rotate-hint {
  0%, 100% { transform: rotate(0deg); }
  30% { transform: rotate(90deg); }
  70% { transform: rotate(90deg); }
}

/* ── LOADING ── */
#loading {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg);
  background-image:
    linear-gradient(180deg, rgba(9, 9, 11, 0.42) 0%, rgba(9, 9, 11, 0.78) 100%),
    url('./assets/images/portada-album.png');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.loading-cover {
  display: none;
}

.loading-logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.loading-isologo {
  height: 60px;
  width: auto;
}

.loading-title {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 1px;
  color: #fff;
}

.loading-bar-wrap {
  width: 200px;
  height: 3px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  border-radius: 2px;
  animation: loadBar 1.5s ease-in-out infinite;
}

@keyframes loadBar {
  0% {
    width: 0%;
    margin-left: 0;
  }

  50% {
    width: 60%;
    margin-left: 20%;
  }

  100% {
    width: 0%;
    margin-left: 100%;
  }
}

.loading-txt {
  font-size: 13px;
  color: var(--text3);
}
