:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #16a34a;
  --accent-dark: #15803d;
  --danger: #dc2626;
  --gold: #f59e0b;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(15, 23, 42, .12);
}

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

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand small { display: block; font-weight: 400; color: #94a3b8; font-size: .68rem; }

.cuenta { display: flex; align-items: center; gap: 10px; font-size: .85rem; }
.cuenta .saldo {
  background: rgba(22, 163, 74, .18);
  color: #86efac;
  border: 1px solid rgba(22, 163, 74, .5);
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}
.cuenta a, .cuenta button {
  background: transparent;
  color: #e2e8f0;
  border: 1px solid #334155;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .8rem;
  cursor: pointer;
}
.cuenta a:active, .cuenta button:active { background: #334155; }

/* ---------- Layout ---------- */
.wrap { max-width: 900px; margin: 0 auto; padding: 16px; }

.hero {
  text-align: center;
  padding: 22px 4px 10px;
}
.hero h1 { font-size: 1.35rem; margin: 0 0 6px; }
.hero p { margin: 0; color: var(--muted); font-size: .9rem; }

/* ---------- Buscador ---------- */
.buscador { position: relative; margin: 16px 0 8px; }
.buscador label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: .95rem;
}
.search-wrap { position: relative; }
.search-wrap input {
  width: 100%;
  padding: 16px 46px 16px 46px;
  font-size: 1rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  box-shadow: var(--shadow);
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 1.1rem;
}
.search-wrap .clear {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: none; background: #f1f5f9; color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; font-size: 1rem;
  cursor: pointer; display: none;
}

.suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 30;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
}
.suggest.show { display: block; }
.suggest-item {
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:active, .suggest-item.active { background: #f0fdf4; }
.suggest-item .d { font-weight: 600; }
.suggest-item .dep { font-size: .78rem; color: var(--muted); }
.suggest-empty { padding: 14px 16px; color: var(--muted); font-size: .88rem; }

/* ---------- Resultado ---------- */
.resultado-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 12px;
  padding: 12px 14px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.resultado-head .pin-dist {
  width: 8px; height: 34px; border-radius: 4px; background: var(--accent);
}
.resultado-head h2 { margin: 0; font-size: 1.05rem; }
.resultado-head span { color: var(--muted); font-size: .82rem; }
.aviso {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: .85rem;
  margin-bottom: 12px;
}

.credito-box {
  background: #f0fdf4;
  border: 1px dashed var(--accent);
  color: #166534;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: .85rem;
  margin-bottom: 14px;
}
.credito-box b { color: var(--accent-dark); }

/* ---------- Bono por candidato ---------- */
.bonus {
  margin-top: 8px;
  font-size: .78rem;
  color: var(--muted);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 5px 9px;
  text-align: center;
}
.bonus b { color: var(--accent-dark); }

.cards { display: grid; grid-template-columns: 1fr; gap: 12px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  gap: 12px;
  padding: 12px;
  position: relative;
}
.card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--c, #888);
}
.card .foto {
  width: 78px; height: 78px; flex: 0 0 78px;
  border-radius: 12px; object-fit: cover; background: #e2e8f0;
}
.card .info { flex: 1; min-width: 0; }
.card .nombre { font-weight: 700; font-size: 1rem; line-height: 1.25; }
.card .partido {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; color: var(--muted); margin: 3px 0 8px;
}
.card .partido .dot { width: 10px; height: 10px; border-radius: 50%; }
.card .row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card .odds {
  font-size: .8rem; color: var(--muted);
}
.card .odds b { color: var(--gold); font-size: 1.05rem; }
.btn-apostar {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .9rem;
  cursor: pointer;
}
.btn-apostar:active { background: var(--accent-dark); }
.btn-apostar[disabled] { background: #cbd5e1; cursor: not-allowed; }

.vacio {
  text-align: center; color: var(--muted); padding: 40px 16px;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .6);
  display: none; align-items: flex-end; justify-content: center; z-index: 60;
  padding: 0;
}
.modal.show { display: flex; }
.modal-box {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 20px 18px 26px;
  max-height: 92vh; overflow-y: auto;
  animation: subir .18s ease-out;
}
@keyframes subir { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 560px) {
  .modal { align-items: center; }
  .modal-box { border-radius: 20px; }
}
.modal-box h3 { margin: 0 0 4px; font-size: 1.15rem; }
.modal-box .sub { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }
.modal-box .cerrar {
  position: absolute; top: 12px; right: 14px;
  border: none; background: #f1f5f9; width: 34px; height: 34px;
  border-radius: 50%; font-size: 1.2rem; cursor: pointer; color: var(--muted);
}
.modal-box { position: relative; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 14px 14px; font-size: 1.05rem;
  border: 2px solid var(--line); border-radius: 12px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.field input.centro { text-align: center; letter-spacing: 8px; font-weight: 700; }

.btn-primary {
  width: 100%; background: var(--accent); color: #fff; border: none;
  padding: 15px; border-radius: 12px; font-size: 1rem; font-weight: 700;
  cursor: pointer;
}
.btn-primary:active { background: var(--accent-dark); }
.btn-primary[disabled] { background: #cbd5e1; }

.msg { margin: 12px 0 0; font-size: .88rem; min-height: 1em; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--accent-dark); }

.pin-box {
  background: #f0fdf4; border: 1px dashed var(--accent);
  border-radius: 12px; padding: 14px; text-align: center; margin: 12px 0;
}
.pin-box .pin {
  font-size: 2rem; font-weight: 800; letter-spacing: 10px;
  color: var(--accent-dark); margin: 6px 0;
}
.pin-box small { color: var(--muted); }

.premio-box {
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px;
  padding: 12px; display: flex; justify-content: space-between; align-items: center;
  margin-top: 4px;
}
.premio-box b { color: var(--gold); font-size: 1.15rem; }

.footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 26px 16px 40px; }
.footer a { text-decoration: underline; }

@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .hero h1 { font-size: 1.7rem; }
}

