/* ══════════════════════════════════════════════════════════════
   Panel de gestión — sistema visual "sala de pesas"
   Paleta: colores normados de discos olímpicos (IWF)
     rojo 25kg  → acción / morosidad      azul 20kg → información
     amarillo 15kg → recordatorio          verde 10kg → al día
   Tipografía: Archivo + Archivo Black (Omnibus-Type, Buenos Aires)
   Firma: numerales de marcador (scoreboard) en stats y check-in
   ══════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Archivo';
  src: url('/fonts/Archivo-var.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Archivo Black';
  src: url('/fonts/ArchivoBlack-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

:root {
  /* superficie */
  --hormigon: #eef0ef;        /* fondo general (piso de hormigón) */
  --papel: #ffffff;           /* tarjetas */
  --goma: #17191d;            /* sidebar (piso de goma) */
  --goma-2: #22252b;
  --tiza: #f2f2ee;            /* texto sobre goma */
  --tinta: #191c21;
  --tinta-2: #5b6370;
  --linea: #dde1de;
  /* discos */
  --rojo: #c8102e;            /* 25 kg */
  --rojo-oscuro: #a30d25;
  --azul: #1e5aa8;            /* 20 kg */
  --amarillo: #d99011;        /* 15 kg */
  --verde: #1f9d55;           /* 10 kg */
  --rojo-suave: #c8102e14; --azul-suave: #1e5aa814;
  --amarillo-suave: #d9901120; --verde-suave: #1f9d5514;

  --radius: 6px;
  --font: 'Archivo', -apple-system, 'Segoe UI', sans-serif;
  --display: 'Archivo Black', 'Archivo', sans-serif;
  --sombra: 0 1px 2px rgba(25, 28, 33, 0.05), 0 2px 8px rgba(25, 28, 33, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--hormigon); color: var(--tinta); font-family: var(--font); font-size: 14.5px; line-height: 1.5; }
a { color: var(--rojo); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--rojo); outline-offset: 2px; }

/* ── Layout ─────────────────────────────────────────────────── */
.layout { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--goma); padding: 22px 0 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  /* textura sutil de piso de goma */
  background-image: radial-gradient(rgba(255,255,255,0.028) 1px, transparent 1px);
  background-size: 14px 14px;
}
.brand {
  font-family: var(--display); color: var(--tiza); font-size: 17px;
  letter-spacing: 0.04em; padding: 0 20px 6px; text-transform: uppercase;
}
.brand span { color: var(--rojo); }
/* barra cargada: marca de la casa */
.brand::after {
  content: ''; display: block; margin-top: 10px; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg,
    var(--rojo) 0 14%, var(--goma-2) 14% 18%,
    var(--azul) 18% 28%, var(--goma-2) 28% 32%,
    #4a4f58 32% 68%,
    var(--goma-2) 68% 72%, var(--azul) 72% 82%,
    var(--goma-2) 82% 86%, var(--rojo) 86% 100%);
}
.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: #6b7280; padding: 18px 20px 5px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 20px;
  color: #b8bcc4; cursor: pointer; font-weight: 500; font-size: 13.5px;
  border-left: 3px solid transparent; transition: color 0.12s, background 0.12s;
}
.nav-item:hover { color: var(--tiza); background: rgba(255,255,255,0.04); }
.nav-item.active {
  color: var(--tiza); border-left-color: var(--rojo);
  background: linear-gradient(90deg, rgba(200,16,46,0.16), transparent 75%);
  font-weight: 600;
}
.main { padding: 30px 36px 60px; max-width: 1180px; }
.page-title {
  font-family: var(--display); font-size: 26px; letter-spacing: 0.01em;
  text-transform: uppercase; margin-bottom: 2px;
}
.page-sub { color: var(--tinta-2); margin-bottom: 26px; }
.userbox { margin-top: 22px; padding: 14px 20px 0; border-top: 1px solid var(--goma-2); font-size: 12.5px; color: #9aa1ab; }
.userbox a { color: #b8bcc4; font-weight: 500; }
.userbox a:hover { color: var(--tiza); }

@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding-bottom: 4px; }
  .main { padding: 20px 16px 50px; }
  .nav-item { display: inline-flex; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--rojo); background: none; }
  .nav-section { display: none; }
  nav { display: flex; flex-wrap: wrap; }
}

/* ── Tarjetas y stats (el marcador) ─────────────────────────── */
.card {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--sombra);
}
.card h3 {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--tinta-2); margin-bottom: 14px;
}
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 940px) { .grid-2 { grid-template-columns: 1fr; } }

