*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  line-height: 1.5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

header {
  background: #1e40af;
  color: #fff;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

header a {
  color: #bfdbfe;
  text-decoration: none;
  font-size: 0.95rem;
}

header a:hover {
  color: #fff;
  text-decoration: underline;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: #1e40af;
  border-bottom: 2px solid #dbeafe;
  padding-bottom: 0.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.form-group select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
}

.form-group select:focus {
  outline: none;
  border-color: #b91c1c;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15);
}

.badge-categoria {
  margin-bottom: 0.35rem;
}

.equipo-header h3 {
  margin: 0.25rem 0 0;
}

.form-group input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: #1e40af;
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15);
}

.table-wrap {
  overflow-x: auto;
}

.tabla-jugadores {
  table-layout: fixed;
  width: 100%;
}

.tabla-jugadores .col-dni {
  width: 115px;
}

.tabla-jugadores .col-celular {
  width: 125px;
}

.tabla-jugadores .col-camiseta {
  width: 85px;
}

.tabla-jugadores .col-refuerzo {
  width: 175px;
}

.tabla-jugadores .col-acciones {
  width: 72px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  background: #eff6ff;
  color: #1e3a8a;
  padding: 0.65rem 0.5rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: bottom;
}

.tabla-jugadores thead th:last-child,
.tabla-jugadores .td-acciones {
  text-align: center;
}

tbody td {
  padding: 0.45rem 0.4rem;
  vertical-align: top;
  border-bottom: 1px solid #e2e8f0;
}

.tabla-jugadores .td-acciones {
  vertical-align: middle;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.cell-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

tbody input {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.45rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.9rem;
  box-sizing: border-box;
}

tbody select {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.45rem 0.35rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.82rem;
  background: #fff;
  box-sizing: border-box;
}

tbody select:focus,
.promocion-wrap input:focus {
  outline: none;
  border-color: #1e40af;
}

.promocion-wrap {
  margin-top: 0.2rem;
}

.promocion-wrap[hidden] {
  display: none !important;
}

.promocion-wrap input {
  display: block;
  width: 100%;
  padding: 0.4rem 0.45rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 0.8rem;
  box-sizing: border-box;
}

tbody input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

tbody input[type="number"]::-webkit-outer-spin-button,
tbody input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

tbody input:focus {
  outline: none;
  border-color: #1e40af;
}

tbody input.input-error {
  border-color: #dc2626;
  background: #fef2f2;
}

tbody input.input-ok {
  border-color: #16a34a;
}

.dni-hint {
  display: block;
  min-height: 1rem;
  font-size: 0.7rem;
  line-height: 1.1;
  color: #64748b;
  margin: 0;
}

.dni-hint.error {
  color: #dc2626;
}

.dni-hint.ok {
  color: #16a34a;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: #1e40af;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1e3a8a;
}

.btn-danger {
  background: #fee2e2;
  color: #dc2626;
  padding: 0.35rem 0.6rem;
  font-size: 1rem;
  line-height: 1;
}

.btn-danger:hover:not(:disabled) {
  background: #fecaca;
}

.btn-add {
  background: #dbeafe;
  color: #1e40af;
  padding: 0.4rem 0.75rem;
  font-size: 1.2rem;
  line-height: 1;
  margin-top: 0.75rem;
}

.btn-add:hover {
  background: #bfdbfe;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.alert-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.equipo-item {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  overflow: hidden;
}

.equipo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  gap: 0.5rem;
}

.equipo-header:hover {
  background: #eff6ff;
}

.equipo-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #1e3a8a;
}

.equipo-meta {
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
}

.equipo-body {
  display: none;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid #e2e8f0;
}

.equipo-item.open .equipo-body {
  display: block;
}

.equipo-header .toggle {
  font-size: 1.1rem;
  color: #64748b;
  transition: transform 0.2s;
}

.equipo-item.open .equipo-header .toggle {
  transform: rotate(180deg);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #64748b;
}

.empty-state p {
  margin: 0.5rem 0 0;
}

.badge {
  display: inline-block;
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.equipo-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-edit {
  background: #fff;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-edit:hover {
  background: #fef2f2;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0;
  z-index: 1;
}

.modal-content h2 {
  margin: 0 0 0.5rem;
  color: #b91c1c;
}

.modal-subtitle {
  margin: 0 0 1rem;
  color: #64748b;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  header h1 {
    font-size: 1.2rem;
  }

  .tabla-jugadores .col-dni { width: 95px; }
  .tabla-jugadores .col-celular { width: 105px; }
  .tabla-jugadores .col-camiseta { width: 70px; }
  .tabla-jugadores .col-refuerzo { width: 140px; }
  .tabla-jugadores .col-acciones { width: 60px; }

  thead th,
  tbody td {
    font-size: 0.8rem;
    padding: 0.35rem 0.25rem;
  }

  tbody input {
    font-size: 0.8rem;
    padding: 0.4rem 0.35rem;
  }
}