/* ---------- Paneles / cuenta ---------- */
.panel {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-top: 16px;
}
.panel-row { display: flex; gap: 12px; flex-wrap: wrap; }
.panel-row + .panel-row { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.dato { flex: 1; min-width: 130px; display: flex; flex-direction: column; }
.dato .k, .stat .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.dato .v, .stat .v { font-size: 1.1rem; font-weight: 700; }
.dato .v.verde, .stat .v.verde { color: var(--accent-dark); }
.dato .v.dorado, .stat .v.dorado { color: var(--gold); }
.stat {
  flex: 1; min-width: 100px; background: #fff; border-radius: 14px;
  box-shadow: var(--shadow); padding: 12px; display: flex; flex-direction: column; gap: 2px;
}
.seccion { font-size: 1.05rem; margin: 22px 0 12px; }
.fecha { font-size: .72rem; color: var(--muted); margin-top: 6px; }

/* ---------- Formularios sueltos ---------- */
.form-simple {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; max-width: 460px; margin: 16px auto;
}
.form-simple h1 { font-size: 1.25rem; margin: 0 0 6px; }
.form-simple p { color: var(--muted); font-size: .88rem; margin: 0 0 16px; }

/* ---------- Admin ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.admin-tabs a {
  padding: 8px 14px; border-radius: 999px; background: #fff; font-size: .85rem;
  font-weight: 600; border: 1px solid var(--line);
}
.admin-tabs a.on { background: var(--bg); color: #fff; border-color: var(--bg); }
.tabla { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); font-size: .85rem; }
.tabla th, .tabla td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabla th { background: #f8fafc; font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.tabla tr:last-child td { border-bottom: none; }
.tabla input { width: 90px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; }
.tabla .btn-mini { background: var(--accent); color: #fff; border: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: .8rem; font-weight: 600; }
.tabla .btn-mini.gris { background: #e2e8f0; color: var(--text); }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.badge.pend { background: #fef3c7; color: #92400e; }
.badge.ok { background: #dcfce7; color: #166534; }
.admin-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
