:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --text: #14171f;
  --text-muted: #666d7a;
  --border: #e2e5ea;
  --primary: #1C4FC7;
  --primary-dark: #123a94;
  --accent: #E31E24;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ── Layout ─────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .5rem;
  background: var(--primary); color: #fff;
  padding: .6rem .8rem;
}
.topbar h1 { font-size: 1.05rem; flex: 1; color: #fff; }
.icon-btn {
  background: none; border: none; font-size: 1.3rem; padding: .4rem .6rem;
  cursor: pointer; border-radius: var(--radius); color: #fff;
}
.icon-btn:hover { background: rgba(255,255,255,.15); }

.sidenav {
  position: fixed; top: 0; left: 0; bottom: 0; width: 240px; z-index: 30;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 1rem .5rem; display: flex; flex-direction: column; gap: .25rem;
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidenav.open { transform: translateX(0); }
.sidenav a {
  color: var(--text); padding: .7rem .8rem; border-radius: var(--radius); font-weight: 500;
}
.sidenav a:hover, .sidenav a.active { background: #e8edfc; color: var(--primary); }
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25;
}

main#app { padding: 1rem; max-width: 1100px; margin: 0 auto; padding-bottom: 3rem; }

@media (min-width: 860px) {
  .sidenav { transform: translateX(0); position: sticky; height: 100vh; }
  .backdrop { display: none !important; }
  #menuToggle { display: none; }
  body { display: flex; }
  .page-wrap { flex: 1; min-width: 0; }
}

/* ── Componentes genéricos ──────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.card h2 { font-size: 1.05rem; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  background: var(--primary); color: #fff; border: none; border-radius: var(--radius);
  padding: .6rem 1rem; cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.accent { background: var(--accent); }
.btn.accent:hover { background: #b5171b; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: .6rem; }

label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; color: var(--text-muted); }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=tel], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.field { margin-bottom: .8rem; min-width: 160px; }

table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { background: var(--bg); position: sticky; top: 0; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-scroll table { margin: 0; border: none; }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: #dcfce7; color: var(--success); }
.badge.warn { background: #fef3c7; color: var(--warning); }
.badge.risk { background: #fee2e2; color: var(--danger); }
.badge.neutral { background: #eef0f3; color: var(--text-muted); }
/* Estados de cuota/multa */
.badge.paid { background: #dcfce7; color: var(--success); }
.badge.partial { background: #fef3c7; color: var(--warning); }
.badge.pending { background: #fee2e2; color: var(--danger); }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab { padding: .6rem 1rem; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.tab.active { color: var(--primary); border-color: var(--primary); }

.empty { color: var(--text-muted); text-align: center; padding: 2rem 1rem; }
.muted { color: var(--text-muted); }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, var(--primary), var(--primary-dark)); }
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card h2 { color: var(--primary); }
.login-logo { width: 84px; height: 84px; margin: 0 auto .5rem; display: block; }

.toast {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: .7rem 1.1rem; border-radius: var(--radius);
  z-index: 50; font-size: .9rem; max-width: 90vw;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.spinner { text-align: center; padding: 2rem; color: var(--text-muted); }

/* ── Dashboard: stat tiles ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-tile .stat-value { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-tile.accent .stat-value { color: var(--accent); }
.stat-tile .stat-label { color: var(--text-muted); font-size: .85rem; }

/* ── Lista de jugadores: fila compacta con acción rápida ───────────── */
.player-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem .3rem; border-bottom: 1px solid var(--border); }
.player-row:last-child { border-bottom: none; }
.player-name { font-weight: 600; }
.player-row .balance { font-weight: 700; }
.player-row .balance.ok { color: var(--success); }
.player-row .balance.debt { color: var(--danger); }

/* ── Modal simple para cargar pagos/multas rápido ──────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; padding: 1.2rem; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius); }
}
