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

:root {
  --gold: #FFD700;
  --navy: #1a1a2e;
  --navy2: #16213e;
  --radius: 10px;
  --radius-sm: 6px;
  --green: #1D9E75;
  --red: #E24B4A;
  --amber: #F59E0B;
}

[data-theme="light"] {
  --text: #111827;
  --muted: #6b7280;
  --bg: #f9fafb;
  --white: #ffffff;
  --border: 1px solid #e5e7eb;
}

[data-theme="dark"] {
  --text: #f3f4f6;
  --muted: #9ca3af;
  --bg: #111827;
  --white: #1f2937;
  --border: 1px solid #374151;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── Auth ── */
.auth-wrap {
  max-width: 400px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}
.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: .75rem;
}
.star-sm {
  font-size: 20px;
  color: #FFD700;
  line-height: 1;
  margin-top: 6px;
}
.star-lg {
  font-size: 34px;
  color: #FFD700;
  line-height: 1;
}
.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.3px;
}
[data-theme="dark"] .auth-title { color: var(--gold); }
.auth-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 6px;
}
.auth-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.auth-hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: .75rem;
  line-height: 1.6;
  padding: 0 1rem;
}
footer { color: var(--muted) !important; }
footer a { color: var(--gold) !important; }

/* ── Cards ── */
.card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

/* ── Topbar ── */
.topbar {
  background: var(--navy);
  color: var(--gold);
  padding: .75rem 1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 1rem;
}
.topbar-title { font-size: 16px; font-weight: 700; flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: 6px; font-size: 13px; color: rgba(255,255,255,.9); min-width: 0; }
.topbar-username { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.topbar-codigo { font-size: 10px; opacity: .7; letter-spacing: .5px; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ── Stats ── */
.stats-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: .75rem; }
.stat-card { background: var(--white); border: var(--border); border-radius: var(--radius-sm); padding: .75rem; text-align: center; }
.stat-num  { font-size: 22px; font-weight: 700; }
.stat-lbl  { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ── Progress ── */
.progress-wrap { height: 5px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin-bottom: 1rem; }
.progress-fill { height: 100%; background: var(--gold); border-radius: 3px; transition: width .4s; }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; border-bottom: var(--border); margin-bottom: 1rem; }
.tab {
  font-size: 13px;
  padding: 7px 14px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab.active { color: var(--navy); border-bottom-color: var(--gold); font-weight: 600; }
@media (prefers-color-scheme: dark) { .tab.active { color: var(--gold); } }
.badge-count {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  margin-left: 3px;
}

/* ── Forms ── */
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
}
input[type=text], input[type=password], input:not([type]) {
  width: 100%;
  padding: 9px 12px;
  border: var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255,215,0,.15); }

/* Neutralizar autofill del browser — usa el mismo fondo que el input */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px var(--white) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}
.field-err { font-size: 12px; color: var(--red); min-height: 16px; margin-bottom: .5rem; }