.stat {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radius);
  padding: 14px 18px 12px; box-shadow: var(--sombra); border-top: 3px solid var(--tinta);
}
.stat .n {
  font-family: var(--display); font-size: 30px; line-height: 1.15;
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
.stat .l { color: var(--tinta-2); font-size: 12px; margin-top: 2px; font-weight: 500; }
.stat.good { border-top-color: var(--verde); } .stat.good .n { color: var(--verde); }
.stat.bad { border-top-color: var(--rojo); } .stat.bad .n { color: var(--rojo); }
.stat.warn { border-top-color: var(--amarillo); } .stat.warn .n { color: var(--amarillo); }

/* ── Tablas ─────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--tinta-2); padding: 8px 10px; border-bottom: 2px solid var(--tinta);
  font-weight: 700;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--linea); vertical-align: middle; font-variant-numeric: tabular-nums; }
tr:hover td { background: #f7f8f7; }
.table-wrap { overflow-x: auto; }

/* ── Controles ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--rojo); color: #fff; border: 1px solid var(--rojo);
  padding: 8px 16px; border-radius: var(--radius); font-weight: 600; font-size: 13.5px;
  cursor: pointer; font-family: var(--font); transition: background 0.12s, transform 0.05s;
}
.btn:hover { background: var(--rojo-oscuro); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--papel); color: var(--tinta); border-color: #c4c9c5; }
.btn.secondary:hover { background: var(--hormigon); }
.btn.danger { background: transparent; color: var(--rojo); border-color: var(--rojo); }
.btn.danger:hover { background: var(--rojo-suave); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

input, select, textarea {
  width: 100%; background: var(--papel); border: 1px solid #c4c9c5; color: var(--tinta);
  padding: 8px 12px; border-radius: var(--radius); font-family: var(--font); font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rojo); outline-offset: -1px; border-color: transparent; }
label { display: block; font-size: 12px; color: var(--tinta-2); margin: 10px 0 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 14px; }

/* ── Chips (colores de disco) ───────────────────────────────── */
.chip { display: inline-block; padding: 2px 10px; border-radius: 3px; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.chip.green { background: var(--verde-suave); color: var(--verde); box-shadow: inset 0 0 0 1px var(--verde); }
.chip.red { background: var(--rojo-suave); color: var(--rojo); box-shadow: inset 0 0 0 1px var(--rojo); }
.chip.yellow { background: var(--amarillo-suave); color: #9c680c; box-shadow: inset 0 0 0 1px var(--amarillo); }
.chip.gray { background: #f0f1f0; color: var(--tinta-2); box-shadow: inset 0 0 0 1px #c4c9c5; }
.chip.accent { background: var(--azul-suave); color: var(--azul); box-shadow: inset 0 0 0 1px var(--azul); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.spacer { flex: 1; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,25,29,0.55); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--papel); border-radius: 10px; padding: 26px; width: 100%; max-width: 640px; box-shadow: 0 12px 40px rgba(0,0,0,0.25); border-top: 4px solid var(--rojo); }
.modal h2 { font-family: var(--display); font-size: 17px; text-transform: uppercase; margin-bottom: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--goma); color: var(--tiza); border-left: 4px solid var(--azul); padding: 12px 18px; border-radius: var(--radius); min-width: 260px; box-shadow: 0 6px 24px rgba(0,0,0,0.3); animation: slideIn 0.2s ease; }
.toast.error { border-left-color: var(--rojo); }
.toast.success { border-left-color: var(--verde); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Login ──────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--goma);
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 14px 14px;
}
.login-card { background: var(--papel); border-radius: 12px; padding: 38px; width: 100%; max-width: 400px; border-top: 6px solid var(--rojo); box-shadow: 0 20px 60px rgba(0,0,0,0.4); }
.login-card h1 { font-family: var(--display); font-size: 22px; text-transform: uppercase; margin-bottom: 2px; }
.login-card h1 span { color: var(--rojo); }
.login-card p { color: var(--tinta-2); margin-bottom: 18px; font-size: 13.5px; }

/* ── Check-in: el veredicto de marcador ─────────────────────── */
.checkin-result { text-align: center; padding: 28px 20px; border-radius: var(--radius); margin-top: 16px; font-size: 16px; font-weight: 600; }
.checkin-result .big {
  font-family: var(--display); font-size: 44px; display: block; margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.1;
}
.checkin-result.ok { background: var(--verde-suave); border: 2px solid var(--verde); color: var(--verde); }
.checkin-result.denied { background: var(--rojo-suave); border: 2px solid var(--rojo); color: var(--rojo); }

/* ── Gráfico de barras (recaudación) ────────────────────────── */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 44px; background: var(--tinta); border-radius: 3px 3px 0 0; min-height: 3px; transition: background 0.12s; }
.bar-col:last-child .bar { background: var(--rojo); }
.bar-col:hover .bar { background: var(--azul); }
.bar-label { font-size: 11px; color: var(--tinta-2); font-variant-numeric: tabular-nums; }
.progress { height: 8px; background: var(--hormigon); border-radius: 4px; overflow: hidden; min-width: 120px; }
.progress > div { height: 100%; background: var(--verde); border-radius: 4px; }

/* ── Ranking (podio) ────────────────────────────────────────── */
.rank-row { display: flex; align-items: center; gap: 14px; padding: 9px 14px; border-radius: var(--radius); border-bottom: 1px solid var(--linea); }
.rank-row:last-child { border-bottom: none; }
.rank-row.me { background: var(--azul-suave); box-shadow: inset 0 0 0 1.5px var(--azul); border-bottom: none; }
.rank-pos {
  font-family: var(--display); font-size: 15px; width: 40px; color: var(--tinta-2);
  font-variant-numeric: tabular-nums;
}
.rank-pos.top1 { color: var(--rojo); }
.rank-name { flex: 1; font-weight: 600; }
.rank-pts { font-family: var(--display); font-size: 15px; font-variant-numeric: tabular-nums; }

.muted { color: var(--tinta-2); font-size: 13px; }
.mb0 { margin-bottom: 0; } .mt16 { margin-top: 16px; }
h4.day-h {
  color: var(--rojo); font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em;
  margin: 16px 0 6px; font-weight: 700; border-bottom: 2px solid var(--rojo);
  display: inline-block; padding-bottom: 2px;
}
.section-h {
  display: inline-block; margin: 10px 0 4px; padding: 2px 10px; border-radius: 3px;
  background: var(--azul-suave); color: var(--azul); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; box-shadow: inset 0 0 0 1px var(--azul);
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
