:root {
  /* Paleta Pastel */
  --bg: #faf7fc;
  --surface: #ffffff;
  --primary: #7c6992;        /* Lavanda pastel oscuro */
  --primary-soft: #f2ecf9;   /* Lavanda muy claro */
  --secondary: #84a59d;      /* Verde salvia pastel */
  --secondary-soft: #eef5f3;
  --peach: #f6bd60;          /* Durazno pastel */
  --rose: #f28482;           /* Rosa coral pastel */
  --text: #3d3547;
  --muted: #7a7085;
  --border: #e6dfee;
  --radius: 12px;

  /* Indicadores de estado (Verde, Naranja, Azul, Rojo) */
  --status-green-bg: #dcfce7;
  --status-green-border: #22c55e;
  --status-green-text: #15803d;

  --status-orange-bg: #ffedd5;
  --status-orange-border: #f97316;
  --status-orange-text: #c2410c;

  --status-blue-bg: #dbeafe;
  --status-blue-border: #3b82f6;
  --status-blue-text: #1d4ed8;

  --status-red-bg: #fee2e2;
  --status-red-border: #ef4444;
  --status-red-text: #b91c1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
body { background: var(--bg); color: var(--text); line-height: 1.5; }

header {
  background: linear-gradient(135deg, #8e7aa6 0%, #6d597a 100%);
  color: #fff;
  padding: 1.1rem 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 2px 10px rgba(109, 89, 122, 0.15);
}
header h1 { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.2px; }
.nav-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tab-btn {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 0.5rem 0.95rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: 0.2s;
}
.tab-btn.active, .tab-btn:hover { background: #fff; color: var(--primary); }

.container { max-width: 1320px; margin: 1.5rem auto; padding: 0 1rem; }
.section { display: none; }
.section.active { display: block; }

.config-bar {
  background: var(--surface);
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 6px rgba(124, 105, 146, 0.05);
}
.config-group { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.config-group label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fdfcff;
  color: var(--text);
}

.btn {
  padding: 0.5rem 0.9rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.15s;
}
.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
.btn-primary { background: #8e7aa6; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #7b6694; }
.btn-accent { background: #74a892; color: #fff; }
.btn-accent:hover:not(:disabled) { background: #629680; }
.btn-jpg { background: #e5989b; color: #fff; }
.btn-jpg:hover:not(:disabled) { background: #d68285; }
.btn-warn { background: #f4a261; color: #fff; }
.btn-warn:hover:not(:disabled) { background: #e78e48; }
.btn-danger { background: #e07a5f; color: #fff; }
.btn-outline { background: var(--primary-soft); border: 1px solid var(--border); color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: #e6dcf3; }
.btn-sm { padding: 0.32rem 0.65rem; font-size: 0.78rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--surface);
  padding: 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 5px solid #b5a1cc;
  box-shadow: 0 2px 8px rgba(124, 105, 146, 0.05);
}
.kpi-card.mint { border-left-color: #84a59d; background: #fbfdfc; }
.kpi-card.peach { border-left-color: #f6bd60; background: #fffdf9; }
.kpi-card.rose { border-left-color: #f28482; background: #fffafa; }
.kpi-card.sky { border-left-color: #90be6d; background: #fafdf9; }
.kpi-title { font-size: 0.76rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.kpi-value { font-size: 1.55rem; font-weight: 800; margin: 0.28rem 0; color: var(--text); }
.kpi-sub { font-size: 0.8rem; color: var(--muted); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(124, 105, 146, 0.04);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.72rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--primary-soft); font-weight: 700; color: var(--primary); font-size: 0.78rem; text-transform: uppercase; }
tr:hover td { background: #fcfaff; }

/* Indicadores de estado */
.badge {
  display: inline-block;
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}
.badge-ok { background: var(--status-green-bg); color: var(--status-green-text); border: 1px solid #86efac; }
.badge-pending { background: var(--status-orange-bg); color: var(--status-orange-text); border: 1px solid #fdba74; }
.badge-ext { background: var(--status-blue-bg); color: var(--status-blue-text); border: 1px solid #93c5fd; }
.badge-closed { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

.raffle-chip {
  background: #fdfbff;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  border: 1px solid var(--border);
}
.num-pill {
  display: inline-block;
  padding: 0.12rem 0.42rem;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.75rem;
  margin: 0.15rem 0.15rem 0 0;
}
.num-pill.paid { background: var(--status-green-bg); color: var(--status-green-text); border: 1px solid var(--status-green-border); }
.num-pill.unpaid { background: var(--status-orange-bg); color: var(--status-orange-text); border: 1px solid var(--status-orange-border); }

/* Banner Rifa Activa */
.active-raffle-banner {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.15rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Panel de Control de Capital y Límites */
.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  background: var(--primary-soft);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.progress-bar-wrap {
  width: 100%;
  height: 12px;
  background: #e9e2f2;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.45rem;
}
.progress-bar-fill {
  height: 100%;
  background: #22c55e;
  transition: width 0.25s, background 0.25s;
}

/* TALONARIO 00 - 99 */
.board-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  background: var(--primary-soft);
  padding: 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.82rem;
  margin-bottom: 1rem;
  align-items: center;
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.legend-box { width: 16px; height: 16px; border-radius: 4px; border: 1px solid #cbd5e1; }

.number-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 0.45rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 700px) {
  .number-grid { grid-template-columns: repeat(5, 1fr); }
}
.num-cell {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.25rem;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  transition: 0.15s;
  user-select: none;
}
.num-cell:hover { transform: translateY(-2px); box-shadow: 0 3px 8px rgba(124, 105, 146, 0.12); }
.num-cell .n-code { font-size: 1.05rem; font-weight: 800; display: block; }
.num-cell .n-owner {
  font-size: 0.68rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.num-cell.free { background: #ffffff; color: var(--text); }
.num-cell.free .n-owner { color: #629680; font-weight: 600; }
.num-cell.taken-unpaid { background: var(--status-orange-bg); border-color: var(--status-orange-border); color: var(--status-orange-text); }
.num-cell.taken-paid { background: var(--status-green-bg); border-color: var(--status-green-border); color: var(--status-green-text); }
.num-cell.selected-now { background: var(--status-blue-bg); border-color: var(--status-blue-border); color: var(--status-blue-text); }

.missing-box {
  background: var(--secondary-soft);
  border: 1px dashed #84a59d;
  border-radius: 10px;
  padding: 1rem;
}
.missing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.6rem;
}
.missing-tag {
  background: #ffffff;
  color: var(--text);
  border: 1px solid #cde0da;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.2rem 0.48rem;
  border-radius: 5px;
}

/* Modals */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61, 53, 71, 0.45);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  padding: 1.5rem;
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(61, 53, 71, 0.18);
  max-height: 92vh;
  overflow-y: auto;
}
.modal h3 { margin-bottom: 1rem; color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 0.85rem; }
.form-group label { display: block; font-size: 0.83rem; font-weight: 600; margin-bottom: 0.28rem; color: var(--muted); }
.form-group input, .form-group select, .form-group textarea { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.1rem; }

.alert-box {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.83rem;
  margin-bottom: 0.85rem;
  font-weight: 600;
}
.alert-ok { background: var(--status-green-bg); color: var(--status-green-text); border: 1px solid #86efac; }
.alert-warn { background: var(--status-orange-bg); color: var(--status-orange-text); border: 1px solid #fdba74; }
.alert-err { background: var(--status-red-bg); color: var(--status-red-text); border: 1px solid #fca5a5; }

.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.empty-row { color: var(--muted); text-align: center; padding: 1.25rem; }