/* ── Buttons ── */
.btn {
  font-size: 13px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: var(--border);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: background .15s;
}
.btn:hover { background: var(--bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: var(--gold); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy2); }
.btn-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.btn-danger  { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.btn-outline-gold { border-color: rgba(255,215,0,.5); color: var(--gold); background: transparent; }
.btn-outline-gold:hover { background: rgba(255,255,255,.1); }
.btn-sm { font-size: 12px; padding: 4px 10px; }
.w100 { width: 100%; margin-top: .5rem; }
.w50 { width: 48%; }

/* ── Avatar ── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }

/* ── Teams grid ── */
.search-input {
  width: 100%; padding: 8px 12px;
  border: var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--bg); color: var(--text);
  margin-bottom: 1rem; outline: none;
}
.group-section { margin-bottom: 1.5rem; }
.group-header { display: flex; align-items: center; gap: 8px; margin-bottom: .625rem; }
.group-badge {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--navy); color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.group-title { font-size: 14px; font-weight: 600; }
.group-prog  { margin-left: auto; font-size: 12px; color: var(--muted); }
.teams-grid  { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 6px; }
.team-card {
  background: var(--white); border: var(--border);
  border-radius: var(--radius-sm); padding: .625rem .75rem;
  cursor: pointer; transition: border-color .15s;
}
.team-card:hover { border-color: var(--navy); }
.team-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.flag { font-size: 18px; line-height: 1; }
.flag.sm { font-size: 14px; }
.team-info { flex: 1; min-width: 0; }
.team-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-sub  { font-size: 10px; color: var(--muted); }
.mini-prog { height: 3px; background: #e5e7eb; border-radius: 2px; overflow: hidden; }
.mini-prog.sm { margin-top: 4px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-box {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; }
.modal-title { font-size: 15px; font-weight: 600; }
.modal-sub   { font-size: 12px; color: var(--muted); }
.stickers-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; }
.sticker-wrap  { text-align: center; cursor: pointer; }
.sticker {
  border: 1.5px solid #d1d5db;
  border-radius: 5px;
  padding: 5px 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg);
  transition: all .12s;
}
.sticker.have { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.sticker-lbl  { font-size: 8px; color: var(--muted); margin-top: 2px; line-height: 1.2; }
.modal-actions { display: flex; gap: 8px; margin-top: .875rem; }

/* ── Amigos ── */
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: .75rem 0;
  border-bottom: var(--border);
  cursor: pointer;
}
.user-row:last-child { border-bottom: none; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; }
.user-sub  { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chevron { color: var(--muted); font-size: 14px; }
.back-row { display: flex; align-items: center; gap: 8px; margin-bottom: .75rem; }
.friend-name { font-size: 14px; font-weight: 600; }
.friend-sub  { font-size: 11px; color: var(--muted); }
.compare-row {
  display: flex; align-items: center; gap: 8px;
  padding: .375rem 0; border-bottom: var(--border);
}
.compare-team { font-size: 12px; min-width: 90px; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; flex: 1; }
.chip {
  background: #eff6ff; color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 20px; padding: 1px 7px; font-size: 10px;
}
.chip.muted { background: #f3f4f6; color: var(--muted); border-color: #e5e7eb; }

/* ── Nuevo intercambio ── */
.sec-title { font-size: 13px; font-weight: 600; margin-bottom: .75rem; color: var(--text); }
.sec-title.warn { color: #92400e; }
.sec-title.muted { color: var(--muted); }
.hint-text { font-size: 11px; color: var(--muted); margin-bottom: .625rem; }
.step-label { font-size: 13px; color: var(--text); }
.teams-sel {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr));
  gap: 6px; max-height: 300px; overflow-y: auto; margin-bottom: 1rem;
}
.team-opt {
  padding: .5rem .75rem; border: var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 12px; display: flex; align-items: center; gap: 6px;
}
.team-opt:hover { background: var(--bg); }
.team-opt.sel   { border-color: var(--navy); background: #eff6ff; }
.team-opt-name  { flex: 1; }
.dot-green { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.stickers-pick-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; margin-bottom: .875rem; }
.sticker-pick {
  border: 1.5px solid #d1d5db; border-radius: 5px;
  padding: 5px 2px; font-size: 11px; font-weight: 500;
  text-align: center; color: var(--muted); background: var(--bg);
  transition: all .12s;
}
.sticker-pick.useful { border-color: var(--green); background: #d1fae5; color: #065f46; }
.sticker-pick.sel    { border-color: var(--navy); background: var(--navy); color: var(--gold); }
.sticker-pick.disabled { opacity: .3; }
.dimmed { opacity: .4; cursor: not-allowed !important; }

/* ── Intercambios ── */
.ex-card { border: var(--border); border-radius: var(--radius-sm); padding: .75rem; margin-bottom: .5rem; }
.ex-card.pending { border-left: 3px solid var(--amber); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.ex-card.done    { border-left: 3px solid var(--green); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; opacity: .75; }
.ex-head    { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ex-who     { font-size: 13px; font-weight: 600; }
.ex-detail  { font-size: 12px; color: var(--muted); margin-top: 3px; }
.ex-actions { display: flex; gap: 4px; flex-shrink: 0; }
.muted { color: var(--muted); font-weight: 400; }

/* ── Badges ── */
.badge-warn { background: #fef3c7; color: #92400e; font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 500; }
.badge-ok   { background: #d1fae5; color: #065f46; font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 500; }

/* ── Misc ── */
.empty-msg { text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: 14px; }

@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .tabs { overflow-x: auto; }
  .tab { font-size: 12px; padding: 6px 10px; }
}

/* Tarjeta expandida al buscar */
.expanded-card {
  grid-column: 1 / -1;
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius);
  padding: .875rem 1rem;
}
.stickers-grid-inline {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
}
@media (max-width: 600px) {
  .stickers-grid-inline { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .stickers-grid-inline .sticker { font-size: 12px; padding: 7px 2px; }
  .stickers-grid-inline .sticker-lbl { font-size: 9px; }
}

@media (max-width: 380px) {
  .topbar-title { font-size: 13px; }
  .topbar-username { max-width: 65px; }
  .topbar-codigo { display: none; }
}
